diff options
author | Marco Bubke <marco.bubke@theqtcompany.com> | 2015-12-02 20:57:53 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2015-12-07 08:41:03 +0000 |
commit | c209aaf22e2c8a6e438037fe509b6d039b18d712 (patch) | |
tree | f845452df054ea5c2ae949b4054f2b596bcfd4ba | |
parent | ea8665c2e22e22de13c87d3a00be7357cc0f4ec5 (diff) |
Clang: Fix highlighting issues
...for macros, typedefs and enums.
Change-Id: I926e7238695caefd7f4463dbe0cf5b428aa98c1a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
4 files changed, 81 insertions, 4 deletions
diff --git a/src/plugins/clangcodemodel/clanghighlightingmarksreporter.cpp b/src/plugins/clangcodemodel/clanghighlightingmarksreporter.cpp index 698f158c65..162c78c5c9 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 a570f3cf5c..30ade394ec 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 db5f8afde7..ca7eaa392f 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 X> +class TemplateClass +{ + +}; +} + +void f20() +{ + TemplateClassNamespace::TemplateClass<ScopeClass> 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 0af449e4d4..9413d3a2ff 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() |