From c90c6ab750ab05dd6d337e4f857958b8f3d00153 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 13 Jun 2022 12:20:35 -0700 Subject: Language Server improvements. (#2269) * Language Server improvements. - Improve parser robustness around `attribute_syntax`. - Exclude instance members in a static query. - Coloring accessors - Improved signature help cursor range check. * Add expected test result. * Language server: support configuring predefined macros. * Fix constructor highlighting. * Improving performance by supporting incremental text change notifications. * Fix UTF16 positions and highlighting of constructor calls. * Add completion suggestions for HLSL semantics. * Fix tests. * Fix: don't skip static variables in a static query. * Include literal init expr value in hover text. * Fix scenarios where completion failed to trigger. * Fixing language server protocol field initializations. Co-authored-by: Yong He --- source/slang/slang-parser.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-parser.cpp') diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index b2179c1af..38317009d 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -3105,7 +3105,11 @@ namespace Slang static NodeBase* parseConstructorDecl(Parser* parser, void* /*userData*/) { ConstructorDecl* decl = parser->astBuilder->create(); - parser->FillPosition(decl); + + // Note: we leave the source location of this decl as invalid, to + // trigger the fallback logic that fills in the location of the + // `__init` keyword later. + parser->PushScope(decl); // TODO: we need to make sure that all initializers have @@ -3132,6 +3136,7 @@ namespace Slang AccessorDecl* decl = nullptr; auto loc = peekToken(parser).loc; + auto name = peekToken(parser).getName(); if( AdvanceIf(parser, "get") ) { decl = parser->astBuilder->create(); @@ -3150,6 +3155,8 @@ namespace Slang return nullptr; } decl->loc = loc; + decl->nameAndLoc.name = name; + decl->nameAndLoc.loc = loc; _addModifiers(decl, modifiers); -- cgit v1.2.3