Commit c209aaf2 authored by Marco Bubke's avatar Marco Bubke Committed by Nikolai Kosjar

Clang: Fix highlighting issues

...for macros, typedefs and enums.
	
Change-Id: I926e7238695caefd7f4463dbe0cf5b428aa98c1a
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent ea8665c2
......@@ -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;
......
......@@ -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:
......
......@@ -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 {
};
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment