Search in sources :

Example 21 with PublishDiagnosticsParams

use of org.eclipse.lsp4j.PublishDiagnosticsParams in project eclipse.jdt.ls by eclipse.

the class DocumentLifeCycleHandlerTest method testDidOpenNotOnClasspath.

@Test
public void testDidOpenNotOnClasspath() throws Exception {
    importProjects("eclipse/hello");
    IProject project = WorkspaceHelper.getProject("hello");
    URI uri = project.getFile("nopackage/Test2.java").getRawLocationURI();
    ICompilationUnit cu = JDTUtils.resolveCompilationUnit(uri);
    String source = FileUtils.readFileToString(FileUtils.toFile(uri.toURL()));
    openDocument(cu, source, 1);
    Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor);
    assertEquals(project, cu.getJavaProject().getProject());
    assertEquals(source, cu.getSource());
    List<PublishDiagnosticsParams> diagnosticReports = getClientRequests("publishDiagnostics");
    assertEquals(1, diagnosticReports.size());
    PublishDiagnosticsParams diagParam = diagnosticReports.get(0);
    assertEquals(1, diagParam.getDiagnostics().size());
    closeDocument(cu);
    Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitor);
    diagnosticReports = getClientRequests("publishDiagnostics");
    assertEquals(2, diagnosticReports.size());
    diagParam = diagnosticReports.get(1);
    assertEquals(0, diagParam.getDiagnostics().size());
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) PublishDiagnosticsParams(org.eclipse.lsp4j.PublishDiagnosticsParams) URI(java.net.URI) IProject(org.eclipse.core.resources.IProject) AbstractProjectsManagerBasedTest(org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest) Test(org.junit.Test)

Example 22 with PublishDiagnosticsParams

use of org.eclipse.lsp4j.PublishDiagnosticsParams in project xtext-core by eclipse.

the class LanguageServerImpl method publishDiagnostics.

private void publishDiagnostics(URI uri, Iterable<? extends Issue> issues) {
    initialized.thenAccept((initParams) -> {
        PublishDiagnosticsParams publishDiagnosticsParams = new PublishDiagnosticsParams();
        publishDiagnosticsParams.setUri(uriExtensions.toUriString(uri));
        publishDiagnosticsParams.setDiagnostics(toDiagnostics(issues));
        client.publishDiagnostics(publishDiagnosticsParams);
    });
}
Also used : PublishDiagnosticsParams(org.eclipse.lsp4j.PublishDiagnosticsParams)

Aggregations

PublishDiagnosticsParams (org.eclipse.lsp4j.PublishDiagnosticsParams)22 Diagnostic (org.eclipse.lsp4j.Diagnostic)8 URI (java.net.URI)7 ArrayList (java.util.ArrayList)6 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)6 HashMap (java.util.HashMap)4 ICompilerProblem (org.apache.flex.compiler.problems.ICompilerProblem)4 AbstractProjectsManagerBasedTest (org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)4 Test (org.junit.Test)4 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 ConcurrentModificationException (java.util.ConcurrentModificationException)3 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)3 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)3 Path (java.nio.file.Path)2 List (java.util.List)2 Map (java.util.Map)2 Workspace (org.apache.flex.compiler.internal.workspaces.Workspace)2 IWorkspace (org.apache.flex.compiler.workspaces.IWorkspace)2