forked from qt-creator/qt-creator
Clang: Fix highlighting issues
...for macros, typedefs and enums. Change-Id: I926e7238695caefd7f4463dbe0cf5b428aa98c1a Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
committed by
Nikolai Kosjar
parent
ea8665c2e2
commit
c209aaf22e
@@ -62,6 +62,8 @@ CppTools::SemanticHighlighter::Kind toCppToolsSemanticHighlighterKind(
|
|||||||
case HighlightingType::Label:
|
case HighlightingType::Label:
|
||||||
return SemanticHighlighter::LabelUse;
|
return SemanticHighlighter::LabelUse;
|
||||||
case HighlightingType::Preprocessor:
|
case HighlightingType::Preprocessor:
|
||||||
|
case HighlightingType::PreprocessorDefinition:
|
||||||
|
case HighlightingType::PreprocessorExpansion:
|
||||||
return SemanticHighlighter::MacroUse;
|
return SemanticHighlighter::MacroUse;
|
||||||
default:
|
default:
|
||||||
return SemanticHighlighter::Unknown;
|
return SemanticHighlighter::Unknown;
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ HighlightingType HighlightingInformation::referencedTypeKind(const Cursor &curso
|
|||||||
case CXCursor_ClassDecl:
|
case CXCursor_ClassDecl:
|
||||||
case CXCursor_StructDecl:
|
case CXCursor_StructDecl:
|
||||||
case CXCursor_UnionDecl:
|
case CXCursor_UnionDecl:
|
||||||
|
case CXCursor_TypedefDecl:
|
||||||
case CXCursor_TemplateTypeParameter:
|
case CXCursor_TemplateTypeParameter:
|
||||||
case CXCursor_TypeAliasDecl: return HighlightingType::Type;
|
case CXCursor_TypeAliasDecl: return HighlightingType::Type;
|
||||||
case CXCursor_EnumDecl: return HighlightingType::Enumeration;
|
case CXCursor_EnumDecl: return HighlightingType::Enumeration;
|
||||||
@@ -205,8 +206,8 @@ HighlightingType HighlightingInformation::identifierKind(const Cursor &cursor) c
|
|||||||
case CXCursor_NamespaceRef:
|
case CXCursor_NamespaceRef:
|
||||||
case CXCursor_NamespaceAlias:
|
case CXCursor_NamespaceAlias:
|
||||||
case CXCursor_TypeAliasDecl:
|
case CXCursor_TypeAliasDecl:
|
||||||
|
case CXCursor_TypedefDecl:
|
||||||
case CXCursor_ClassTemplate:
|
case CXCursor_ClassTemplate:
|
||||||
case CXCursor_UnexposedDecl:
|
|
||||||
case CXCursor_CXXStaticCastExpr:
|
case CXCursor_CXXStaticCastExpr:
|
||||||
case CXCursor_CXXReinterpretCastExpr:
|
case CXCursor_CXXReinterpretCastExpr:
|
||||||
case CXCursor_ObjCCategoryDecl:
|
case CXCursor_ObjCCategoryDecl:
|
||||||
|
|||||||
@@ -399,3 +399,28 @@ void f19()
|
|||||||
{
|
{
|
||||||
ScopeClass::ScopeOperator();
|
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));
|
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)
|
TEST_F(HighlightingInformations, FriendArgumentTypeDeclaration)
|
||||||
{
|
{
|
||||||
const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(351, 65));
|
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));
|
const auto infos = translationUnit.highlightingInformationsInRange(sourceRange(351, 65));
|
||||||
|
|
||||||
@@ -903,6 +903,55 @@ TEST_F(HighlightingInformations, ScopeOperator)
|
|||||||
ASSERT_THAT(infos[1], HasType(HighlightingType::Invalid));
|
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;
|
Data *HighlightingInformations::d;
|
||||||
|
|
||||||
void HighlightingInformations::SetUpTestCase()
|
void HighlightingInformations::SetUpTestCase()
|
||||||
|
|||||||
Reference in New Issue
Block a user