[clangd] Add semantic token for labels
Reviewed By: kadircet Differential Revision: https://reviews.llvm.org/D143260
This commit is contained in:
parent
d57ed844fe
commit
e72baa76b9
@ -166,6 +166,8 @@ std::optional<HighlightingKind> kindForDecl(const NamedDecl *D,
|
||||
return HighlightingKind::TemplateParameter;
|
||||
if (isa<ConceptDecl>(D))
|
||||
return HighlightingKind::Concept;
|
||||
if (isa<LabelDecl>(D))
|
||||
return HighlightingKind::Label;
|
||||
if (const auto *UUVD = dyn_cast<UnresolvedUsingValueDecl>(D)) {
|
||||
auto Targets = Resolver->resolveUsingValueDecl(UUVD);
|
||||
if (!Targets.empty() && Targets[0] != UUVD) {
|
||||
@ -1271,6 +1273,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, HighlightingKind K) {
|
||||
return OS << "Operator";
|
||||
case HighlightingKind::Bracket:
|
||||
return OS << "Bracket";
|
||||
case HighlightingKind::Label:
|
||||
return OS << "Label";
|
||||
case HighlightingKind::InactiveCode:
|
||||
return OS << "InactiveCode";
|
||||
}
|
||||
@ -1470,6 +1474,8 @@ llvm::StringRef toSemanticTokenType(HighlightingKind Kind) {
|
||||
return "operator";
|
||||
case HighlightingKind::Bracket:
|
||||
return "bracket";
|
||||
case HighlightingKind::Label:
|
||||
return "label";
|
||||
case HighlightingKind::InactiveCode:
|
||||
return "comment";
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ enum class HighlightingKind {
|
||||
Modifier,
|
||||
Operator,
|
||||
Bracket,
|
||||
Label,
|
||||
|
||||
// This one is different from the other kinds as it's a line style
|
||||
// rather than a token style.
|
||||
|
@ -1028,6 +1028,16 @@ $Bracket[[>]]$Bracket[[>]] $LocalVariable_def[[s6]];
|
||||
template $Bracket[[<]]$Concept[[C2]]$Bracket[[<]]int$Bracket[[>]] $TemplateParameter_def[[A]]$Bracket[[>]]
|
||||
class $Class_def[[B]] {};
|
||||
)cpp",
|
||||
// Labels
|
||||
R"cpp(
|
||||
bool $Function_def[[funcWithGoto]](bool $Parameter_def[[b]]) {
|
||||
if ($Parameter[[b]])
|
||||
goto $Label[[return_true]];
|
||||
return false;
|
||||
$Label_decl[[return_true]]:
|
||||
return true;
|
||||
}
|
||||
)cpp",
|
||||
// no crash
|
||||
R"cpp(
|
||||
struct $Class_def[[Foo]] {
|
||||
|
Loading…
x
Reference in New Issue
Block a user