From d14be7493f8ed963840d198315ef46b4641427bd Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Tue, 8 Sep 2020 15:48:52 +0200 Subject: ClangBackEnd: Support highlighting of alias templates Fixes: QTCREATORBUG-24552 Change-Id: I80d2b16114234cf896173cd4104e6a5f12009f69 Reviewed-by: Christian Stenger --- src/tools/clangbackend/source/tokeninfo.cpp | 1 + tests/unit/unittest/data/highlightingmarks.cpp | 4 ++++ tests/unit/unittest/tokenprocessor-test.cpp | 7 +++++++ tests/unit/unittest/unittest.pro | 10 +++++----- tests/unit/unittest/unittest.qbs | 6 +++--- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/tools/clangbackend/source/tokeninfo.cpp b/src/tools/clangbackend/source/tokeninfo.cpp index de40a954e1..47b8188986 100644 --- a/src/tools/clangbackend/source/tokeninfo.cpp +++ b/src/tools/clangbackend/source/tokeninfo.cpp @@ -317,6 +317,7 @@ void TokenInfo::typeKind(const Cursor &cursor) m_types.mixinHighlightingTypes.push_back(HighlightingType::Namespace); return; case CXCursor_TypeAliasDecl: + case CXCursor_TypeAliasTemplateDecl: m_types.mixinHighlightingTypes.push_back(HighlightingType::TypeAlias); return; case CXCursor_TypedefDecl: diff --git a/tests/unit/unittest/data/highlightingmarks.cpp b/tests/unit/unittest/data/highlightingmarks.cpp index a703e89a11..2476cabfb2 100644 --- a/tests/unit/unittest/data/highlightingmarks.cpp +++ b/tests/unit/unittest/data/highlightingmarks.cpp @@ -695,3 +695,7 @@ protected: private: static int privateValue; }; + +template struct S { }; +template using spec = S; +spec<2> s; diff --git a/tests/unit/unittest/tokenprocessor-test.cpp b/tests/unit/unittest/tokenprocessor-test.cpp index 285c6d3446..786b980f22 100644 --- a/tests/unit/unittest/tokenprocessor-test.cpp +++ b/tests/unit/unittest/tokenprocessor-test.cpp @@ -1722,6 +1722,13 @@ TEST_F(TokenProcessor, StaticPrivateMember) ASSERT_THAT(container.extraInfo.accessSpecifier, ClangBackEnd::AccessSpecifier::Private); } +TEST_F(TokenProcessor, TemplateAlias) +{ + const auto infos = translationUnit.tokenInfosInRange(sourceRange(701, 8)); + + ASSERT_THAT(infos[0], HasTwoTypes(HighlightingType::Type, HighlightingType::TypeAlias)); +} + Data *TokenProcessor::d; void TokenProcessor::SetUpTestCase() diff --git a/tests/unit/unittest/unittest.pro b/tests/unit/unittest/unittest.pro index 3917237d0b..4b3254a4d2 100644 --- a/tests/unit/unittest/unittest.pro +++ b/tests/unit/unittest/unittest.pro @@ -174,12 +174,14 @@ SOURCES += \ diagnosticset-test.cpp \ diagnostic-test.cpp \ fixit-test.cpp \ + gtest-clang-printing.cpp \ highlightingresultreporter-test.cpp \ senddocumenttracker-test.cpp \ skippedsourceranges-test.cpp \ sourcelocation-test.cpp \ sourcerange-test.cpp \ token-test.cpp \ + tokenprocessor-test.cpp \ translationunitupdater-test.cpp \ unsavedfiles-test.cpp \ unsavedfile-test.cpp \ @@ -201,7 +203,6 @@ SOURCES += \ clangqueryprojectfindfilter-test.cpp \ clangquery-test.cpp \ clangreferencescollector-test.cpp \ - gtest-clang-printing.cpp \ pchcreator-test.cpp \ refactoringclientserverinprocess-test.cpp \ refactoringclient-test.cpp \ @@ -212,8 +213,7 @@ SOURCES += \ symbolscollector-test.cpp \ testclangtool.cpp \ usedmacrocollector-test.cpp \ - builddependencycollector-test.cpp \ - tokenprocessor-test.cpp + builddependencycollector-test.cpp !isEmpty(QTC_UNITTEST_BUILD_CPP_PARSER):SOURCES += refactoringengine-test.cpp @@ -311,14 +311,14 @@ HEADERS += \ clangasyncjob-base.h \ clangcompareoperators.h \ diagnosticcontainer-matcher.h \ + gtest-clang-printing.h } !isEmpty(LIBTOOLING_LIBS) { HEADERS += \ - gtest-clang-printing.h \ mockrefactoringclient.h \ mockrefactoringserver.h \ - testclangtool.h \ + testclangtool.h } OTHER_FILES += $$files(data/*) $$files(data/include/*) diff --git a/tests/unit/unittest/unittest.qbs b/tests/unit/unittest/unittest.qbs index 43cfc86eed..4e5a7993e4 100644 --- a/tests/unit/unittest/unittest.qbs +++ b/tests/unit/unittest/unittest.qbs @@ -323,6 +323,8 @@ CppApplication { "diagnosticcontainer-matcher.h", "diagnosticset-test.cpp", "fixit-test.cpp", + "gtest-clang-printing.cpp", + "gtest-clang-printing.h", "highlightingresultreporter-test.cpp", "readexporteddiagnostics-test.cpp", "senddocumenttracker-test.cpp", @@ -330,6 +332,7 @@ CppApplication { "sourcelocation-test.cpp", "sourcerange-test.cpp", "token-test.cpp", + "tokenprocessor-test.cpp", "translationunitupdater-test.cpp", "unsavedfile-test.cpp", "unsavedfiles-test.cpp", @@ -347,8 +350,6 @@ CppApplication { "clangquerygatherer-test.cpp", "clangqueryprojectfindfilter-test.cpp", "clangreferencescollector-test.cpp", - "gtest-clang-printing.cpp", - "gtest-clang-printing.h", "gtest-llvm-printing.cpp", "mockrefactoringclient.h", "mockrefactoringserver.h", @@ -363,7 +364,6 @@ CppApplication { "symbolscollector-test.cpp", "testclangtool.cpp", "testclangtool.h", - "tokenprocessor-test.cpp", "usedmacrocollector-test.cpp", ] } -- cgit v1.2.3