Skip to content

feat: Show LSP diagnostic errors in Project Errors #969

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

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@

import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.problems.WolfTheProblemSolver;
import com.intellij.util.containers.ContainerUtil;
import com.redhat.devtools.lsp4ij.ClosedDocument;
import com.redhat.devtools.lsp4ij.LSPIJUtils;
import com.redhat.devtools.lsp4ij.LanguageServerWrapper;
import com.redhat.devtools.lsp4ij.OpenedDocument;
import com.redhat.devtools.lsp4ij.client.features.FileUriSupport;
import org.eclipse.lsp4j.DiagnosticSeverity;
import org.eclipse.lsp4j.PublishDiagnosticsParams;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -53,7 +56,8 @@ private void updateDiagnostics(@NotNull PublishDiagnosticsParams params, @NotNul
if (project.isDisposed()) {
return;
}
VirtualFile file = FileUriSupport.findFileByUri(params.getUri(), languageServerWrapper.getClientFeatures());
var clientFeatures = languageServerWrapper.getClientFeatures();
VirtualFile file = FileUriSupport.findFileByUri(params.getUri(), clientFeatures);
if (file == null) {
return;
}
Expand All @@ -71,6 +75,13 @@ private void updateDiagnostics(@NotNull PublishDiagnosticsParams params, @NotNul
ClosedDocument closedDocument = languageServerWrapper.getClosedDocument(fileURI, true);
closedDocument.updateDiagnostics(params.getDiagnostics());
}

WolfTheProblemSolver wolf = WolfTheProblemSolver.getInstance(project);
if (ContainerUtil.exists(params.getDiagnostics(), diagnostic -> diagnostic.getSeverity() == DiagnosticSeverity.Error)) {
wolf.reportProblemsFromExternalSource(file, languageServerWrapper);
} else {
wolf.clearProblemsFromExternalSource(file, languageServerWrapper);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2025 Red Hat Inc. and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*
* Contributors:
* Red Hat Inc. - initial API and implementation
*******************************************************************************/
package com.redhat.devtools.lsp4ij.features.diagnostics;

import com.intellij.openapi.util.Condition;
import com.intellij.openapi.vfs.VirtualFile;

public class LSPProblemFileHighlightFilter implements Condition<VirtualFile> {
@Override
public boolean value(VirtualFile file) {
return true;
}
}
2 changes: 2 additions & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@
groupName="Language Servers"
displayName="Diagnostics"
implementationClass="com.redhat.devtools.lsp4ij.inspections.LSPLocalInspectionTool"/>
<problemFileHighlightFilter id ="LSPProblemFileHighlightFilter"
implementation="com.redhat.devtools.lsp4ij.features.diagnostics.LSPProblemFileHighlightFilter"/>

<!-- LSP textDocument/completion request support -->
<typedHandler id="LSPCompletionTriggerTypedHandler"
Expand Down
Loading