Merge branch 'master' of github.com:spring-projects/sts4

This commit is contained in:
Kris De Volder
2017-11-17 13:55:53 -08:00
36 changed files with 983 additions and 148 deletions

View File

@@ -14,6 +14,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -30,9 +31,12 @@ import org.springframework.ide.vscode.boot.java.beans.test.SpringIndexerHarness.
import org.springframework.ide.vscode.boot.java.handlers.SymbolProvider;
import org.springframework.ide.vscode.boot.java.utils.SpringIndexer;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFolder;
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
import com.google.common.collect.ImmutableList;
/**
* @author Martin Lippert
*/
@@ -57,7 +61,7 @@ public class SpringIndexerBeansTest {
public void testScanSimpleConfigurationClass() throws Exception {
SpringIndexerHarness indexer = new SpringIndexerHarness(harness.getServer(), projectFinder, symbolProviders);
File directory = new File(ProjectsHarness.class.getResource("/test-projects/test-annotation-indexing-beans/").toURI());
indexer.initialize(directory.toPath());
indexer.initialize(indexer.wsFolder(directory));
String uriPrefix = "file://" + directory.getAbsolutePath();
indexer.assertDocumentSymbols(uriPrefix + "/src/main/java/org/test/SimpleConfiguration.java",
@@ -71,7 +75,7 @@ public class SpringIndexerBeansTest {
@Test public void testScanSpecialConfigurationClass() throws Exception {
SpringIndexerHarness indexer = new SpringIndexerHarness(harness.getServer(), projectFinder, symbolProviders);
File directory = new File(ProjectsHarness.class.getResource("/test-projects/test-annotation-indexing-beans/").toURI());
indexer.initialize(directory.toPath());
indexer.initialize(indexer.wsFolder(directory));
String uriPrefix = "file://" + directory.getAbsolutePath();
String docUri = uriPrefix + "/src/main/java/org/test/SpecialConfiguration.java";
@@ -103,7 +107,7 @@ public class SpringIndexerBeansTest {
public void testScanSimpleFunctionBean() throws Exception {
SpringIndexerHarness indexer = new SpringIndexerHarness(harness.getServer(), projectFinder, symbolProviders);
File directory = new File(ProjectsHarness.class.getResource("/test-projects/test-annotation-indexing-beans/").toURI());
indexer.initialize(directory.toPath());
indexer.initialize(indexer.wsFolder(directory));
String uriPrefix = "file://" + directory.getAbsolutePath();
indexer.assertDocumentSymbols(uriPrefix + "/src/main/java/org/test/FunctionClass.java",
@@ -119,7 +123,7 @@ public class SpringIndexerBeansTest {
public void testScanSimpleComponentClass() throws Exception {
SpringIndexerHarness indexer = new SpringIndexerHarness(harness.getServer(), projectFinder, symbolProviders);
File directory = new File(ProjectsHarness.class.getResource("/test-projects/test-annotation-indexing-beans/").toURI());
indexer.initialize(directory.toPath());
indexer.initialize(indexer.wsFolder(directory));
String uriPrefix = "file://" + directory.getAbsolutePath();
indexer.assertDocumentSymbols(uriPrefix + "/src/main/java/org/test/SimpleComponent.java",
@@ -134,7 +138,7 @@ public class SpringIndexerBeansTest {
@Test public void testScanSimpleControllerClass() throws Exception {
SpringIndexerHarness indexer = new SpringIndexerHarness(harness.getServer(), projectFinder, symbolProviders);
File directory = new File(ProjectsHarness.class.getResource("/test-projects/test-annotation-indexing-beans/").toURI());
indexer.initialize(directory.toPath());
indexer.initialize(indexer.wsFolder(directory));
String uriPrefix = "file://" + directory.getAbsolutePath();
String docUri = uriPrefix + "/src/main/java/org/test/SimpleController.java";
@@ -148,7 +152,7 @@ public class SpringIndexerBeansTest {
@Test public void testScanRestControllerClass() throws Exception {
SpringIndexerHarness indexer = new SpringIndexerHarness(harness.getServer(), projectFinder, symbolProviders);
File directory = new File(ProjectsHarness.class.getResource("/test-projects/test-annotation-indexing-beans/").toURI());
indexer.initialize(directory.toPath());
indexer.initialize(indexer.wsFolder(directory));
String uriPrefix = "file://" + directory.getAbsolutePath();
String docUri = uriPrefix + "/src/main/java/org/test/SimpleRestController.java";

View File

@@ -12,14 +12,14 @@ package org.springframework.ide.vscode.boot.java.beans.test;
import static org.junit.Assert.assertEquals;
import java.io.File;
import java.net.URI;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.eclipse.lsp4j.Range;
@@ -29,6 +29,7 @@ import org.springframework.ide.vscode.boot.java.annotations.AnnotationHierarchyA
import org.springframework.ide.vscode.boot.java.handlers.SymbolProvider;
import org.springframework.ide.vscode.boot.java.utils.SpringIndexer;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFolder;
import org.springframework.ide.vscode.commons.util.text.LanguageId;
import org.springframework.ide.vscode.commons.util.text.TextDocument;
import org.springframework.ide.vscode.languageserver.testharness.Editor;
@@ -139,7 +140,17 @@ public class SpringIndexerHarness {
return ImmutableList.of();
}
public void initialize(Path wsRoot) {
indexer.initialize(wsRoot);
public Collection<WorkspaceFolder> wsFolder(File directory) {
if (directory!=null) {
return ImmutableList.of(new WorkspaceFolder(
directory.toURI().toString(),
directory.getName()
));
}
return ImmutableList.of();
}
public void initialize(Collection<WorkspaceFolder> wsRoots) {
indexer.initialize(wsRoots);
}
}

View File

@@ -13,17 +13,22 @@ package org.springframework.ide.vscode.boot.java.references.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.File;
import java.net.URI;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.eclipse.lsp4j.Location;
import org.junit.Test;
import org.springframework.ide.vscode.boot.java.value.ValuePropertyReferencesProvider;
import org.springframework.ide.vscode.commons.languageserver.multiroot.WorkspaceFolder;
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
import com.google.common.collect.ImmutableList;
/**
* @author Martin Lippert
*/
@@ -34,7 +39,7 @@ public class PropertyReferenceFinderTest {
ValuePropertyReferencesProvider provider = new ValuePropertyReferencesProvider(null);
Path root = Paths.get(ProjectsHarness.class.getResource("/test-property-files/simple-case/").toURI());
CompletableFuture<List<? extends Location>> resultFuture = provider.findReferencesFromPropertyFiles(root, "test.property");
CompletableFuture<List<? extends Location>> resultFuture = provider.findReferencesFromPropertyFiles(wsFolder(root), "test.property");
assertNotNull(resultFuture);
List<? extends Location> locations = resultFuture.get();
@@ -49,12 +54,22 @@ public class PropertyReferenceFinderTest {
assertEquals(13, location.getRange().getEnd().getCharacter());
}
private Collection<WorkspaceFolder> wsFolder(Path directory) {
if (directory!=null) {
return ImmutableList.of(new WorkspaceFolder(
directory.toUri().toString(),
directory.getFileName().toString()
));
}
return ImmutableList.of();
}
@Test
public void testFindReferenceAtBeginningYMLFile() throws Exception {
ValuePropertyReferencesProvider provider = new ValuePropertyReferencesProvider(null);
Path root = Paths.get(ProjectsHarness.class.getResource("/test-property-files/simple-yml/").toURI());
CompletableFuture<List<? extends Location>> resultFuture = provider.findReferencesFromPropertyFiles(root, "test.property");
CompletableFuture<List<? extends Location>> resultFuture = provider.findReferencesFromPropertyFiles(wsFolder(root), "test.property");
assertNotNull(resultFuture);
List<? extends Location> locations = resultFuture.get();
@@ -74,7 +89,7 @@ public class PropertyReferenceFinderTest {
ValuePropertyReferencesProvider provider = new ValuePropertyReferencesProvider(null);
Path root = Paths.get(ProjectsHarness.class.getResource("/test-property-files/simple-case/").toURI());
CompletableFuture<List<? extends Location>> resultFuture = provider.findReferencesFromPropertyFiles(root, "server.port");
CompletableFuture<List<? extends Location>> resultFuture = provider.findReferencesFromPropertyFiles(wsFolder(root), "server.port");
assertNotNull(resultFuture);
List<? extends Location> locations = resultFuture.get();
@@ -94,7 +109,7 @@ public class PropertyReferenceFinderTest {
ValuePropertyReferencesProvider provider = new ValuePropertyReferencesProvider(null);
Path root = Paths.get(ProjectsHarness.class.getResource("/test-property-files/multiple-files/").toURI());
CompletableFuture<List<? extends Location>> resultFuture = provider.findReferencesFromPropertyFiles(root, "appl1.prop");
CompletableFuture<List<? extends Location>> resultFuture = provider.findReferencesFromPropertyFiles(wsFolder(root), "appl1.prop");
assertNotNull(resultFuture);
List<? extends Location> locations = resultFuture.get();
@@ -121,14 +136,14 @@ public class PropertyReferenceFinderTest {
assertEquals(1, location.getRange().getEnd().getLine());
assertEquals(10, location.getRange().getEnd().getCharacter());
}
private Location getLocation(List<? extends Location> locations, URI docURI) {
for (Location location : locations) {
if (docURI.toString().equals(location.getUri())) {
return location;
}
}
return null;
}
@@ -137,7 +152,7 @@ public class PropertyReferenceFinderTest {
ValuePropertyReferencesProvider provider = new ValuePropertyReferencesProvider(null);
Path root = Paths.get(ProjectsHarness.class.getResource("/test-property-files/mixed-multiple-files/").toURI());
CompletableFuture<List<? extends Location>> resultFuture = provider.findReferencesFromPropertyFiles(root, "appl1.prop");
CompletableFuture<List<? extends Location>> resultFuture = provider.findReferencesFromPropertyFiles(wsFolder(root), "appl1.prop");
assertNotNull(resultFuture);
List<? extends Location> locations = resultFuture.get();

View File

@@ -48,7 +48,7 @@ public class SpringPropertyIndexTest {
}
@Test
public void testScanningAllAnnotationsSimpleProjectUpfront() throws Exception {
public void testPropertiesIndexRefreshOnProjectChange() throws Exception {
harness.intialize(new File(ProjectsHarness.class.getResource("/test-projects/test-annotation-indexing-parent/test-annotation-indexing/").toURI()));
propertyIndexProvider = (DefaultSpringPropertyIndexProvider) harness.getServer().getSpringPropertyIndexProvider();