diff options
-rw-r--r-- | src/libs/3rdparty/cplusplus/Token.h | 3 | ||||
-rw-r--r-- | src/libs/clangsupport/clangsupport_global.h | 1 | ||||
-rw-r--r-- | src/libs/clangsupport/tokeninfocontainer.cpp | 1 | ||||
-rw-r--r-- | src/libs/clangsupport/tokeninfocontainer.h | 2 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/clanghighlightingresultreporter.cpp | 2 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/clangutils.cpp | 3 | ||||
-rw-r--r-- | src/plugins/cppeditor/cpphighlighter.cpp | 2 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditorconstants.h | 1 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditorsettings.cpp | 13 | ||||
-rw-r--r-- | src/tools/clangbackend/source/fulltokeninfo.cpp | 2 | ||||
-rw-r--r-- | src/tools/clangbackend/source/tokeninfo.cpp | 8 | ||||
-rw-r--r-- | tests/unit/unittest/data/highlightingmarks.cpp | 1 | ||||
-rw-r--r-- | tests/unit/unittest/gtest-creator-printing.cpp | 1 | ||||
-rw-r--r-- | tests/unit/unittest/tokenprocessor-test.cpp | 132 |
14 files changed, 93 insertions, 79 deletions
diff --git a/src/libs/3rdparty/cplusplus/Token.h b/src/libs/3rdparty/cplusplus/Token.h index 9d30911169..e548b9480a 100644 --- a/src/libs/3rdparty/cplusplus/Token.h +++ b/src/libs/3rdparty/cplusplus/Token.h @@ -332,6 +332,9 @@ public: inline bool isOperator() const { return f.kind >= T_FIRST_OPERATOR && f.kind <= T_LAST_OPERATOR; } + inline bool isPunctuation() const + { return f.kind >= T_FIRST_PUNCTUATION && f.kind <= T_LAST_PUNCTUATION; } + inline bool isPunctuationOrOperator() const { return f.kind >= T_FIRST_PUNCTUATION_OR_OPERATOR && f.kind <= T_LAST_PUNCTUATION_OR_OPERATOR; } diff --git a/src/libs/clangsupport/clangsupport_global.h b/src/libs/clangsupport/clangsupport_global.h index 75454a5288..7b2d62ab50 100644 --- a/src/libs/clangsupport/clangsupport_global.h +++ b/src/libs/clangsupport/clangsupport_global.h @@ -86,6 +86,7 @@ enum class HighlightingType : quint8 Preprocessor, PreprocessorDefinition, PreprocessorExpansion, + Punctuation, Label, Declaration, FunctionDefinition, diff --git a/src/libs/clangsupport/tokeninfocontainer.cpp b/src/libs/clangsupport/tokeninfocontainer.cpp index 2744200c60..41c0a69f7e 100644 --- a/src/libs/clangsupport/tokeninfocontainer.cpp +++ b/src/libs/clangsupport/tokeninfocontainer.cpp @@ -53,6 +53,7 @@ static const char *highlightingTypeToCStringLiteral(HighlightingType type) RETURN_TEXT_FOR_CASE(OutputArgument); RETURN_TEXT_FOR_CASE(PreprocessorDefinition); RETURN_TEXT_FOR_CASE(PreprocessorExpansion); + RETURN_TEXT_FOR_CASE(Punctuation); RETURN_TEXT_FOR_CASE(Namespace); RETURN_TEXT_FOR_CASE(Class); RETURN_TEXT_FOR_CASE(Struct); diff --git a/src/libs/clangsupport/tokeninfocontainer.h b/src/libs/clangsupport/tokeninfocontainer.h index d01d0f92eb..2b8e01e769 100644 --- a/src/libs/clangsupport/tokeninfocontainer.h +++ b/src/libs/clangsupport/tokeninfocontainer.h @@ -138,7 +138,7 @@ public: return extraInfo.declaration && types.mainHighlightingType != HighlightingType::LocalVariable - && ((types.mainHighlightingType == HighlightingType::Operator) + && (types.mixinHighlightingTypes.contains(HighlightingType::Operator) == extraInfo.token.startsWith("operator")); } diff --git a/src/plugins/clangcodemodel/clanghighlightingresultreporter.cpp b/src/plugins/clangcodemodel/clanghighlightingresultreporter.cpp index 795941f6ec..125d4405a7 100644 --- a/src/plugins/clangcodemodel/clanghighlightingresultreporter.cpp +++ b/src/plugins/clangcodemodel/clanghighlightingresultreporter.cpp @@ -62,6 +62,8 @@ TextEditor::TextStyle toTextStyle(ClangBackEnd::HighlightingType type) case HighlightingType::PreprocessorDefinition: case HighlightingType::PreprocessorExpansion: return TextEditor::C_PREPROCESSOR; + case HighlightingType::Punctuation: + return TextEditor::C_PUNCTUATION; case HighlightingType::Declaration: return TextEditor::C_DECLARATION; case HighlightingType::FunctionDefinition: diff --git a/src/plugins/clangcodemodel/clangutils.cpp b/src/plugins/clangcodemodel/clangutils.cpp index 725042488b..9638cfa2dd 100644 --- a/src/plugins/clangcodemodel/clangutils.cpp +++ b/src/plugins/clangcodemodel/clangutils.cpp @@ -235,7 +235,8 @@ int clangColumn(const QTextBlock &line, int cppEditorColumn) ClangBackEnd::StorageClass storageClass = extraInfo.storageClass; if (mainType == ClangBackEnd::HighlightingType::VirtualFunction || mainType == ClangBackEnd::HighlightingType::Function - || mainType == ClangBackEnd::HighlightingType::Operator) { + || token.types.mixinHighlightingTypes.contains( + ClangBackEnd::HighlightingType::Operator)) { if (storageClass != ClangBackEnd::StorageClass::Static) { switch (access) { case ClangBackEnd::AccessSpecifier::Public: diff --git a/src/plugins/cppeditor/cpphighlighter.cpp b/src/plugins/cppeditor/cpphighlighter.cpp index 7d5648646c..075791b021 100644 --- a/src/plugins/cppeditor/cpphighlighter.cpp +++ b/src/plugins/cppeditor/cpphighlighter.cpp @@ -203,6 +203,8 @@ void CppHighlighter::highlightBlock(const QString &text) formatForCategory(C_PRIMITIVE_TYPE)); } else if (tk.isOperator()) { setFormat(tk.utf16charsBegin(), tk.utf16chars(), formatForCategory(C_OPERATOR)); + } else if (tk.isPunctuation()) { + setFormat(tk.utf16charsBegin(), tk.utf16chars(), formatForCategory(C_PUNCTUATION)); } else if (i == 0 && tokens.size() > 1 && tk.is(T_IDENTIFIER) && tokens.at(1).is(T_COLON)) { setFormat(tk.utf16charsBegin(), tk.utf16chars(), formatForCategory(C_LABEL)); } else if (tk.is(T_IDENTIFIER)) { diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 504a6d8ea2..56678f1812 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -60,6 +60,7 @@ enum TextStyle : quint8 { C_PRIMITIVE_TYPE, C_OPERATOR, C_OVERLOADED_OPERATOR, + C_PUNCTUATION, C_PREPROCESSOR, C_LABEL, C_COMMENT, diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp index ff6cb70668..8124f4ab43 100644 --- a/src/plugins/texteditor/texteditorsettings.cpp +++ b/src/plugins/texteditor/texteditorsettings.cpp @@ -224,9 +224,16 @@ TextEditorSettings::TextEditorSettings() formatDescr.emplace_back(C_KEYWORD, tr("Keyword"), tr("Reserved keywords of the programming language except " "keywords denoting primitive types."), Qt::darkYellow); + formatDescr.emplace_back(C_PUNCTUATION, tr("Punctuation"), + tr("Punctuation excluding operators.")); formatDescr.emplace_back(C_OPERATOR, tr("Operator"), tr("Non user-defined language operators.\n" - "To style user-defined operators, use Overloaded Operator.")); + "To style user-defined operators, use Overloaded Operator."), + Format::createMixinFormat()); + formatDescr.emplace_back(C_OVERLOADED_OPERATOR, + tr("Overloaded Operators"), + tr("Calls and declarations of overloaded (user-defined) operators."), + Format::createMixinFormat()); formatDescr.emplace_back(C_PREPROCESSOR, tr("Preprocessor"), tr("Preprocessor directives."), Qt::darkBlue); formatDescr.emplace_back(C_LABEL, tr("Label"), tr("Labels for goto statements."), @@ -313,10 +320,6 @@ TextEditorSettings::TextEditorSettings() QColor(255, 190, 0), QTextCharFormat::DotLine, FormatDescription::ShowUnderlineControl); - formatDescr.emplace_back(C_OVERLOADED_OPERATOR, - tr("Overloaded Operators"), - tr("Calls and declarations of overloaded (user-defined) operators."), - Format::createMixinFormat()); Format declarationFormat = Format::createMixinFormat(); declarationFormat.setBold(true); formatDescr.emplace_back(C_DECLARATION, diff --git a/src/tools/clangbackend/source/fulltokeninfo.cpp b/src/tools/clangbackend/source/fulltokeninfo.cpp index e850e0495c..1bf265b371 100644 --- a/src/tools/clangbackend/source/fulltokeninfo.cpp +++ b/src/tools/clangbackend/source/fulltokeninfo.cpp @@ -243,7 +243,7 @@ void FullTokenInfo::overloadedOperatorKind() { TokenInfo::overloadedOperatorKind(); - if (m_types.mixinHighlightingTypes.front() != HighlightingType::OverloadedOperator) + if (!m_types.mixinHighlightingTypes.contains(HighlightingType::OverloadedOperator)) return; // Overloaded operator diff --git a/src/tools/clangbackend/source/tokeninfo.cpp b/src/tools/clangbackend/source/tokeninfo.cpp index 68877e4032..62742c2c48 100644 --- a/src/tools/clangbackend/source/tokeninfo.cpp +++ b/src/tools/clangbackend/source/tokeninfo.cpp @@ -529,13 +529,13 @@ void TokenInfo::overloadedOperatorKind() if (inOperatorDeclaration && !isTokenPartOfOperator(declarationCursor, m_cxToken)) return; - if (m_types.mainHighlightingType == HighlightingType::Invalid) - m_types.mainHighlightingType = HighlightingType::Operator; + m_types.mixinHighlightingTypes.push_back(HighlightingType::Operator); m_types.mixinHighlightingTypes.push_back(HighlightingType::OverloadedOperator); } void TokenInfo::punctuationOrOperatorKind() { + m_types.mainHighlightingType = HighlightingType::Punctuation; auto kind = m_originalCursor.kind(); switch (kind) { case CXCursor_CallExpr: @@ -557,9 +557,7 @@ void TokenInfo::punctuationOrOperatorKind() case CXCursor_BinaryOperator: case CXCursor_CompoundAssignOperator: case CXCursor_ConditionalOperator: - m_types.mainHighlightingType = HighlightingType::Operator; - break; - default: + m_types.mixinHighlightingTypes.push_back(HighlightingType::Operator); break; } diff --git a/tests/unit/unittest/data/highlightingmarks.cpp b/tests/unit/unittest/data/highlightingmarks.cpp index 3592f8024d..a5b6e85872 100644 --- a/tests/unit/unittest/data/highlightingmarks.cpp +++ b/tests/unit/unittest/data/highlightingmarks.cpp @@ -672,4 +672,5 @@ int signalSlotTest() { SIGNAL(something(QString)); SLOT(something(QString)); SIGNAL(something(QString (*func1)(QString))); + 1 == 2; } diff --git a/tests/unit/unittest/gtest-creator-printing.cpp b/tests/unit/unittest/gtest-creator-printing.cpp index 5e078d5b71..c2ce8a9cbc 100644 --- a/tests/unit/unittest/gtest-creator-printing.cpp +++ b/tests/unit/unittest/gtest-creator-printing.cpp @@ -518,6 +518,7 @@ static const char *highlightingTypeToCStringLiteral(HighlightingType type) RETURN_TEXT_FOR_CASE(PreprocessorDefinition); RETURN_TEXT_FOR_CASE(PreprocessorExpansion); RETURN_TEXT_FOR_CASE(PrimitiveType); + RETURN_TEXT_FOR_CASE(Punctuation); RETURN_TEXT_FOR_CASE(Declaration); RETURN_TEXT_FOR_CASE(Namespace); RETURN_TEXT_FOR_CASE(Class); diff --git a/tests/unit/unittest/tokenprocessor-test.cpp b/tests/unit/unittest/tokenprocessor-test.cpp index e618104af0..a53218f0fc 100644 --- a/tests/unit/unittest/tokenprocessor-test.cpp +++ b/tests/unit/unittest/tokenprocessor-test.cpp @@ -588,64 +588,64 @@ TEST_F(TokenProcessor, OverriddenPlusOperatorDeclaration) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(220, 67)); - ASSERT_THAT(infos[2], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[2], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); } TEST_F(TokenProcessor, CallToOverriddenPlusOperator) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(224, 49)); - ASSERT_THAT(infos[6], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[6], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); } TEST_F(TokenProcessor, CallToOverriddenPlusAssignOperator) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(226, 24)); - ASSERT_THAT(infos[1], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[1], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); } TEST_F(TokenProcessor, OverriddenStarOperatorMemberDefinition) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(604, 26)); - ASSERT_THAT(infos[2], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[2], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); } TEST_F(TokenProcessor, OverriddenStarOperatorNonMemberDefinition) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(607, 29)); - ASSERT_THAT(infos[2], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[2], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); } TEST_F(TokenProcessor, IntegerCallToOverriddenBinaryOperator) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(613, 9)); - ASSERT_THAT(infos[1], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[1], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); } TEST_F(TokenProcessor, FloatCallToOverriddenBinaryOperator) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(614, 9)); - ASSERT_THAT(infos[1], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[1], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); } TEST_F(TokenProcessor, LeftShiftAssignmentOperatorMemberDefinition) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(618, 32)); - ASSERT_THAT(infos[2], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); - ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Invalid)); // ( is a punctuation. + ASSERT_THAT(infos[2], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Punctuation)); // ( is a punctuation. } TEST_F(TokenProcessor, CalledLeftShiftAssignmentOperator) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(629, 18)); - ASSERT_THAT(infos[1], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[1], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); ASSERT_THAT(infos[2], HasOnlyType(HighlightingType::NumberLiteral)); } @@ -653,48 +653,48 @@ TEST_F(TokenProcessor, FunctionCallOperatorMemberDefinition) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(619, 29)); - ASSERT_THAT(infos[2], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); - ASSERT_THAT(infos[3], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); - ASSERT_THAT(infos[4], HasOnlyType(HighlightingType::Invalid)); // ( is a punctuation. + ASSERT_THAT(infos[2], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[3], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[4], HasOnlyType(HighlightingType::Punctuation)); // ( is a punctuation. } TEST_F(TokenProcessor, CalledFunctionCallOperator) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(632, 16)); - ASSERT_THAT(infos[1], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); - ASSERT_THAT(infos[3], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[1], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[3], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); } TEST_F(TokenProcessor, AccessOperatorMemberDefinition) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(620, 38)); - ASSERT_THAT(infos[3], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); - ASSERT_THAT(infos[4], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); - ASSERT_THAT(infos[5], HasOnlyType(HighlightingType::Invalid)); // ( is a punctuation. + ASSERT_THAT(infos[3], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[4], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[5], HasOnlyType(HighlightingType::Punctuation)); // ( is a punctuation. } TEST_F(TokenProcessor, CalledAccessOperator) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(633, 16)); - ASSERT_THAT(infos[1], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); - ASSERT_THAT(infos[3], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[1], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[3], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); } TEST_F(TokenProcessor, NewOperatorMemberDefinition) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(621, 39)); - ASSERT_THAT(infos[3], HasTwoTypes(HighlightingType::Keyword, HighlightingType::OverloadedOperator)); - ASSERT_THAT(infos[4], HasOnlyType(HighlightingType::Invalid)); // ( is a punctuation. + ASSERT_THAT(infos[3], HasThreeTypes(HighlightingType::Keyword, HighlightingType::Operator, HighlightingType::OverloadedOperator)); + ASSERT_THAT(infos[4], HasOnlyType(HighlightingType::Punctuation)); // ( is a punctuation. } TEST_F(TokenProcessor, CalledNewOperator) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(635, 34)); - ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Invalid)); // = is not marked. + ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Punctuation)); // = is not marked. // CLANG-UPGRADE-CHECK: Check if 'new' keyword usage cursor correctly returns referenced() cursor // and uncomment this test in that case. // ASSERT_THAT(infos[4], HasTwoTypes(HighlightingType::Keyword, HighlightingType::OverloadedOperator)); // new @@ -704,8 +704,8 @@ TEST_F(TokenProcessor, DeleteOperatorMemberDefinition) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(622, 37)); - ASSERT_THAT(infos[2], HasTwoTypes(HighlightingType::Keyword, HighlightingType::OverloadedOperator)); // delete - ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Invalid)); // ( is a punctuation. + ASSERT_THAT(infos[2], HasThreeTypes(HighlightingType::Keyword, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // delete + ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Punctuation)); // ( is a punctuation. } TEST_F(TokenProcessor, CalledDeleteOperator) @@ -716,24 +716,24 @@ TEST_F(TokenProcessor, CalledDeleteOperator) // and uncomment this test in that case. // ASSERT_THAT(infos[0], HasTwoTypes(HighlightingType::Keyword, HighlightingType::OverloadedOperator)); // delete ASSERT_THAT(infos[1], HasOnlyType(HighlightingType::LocalVariable)); - ASSERT_THAT(infos[2], HasOnlyType(HighlightingType::Invalid)); // ; is a punctuation. + ASSERT_THAT(infos[2], HasOnlyType(HighlightingType::Punctuation)); // ; is a punctuation. } TEST_F(TokenProcessor, NewArrayOperatorMemberDefinition) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(623, 41)); - ASSERT_THAT(infos[3], HasTwoTypes(HighlightingType::Keyword, HighlightingType::OverloadedOperator)); // new - ASSERT_THAT(infos[4], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); // [ - ASSERT_THAT(infos[5], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); // ] - ASSERT_THAT(infos[6], HasOnlyType(HighlightingType::Invalid)); // ( is a punctuation. + ASSERT_THAT(infos[3], HasThreeTypes(HighlightingType::Keyword, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // new + ASSERT_THAT(infos[4], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // [ + ASSERT_THAT(infos[5], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // ] + ASSERT_THAT(infos[6], HasOnlyType(HighlightingType::Punctuation)); // ( is a punctuation. } TEST_F(TokenProcessor, CalledNewArrayOperator) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(637, 34)); - ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Invalid)); // = is not marked. + ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Punctuation)); // = is not marked. // CLANG-UPGRADE-CHECK: Check if 'new' keyword usage cursor correctly returns referenced() cursor // and uncomment this test in that case. // ASSERT_THAT(infos[4], HasTwoTypes(HighlightingType::Keyword, HighlightingType::OverloadedOperator)); // new @@ -743,10 +743,10 @@ TEST_F(TokenProcessor, DeleteArrayOperatorMemberDefinition) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(624, 39)); - ASSERT_THAT(infos[2], HasTwoTypes(HighlightingType::Keyword, HighlightingType::OverloadedOperator)); // delete - ASSERT_THAT(infos[3], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); // [ - ASSERT_THAT(infos[4], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); // ] - ASSERT_THAT(infos[5], HasOnlyType(HighlightingType::Invalid)); // ( is a punctuation. + ASSERT_THAT(infos[2], HasThreeTypes(HighlightingType::Keyword, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // delete + ASSERT_THAT(infos[3], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // [ + ASSERT_THAT(infos[4], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // ] + ASSERT_THAT(infos[5], HasOnlyType(HighlightingType::Punctuation)); // ( is a punctuation. } TEST_F(TokenProcessor, CalledDeleteArrayOperator) @@ -769,120 +769,120 @@ TEST_F(TokenProcessor, ParenthesisOperatorWithoutArguments) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(654, 25)); - ASSERT_THAT(infos[1], HasTwoTypes(HighlightingType::Keyword, HighlightingType::OverloadedOperator)); // operator - ASSERT_THAT(infos[2], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); // '(' - ASSERT_THAT(infos[3], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); // ')' - ASSERT_THAT(infos[4], HasOnlyType(HighlightingType::Invalid)); // second '(' is a punctuation + ASSERT_THAT(infos[1], HasThreeTypes(HighlightingType::Keyword, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // operator + ASSERT_THAT(infos[2], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // '(' + ASSERT_THAT(infos[3], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // ')' + ASSERT_THAT(infos[4], HasOnlyType(HighlightingType::Punctuation)); // second '(' is a punctuation } TEST_F(TokenProcessor, CalledParenthesisOperatorWithoutArguments) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(662, 14)); - ASSERT_THAT(infos[1], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); // '(' - ASSERT_THAT(infos[2], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); // ')' + ASSERT_THAT(infos[1], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // '(' + ASSERT_THAT(infos[2], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // ')' } TEST_F(TokenProcessor, OperatorWithOnePunctuationTokenWithoutArguments) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(655, 25)); - ASSERT_THAT(infos[1], HasTwoTypes(HighlightingType::Keyword, HighlightingType::OverloadedOperator)); // operator - ASSERT_THAT(infos[2], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); // '*' - ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Invalid)); // ( is a punctuation + ASSERT_THAT(infos[1], HasThreeTypes(HighlightingType::Keyword, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // operator + ASSERT_THAT(infos[2], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // '*' + ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Punctuation)); // ( is a punctuation } TEST_F(TokenProcessor, CalledOperatorWithOnePunctuationTokenWithoutArguments) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(663, 13)); - ASSERT_THAT(infos[0], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); // '*' + ASSERT_THAT(infos[0], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // '*' } TEST_F(TokenProcessor, EqualsOperatorOverload) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(656, 43)); - ASSERT_THAT(infos[1], HasTwoTypes(HighlightingType::Keyword, HighlightingType::OverloadedOperator)); // operator - ASSERT_THAT(infos[2], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); // '=' - ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Invalid)); // ( is a punctuation + ASSERT_THAT(infos[1], HasThreeTypes(HighlightingType::Keyword, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // operator + ASSERT_THAT(infos[2], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // '=' + ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Punctuation)); // ( is a punctuation } TEST_F(TokenProcessor, CalledEqualsOperatorOverload) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(664, 23)); - ASSERT_THAT(infos[1], HasTwoTypes(HighlightingType::Operator, HighlightingType::OverloadedOperator)); // '=' + ASSERT_THAT(infos[1], HasThreeTypes(HighlightingType::Punctuation, HighlightingType::Operator, HighlightingType::OverloadedOperator)); // '=' } TEST_F(TokenProcessor, LeftParenthesisIsAPunctuation) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(607, 29)); - ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Invalid)); + ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Punctuation)); } TEST_F(TokenProcessor, SeparatingCommaIsAPunctuation) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(607, 29)); - ASSERT_THAT(infos[5], HasOnlyType(HighlightingType::Invalid)); + ASSERT_THAT(infos[5], HasOnlyType(HighlightingType::Punctuation)); } TEST_F(TokenProcessor, RightParenthesisIsAPunctuation) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(607, 29)); - ASSERT_THAT(infos[7], HasOnlyType(HighlightingType::Invalid)); + ASSERT_THAT(infos[7], HasOnlyType(HighlightingType::Punctuation)); } TEST_F(TokenProcessor, CurlyLeftParenthesisIsAPunctuation) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(607, 29)); - ASSERT_THAT(infos[8], HasOnlyType(HighlightingType::Invalid)); + ASSERT_THAT(infos[8], HasOnlyType(HighlightingType::Punctuation)); } TEST_F(TokenProcessor, CurlyRightParenthesisIsAPunctuation) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(607, 29)); - ASSERT_THAT(infos[9], HasOnlyType(HighlightingType::Invalid)); + ASSERT_THAT(infos[9], HasOnlyType(HighlightingType::Punctuation)); } TEST_F(TokenProcessor, OperatorColon) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(668, 28)); - ASSERT_THAT(infos[6], HasOnlyType(HighlightingType::Operator)); + ASSERT_THAT(infos[6], HasTwoTypes(HighlightingType::Punctuation, HighlightingType::Operator)); } TEST_F(TokenProcessor, PunctuationColon) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(133, 10)); - ASSERT_THAT(infos[2], HasOnlyType(HighlightingType::Invalid)); + ASSERT_THAT(infos[2], HasOnlyType(HighlightingType::Punctuation)); } TEST_F(TokenProcessor, LessThanOperator) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(668, 28)); - ASSERT_THAT(infos[2], HasOnlyType(HighlightingType::Operator)); + ASSERT_THAT(infos[2], HasTwoTypes(HighlightingType::Punctuation, HighlightingType::Operator)); } TEST_F(TokenProcessor, LessThanPunctuation) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(247, 19)); - ASSERT_THAT(infos[1], HasOnlyType(HighlightingType::Invalid)); + ASSERT_THAT(infos[1], HasOnlyType(HighlightingType::Punctuation)); } TEST_F(TokenProcessor, GreaterThanPunctuation) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(247, 19)); - ASSERT_THAT(infos[4], HasOnlyType(HighlightingType::Invalid)); + ASSERT_THAT(infos[4], HasOnlyType(HighlightingType::Punctuation)); } TEST_F(TokenProcessor, Comment) @@ -1136,13 +1136,13 @@ TEST_F(TokenProcessor, StaticCastIsKeyword) ASSERT_THAT(infos[0], HasOnlyType(HighlightingType::Keyword)); } -TEST_F(TokenProcessor, StaticCastPunctationIsInvalid) +TEST_F(TokenProcessor, StaticCastPunctation) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(328, 64)); - ASSERT_THAT(infos[1], HasOnlyType(HighlightingType::Invalid)); - ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Invalid)); - ASSERT_THAT(infos[5], HasOnlyType(HighlightingType::Invalid)); + ASSERT_THAT(infos[1], HasOnlyType(HighlightingType::Punctuation)); + ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::Punctuation)); + ASSERT_THAT(infos[5], HasOnlyType(HighlightingType::Punctuation)); } TEST_F(TokenProcessor, TypeInReinterpretCast) @@ -1240,14 +1240,14 @@ TEST_F(TokenProcessor, NoOperator) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(389, 24)); - ASSERT_THAT(infos[2], HasOnlyType(HighlightingType::Invalid)); + ASSERT_THAT(infos[2], HasOnlyType(HighlightingType::Punctuation)); } TEST_F(TokenProcessor, ScopeOperator) { const auto infos = translationUnit.tokenInfosInRange(sourceRange(400, 33)); - ASSERT_THAT(infos[1], HasOnlyType(HighlightingType::Invalid)); + ASSERT_THAT(infos[1], HasOnlyType(HighlightingType::Punctuation)); } TEST_F(TokenProcessor, TemplateClassNamespace) @@ -1652,7 +1652,7 @@ TEST_F(TokenProcessor, LexicalParentIndex) const auto containers = translationUnit.fullTokenInfosInRange( translationUnit.sourceRange(50, 1, 53, 3)).toTokenInfoContainers(); - ASSERT_THAT(containers[3].extraInfo.lexicalParentIndex, 1); + ASSERT_THAT(containers[4].extraInfo.lexicalParentIndex, 1); } TEST_F(TokenProcessor, QtOldStyleSignal) |