diff options
| author | Harsh Aggarwal (NVIDIA) <haaggarwal@nvidia.com> | 2025-07-02 09:53:42 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-02 04:23:42 +0000 |
| commit | 35f00363d03afad74874b330f623bcd4caf115be (patch) | |
| tree | cc62b6708c8b8183f616be041a8196f31d224bc0 /source/slang/slang.cpp | |
| parent | 7ffb9f53e41c409a51c41318442067cc6c7e4f48 (diff) | |
Fix diagnostics not appearing when semantic tokens are disabled (#7477) (#7532)
* Fix diagnostics not appearing when semantic tokens are disabled (#7477)
Previously, the language server only triggered module loading and compilation
through semantic token requests. When semantic tokens were disabled,
didOpenTextDocument and didChangeTextDocument would only update the workspace
without compiling modules, meaning no diagnostics were generated.
This change:
- Adds module loading to didOpenTextDocument for .slang/.hlsl files
- Adds module loading to didChangeTextDocument for .slang/.hlsl files
- Triggers diagnostic updates via resetDiagnosticUpdateTime for Slang files
- Ensures diagnostics appear immediately when opening/editing files
- Maintains backward compatibility with existing LSP features
Additionally fixes JSON serialization to properly handle NullResponse types
by serializing them as JSON null instead of empty objects, improving LSP
protocol compliance.
Now diagnostics work correctly regardless of semantic token settings.
* Revert: Remove unrelated change - will pick up in seprate PR
* Fix module state corruption when checkAllTranslationUnits throws
Add try/catch in Linkage::loadParsedModule to properly clean up
module maps when checkAllTranslationUnits() fails with an exception. This
prevents incorrect state in WorkspaceVersion::getOrLoadModule where
failed modules remained in the loaded modules map, causing
subsequent calls to return stale/invalid module references.
* Update to address review comments
* update: remove explicit checking for .slang and .hlsl
Diffstat (limited to 'source/slang/slang.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index e149058b1..e98187c85 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -4131,8 +4131,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. |
