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);
return;
case CXCursor_TypeAliasDecl:
case CXCursor_TypeAliasTemplateDecl:
m_types.mixinHighlightingTypes.push_back(HighlightingType::TypeAlias);
return;
case CXCursor_TypedefDecl:

View File

@@ -695,3 +695,7 @@ protected:
private:
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);
}
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()

View File

@@ -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/*)

View File

@@ -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",
]
}