forked from qt-creator/qt-creator
clangbackend: Fix highlighting for #include directives
These were falsely categorized as string literals. No one ever noticed,
because highlighting information for string literals was ignored until
baf25e4cdb
.
Change-Id: Ib59fde04359aecb6da3995de1a9febbbf41b12c8
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -440,7 +440,10 @@ void TokenInfo::identifierKind(const Cursor &cursor, Recursion recursion)
|
||||
m_types.mainHighlightingType = HighlightingType::PreprocessorDefinition;
|
||||
break;
|
||||
case CXCursor_InclusionDirective:
|
||||
m_types.mainHighlightingType = HighlightingType::StringLiteral;
|
||||
// Included files are sometimes reported as strings and sometimes as
|
||||
// include directives, depending on various circumstances.
|
||||
m_types.mainHighlightingType = m_token->spelling() == "include"
|
||||
? HighlightingType::Preprocessor : HighlightingType::StringLiteral;
|
||||
break;
|
||||
case CXCursor_LabelRef:
|
||||
case CXCursor_LabelStmt:
|
||||
|
@@ -928,7 +928,8 @@ TEST_F(TokenProcessor, PreprocessorInclusionDirective)
|
||||
{
|
||||
const auto infos = translationUnit.tokenInfosInRange(sourceRange(239, 18));
|
||||
|
||||
ASSERT_THAT(infos[1], HasOnlyType(HighlightingType::StringLiteral));
|
||||
ASSERT_THAT(infos[1], HasOnlyType(HighlightingType::Preprocessor));
|
||||
ASSERT_THAT(infos[2], HasOnlyType(HighlightingType::StringLiteral));
|
||||
}
|
||||
|
||||
TEST_F(TokenProcessor, GotoLabelStatement)
|
||||
@@ -1080,6 +1081,7 @@ TEST_F(TokenProcessor, PreprocessorInclusionDirectiveWithAngleBrackets )
|
||||
{
|
||||
const auto infos = translationUnit.tokenInfosInRange(sourceRange(289, 38));
|
||||
|
||||
ASSERT_THAT(infos[1], HasOnlyType(HighlightingType::Preprocessor));
|
||||
ASSERT_THAT(infos[3], HasOnlyType(HighlightingType::StringLiteral));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user