Search in sources :

Example 46 with Diagnostic

use of org.eclipse.lsp4j.Diagnostic in project sts4 by spring-projects.

the class ApplicationPropertiesEditorTest method testDeprecatedPropertyQuickfix.

@Ignore
@Test
public void testDeprecatedPropertyQuickfix() throws Exception {
    data("error.path", "java.lang.String", null, "Path of the error controller.");
    deprecate("error.path", "server.error.path", null);
    Editor editor = newEditor("# a comment\n" + "error.path=foo\n");
    Diagnostic problem = editor.assertProblem("error.path");
    CompletionItem fix = editor.assertFirstQuickfix(problem, "Change to 'server.error.path'");
    editor.apply(fix);
    editor.assertText("# a comment\n" + "server.error.path<*>=foo\n");
}
Also used : CompletionItem(org.eclipse.lsp4j.CompletionItem) Diagnostic(org.eclipse.lsp4j.Diagnostic) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Ignore(org.junit.Ignore) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) Test(org.junit.Test)

Example 47 with Diagnostic

use of org.eclipse.lsp4j.Diagnostic in project sts4 by spring-projects.

the class ConcourseEditorTest method quickfixForOneOfMultipleMarkersOnSameRange.

@Test
public void quickfixForOneOfMultipleMarkersOnSameRange() throws Exception {
    Editor editor = harness.newEditor("jobs:\n" + "- name: myjob\n" + "  plan:\n" + "  - task: foo\n" + "    config:\n" + "      inputs:\n" + "      - name: foo");
    List<Diagnostic> problems = editor.assertProblems("config|[image_resource, rootfs_uri, image] is required", "config|[platform, run] are required");
    assertTrue(editor.getCodeActions(problems.get(0)).isEmpty());
    CodeAction quickfix = editor.assertCodeAction(problems.get(1));
    assertEquals("Add properties: [platform, run]", quickfix.getLabel());
    quickfix.perform();
    editor.assertText("jobs:\n" + "- name: myjob\n" + "  plan:\n" + "  - task: foo\n" + "    config:\n" + "      inputs:\n" + "      - name: foo\n" + "      platform: <*>\n" + "      run:\n" + "        path: ");
}
Also used : CodeAction(org.springframework.ide.vscode.languageserver.testharness.CodeAction) Diagnostic(org.eclipse.lsp4j.Diagnostic) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 48 with Diagnostic

use of org.eclipse.lsp4j.Diagnostic in project sts4 by spring-projects.

the class ConcourseEditorTest method gitResourceFetchParameter.

@Test
public void gitResourceFetchParameter() throws Exception {
    Editor editor = harness.newEditor("resources:\n" + "  - name: cf-networking-dev\n" + "    type: git\n" + "    source:\n" + "      uri: git@someplace.com:cloudfoundry-incubator/cf-networking-release.git\n" + "      branch: develop\n" + "      ignore_paths:\n" + "        - docs\n" + "      private_key: {{cf-networking-deploy-key}}\n" + "jobs:\n" + "- name: foo\n" + "  plan:\n" + "  - get: cf-networking-dev\n" + "    params:\n" + "      fetch: [master]\n" + "      submodules: none\n");
    Diagnostic p = editor.assertProblems("fetch|Deprecated").get(0);
    assertEquals(DiagnosticSeverity.Warning, p.getSeverity());
}
Also used : Diagnostic(org.eclipse.lsp4j.Diagnostic) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 49 with Diagnostic

use of org.eclipse.lsp4j.Diagnostic in project sts4 by spring-projects.

the class ConcourseEditorTest method concourse_3_0_rootfs_uri_prop.

@Test
public void concourse_3_0_rootfs_uri_prop() throws Exception {
    Editor editor = harness.newEditor(LanguageId.CONCOURSE_TASK, "platform: linux\n" + "image: blah\n" + "run:\n" + "  path: demo-repo/ci/tasks/run-tests.sh");
    Diagnostic p = editor.assertProblems("image|renamed to 'rootfs_uri'").get(0);
    assertEquals(DiagnosticSeverity.Warning, p.getSeverity());
    editor = harness.newEditor(LanguageId.CONCOURSE_TASK, "platform: linux\n" + "image: blah\n" + "run:\n" + "  path: demo-repo/ci/tasks/run-tests.sh");
    editor.assertHoverContains("image", "renamed to `rootfs_uri`");
}
Also used : Diagnostic(org.eclipse.lsp4j.Diagnostic) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 50 with Diagnostic

use of org.eclipse.lsp4j.Diagnostic in project sts4 by spring-projects.

the class Editor method assertProblem.

/**
 * Get a problem that covers the given text in the editor. Throws exception
 * if no matching problem is found.
 */
public Diagnostic assertProblem(String coveredText) throws Exception {
    Editor editor = this;
    List<Diagnostic> problems = editor.reconcile();
    for (Diagnostic p : problems) {
        String c = editor.getText(p.getRange());
        if (c.equals(coveredText)) {
            return p;
        }
    }
    fail("No problem found covering the text '" + coveredText + "' in: \n" + problemSumary(editor, problems));
    // unreachable but compiler doesn't know
    return null;
}
Also used : Diagnostic(org.eclipse.lsp4j.Diagnostic) MarkedString(org.eclipse.lsp4j.MarkedString)

Aggregations

Diagnostic (org.eclipse.lsp4j.Diagnostic)56 Test (org.junit.Test)31 Editor (org.springframework.ide.vscode.languageserver.testharness.Editor)22 Range (org.eclipse.lsp4j.Range)13 ArrayList (java.util.ArrayList)12 PublishDiagnosticsParams (org.eclipse.lsp4j.PublishDiagnosticsParams)11 List (java.util.List)8 Position (org.eclipse.lsp4j.Position)8 DiagnosticSeverity (org.eclipse.lsp4j.DiagnosticSeverity)7 URI (java.net.URI)5 Path (java.nio.file.Path)5 Map (java.util.Map)5 AbstractProjectsManagerBasedTest (org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)5 Command (org.eclipse.lsp4j.Command)5 MarkedString (org.eclipse.lsp4j.MarkedString)5 CodeAction (org.springframework.ide.vscode.languageserver.testharness.CodeAction)5 IOException (java.io.IOException)4 Collections (java.util.Collections)4 HashMap (java.util.HashMap)4 ImmutableList (com.google.common.collect.ImmutableList)3