ClangBackEnd: Support highlighting of alias templates

Fixes: QTCREATORBUG-24552
Change-Id: I80d2b16114234cf896173cd4104e6a5f12009f69
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2020-09-08 15:48:52 +02:00
parent 226982b7b0
commit d14be7493f
5 changed files with 20 additions and 8 deletions

View File

@@ -317,6 +317,7 @@ void TokenInfo::typeKind(const Cursor &cursor)
m_types.mixinHighlightingTypes.push_back(HighlightingType::Namespace); m_types.mixinHighlightingTypes.push_back(HighlightingType::Namespace);
return; return;
case CXCursor_TypeAliasDecl: case CXCursor_TypeAliasDecl:
case CXCursor_TypeAliasTemplateDecl:
m_types.mixinHighlightingTypes.push_back(HighlightingType::TypeAlias); m_types.mixinHighlightingTypes.push_back(HighlightingType::TypeAlias);
return; return;
case CXCursor_TypedefDecl: case CXCursor_TypedefDecl:

View File

@@ -695,3 +695,7 @@ protected:
private: private:
static int privateValue; static int privateValue;
}; };
template <int i, int j> struct S { };
template <int i> using spec = S<i, 1>;
spec<2> s;

View File

@@ -1722,6 +1722,13 @@ TEST_F(TokenProcessor, StaticPrivateMember)
ASSERT_THAT(container.extraInfo.accessSpecifier, ClangBackEnd::AccessSpecifier::Private); 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; Data *TokenProcessor::d;
void TokenProcessor::SetUpTestCase() void TokenProcessor::SetUpTestCase()

View File

@@ -174,12 +174,14 @@ SOURCES += \
diagnosticset-test.cpp \ diagnosticset-test.cpp \
diagnostic-test.cpp \ diagnostic-test.cpp \
fixit-test.cpp \ fixit-test.cpp \
gtest-clang-printing.cpp \
highlightingresultreporter-test.cpp \ highlightingresultreporter-test.cpp \
senddocumenttracker-test.cpp \ senddocumenttracker-test.cpp \
skippedsourceranges-test.cpp \ skippedsourceranges-test.cpp \
sourcelocation-test.cpp \ sourcelocation-test.cpp \
sourcerange-test.cpp \ sourcerange-test.cpp \
token-test.cpp \ token-test.cpp \
tokenprocessor-test.cpp \
translationunitupdater-test.cpp \ translationunitupdater-test.cpp \
unsavedfiles-test.cpp \ unsavedfiles-test.cpp \
unsavedfile-test.cpp \ unsavedfile-test.cpp \
@@ -201,7 +203,6 @@ SOURCES += \
clangqueryprojectfindfilter-test.cpp \ clangqueryprojectfindfilter-test.cpp \
clangquery-test.cpp \ clangquery-test.cpp \
clangreferencescollector-test.cpp \ clangreferencescollector-test.cpp \
gtest-clang-printing.cpp \
pchcreator-test.cpp \ pchcreator-test.cpp \
refactoringclientserverinprocess-test.cpp \ refactoringclientserverinprocess-test.cpp \
refactoringclient-test.cpp \ refactoringclient-test.cpp \
@@ -212,8 +213,7 @@ SOURCES += \
symbolscollector-test.cpp \ symbolscollector-test.cpp \
testclangtool.cpp \ testclangtool.cpp \
usedmacrocollector-test.cpp \ usedmacrocollector-test.cpp \
builddependencycollector-test.cpp \ builddependencycollector-test.cpp
tokenprocessor-test.cpp
!isEmpty(QTC_UNITTEST_BUILD_CPP_PARSER):SOURCES += refactoringengine-test.cpp !isEmpty(QTC_UNITTEST_BUILD_CPP_PARSER):SOURCES += refactoringengine-test.cpp
@@ -311,14 +311,14 @@ HEADERS += \
clangasyncjob-base.h \ clangasyncjob-base.h \
clangcompareoperators.h \ clangcompareoperators.h \
diagnosticcontainer-matcher.h \ diagnosticcontainer-matcher.h \
gtest-clang-printing.h
} }
!isEmpty(LIBTOOLING_LIBS) { !isEmpty(LIBTOOLING_LIBS) {
HEADERS += \ HEADERS += \
gtest-clang-printing.h \
mockrefactoringclient.h \ mockrefactoringclient.h \
mockrefactoringserver.h \ mockrefactoringserver.h \
testclangtool.h \ testclangtool.h
} }
OTHER_FILES += $$files(data/*) $$files(data/include/*) OTHER_FILES += $$files(data/*) $$files(data/include/*)

View File

@@ -323,6 +323,8 @@ CppApplication {
"diagnosticcontainer-matcher.h", "diagnosticcontainer-matcher.h",
"diagnosticset-test.cpp", "diagnosticset-test.cpp",
"fixit-test.cpp", "fixit-test.cpp",
"gtest-clang-printing.cpp",
"gtest-clang-printing.h",
"highlightingresultreporter-test.cpp", "highlightingresultreporter-test.cpp",
"readexporteddiagnostics-test.cpp", "readexporteddiagnostics-test.cpp",
"senddocumenttracker-test.cpp", "senddocumenttracker-test.cpp",
@@ -330,6 +332,7 @@ CppApplication {
"sourcelocation-test.cpp", "sourcelocation-test.cpp",
"sourcerange-test.cpp", "sourcerange-test.cpp",
"token-test.cpp", "token-test.cpp",
"tokenprocessor-test.cpp",
"translationunitupdater-test.cpp", "translationunitupdater-test.cpp",
"unsavedfile-test.cpp", "unsavedfile-test.cpp",
"unsavedfiles-test.cpp", "unsavedfiles-test.cpp",
@@ -347,8 +350,6 @@ CppApplication {
"clangquerygatherer-test.cpp", "clangquerygatherer-test.cpp",
"clangqueryprojectfindfilter-test.cpp", "clangqueryprojectfindfilter-test.cpp",
"clangreferencescollector-test.cpp", "clangreferencescollector-test.cpp",
"gtest-clang-printing.cpp",
"gtest-clang-printing.h",
"gtest-llvm-printing.cpp", "gtest-llvm-printing.cpp",
"mockrefactoringclient.h", "mockrefactoringclient.h",
"mockrefactoringserver.h", "mockrefactoringserver.h",
@@ -363,7 +364,6 @@ CppApplication {
"symbolscollector-test.cpp", "symbolscollector-test.cpp",
"testclangtool.cpp", "testclangtool.cpp",
"testclangtool.h", "testclangtool.h",
"tokenprocessor-test.cpp",
"usedmacrocollector-test.cpp", "usedmacrocollector-test.cpp",
] ]
} }