diff --git a/src/plugins/clangcodemodel/clanghighlightingmarksreporter.cpp b/src/plugins/clangcodemodel/clanghighlightingmarksreporter.cpp index 698f158c654..162c78c5c93 100644 --- a/src/plugins/clangcodemodel/clanghighlightingmarksreporter.cpp +++ b/src/plugins/clangcodemodel/clanghighlightingmarksreporter.cpp @@ -62,6 +62,8 @@ CppTools::SemanticHighlighter::Kind toCppToolsSemanticHighlighterKind( case HighlightingType::Label: return SemanticHighlighter::LabelUse; case HighlightingType::Preprocessor: + case HighlightingType::PreprocessorDefinition: + case HighlightingType::PreprocessorExpansion: return SemanticHighlighter::MacroUse; default: return SemanticHighlighter::Unknown; diff --git a/src/tools/clangbackend/ipcsource/highlightinginformation.cpp b/src/tools/clangbackend/ipcsource/highlightinginformation.cpp index a570f3cf5cf..30ade394ec4 100644 --- a/src/tools/clangbackend/ipcsource/highlightinginformation.cpp +++ b/src/tools/clangbackend/ipcsource/highlightinginformation.cpp @@ -130,6 +130,7 @@ HighlightingType HighlightingInformation::referencedTypeKind(const Cursor &curso case CXCursor_ClassDecl: case CXCursor_StructDecl: case CXCursor_UnionDecl: + case CXCursor_TypedefDecl: case CXCursor_TemplateTypeParameter: case CXCursor_TypeAliasDecl: return HighlightingType::Type; case CXCursor_EnumDecl: return HighlightingType::Enumeration; @@ -205,8 +206,8 @@ HighlightingType HighlightingInformation::identifierKind(const Cursor &cursor) c case CXCursor_NamespaceRef: case CXCursor_NamespaceAlias: case CXCursor_TypeAliasDecl: + case CXCursor_TypedefDecl: case CXCursor_ClassTemplate: - case CXCursor_UnexposedDecl: case CXCursor_CXXStaticCastExpr: case CXCursor_CXXReinterpretCastExpr: case CXCursor_ObjCCategoryDecl: diff --git a/tests/unit/unittest/data/highlightinginformations.cpp b/tests/unit/unittest/data/highlightinginformations.cpp index db5f8afde72..ca7eaa392f2 100644 --- a/tests/unit/unittest/data/highlightinginformations.cpp +++ b/tests/unit/unittest/data/highlightinginformations.cpp @@ -399,3 +399,28 @@ void f19() { ScopeClass::ScopeOperator(); } + +namespace TemplateClassNamespace { +template +class TemplateClass +{ + +}; +} + +void f20() +{ + TemplateClassNamespace::TemplateClass TemplateClassDefinition; +} + +void f21() +{ + typedef int TypeDefDeclaration; + TypeDefDeclaration TypeDefDeclarationUsage; +} + +typedef int EnumerationTypeDef; + +enum Enumeration2 : EnumerationTypeDef { + +}; diff --git a/tests/unit/unittest/highlightinginformationstest.cpp b/tests/unit/unittest/highlightinginformationstest.cpp index 0af449e4d44..9413d3a2ff9 100644 --- a/tests/unit/unittest/highlightinginformationstest.cpp +++ b/tests/unit/unittest/highlightinginformationstest.cpp @@ -844,17 +844,17 @@ TEST_F(HighlightingInformations, FriendTypeDeclaration) { const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(350, 28)); - ASSERT_THAT(infos[2], HasType(HighlightingType::Type)); + ASSERT_THAT(infos[2], HasType(HighlightingType::Invalid)); } TEST_F(HighlightingInformations, FriendArgumentTypeDeclaration) { const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(351, 65)); - ASSERT_THAT(infos[6], HasType(HighlightingType::Type)); + ASSERT_THAT(infos[6], HasType(HighlightingType::Invalid)); } -TEST_F(HighlightingInformations, DISABLED_FriendArgumentDeclaration) +TEST_F(HighlightingInformations, FriendArgumentDeclaration) { const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(351, 65)); @@ -903,6 +903,55 @@ TEST_F(HighlightingInformations, ScopeOperator) ASSERT_THAT(infos[1], HasType(HighlightingType::Invalid)); } +TEST_F(HighlightingInformations, TemplateClassNamespace) +{ + const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(413, 78)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingInformations, TemplateClass) +{ + const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(413, 78)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingInformations, TemplateClassParameter) +{ + const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(413, 78)); + + ASSERT_THAT(infos[4], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingInformations, TemplateClassDeclaration) +{ + const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(413, 78)); + + ASSERT_THAT(infos[6], HasType(HighlightingType::LocalVariable)); +} + +TEST_F(HighlightingInformations, TypeDefDeclaration) +{ + const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(418, 36)); + + ASSERT_THAT(infos[2], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingInformations, TypeDefDeclarationUsage) +{ + const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(419, 48)); + + ASSERT_THAT(infos[0], HasType(HighlightingType::Type)); +} + +TEST_F(HighlightingInformations, DISABLED_EnumerationTypeDef) +{ + const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(424, 41)); + + ASSERT_THAT(infos[3], HasType(HighlightingType::Type)); +} + Data *HighlightingInformations::d; void HighlightingInformations::SetUpTestCase()