https://github.com/Decodetalkers updated https://github.com/llvm/llvm-project/pull/204511
>From 9adbd7b88a12ace21bea5846afd27035f0e09f1f Mon Sep 17 00:00:00 2001 From: ShootingStarDragons <[email protected]> Date: Thu, 18 Jun 2026 18:08:05 +0900 Subject: [PATCH] feat: highlight for import, export keyword This pr aims to add highlight for import and export keyword And induced new SemanticHighlight `keyword` --- clang-tools-extra/clangd/SemanticHighlighting.cpp | 13 +++++++++++++ clang-tools-extra/clangd/SemanticHighlighting.h | 1 + 2 files changed, 14 insertions(+) diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp index 856904bc810d1..eb2bd5f1e967f 100644 --- a/clang-tools-extra/clangd/SemanticHighlighting.cpp +++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -582,6 +582,15 @@ class CollectExtraHighlightings return true; } + bool VisitImportDecl(const ImportDecl *D) { + H.addToken(D->getLocation(), HighlightingKind::Keyword); + return true; + } + bool VisitExportDecl(const ExportDecl *D) { + H.addToken(D->getLocation(), HighlightingKind::Keyword); + return true; + } + bool VisitTagDecl(TagDecl *D) { for (TemplateParameterList *TPL : D->getTemplateParameterLists()) H.addAngleBracketTokens(TPL->getLAngleLoc(), TPL->getRAngleLoc()); @@ -1120,6 +1129,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, HighlightingKind K) { return OS << "Function"; case HighlightingKind::Method: return OS << "Method"; + case HighlightingKind::Keyword: + return OS << "Keyword"; case HighlightingKind::StaticMethod: return OS << "StaticMethod"; case HighlightingKind::Field: @@ -1323,6 +1334,8 @@ llvm::StringRef toSemanticTokenType(HighlightingKind Kind) { return "function"; case HighlightingKind::Method: return "method"; + case HighlightingKind::Keyword: + return "keyword"; case HighlightingKind::StaticMethod: // FIXME: better method with static modifier? return "function"; diff --git a/clang-tools-extra/clangd/SemanticHighlighting.h b/clang-tools-extra/clangd/SemanticHighlighting.h index 59d742b83ee52..3b1c12418becb 100644 --- a/clang-tools-extra/clangd/SemanticHighlighting.h +++ b/clang-tools-extra/clangd/SemanticHighlighting.h @@ -34,6 +34,7 @@ enum class HighlightingKind { Parameter, Function, Method, + Keyword, StaticMethod, Field, StaticField, _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
