Search in sources :

Example 36 with IJavaProject

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

the class ScopeCompletionTest method setup.

@Before
public void setup() throws Exception {
    IJavaProject testProject = ProjectsHarness.INSTANCE.mavenProject("test-annotations");
    harness = BootJavaLanguageServerHarness.builder().mockDefaults().build();
    harness.useProject(testProject);
    harness.intialize(null);
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Before(org.junit.Before)

Example 37 with IJavaProject

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

the class CompilationUnitCacheTest method cu_cached.

@Test
public void cu_cached() 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");
    CompilationUnit cu = getCompilationUnit(doc);
    assertNotNull(cu);
    CompilationUnit cuAnother = getCompilationUnit(doc);
    assertTrue(cu == cuAnother);
}
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 38 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_change.

@Test
public void cu_cache_invalidated_by_doc_change() 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.changeDocument(doc.getUri(), 0, 0, "     ");
    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 39 with IJavaProject

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

the class ActuatorWarningHoverTest method warningHoverHasPreciseLocation.

@Test
public void warningHoverHasPreciseLocation() throws Exception {
    // It will be less annoying if limit the area the hover responds to, to just inside the
    // annotation name rather than the whole range of the ast node.
    // Has running app:
    mockAppProvider.builder().isSpringBootApp(true).processId("22022").processName("foo.bar.RunningApp").profilesUnknown().build();
    // No actuator on classpath:
    String projectName = NO_ACTUATOR_PROJECT;
    IJavaProject project = projects.mavenProject(projectName);
    harness.useProject(project);
    harness.intialize(null);
    Editor editor = harness.newEditor(LanguageId.JAVA, "package hello;\n" + "\n" + "import org.springframework.context.annotation.Bean;\n" + "import org.springframework.context.annotation.Configuration;\n" + "import org.springframework.context.annotation.Profile;\n" + "\n" + "@Configuration\n" + "public class LocalConfig {\n" + "	\n" + "	@Bean(\"the-bean-name\")\n" + "	Foo myFoo() {\n" + "		return new FooImplementation();\n" + "	}\n" + "}");
    editor.assertHighlights();
    editor.assertHoverContains("@Bean", "No live hover information");
    editor.assertNoHover("the-bean-name");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) Test(org.junit.Test)

Example 40 with IJavaProject

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

the class ActuatorWarningHoverTest method noWarningIf_NoRunningApps.

@Test
public void noWarningIf_NoRunningApps() throws Exception {
    // No running app:
    // actaully... no code needed to set that up. mockAppBuilder is 'empty' by default.
    // No actuator on classpath:
    String projectName = NO_ACTUATOR_PROJECT;
    IJavaProject project = projects.mavenProject(projectName);
    harness.useProject(project);
    harness.intialize(null);
    Editor editor = harness.newEditor(LanguageId.JAVA, "package hello;\n" + "\n" + "import org.springframework.context.annotation.Configuration;\n" + "import org.springframework.context.annotation.Profile;\n" + "\n" + "@Configuration\n" + "@Profile({\"local-profile\", \"inactive\", \"testing-profile\"})\n" + "public class LocalConfig {\n" + "}");
    editor.assertHighlights();
    editor.assertNoHover("@Profile");
}
Also used : IJavaProject(org.springframework.ide.vscode.commons.java.IJavaProject) Editor(org.springframework.ide.vscode.languageserver.testharness.Editor) 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