Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match diagnostics with empty ranges #576

Merged
merged 1 commit into from
Mar 28, 2023
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
2 changes: 1 addition & 1 deletion org.eclipse.lsp4e.tests.mock/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Mock Language Server to test LSP4E
Bundle-SymbolicName: org.eclipse.lsp4e.tests.mock
Bundle-Version: 0.16.1.qualifier
Bundle-Version: 0.16.2.qualifier
Bundle-Vendor: Eclipse LSP4E
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.lsp4j;bundle-version="[0.20.0,0.21.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,17 @@ public void didOpen(DidOpenTextDocumentParams params) {
}

if (this.diagnostics != null && !this.diagnostics.isEmpty()) {
// 'collect(Collectors.toSet()` is added here in order to prevent a
// ConcurrentModificationException appearance
this.remoteProxies.stream().collect(Collectors.toSet()).forEach(p -> p.publishDiagnostics(
new PublishDiagnosticsParams(params.getTextDocument().getUri(), this.diagnostics)));
// we're not sure which remote proxy to use, but we know we should only use one
// per didOpen
// for proper LS interaction; so a strategy is to use the first one and rotate
// the others
// for further executions
synchronized (this.remoteProxies) {
// and we synchronize to avoid concurrent read/write on the list
this.remoteProxies.get(0).publishDiagnostics(
new PublishDiagnosticsParams(params.getTextDocument().getUri(), this.diagnostics));
Collections.rotate(this.remoteProxies, 1);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private IMarker getExistingMarkerFor(IDocument document, Diagnostic diagnostic,
for (IMarker marker : remainingMarkers) {
try {
if (LSPEclipseUtils.toOffset(diagnostic.getRange().getStart(), document) == MarkerUtilities.getCharStart(marker)
&& LSPEclipseUtils.toOffset(diagnostic.getRange().getEnd(), document) == MarkerUtilities.getCharEnd(marker)
&& (LSPEclipseUtils.toOffset(diagnostic.getRange().getEnd(), document) == MarkerUtilities.getCharEnd(marker) || Objects.equals(diagnostic.getRange().getStart(), diagnostic.getRange().getEnd()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since when we create the marker, we already set the end position to be one char forward, would the existing condition not match already? Why do we need a new one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since when we create the marker, we already set the end position to be one char forward

Only in case of empty range

would the existing condition not match already?

No, it does not match this case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

&& Objects.equals(marker.getAttribute(IMarker.MESSAGE), diagnostic.getMessage())
&& Objects.equals(marker.getAttribute(LANGUAGE_SERVER_ID), this.languageServerId)) {
return marker;
Expand Down