Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions source/slang/slang-language-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ SlangResult LanguageServerCore::didOpenTextDocument(const DidOpenTextDocumentPar
{
String canonicalPath = uriToCanonicalPath(args.textDocument.uri);
m_workspace->openDoc(canonicalPath, args.textDocument.text);

auto version = m_workspace->getCurrentVersion();
Module* parsedModule = version->getOrLoadModule(canonicalPath);
if (!parsedModule)
{
return SLANG_FAIL;
}

return SLANG_OK;
}

Expand Down Expand Up @@ -2605,6 +2613,14 @@ SlangResult LanguageServerCore::didChangeTextDocument(const DidChangeTextDocumen
String canonicalPath = uriToCanonicalPath(args.textDocument.uri);
for (auto change : args.contentChanges)
m_workspace->changeDoc(canonicalPath, change.range, change.text);

auto version = m_workspace->getCurrentVersion();
Module* parsedModule = version->getOrLoadModule(canonicalPath);
if (!parsedModule)
{
return SLANG_FAIL;
}

return SLANG_OK;
}

Expand Down
14 changes: 12 additions & 2 deletions source/slang/slang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4161,8 +4161,18 @@ void Linkage::loadParsedModule(
auto sink = translationUnit->compileRequest->getSink();

int errorCountBefore = sink->getErrorCount();
compileRequest->checkAllTranslationUnits();
int errorCountAfter = sink->getErrorCount();
int errorCountAfter;
try
{
compileRequest->checkAllTranslationUnits();
}
catch (...)
{
mapPathToLoadedModule.remove(mostUniqueIdentity);
mapNameToLoadedModules.remove(name);
throw;
}
errorCountAfter = sink->getErrorCount();
if (isInLanguageServer())
{
// Don't generate IR as language server.
Expand Down
Loading