Copilot commented on code in PR #9665:
URL: https://github.com/apache/netbeans/pull/9665#discussion_r4181085442
##########
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/protocol/TextDocumentServiceImpl.java:
##########
@@ -2149,12 +2149,12 @@ CompletableFuture<List<Diagnostic>>
computeDiagnostics(String uri, EnumSet<Error
Document originalDoc =
server.getOpenedDocuments().getDocument(uri);
long originalVersion = documentVersion(originalDoc);
AtomicReference<Document> docHolder = new
AtomicReference<>(originalDoc);
- List<Diagnostic> result = Collections.emptyList();
+ List<Diagnostic> result = new ArrayList<>();
if (types.contains(ErrorProvider.Kind.ERRORS)) {
- result = computeDiags(uri, -1, ErrorProvider.Kind.ERRORS,
originalVersion, docHolder);
+ result.addAll(computeDiags(uri, -1,
ErrorProvider.Kind.ERRORS, originalVersion, docHolder));
}
if (types.contains(ErrorProvider.Kind.HINTS)) {
- result = computeDiags(uri, -1, ErrorProvider.Kind.HINTS,
originalVersion, docHolder);
+ result.addAll(computeDiags(uri, -1,
ErrorProvider.Kind.HINTS, originalVersion, docHolder));
Review Comment:
`computeDiags` already returns the complete merged set by reading both
`lsp-errors-errors` and `lsp-errors-hints` properties (lines 2259-2266). After
the ERRORS call, the HINTS call therefore returns errors plus hints, so
appending both results emits every error twice; an already-cached hint can also
be appended once before being recomputed. Retain only the latest merged result
(and add a regression assertion for one error plus one hint), or refactor the
helper to return only the requested kind before concatenating.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists