diff options
author | Marco Bubke <marco.bubke@qt.io> | 2017-07-20 17:59:35 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2017-07-24 14:31:23 +0000 |
commit | 99af4ae8e69db2e494cc8192b0b489c681456d91 (patch) | |
tree | 3b4059adeefa51178e2527688db77b986422dfb3 /src/tools | |
parent | e97ff9f739b61305161ebee524abbfb7972d33f1 (diff) | |
download | qt-creator-99af4ae8e69db2e494cc8192b0b489c681456d91.tar.gz |
Clang: Show all tokens of a getter as output argument
f(x.get()); -> x.get() should be shown as a output argument
Task-number: QTCREATORBUG-18591
Change-Id: I99f5637660bcd0a889338ebfa6737d79de226f87
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/clangbackend/ipcsource/highlightingmark.cpp | 18 | ||||
-rw-r--r-- | src/tools/clangbackend/ipcsource/highlightingmarks.cpp | 12 | ||||
-rw-r--r-- | src/tools/clangbackend/ipcsource/highlightingmarks.h | 2 |
3 files changed, 26 insertions, 6 deletions
diff --git a/src/tools/clangbackend/ipcsource/highlightingmark.cpp b/src/tools/clangbackend/ipcsource/highlightingmark.cpp index 03dd894a69..bc918326a7 100644 --- a/src/tools/clangbackend/ipcsource/highlightingmark.cpp +++ b/src/tools/clangbackend/ipcsource/highlightingmark.cpp @@ -247,22 +247,22 @@ void HighlightingMark::collectOutputArguments(const Cursor &cursor) namespace { -uint getStart(CXSourceRange cxSourceRange) +uint getEnd(CXSourceRange cxSourceRange) { - CXSourceLocation startSourceLocation = clang_getRangeStart(cxSourceRange); + CXSourceLocation startSourceLocation = clang_getRangeEnd(cxSourceRange); - uint startOffset; + uint endOffset; - clang_getFileLocation(startSourceLocation, nullptr, nullptr, nullptr, &startOffset); + clang_getFileLocation(startSourceLocation, nullptr, nullptr, nullptr, &endOffset); - return startOffset; + return endOffset; } } void HighlightingMark::filterOutPreviousOutputArguments() { auto isAfterLocation = [this] (CXSourceRange outputRange) { - return getStart(outputRange) > m_offset; + return getEnd(outputRange) > m_offset; }; auto precedingBegin = std::partition(m_currentOutputArgumentRanges->begin(), @@ -279,6 +279,9 @@ void HighlightingMark::functionKind(const Cursor &cursor, Recursion recursion) else m_types.mainHighlightingType = HighlightingType::Function; + if (isOutputArgument()) + m_types.mixinHighlightingTypes.push_back(HighlightingType::OutputArgument); + addExtraTypeIfFirstPass(HighlightingType::Declaration, recursion); } @@ -384,6 +387,9 @@ HighlightingType HighlightingMark::punctuationKind(const Cursor &cursor) default: break; } + if (isOutputArgument()) + m_types.mixinHighlightingTypes.push_back(HighlightingType::OutputArgument); + return highlightingType; } diff --git a/src/tools/clangbackend/ipcsource/highlightingmarks.cpp b/src/tools/clangbackend/ipcsource/highlightingmarks.cpp index 725e6eb316..2e157ff835 100644 --- a/src/tools/clangbackend/ipcsource/highlightingmarks.cpp +++ b/src/tools/clangbackend/ipcsource/highlightingmarks.cpp @@ -109,4 +109,16 @@ HighlightingMark HighlightingMarks::operator[](size_t index) const currentOutputArgumentRanges); } +std::ostream &operator<<(std::ostream &out, const HighlightingMarks &marks) +{ + out << "["; + + for (const HighlightingMark entry : marks) + out << entry; + + out << "]"; + + return out; +} + } // namespace ClangBackEnd diff --git a/src/tools/clangbackend/ipcsource/highlightingmarks.h b/src/tools/clangbackend/ipcsource/highlightingmarks.h index 6904bb3184..e573dc267e 100644 --- a/src/tools/clangbackend/ipcsource/highlightingmarks.h +++ b/src/tools/clangbackend/ipcsource/highlightingmarks.h @@ -69,4 +69,6 @@ private: std::vector<CXCursor> cxCursor; }; +std::ostream &operator<<(std::ostream &out, const HighlightingMarks &marks); + } // namespace ClangBackEnd |