diff options
| author | Yong He <yonghe@outlook.com> | 2025-04-30 14:17:45 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-30 14:17:45 -0700 |
| commit | 7f1df9d0b31413e59846cc955d2a955d3f361e2a (patch) | |
| tree | 8cfcb7b6dde96f90e9581f9a904a25158a7358cb /source/slang/slang-language-server-ast-lookup.cpp | |
| parent | 678de6547bc8cac15e31de30b400e9a3b45c216f (diff) | |
Initial support for immutable lambda expressions. (#6914)
* Initial support for immutable lambda expressions.
* More diagnostics, and langauge server fix.
* Language server fix.
* Fix bug identified in review.
* Add expected result.
* Update expected result.
Diffstat (limited to 'source/slang/slang-language-server-ast-lookup.cpp')
| -rw-r--r-- | source/slang/slang-language-server-ast-lookup.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/source/slang/slang-language-server-ast-lookup.cpp b/source/slang/slang-language-server-ast-lookup.cpp index 7375756f5..b08388aee 100644 --- a/source/slang/slang-language-server-ast-lookup.cpp +++ b/source/slang/slang-language-server-ast-lookup.cpp @@ -62,9 +62,10 @@ static Index _getDeclNameLength(Name* name, Decl* optionalDecl = nullptr) return 0; } // HACK: our __subscript functions currently have a name "operator[]". + // and our operator() functions have a name "()". // Since this isn't the name that actually appears in user's code, // we need to shorten its reported length to 1 for now. - if (name->text.startsWith("operator")) + if (name->text.startsWith("operator") || name->text.startsWith("()")) { return 1; } @@ -75,7 +76,7 @@ bool _isLocInRange(ASTLookupContext* context, SourceLoc loc, Int length) { auto humaneLoc = context->sourceManager->getHumaneLoc(loc, SourceLocType::Actual); return humaneLoc.line == context->line && context->col >= humaneLoc.column && - context->col <= humaneLoc.column + length && + context->col < humaneLoc.column + length && humaneLoc.pathInfo.foundPath.getUnownedSlice().endsWithCaseInsensitive( context->sourceFileName); } @@ -87,7 +88,7 @@ bool _isLocInRange(ASTLookupContext* context, SourceLoc start, SourceLoc end) 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); } @@ -667,17 +668,27 @@ bool _findAstNodeImpl(ASTLookupContext& context, SyntaxNode* node) { if (_isLocInRange(&context, decl->nameAndLoc.loc, _getDeclNameLength(decl->getName()))) { + bool isRealDeclName = true; for (auto modifier : decl->modifiers) { if (as<SynthesizedModifier>(modifier)) - return false; + { + isRealDeclName = false; + break; + } if (as<ImplicitParameterGroupElementTypeModifier>(modifier)) - return false; + { + isRealDeclName = false; + break; + } + } + if (isRealDeclName) + { + ASTLookupResult result; + result.path = context.nodePath; + context.results.add(_Move(result)); + return true; } - ASTLookupResult result; - result.path = context.nodePath; - context.results.add(_Move(result)); - return true; } } if (auto funcDecl = as<FunctionDeclBase>(node)) |
