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.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'source/slang/slang.cpp') diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 7602096d4..02b1efedf 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -2611,6 +2611,11 @@ void Linkage::loadParsedModule( } } loadedModulesList.add(loadedModule); + + if (m_moduleCache) + { + m_moduleCache->storeModule(this, pathInfo.foundPath, loadedModule); + } } Module* Linkage::loadModule(String const& name) @@ -2794,6 +2799,19 @@ RefPtr Linkage::findOrImportModule( if (mapPathToLoadedModule.TryGetValue(filePathInfo.getMostUniqueIdentity(), loadedModule)) return loadedModule; + // Is this module in user provided cache? + // (yong): module cache is intended to speed up language server reparsing. + // currently it is *not* enabled in language server. + if (m_moduleCache) + { + loadedModule = m_moduleCache->tryLoadModule(this, filePathInfo.foundPath); + if (loadedModule) + { + mapPathToLoadedModule[filePathInfo.getMostUniqueIdentity()] = loadedModule; + return loadedModule; + } + } + // Try to load it ComPtr fileContents; if(SLANG_FAILED(includeSystem.loadFile(filePathInfo, fileContents))) @@ -2945,9 +2963,7 @@ static bool _canExportDeclSymbol(ASTNodeType type) { switch (type) { - case ASTNodeType::ModuleDecl: case ASTNodeType::EmptyDecl: - case ASTNodeType::NamespaceDecl: { return false; } -- cgit v1.2.3