Search in sources :

Example 11 with IJavaProject

use of org.springframework.ide.vscode.commons.java.IJavaProject in project sts4 by spring-projects.

the class CompilationUnitCacheTest method cu_cache_invalidated_by_doc_close.

@Test
public void cu_cache_invalidated_by_doc_close() throws Exception {
    harness = BootJavaLanguageServerHarness.builder().mockDefaults().build();
    harness.useProject(new IJavaProject() {

        @Override
        public IClasspath getClasspath() {
            return new DelegatingCachedClasspath<>(() -> null, null);
        }
    });
    harness.intialize(null);
    TextDocument doc = new TextDocument(harness.createTempUri(), LanguageId.JAVA, 0, "package my.package\n" + "\n" + "public class SomeClass {\n" + "\n" + "}\n");
    harness.newEditorFromFileUri(doc.getUri(), doc.getLanguageId());
    CompilationUnit cu = getCompilationUnit(doc);
    assertNotNull(cu);
    harness.closeDocument(doc.getId());
    CompilationUnit cuAnother = getCompilationUnit(doc);
    assertNotNull(cuAnother);
    assertFalse(cu == cuAnother);
    CompilationUnit cuYetAnother = getCompilationUnit(doc);
    assertTrue(cuAnother == cuYetAnother);
}
Also used : CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) TextDocument(org.springframework.ide.vscode.commons.util.text.TextDocument) IClasspath(org.springframework.ide.vscode.commons.java.IClasspath) Test(org.junit.Test)

Example 12 with IJavaProject

use of org.springframework.ide.vscode.commons.java.IJavaProject in project sts4 by spring-projects.

the class ApplicationPropertiesEditorTest method testPojoArrayCompletions.

@Test
public void testPojoArrayCompletions() throws Exception {
    IJavaProject p = createPredefinedMavenProject("boot-1.2.1-app-properties-list-of-pojo");
    useProject(p);
    assertNotNull(p.getClasspath().findType("demo.Foo"));
    assertCompletionsVariations("volder.foo.l<*>", "volder.foo.list[<*>");
    assertCompletionsDisplayStringAndDetail("volder.foo.list[0].<*>", new String[] { "description", "String" }, new String[] { "name", "String" }, new String[] { "roles", "List<String>" });
    assertCompletionsVariations("volder.foo.list[0].na<*>", "volder.foo.list[0].name=<*>");
    assertCompletionsVariations("volder.foo.list[0].d<*>", "volder.foo.list[0].description=<*>");
    assertCompletionsVariations("volder.foo.list[0].rl<*>", "volder.foo.list[0].roles=<*>");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) Test(org.junit.Test)

Example 13 with IJavaProject

use of org.springframework.ide.vscode.commons.java.IJavaProject in project sts4 by spring-projects.

the class ApplicationPropertiesEditorTest method testPredefinedProject.

@Test
public void testPredefinedProject() throws Exception {
    IJavaProject p = createPredefinedMavenProject("tricky-getters-boot-1.3.1-app");
    IType type = p.getClasspath().findType("demo.DemoApplication");
    assertNotNull(type);
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) IType(org.springframework.ide.vscode.commons.java.IType) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) Test(org.junit.Test)

Example 14 with IJavaProject

use of org.springframework.ide.vscode.commons.java.IJavaProject in project sts4 by spring-projects.

the class ApplicationPropertiesEditorTest method testEnumsInLowerCaseReconciling.

@Test
public void testEnumsInLowerCaseReconciling() throws Exception {
    IJavaProject p = createPredefinedMavenProject("enums-boot-1.3.2-app");
    useProject(p);
    assertNotNull(p.getClasspath().findType("demo.ClothingSize"));
    data("simple.pants.size", "demo.ClothingSize", null, "The simple pant's size");
    Editor editor = newEditor("simple.pants.size=NOT_A_SIZE\n" + "simple.pants.size=EXTRA_SMALL\n" + "simple.pants.size=extra-small\n" + "simple.pants.size=small\n" + "simple.pants.size=SMALL\n");
    // ignore deliberate abuse of dups
    editor.ignoreProblem(PROP_DUPLICATE_KEY);
    editor.assertProblems("NOT_A_SIZE|ClothingSize");
    editor = newEditor("foo.color-names.red=Rood\n" + "foo.color-names.green=Groen\n" + "foo.color-names.blue=Blauw\n" + "foo.color-names.not-a-color=Wrong\n" + "foo.color-names.blue.bad=Blauw\n");
    editor.assertProblems("not-a-color|Color", // because value type is not dotable the dots will be taken to be part of map key
    "blue.bad|Color");
    editor = newEditor("foo.color-data.red.next=green\n" + "foo.color-data.green.next=not a color\n" + "foo.color-data.red.bogus=green\n" + "foo.color-data.red.name=Rood\n");
    editor.assertProblems("not a color|Color", "bogus|no property");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) Test(org.junit.Test)

Example 15 with IJavaProject

use of org.springframework.ide.vscode.commons.java.IJavaProject in project sts4 by spring-projects.

the class ApplicationPropertiesEditorTest method testReconcilePojoArray.

@Test
public void testReconcilePojoArray() throws Exception {
    IJavaProject p = createPredefinedMavenProject("boot-1.2.1-app-properties-list-of-pojo");
    useProject(p);
    assertNotNull(p.getClasspath().findType("demo.Foo"));
    Editor editor = newEditor("token.bad.guy=problem\n" + "volder.foo.list[0].name=Kris\n" + "volder.foo.list[0].description=Kris\n" + "volder.foo.list[0].roles[0]=Developer\n" + "volder.foo.list[0]garbage=Grable\n" + "volder.foo.list[0].bogus=Bad\n");
    // This is the more ambitious requirement but it is not implemented yet.
    editor.assertProblems("token.bad.guy|unknown property", // 'description' is ok
    "garbage|'.' or '['", "bogus|has no property");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) AbstractPropsEditorTest(org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest) Test(org.junit.Test)

Aggregations

IJavaProject (org.springframework.ide.vscode.commons.java.IJavaProject)63 Test (org.junit.Test)52 AbstractPropsEditorTest (org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest)35 Editor (org.springframework.ide.vscode.languageserver.testharness.Editor)24 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)8 Ignore (org.junit.Ignore)8 IClasspath (org.springframework.ide.vscode.commons.java.IClasspath)7 TextDocument (org.springframework.ide.vscode.commons.util.text.TextDocument)7 File (java.io.File)6 Path (java.nio.file.Path)6 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)6 URI (java.net.URI)5 Map (java.util.Map)5 Listener (org.springframework.ide.vscode.commons.languageserver.java.ProjectObserver.Listener)5 Stream (java.util.stream.Stream)4 JavaCore (org.eclipse.jdt.core.JavaCore)4 AST (org.eclipse.jdt.core.dom.AST)4 ASTParser (org.eclipse.jdt.core.dom.ASTParser)4 JavaProjectFinder (org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder)4 List (java.util.List)3