ClangCodeModel: Do not traverse the AST in the semantic highlighter

... with clangd >= 17. We do not need to look at AST nodes anymore;
everything comes from the server.

Change-Id: I46eb91f26515e31b752020edbc32f1b23c1d79c7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2023-01-31 18:32:29 +01:00
parent 801709f72e
commit e771560ec7
2 changed files with 113 additions and 111 deletions

View File

@@ -1468,6 +1468,9 @@ void ClangdClient::Private::handleSemanticTokens(TextDocument *doc,
data.highlighter->setHighlightingRunner(runner);
data.highlighter->run();
};
if (q->versionNumber().majorVersion() >= 17)
astHandler({}, {});
else
getAndHandleAst(doc, astHandler, AstCallbackMode::SyncIfPossible);
}

View File

@@ -461,6 +461,7 @@ void ExtraHighlightingResultsCollector::collect()
if (!m_ast.isValid())
return;
QTC_ASSERT(m_clangdVersion < 17, return);
visitNode(m_ast);
}
@@ -656,7 +657,6 @@ void ExtraHighlightingResultsCollector::collectFromNode(const ClangdAstNode &nod
return;
}
if (m_clangdVersion < 17) {
if (isDeclaration && (node.kind() == "FunctionTemplate" || node.kind() == "ClassTemplate")) {
// The child nodes are the template parameters and and the function or class.
// The opening angle bracket is before the first child node, the closing angle
@@ -776,7 +776,6 @@ void ExtraHighlightingResultsCollector::collectFromNode(const ClangdAstNode &nod
}
return;
}
}
if (!isExpression && !isDeclaration)
return;