summaryrefslogtreecommitdiff
path: root/source/slang/slang-language-server-semantic-tokens.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-02-02 22:28:02 -0800
committerGitHub <noreply@github.com>2024-02-02 22:28:02 -0800
commit14764896c34b230a5563f48d8b8e565de2f3aa10 (patch)
tree2f105d3f6222103f458054f1cd38e280b6fb52b4 /source/slang/slang-language-server-semantic-tokens.cpp
parentc15e7ade4e27e1649d5b98f5854e9e52bb9e60ae (diff)
Capability type checking. (#3530)
* Capability type checking. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-language-server-semantic-tokens.cpp')
-rw-r--r--source/slang/slang-language-server-semantic-tokens.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/source/slang/slang-language-server-semantic-tokens.cpp b/source/slang/slang-language-server-semantic-tokens.cpp
index ae10d62e8..3a40c8e92 100644
--- a/source/slang/slang-language-server-semantic-tokens.cpp
+++ b/source/slang/slang-language-server-semantic-tokens.cpp
@@ -126,7 +126,7 @@ List<SemanticToken> getSemanticTokens(Linkage* linkage, Module* module, UnownedS
}
maybeInsertToken(token);
};
- iterateAST(
+ iterateASTWithLanguageServerFilter(
fileName,
manager,
module->getModuleDecl(),
@@ -240,8 +240,34 @@ List<SemanticToken> getSemanticTokens(Linkage* linkage, Module* module, UnownedS
token.length = (int)attr->originalIdentifierToken.getContentLength();
token.type = SemanticTokenType::Type;
maybeInsertToken(token);
+
+ // Insert capability names as enum cases.
+ if (as<RequireCapabilityAttribute>(attr))
+ {
+ for (auto arg : attr->args)
+ {
+ if (auto varExpr = as<VarExpr>(arg))
+ {
+ if (varExpr->name)
+ {
+ SemanticToken capToken = _createSemanticToken(
+ manager, varExpr->loc, nullptr);
+ capToken.length = (int)varExpr->name->text.getLength();
+ capToken.type = SemanticTokenType::EnumMember;
+ maybeInsertToken(capToken);
+ }
+ }
+ }
+ }
}
}
+ else if (auto targetCase = as<TargetCaseStmt>(node))
+ {
+ SemanticToken token = _createSemanticToken(
+ manager, targetCase->capabilityToken.loc, targetCase->capabilityToken.getName());
+ token.type = SemanticTokenType::EnumMember;
+ maybeInsertToken(token);
+ }
else if (auto spirvAsmExpr = as<SPIRVAsmExpr>(node))
{
// Highlight opcodes and enums.