Implement Workspace Diagnostic Scanning (Issue 31) - #33
Open
Moataz-Aldawood wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Implement Workspace Diagnostic Scanning (Issue #31)
Overview
This PR introduces a much-requested feature: the ability to proactively scan an entire workspace for compilation errors and warnings without requiring the user to open every file manually. It fulfills Issue #31 and also addresses exclusion glob-patterns requested in Issue #19.
Changes & Features Introduced
Workspace Scanning Configuration:
netbeans.autoScanWorkspace: A new boolean setting (default:false) that allows users to automatically trigger a full workspace diagnostic scan whenever they load a project.netbeans.scanExclude: A new array configuration (default:["**/node_modules/**", "**/target/**", "**/build/**"]) allowing users to define glob patterns for directories that should be skipped during the scan to save resources.New User Commands:
nbls.workspace.scan(Java: Scan Workspace for Diagnostics): Allows the user to manually trigger a background scan of all.javafiles in the workspace at any time. It includes a cancellable VS Code progress bar.nbls.workspace.scan.clear(Java: Clear Workspace Diagnostics): A utility command to instantly clear all background scan results from the custom VS Code Problems panel collection.Background Scanner Logic (
extension.ts):doWorkspaceScanwhich batch processes files by invoking the backendnbls.get.diagnosticscommand in small chunks. This prevents overloading the LSP server with hundreds of simultaneous parsing requests.ExceptionInInitializerErrorstack traces caused by upstream Lombok incompatibilities.Fixes
Critical Bug Fix in
TextDocumentServiceImpl.javaWhile implementing the scanner, we discovered a major bug in the
computeDiagnosticsmethod inside the backend language server. Previously, when the server computed errors and hints simultaneously, the resultingresultlist was being overwritten rather than aggregated. This caused standard compilation errors to randomly disappear or be completely overwritten by simple code hints.computeDiagnosticsto use anArrayList<>and.addAll()so that both ERRORS and HINTS are correctly merged and returned to the client in a single payload.Challenges Encountered
Lombok Compatibility on
masterBranch:During testing on the
masterbranch, we encountered a significant challenge with Lombok throwing fataljava.lang.NoClassDefFoundError: Could not initialize class lombok.javac.Javacexceptions.apache/netbeansmaster branch. The NetBeans team recently updated the internalnbjavaccompiler to Java 22/23 and unfortunately dropped theEndPosTablecompatibility patch (which existed in NetBeans 21) that allowed Lombok to function on newer JDKs.cannot find symbolerrors that result from the failed Lombok processing.Native LSP Diagnostic Caching:
We encountered confusion regarding lingering diagnostics in the Problems panel after closing files. This is due to the native
vscode-languageclientarchitecture where the backend server does not explicitly send empty arrays ([]) to clear diagnostics when files are closed. We solved this from the user's perspective by keeping our background scan results isolated in a separate, clearable custom bucket (projectDiagnosticCollection).Recommendations for Upstream
EndPosTableinnbjavac: We highly recommend filing a bug against the coreapache/netbeansrepository to reinstate the dummyEndPosTablepatch innbjavacfor Java 22/23. Until this is fixed upstream, Lombok users running the latest NetBeans Language Server on modern JDKs will experience completely broken annotation processing.didClose: The NetBeans Language Server should be updated to actively sendpublishDiagnostics(uri, [])when it receives adidClosenotification for a file, ensuring that the VS Code Problems panel cleans up gracefully when a user closes a broken file.PR approval and merge checklist: