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-serialize-container.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'source/slang/slang-serialize-container.cpp') diff --git a/source/slang/slang-serialize-container.cpp b/source/slang/slang-serialize-container.cpp index 344b4aa02..09aea6c8b 100644 --- a/source/slang/slang-serialize-container.cpp +++ b/source/slang/slang-serialize-container.cpp @@ -350,7 +350,7 @@ static List& _getCandidateExtensionList( { auto startChunk = chunk; - RefPtr astBuilder; + RefPtr astBuilder = options.astBuilder; NodeBase* astRootNode = nullptr; RefPtr irModule; @@ -385,8 +385,10 @@ static List& _getCandidateExtensionList( StringBuilder buf; buf << "tu" << out.modules.getCount(); - - astBuilder = new ASTBuilder(options.sharedASTBuilder, buf.ProduceString()); + if (!astBuilder) + { + astBuilder = new ASTBuilder(options.sharedASTBuilder, buf.ProduceString()); + } DefaultSerialObjectFactory objectFactory(astBuilder); @@ -419,7 +421,7 @@ static List& _getCandidateExtensionList( { UnownedStringSlice mangledName = reader.getStringSlice(SerialIndex(i)); - UnownedStringSlice moduleName; + String moduleName; SLANG_RETURN_ON_FAIL(MangledNameParser::parseModuleName(mangledName, moduleName)); // If we already have looked up this module and it has the same name just use what we have @@ -457,8 +459,11 @@ static List& _getCandidateExtensionList( options.sink->diagnose(SourceLoc::fromRaw(0), Diagnostics::unableToFindSymbolInModule, mangledName, moduleName); } - // If didn't find the export then we are done - return SLANG_FAIL; + // If didn't find the export then we create an UnresolvedDecl node to represent the error. + auto unresolved = astBuilder->create(); + unresolved->nameAndLoc.name = + options.linkage->getNamePool()->getName(mangledName); + nodeBase = unresolved; } // set the result -- cgit v1.2.3