summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-language-server-ast-lookup.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-08-19 15:03:56 -0700
committerGitHub <noreply@github.com>2024-08-19 15:03:56 -0700
commit453683bf44f2112719802eaac2b332d49eebd640 (patch)
treed399db4c9cba90c11980186d3df1ffcc4d423b5a /source/slang/slang-language-server-ast-lookup.cpp
parentecf85df6eee3da76ef54b14e4ab083f22da89e46 (diff)
Tuple swizzling, concat, comparison and `countof`. (#4856)
* Tuple swizzling and element access. * Update proposal status. * Cleanup. * Fix merrge error. * Address review.
Diffstat (limited to 'source/slang/slang-language-server-ast-lookup.cpp')
-rw-r--r--source/slang/slang-language-server-ast-lookup.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/source/slang/slang-language-server-ast-lookup.cpp b/source/slang/slang-language-server-ast-lookup.cpp
index 5c73d2ab9..2d6ed2568 100644
--- a/source/slang/slang-language-server-ast-lookup.cpp
+++ b/source/slang/slang-language-server-ast-lookup.cpp
@@ -118,6 +118,27 @@ public:
return dispatchIfNotNull(subscriptExpr->baseExpression);
}
+ bool visitSizeOfLikeExpr(SizeOfLikeExpr* expr)
+ {
+ int tokenLength = 0;
+ if (as<CountOfExpr>(expr))
+ tokenLength = 7; // strlen("countof");
+ else if (as<SizeOfExpr>(expr))
+ tokenLength = 6; // strlen("sizeof");
+ else if (as<AlignOfExpr>(expr))
+ tokenLength = 7; // strlen("alignof");
+
+ if (_isLocInRange(context, expr->loc, tokenLength))
+ {
+ ASTLookupResult result;
+ result.path = context->nodePath;
+ result.path.add(expr);
+ context->results.add(result);
+ return true;
+ }
+ return dispatchIfNotNull(expr->value);
+ }
+
bool visitParenExpr(ParenExpr* expr)
{
return dispatchIfNotNull(expr->base);
@@ -225,7 +246,10 @@ public:
}
bool visitSwizzleExpr(SwizzleExpr* expr)
{
- if (_isLocInRange(context, expr->memberOpLoc, 0))
+ Index tokenLength = expr->elementIndices.getCount();
+ if (expr->base && as<TupleType>(expr->base->type))
+ tokenLength *= 2;
+ if (_isLocInRange(context, expr->loc, tokenLength))
{
ASTLookupResult result;
result.path = context->nodePath;