diff options
| author | Yong He <yonghe@outlook.com> | 2022-06-22 19:58:34 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-22 19:58:34 -0700 |
| commit | 07a380d72a13899a84cbdc35692be7a3d9246dcb (patch) | |
| tree | 68e77f2e9682b3b7c3debd745604a494439e5b25 /source/slang/slang-language-server-ast-lookup.cpp | |
| parent | e5a75563a1ba2e378353af8b937b8b7bb0fe2c2b (diff) | |
More Language Server Improvements. (#2289)
Diffstat (limited to 'source/slang/slang-language-server-ast-lookup.cpp')
| -rw-r--r-- | source/slang/slang-language-server-ast-lookup.cpp | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/source/slang/slang-language-server-ast-lookup.cpp b/source/slang/slang-language-server-ast-lookup.cpp index 0e5a68687..6792a18e7 100644 --- a/source/slang/slang-language-server-ast-lookup.cpp +++ b/source/slang/slang-language-server-ast-lookup.cpp @@ -78,11 +78,13 @@ bool _isLocInRange(ASTLookupContext* context, SourceLoc start, SourceLoc end) { auto startLoc = context->sourceManager->getHumaneLoc(start, SourceLocType::Actual); auto endLoc = context->sourceManager->getHumaneLoc(end, SourceLocType::Actual); - + Loc s{startLoc.line, startLoc.column}; Loc e{endLoc.line, endLoc.column}; Loc c{context->line, context->col}; - return s <= c && c <= e; + return s <= c && c <= e && + startLoc.pathInfo.foundPath.getUnownedSlice().endsWithCaseInsensitive( + context->sourceFileName); } bool _findAstNodeImpl(ASTLookupContext& context, SyntaxNode* node); @@ -149,6 +151,8 @@ public: PushNode pushNodeRAII(context, expr); if (dispatchIfNotNull(expr->functionExpr)) return true; + if (dispatchIfNotNull(expr->originalFunctionExpr)) + return true; for (auto arg : expr->arguments) if (dispatchIfNotNull(arg)) return true; @@ -317,7 +321,7 @@ public: context->results.add(result); return true; } - return false; + return dispatchIfNotNull(expr->originalExpr); } bool visitStaticMemberExpr(StaticMemberExpr* expr) @@ -548,6 +552,16 @@ bool _findAstNodeImpl(ASTLookupContext& context, SyntaxNode* node) if (visitor.dispatchIfNotNull(extDecl->targetType.exp)) return true; } + else if (auto importDecl = as<ImportDecl>(node)) + { + if (_isLocInRange(&context, importDecl->startLoc, importDecl->endLoc)) + { + ASTLookupResult result; + result.path = context.nodePath; + context.results.add(_Move(result)); + return true; + } + } for (auto modifier : decl->modifiers) { if (auto hlslSemantic = as<HLSLSemantic>(modifier)) @@ -562,6 +576,21 @@ bool _findAstNodeImpl(ASTLookupContext& context, SyntaxNode* node) return true; } } + else if (auto attribute = as<AttributeBase>(modifier)) + { + if (attribute->getKeywordName() && + _isLocInRange( + &context, + attribute->getKeywordNameAndLoc().loc, + attribute->getKeywordName()->text.getLength())) + { + ASTLookupResult result; + result.path = context.nodePath; + result.path.add(attribute); + context.results.add(result); + return true; + } + } } if (auto container = as<ContainerDecl>(node)) { |
