Search in sources :

Example 1 with LSPEclipseUtils

use of org.eclipse.lsp4e.LSPEclipseUtils in project lsp4e by eclipse.

the class LSPDiagnosticsToMarkers method accept.

@Override
public void accept(PublishDiagnosticsParams diagnostics) {
    try {
        String uri = diagnostics.getUri();
        IResource resource = LSPEclipseUtils.findResourceFor(uri);
        if (resource != null && resource.exists()) {
            updateMarkers(diagnostics, resource);
        } else {
            LSPEclipseUtils.findOpenEditorsFor(LSPEclipseUtils.toUri(uri)).stream().map(reference -> reference.getEditor(true)).filter(Objects::nonNull).map(LSPEclipseUtils::getTextViewer).filter(Objects::nonNull).filter(ISourceViewer.class::isInstance).map(ISourceViewer.class::cast).forEach(sourceViewer -> updateEditorAnnotations(sourceViewer, diagnostics));
        }
    } catch (CoreException ex) {
        LanguageServerPlugin.logError(ex);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) LSPEclipseUtils(org.eclipse.lsp4e.LSPEclipseUtils) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) IResource(org.eclipse.core.resources.IResource)

Aggregations

IResource (org.eclipse.core.resources.IResource)1 CoreException (org.eclipse.core.runtime.CoreException)1 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)1 LSPEclipseUtils (org.eclipse.lsp4e.LSPEclipseUtils)1