LSP4J 0.14.0. SymbolInformation -> WorkspaceSymbol where possible

This commit is contained in:
aboyko
2022-08-08 22:35:28 -04:00
parent a15ad9261a
commit afd6b9eac0
35 changed files with 300 additions and 359 deletions

View File

@@ -21,7 +21,7 @@ import java.util.List;
import org.apache.commons.io.IOUtils;
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.springframework.ide.vscode.boot.app.SpringSymbolIndex;
import org.springframework.ide.vscode.commons.util.text.LanguageId;
import org.springframework.ide.vscode.commons.util.text.TextDocument;
@@ -82,14 +82,14 @@ public class SpringIndexerHarness {
}
private static final Comparator<Range> RANGE_COMPARATOR = Editor.RANGE_COMPARATOR;
private static final Comparator<SymbolInformation> SYMBOL_COMPARATOR = new Comparator<SymbolInformation>() {
private static final Comparator<WorkspaceSymbol> SYMBOL_COMPARATOR = new Comparator<WorkspaceSymbol>() {
@Override
public int compare(SymbolInformation o1, SymbolInformation o2) {
int r = o1.getLocation().getUri().compareTo(o2.getLocation().getUri());
public int compare(WorkspaceSymbol o1, WorkspaceSymbol o2) {
int r = o1.getLocation().getLeft().getUri().compareTo(o2.getLocation().getLeft().getUri());
if (r!=0) return r;
r = RANGE_COMPARATOR.compare(o1.getLocation().getRange(), o2.getLocation().getRange());
r = RANGE_COMPARATOR.compare(o1.getLocation().getLeft().getRange(), o2.getLocation().getLeft().getRange());
if (r!=0) return r;
return o1.getName().compareTo(o2.getName());
@@ -115,15 +115,15 @@ public class SpringIndexerHarness {
}
public static List<TestSymbolInfo> getSymbolsInFile(SpringSymbolIndex indexer, String docURI) throws Exception {
List<? extends SymbolInformation> symbols = indexer.getSymbols(docURI);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docURI);
if (symbols!=null) {
symbols = new ArrayList<>(symbols);
Collections.sort(symbols, SYMBOL_COMPARATOR);
TextDocument doc = new TextDocument(docURI, LanguageId.JAVA, 1, IOUtils.toString(new URI(docURI)));
ImmutableList.Builder<TestSymbolInfo> symbolInfos = ImmutableList.builder();
for (SymbolInformation s : symbols) {
int start = doc.toOffset(s.getLocation().getRange().getStart());
int end = doc.toOffset(s.getLocation().getRange().getEnd());
for (WorkspaceSymbol s : symbols) {
int start = doc.toOffset(s.getLocation().getLeft().getRange().getStart());
int end = doc.toOffset(s.getLocation().getLeft().getRange().getEnd());
symbolInfos.add(new TestSymbolInfo(doc.textBetween(start, end), s.getName()));
}
return symbolInfos.build();

View File

@@ -19,8 +19,8 @@ import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -67,7 +67,7 @@ public class DataRepositorySymbolProviderTest {
@Test
public void testSimpleRepositorySymbol() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/CustomerRepository.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(1, symbols.size());
assertTrue(containsSymbol(symbols, "@+ 'customerRepository' (Customer) Repository<Customer,Long>", docUri, 6, 17, 6, 35));
@@ -77,16 +77,16 @@ public class DataRepositorySymbolProviderTest {
assertEquals("customerRepository", ((BeansSymbolAddOnInformation)addon.get(0)).getBeanID());
}
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
SymbolInformation symbol = iterator.next();
private boolean containsSymbol(List<? extends WorkspaceSymbol> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
for (Iterator<? extends WorkspaceSymbol> iterator = symbols.iterator(); iterator.hasNext();) {
WorkspaceSymbol symbol = iterator.next();
if (symbol.getName().equals(name)
&& symbol.getLocation().getUri().equals(uri)
&& symbol.getLocation().getRange().getStart().getLine() == startLine
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
&& symbol.getLocation().getLeft().getUri().equals(uri)
&& symbol.getLocation().getLeft().getRange().getStart().getLine() == startLine
&& symbol.getLocation().getLeft().getRange().getStart().getCharacter() == startCHaracter
&& symbol.getLocation().getLeft().getRange().getEnd().getLine() == endLine
&& symbol.getLocation().getLeft().getRange().getEnd().getCharacter() == endCharacter) {
return true;
}
}

View File

@@ -23,8 +23,8 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.eclipse.lsp4j.Location;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -81,7 +81,7 @@ public class RequestMappingDependentConstantChangedTest {
public void testSimpleRequestMappingSymbolFromConstantInDifferentClass() throws Exception {
String docUri = directory.resolve("src/main/java/org/test/SimpleMappingClassWithConstantInDifferentClass.java").toUri().toString();
String constantsUri = directory.resolve("src/main/java/org/test/Constants.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(1, symbols.size());
assertSymbol(docUri, "@/path/from/constant", "@RequestMapping(Constants.REQUEST_MAPPING_PATH)");
@@ -104,7 +104,7 @@ public class RequestMappingDependentConstantChangedTest {
public void testSimpleRequestMappingSymbolFromConstantInDifferentClassViaMultipleFilesUpdate() throws Exception {
String docUri = directory.resolve("src/main/java/org/test/SimpleMappingClassWithConstantInDifferentClass.java").toUri().toString();
String constantsUri = directory.resolve("src/main/java/org/test/Constants.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(1, symbols.size());
assertSymbol(docUri, "@/path/from/constant", "@RequestMapping(Constants.REQUEST_MAPPING_PATH)");
@@ -128,7 +128,7 @@ public class RequestMappingDependentConstantChangedTest {
String docUri = directory.resolve("src/main/java/org/test/ChainedRequestMappingPathOverMultipleClasses.java").toUri().toString();
String chainConstantsUri_2 = directory.resolve("src/main/java/org/test/ChainElement2.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(1, symbols.size());
assertSymbol(docUri, "@/path/from/chain", "@RequestMapping(ChainElement1.MAPPING_PATH_1)");
@@ -153,12 +153,12 @@ public class RequestMappingDependentConstantChangedTest {
String pongUri = directory.resolve("src/main/java/org/test/PongConstantRequestMapping.java").toUri().toString();
{
List<? extends SymbolInformation> symbols = indexer.getSymbols(pingUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pingUri);
assertSymbolCount(1, symbols);
assertSymbol(pingUri, "@/pong -- GET", "@GetMapping(PongConstantRequestMapping.PONG)");
}
{
List<? extends SymbolInformation> symbols = indexer.getSymbols(pongUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pongUri);
assertSymbolCount(1, symbols);
assertSymbol(pongUri, "@/ping -- GET", "@GetMapping(PingConstantRequestMapping.PING)");
}
@@ -167,12 +167,12 @@ public class RequestMappingDependentConstantChangedTest {
indexer.updateDocument(pingUri, null, "triggered by test code").get();
{
List<? extends SymbolInformation> symbols = indexer.getSymbols(pingUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pingUri);
assertSymbolCount(1, symbols);
assertSymbol(pingUri, "@/pong -- GET", "@GetMapping(PongConstantRequestMapping.PONG)");
}
{
List<? extends SymbolInformation> symbols = indexer.getSymbols(pongUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pongUri);
assertSymbolCount(1, symbols);
assertSymbol(pongUri, "@/changed -- GET", "@GetMapping(PingConstantRequestMapping.PING)");
}
@@ -186,12 +186,12 @@ public class RequestMappingDependentConstantChangedTest {
String pongUri = directory.resolve("src/main/java/org/test/PongConstantRequestMapping.java").toUri().toString();
{
List<? extends SymbolInformation> symbols = indexer.getSymbols(pingUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pingUri);
assertSymbolCount(1, symbols);
assertSymbol(pingUri, "@/pong -- GET", "@GetMapping(PongConstantRequestMapping.PONG)");
}
{
List<? extends SymbolInformation> symbols = indexer.getSymbols(pongUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pongUri);
assertSymbolCount(1, symbols);
assertSymbol(pongUri, "@/ping -- GET", "@GetMapping(PingConstantRequestMapping.PING)");
}
@@ -200,12 +200,12 @@ public class RequestMappingDependentConstantChangedTest {
indexer.updateDocuments(new String[] {pingUri}, "triggered by test code").get();
{
List<? extends SymbolInformation> symbols = indexer.getSymbols(pingUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pingUri);
assertSymbolCount(1, symbols);
assertSymbol(pingUri, "@/pong -- GET", "@GetMapping(PongConstantRequestMapping.PONG)");
}
{
List<? extends SymbolInformation> symbols = indexer.getSymbols(pongUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(pongUri);
assertSymbolCount(1, symbols);
assertSymbol(pongUri, "@/changed -- GET", "@GetMapping(PingConstantRequestMapping.PING)");
}
@@ -213,10 +213,10 @@ public class RequestMappingDependentConstantChangedTest {
/////////////////////////////////////////////////////////////////////////////////////////////////////
private void assertSymbolCount(int expectedCount, List<? extends SymbolInformation> symbols) {
private void assertSymbolCount(int expectedCount, List<? extends WorkspaceSymbol> symbols) {
if (symbols.size()!=expectedCount) {
StringBuilder found = new StringBuilder();
for (SymbolInformation s : symbols) {
for (WorkspaceSymbol s : symbols) {
found.append(s.getName());
found.append("\n");
}
@@ -225,15 +225,15 @@ public class RequestMappingDependentConstantChangedTest {
}
private void assertSymbol(String docUri, String name, String coveredText) throws Exception {
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
Optional<? extends SymbolInformation> maybeSymbol = symbols.stream().filter(s -> name.equals(s.getName())).findFirst();
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
Optional<? extends WorkspaceSymbol> maybeSymbol = symbols.stream().filter(s -> name.equals(s.getName())).findFirst();
assertTrue(maybeSymbol.isPresent());
TextDocument doc = new TextDocument(docUri, LanguageId.JAVA);
doc.setText(FileUtils.readFileToString(UriUtil.toFile(docUri)));
SymbolInformation symbol = maybeSymbol.get();
Location loc = symbol.getLocation();
WorkspaceSymbol symbol = maybeSymbol.get();
Location loc = symbol.getLocation().getLeft();
assertEquals(docUri, loc.getUri());
int start = doc.toOffset(loc.getRange().getStart());
int end = doc.toOffset(loc.getRange().getEnd());

View File

@@ -22,8 +22,8 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.eclipse.lsp4j.Location;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -75,7 +75,7 @@ public class RequestMappingSymbolProviderTest {
@Test
public void testSimpleRequestMappingSymbol() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/SimpleMappingClass.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(1, symbols.size());
assertTrue(containsSymbol(symbols, "@/greeting", docUri, 6, 1, 6, 29));
}
@@ -84,7 +84,7 @@ public class RequestMappingSymbolProviderTest {
public void testSimpleRequestMappingSymbolFromConstantInDifferentClass() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/SimpleMappingClassWithConstantInDifferentClass.java").toUri().toString();
String constantsUri = directory.toPath().resolve("src/main/java/org/test/Constants.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(1, symbols.size());
assertTrue(containsSymbol(symbols, "@/path/from/constant", docUri, 6, 1, 6, 48));
@@ -107,7 +107,7 @@ public class RequestMappingSymbolProviderTest {
public void testUpdateDocumentWithConstantFromDifferentClass() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/SimpleMappingClassWithConstantInDifferentClass.java").toUri().toString();
String constantsUri = directory.toPath().resolve("src/main/java/org/test/Constants.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(1, symbols.size());
assertTrue(containsSymbol(symbols, "@/path/from/constant", docUri, 6, 1, 6, 48));
@@ -160,7 +160,7 @@ public class RequestMappingSymbolProviderTest {
@Test
public void testSimpleRequestMappingSymbolFromConstantInSameClass() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/SimpleMappingClassWithConstantInSameClass.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(1, symbols.size());
assertTrue(containsSymbol(symbols, "@/request/mapping/path/from/same/class/constant", docUri, 8, 1, 8, 52));
@@ -171,7 +171,7 @@ public class RequestMappingSymbolProviderTest {
@Test
public void testSimpleRequestMappingSymbolFromConstantInBinaryType() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/SimpleMappingClassWithConstantFromBinaryType.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(1, symbols.size());
assertTrue(containsSymbol(symbols, "@/(inferred)", docUri, 7, 1, 7, 53));
@@ -182,7 +182,7 @@ public class RequestMappingSymbolProviderTest {
@Test
public void testParentRequestMappingSymbol() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/ParentMappingClass.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(1, symbols.size());
assertTrue(containsSymbol(symbols, "@/parent/greeting -- GET", docUri, 8, 1, 8, 47));
}
@@ -190,7 +190,7 @@ public class RequestMappingSymbolProviderTest {
@Test
public void testEmptyPathWithParentRequestMappingSymbol() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/ParentMappingClass2.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(1, symbols.size());
assertTrue(containsSymbol(symbols, "@/parent2 -- GET,POST,DELETE", docUri, 8, 1, 8, 16));
}
@@ -198,7 +198,7 @@ public class RequestMappingSymbolProviderTest {
@Test
public void testMultiRequestMappingSymbol() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/MultiRequestMappingClass.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(2, symbols.size());
assertTrue(containsSymbol(symbols, "@/hello1", docUri, 6, 1, 6, 44));
assertTrue(containsSymbol(symbols, "@/hello2", docUri, 6, 1, 6, 44));
@@ -207,70 +207,70 @@ public class RequestMappingSymbolProviderTest {
@Test
public void testGetMappingSymbol() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertTrue(containsSymbol(symbols, "@/getData -- GET", docUri, 12, 1, 12, 24));
}
@Test
public void testGetMappingSymbolWithoutPath() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertTrue(containsSymbol(symbols, "@/ -- GET", docUri, 40, 1, 40, 16));
}
@Test
public void testGetMappingSymbolWithoutAnything() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertTrue(containsSymbol(symbols, "@/ -- GET", docUri, 44, 1, 44, 14));
}
@Test
public void testDeleteMappingSymbol() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertTrue(containsSymbol(symbols, "@/deleteData -- DELETE",docUri, 20, 1, 20, 30));
}
@Test
public void testPostMappingSymbol() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertTrue(containsSymbol(symbols, "@/postData -- POST", docUri, 24, 1, 24, 26));
}
@Test
public void testPutMappingSymbol() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertTrue(containsSymbol(symbols, "@/putData -- PUT", docUri, 16, 1, 16, 24));
}
@Test
public void testPatchMappingSymbol() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertTrue(containsSymbol(symbols, "@/patchData -- PATCH", docUri, 28, 1, 28, 28));
}
@Test
public void testGetRequestMappingSymbol() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertTrue(containsSymbol(symbols, "@/getHello -- GET", docUri, 32, 1, 32, 61));
}
@Test
public void testMultiRequestMethodMappingSymbol() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMethodClass.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertTrue(containsSymbol(symbols, "@/postAndPutHello -- POST,PUT", docUri, 36, 1, 36, 76));
}
@Test
public void testMediaTypes() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/RequestMappingMediaTypes.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(7, symbols.size());
assertTrue(containsSymbol(symbols, "@/consume1 -- HEAD - Accept: testconsume", docUri, 8, 1, 8, 90));
assertTrue(containsSymbol(symbols, "@/consume2 - Accept: text/plain", docUri, 13, 1, 13, 73));
@@ -281,16 +281,16 @@ public class RequestMappingSymbolProviderTest {
assertTrue(containsSymbol(symbols, "@/everything - Accept: application/json,text/plain,testconsume - Content-Type: application/json", docUri, 38, 1, 38, 170));
}
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
SymbolInformation symbol = iterator.next();
private boolean containsSymbol(List<? extends WorkspaceSymbol> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
for (Iterator<? extends WorkspaceSymbol> iterator = symbols.iterator(); iterator.hasNext();) {
WorkspaceSymbol symbol = iterator.next();
if (symbol.getName().equals(name)
&& symbol.getLocation().getUri().equals(uri)
&& symbol.getLocation().getRange().getStart().getLine() == startLine
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
&& symbol.getLocation().getLeft().getUri().equals(uri)
&& symbol.getLocation().getLeft().getRange().getStart().getLine() == startLine
&& symbol.getLocation().getLeft().getRange().getStart().getCharacter() == startCHaracter
&& symbol.getLocation().getLeft().getRange().getEnd().getLine() == endLine
&& symbol.getLocation().getLeft().getRange().getEnd().getCharacter() == endCharacter) {
return true;
}
}
@@ -299,15 +299,15 @@ public class RequestMappingSymbolProviderTest {
}
private void assertSymbol(String docUri, String name, String coveredText) throws Exception {
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
Optional<? extends SymbolInformation> maybeSymbol = symbols.stream().filter(s -> name.equals(s.getName())).findFirst();
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
Optional<? extends WorkspaceSymbol> maybeSymbol = symbols.stream().filter(s -> name.equals(s.getName())).findFirst();
assertTrue(maybeSymbol.isPresent());
TextDocument doc = new TextDocument(docUri, LanguageId.JAVA);
doc.setText(FileUtils.readFileToString(UriUtil.toFile(docUri)));
SymbolInformation symbol = maybeSymbol.get();
Location loc = symbol.getLocation();
WorkspaceSymbol symbol = maybeSymbol.get();
Location loc = symbol.getLocation().getLeft();
assertEquals(docUri, loc.getUri());
int start = doc.toOffset(loc.getRange().getStart());
int end = doc.toOffset(loc.getRange().getEnd());

View File

@@ -21,8 +21,8 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -35,7 +35,6 @@ import org.springframework.ide.vscode.boot.java.beans.BeansSymbolAddOnInformatio
import org.springframework.ide.vscode.boot.java.handlers.SymbolAddOnInformation;
import org.springframework.ide.vscode.boot.java.requestmapping.WebfluxHandlerInformation;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
import org.springframework.ide.vscode.commons.util.Assert;
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
import org.springframework.test.context.junit4.SpringRunner;
@@ -75,7 +74,7 @@ public class WebFluxMappingSymbolProviderTest {
@Test
public void testSimpleRequestMappingSymbol() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/UserController.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(4, symbols.size());
assertTrue(containsSymbol(symbols, "@/users -- GET - Content-Type: application/json", docUri, 13, 1, 13, 74));
assertTrue(containsSymbol(symbols, "@/users/{username} -- GET - Content-Type: application/json", docUri, 18, 1, 18, 85));
@@ -88,7 +87,7 @@ public class WebFluxMappingSymbolProviderTest {
@Test
public void testRoutesMappingSymbols() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/QuoteRouter.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(6, symbols.size());
assertTrue(containsSymbol(symbols, "@/hello -- GET - Accept: text/plain", docUri, 22, 5, 22, 70));
assertTrue(containsSymbol(symbols, "@/echo -- POST - Accept: text/plain - Content-Type: text/plain", docUri, 23, 5, 23, 101));
@@ -134,7 +133,7 @@ public class WebFluxMappingSymbolProviderTest {
@Test
public void testNestedRoutesMappingSymbols1() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/NestedRouter1.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(5, symbols.size());
assertTrue(containsSymbol(symbols, "@/person/{id} -- GET - Accept: application/json", docUri, 27, 6, 27, 45));
assertTrue(containsSymbol(symbols, "@/person/ -- POST - Content-Type: application/json", docUri, 29, 6, 29, 83));
@@ -171,7 +170,7 @@ public class WebFluxMappingSymbolProviderTest {
@Test
public void testNestedRoutesMappingSymbols2() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/NestedRouter2.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(5, symbols.size());
assertTrue(containsSymbol(symbols, "@/person/{id} -- GET - Accept: application/json", docUri, 29, 6, 29, 45));
assertTrue(containsSymbol(symbols, "@/ -- POST - Accept: application/json - Content-Type: application/json,application/pdf", docUri, 31, 6, 31, 117));
@@ -208,7 +207,7 @@ public class WebFluxMappingSymbolProviderTest {
@Test
public void testNestedRoutesMappingSymbols3() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/NestedRouter3.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(8, symbols.size());
assertTrue(containsSymbol(symbols, "@/person/sub1/sub2/{id} -- GET - Accept: application/json", docUri, 29, 7, 29, 46));
@@ -270,16 +269,16 @@ public class WebFluxMappingSymbolProviderTest {
assertEquals("public Mono<org.springframework.web.reactive.function.server.ServerResponse> deletePerson(org.springframework.web.reactive.function.server.ServerRequest)", handlerInfo6.getHandlerMethod());
}
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
SymbolInformation symbol = iterator.next();
private boolean containsSymbol(List<? extends WorkspaceSymbol> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
for (Iterator<? extends WorkspaceSymbol> iterator = symbols.iterator(); iterator.hasNext();) {
WorkspaceSymbol symbol = iterator.next();
if (symbol.getName().equals(name)
&& symbol.getLocation().getUri().equals(uri)
&& symbol.getLocation().getRange().getStart().getLine() == startLine
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
&& symbol.getLocation().getLeft().getUri().equals(uri)
&& symbol.getLocation().getLeft().getRange().getStart().getLine() == startLine
&& symbol.getLocation().getLeft().getRange().getStart().getCharacter() == startCHaracter
&& symbol.getLocation().getLeft().getRange().getEnd().getLine() == endLine
&& symbol.getLocation().getLeft().getRange().getEnd().getCharacter() == endCharacter) {
return true;
}
}

View File

@@ -18,8 +18,8 @@ import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -67,23 +67,23 @@ public class SpringIndexerMultiProjectTest {
@Test
public void testQueryingAllSymbolsWithRegularLimit() throws Exception {
List<? extends SymbolInformation> symbols = indexer.getAllSymbols("");
List<? extends WorkspaceSymbol> symbols = indexer.getAllSymbols("");
assertEquals(50, symbols.size());
}
@Test
public void testQueryingAllSymbolsWithNoLimit() throws Exception {
List<? extends SymbolInformation> symbols = indexer.getAllSymbols("*");
List<? extends WorkspaceSymbol> symbols = indexer.getAllSymbols("*");
assertEquals(220, symbols.size());
int count1 = 0;
int count2 = 0;
for (SymbolInformation symbol : symbols) {
if (symbol.getLocation().getUri().startsWith(projectUri1)) {
for (WorkspaceSymbol symbol : symbols) {
if (symbol.getLocation().getLeft().getUri().startsWith(projectUri1)) {
count1++;
}
else if (symbol.getLocation().getUri().startsWith(projectUri2)) {
else if (symbol.getLocation().getLeft().getUri().startsWith(projectUri2)) {
count2++;
}
}
@@ -94,31 +94,31 @@ public class SpringIndexerMultiProjectTest {
@Test
public void testQueryingSymbolsForSpecificProjectWithRegularLimit() throws Exception {
List<? extends SymbolInformation> symbols = indexer.getAllSymbols("locationPrefix:" + projectUri2);
List<? extends WorkspaceSymbol> symbols = indexer.getAllSymbols("locationPrefix:" + projectUri2);
assertEquals(50, symbols.size());
for (SymbolInformation symbol : symbols) {
assertTrue(symbol.getLocation().getUri().startsWith(projectUri2));
for (WorkspaceSymbol symbol : symbols) {
assertTrue(symbol.getLocation().getLeft().getUri().startsWith(projectUri2));
}
}
@Test
public void testQueryingSymbolsForSpecificProjectWithNoLimit() throws Exception {
List<? extends SymbolInformation> symbols = indexer.getAllSymbols("locationPrefix:" + projectUri2 + "?*");
List<? extends WorkspaceSymbol> symbols = indexer.getAllSymbols("locationPrefix:" + projectUri2 + "?*");
assertEquals(110, symbols.size());
for (SymbolInformation symbol : symbols) {
assertTrue(symbol.getLocation().getUri().startsWith(projectUri2));
for (WorkspaceSymbol symbol : symbols) {
assertTrue(symbol.getLocation().getLeft().getUri().startsWith(projectUri2));
}
}
@Test
public void testQueryingSymbolsForSpecificProjectWithQuery() throws Exception {
List<? extends SymbolInformation> symbols = indexer.getAllSymbols("locationPrefix:" + projectUri2 + "?seventhWowSuperBean");
List<? extends WorkspaceSymbol> symbols = indexer.getAllSymbols("locationPrefix:" + projectUri2 + "?seventhWowSuperBean");
assertEquals(10, symbols.size());
for (SymbolInformation symbol : symbols) {
assertTrue(symbol.getLocation().getUri().startsWith(projectUri2));
for (WorkspaceSymbol symbol : symbols) {
assertTrue(symbol.getLocation().getLeft().getUri().startsWith(projectUri2));
}
}

View File

@@ -17,14 +17,13 @@ import java.io.File;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.attribute.FileTime;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -90,8 +89,8 @@ public class SpringIndexerMultipleFilesTest {
try {
// update document and update index
List<? extends SymbolInformation> symbols = indexer.getSymbols(changedDocURI);
assertTrue(containsSymbol(symbols, "@/mapping1", changedDocURI));
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(changedDocURI);
assertTrue(SpringIndexerTest.containsSymbol(symbols, "@/mapping1", changedDocURI));
String newContent = originalContent.replace("mapping1", "mapping1-CHANGED");
FileUtils.writeStringToFile(new File(new URI(changedDocURI)), newContent);
@@ -106,8 +105,8 @@ public class SpringIndexerMultipleFilesTest {
// check for updated index per document
symbols = indexer.getSymbols(changedDocURI);
assertEquals(2, symbols.size());
assertTrue(containsSymbol(symbols, "@/mapping1-CHANGED", changedDocURI, 6, 1, 6, 36));
assertTrue(containsSymbol(symbols, "@/mapping2", changedDocURI, 11, 1, 11, 28));
assertTrue(SpringIndexerTest.containsSymbol(symbols, "@/mapping1-CHANGED", changedDocURI, 6, 1, 6, 36));
assertTrue(SpringIndexerTest.containsSymbol(symbols, "@/mapping2", changedDocURI, 11, 1, 11, 28));
fileScanListener.assertScannedUris(changedDocURI);
fileScanListener.assertScannedUri(changedDocURI, 1);
@@ -152,18 +151,18 @@ public class SpringIndexerMultipleFilesTest {
updateFuture.get(5, TimeUnit.SECONDS);
// check for updated index per document
List<? extends SymbolInformation> symbols1 = indexer.getSymbols(doc1URI);
List<? extends WorkspaceSymbol> symbols1 = indexer.getSymbols(doc1URI);
assertEquals(2, symbols1.size());
assertTrue(containsSymbol(symbols1, "@/mapping1-CHANGED", doc1URI, 6, 1, 6, 36));
assertTrue(containsSymbol(symbols1, "@/mapping2", doc1URI, 11, 1, 11, 28));
assertTrue(SpringIndexerTest.containsSymbol(symbols1, "@/mapping1-CHANGED", doc1URI, 6, 1, 6, 36));
assertTrue(SpringIndexerTest.containsSymbol(symbols1, "@/mapping2", doc1URI, 11, 1, 11, 28));
List<? extends SymbolInformation> symbols2 = indexer.getSymbols(doc2URI);
assertTrue(containsSymbol(symbols2, "@+ 'mainClass' (@SpringBootApplication <: @SpringBootConfiguration, @Configuration, @Component) MainClass", doc2URI, 6, 0, 6, 22));
assertTrue(containsSymbol(symbols2, "@/embedded-foo-mapping-CHANGED", doc2URI, 17, 1, 17, 49));
assertTrue(containsSymbol(symbols2, "@/foo-root-mapping/embedded-foo-mapping-with-root", doc2URI, 27, 1, 27, 51));
List<? extends WorkspaceSymbol> symbols2 = indexer.getSymbols(doc2URI);
assertTrue(SpringIndexerTest.containsSymbol(symbols2, "@+ 'mainClass' (@SpringBootApplication <: @SpringBootConfiguration, @Configuration, @Component) MainClass", doc2URI, 6, 0, 6, 22));
assertTrue(SpringIndexerTest.containsSymbol(symbols2, "@/embedded-foo-mapping-CHANGED", doc2URI, 17, 1, 17, 49));
assertTrue(SpringIndexerTest.containsSymbol(symbols2, "@/foo-root-mapping/embedded-foo-mapping-with-root", doc2URI, 27, 1, 27, 51));
List<? extends SymbolInformation> symbols3 = indexer.getSymbols(doc3URI);
assertTrue(containsSymbol(symbols3, "@/classlevel-CHANGED/mapping-subpackage", doc3URI, 7, 1, 7, 38));
List<? extends WorkspaceSymbol> symbols3 = indexer.getSymbols(doc3URI);
assertTrue(SpringIndexerTest.containsSymbol(symbols3, "@/classlevel-CHANGED/mapping-subpackage", doc3URI, 7, 1, 7, 38));
}
finally {
FileUtils.writeStringToFile(new File(new URI(doc1URI)), original1Content);
@@ -185,7 +184,7 @@ public class SpringIndexerMultipleFilesTest {
fileScanListener.assertScannedUris();
fileScanListener.assertScannedUri(unchangedDocURI, 0);
List<? extends SymbolInformation> symbols = indexer.getSymbols(unchangedDocURI);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(unchangedDocURI);
assertEquals(2, symbols.size());
}
@@ -220,16 +219,16 @@ public class SpringIndexerMultipleFilesTest {
updateFuture.get(5, TimeUnit.SECONDS);
// check for updated index per document
List<? extends SymbolInformation> symbols1 = indexer.getSymbols(doc1URI);
List<? extends WorkspaceSymbol> symbols1 = indexer.getSymbols(doc1URI);
assertEquals(2, symbols1.size());
assertTrue(containsSymbol(symbols1, "@/mapping1-CHANGED", doc1URI, 6, 1, 6, 36));
assertTrue(containsSymbol(symbols1, "@/mapping2", doc1URI, 11, 1, 11, 28));
assertTrue(SpringIndexerTest.containsSymbol(symbols1, "@/mapping1-CHANGED", doc1URI, 6, 1, 6, 36));
assertTrue(SpringIndexerTest.containsSymbol(symbols1, "@/mapping2", doc1URI, 11, 1, 11, 28));
List<? extends SymbolInformation> symbols2 = indexer.getSymbols(doc2URI);
List<? extends WorkspaceSymbol> symbols2 = indexer.getSymbols(doc2URI);
assertEquals(3, symbols2.size());
List<? extends SymbolInformation> symbols3 = indexer.getSymbols(doc3URI);
assertTrue(containsSymbol(symbols3, "@/classlevel-CHANGED/mapping-subpackage", doc3URI, 7, 1, 7, 38));
List<? extends WorkspaceSymbol> symbols3 = indexer.getSymbols(doc3URI);
assertTrue(SpringIndexerTest.containsSymbol(symbols3, "@/classlevel-CHANGED/mapping-subpackage", doc3URI, 7, 1, 7, 38));
fileScanListener.assertScannedUris(doc1URI, doc3URI);
fileScanListener.assertScannedUri(doc1URI, 1);
@@ -242,36 +241,4 @@ public class SpringIndexerMultipleFilesTest {
}
}
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri) {
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
SymbolInformation symbol = iterator.next();
if (
symbol.getName().equals(name) &&
symbol.getLocation().getUri().equals(uri)
) {
return true;
}
}
return false;
}
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
SymbolInformation symbol = iterator.next();
if (symbol.getName().equals(name)
&& symbol.getLocation().getUri().equals(uri)
&& symbol.getLocation().getRange().getStart().getLine() == startLine
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
return true;
}
}
return false;
}
}

View File

@@ -14,13 +14,12 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -65,33 +64,16 @@ public class SpringIndexerNonBootProjectTest {
@Test
public void testScanningSimpleRegularSpringProject() throws Exception {
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
assertEquals(3, allSymbols.size());
String docUri = directory.toPath().resolve("src/main/java/org/test/SimpleMappingClass.java").toUri().toString();
assertTrue(containsSymbol(allSymbols, "@/mapping1", docUri, 6, 1, 6, 28));
assertTrue(containsSymbol(allSymbols, "@/mapping2", docUri, 11, 1, 11, 28));
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@/mapping1", docUri, 6, 1, 6, 28));
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@/mapping2", docUri, 11, 1, 11, 28));
docUri = directory.toPath().resolve("src/main/java/org/test/ClassWithDefaultSymbol.java").toUri().toString();
assertTrue(containsSymbol(allSymbols, "@Configurable", docUri, 4, 0, 4, 13));
}
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
SymbolInformation symbol = iterator.next();
if (symbol.getName().equals(name)
&& symbol.getLocation().getUri().equals(uri)
&& symbol.getLocation().getRange().getStart().getLine() == startLine
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
return true;
}
}
return false;
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@Configurable", docUri, 4, 0, 4, 13));
}
}

View File

@@ -23,8 +23,8 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -74,7 +74,7 @@ public class SpringIndexerTest {
@Test
public void testScanningAllAnnotationsSimpleProjectUpfront() throws Exception {
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
assertEquals(7, allSymbols.size());
@@ -98,7 +98,7 @@ public class SpringIndexerTest {
public void testScanTestJavaSources() throws Exception {
indexer.configureIndexer(SymbolIndexConfig.builder().scanTestJavaSources(true).build());
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
assertEquals(8, allSymbols.size());
String docUri = directory.toPath().resolve("src/test/java/demo/ApplicationTests.java").toUri().toString();
assertTrue(containsSymbol(allSymbols, "@SpringBootTest", docUri, 8, 0, 8, 15));
@@ -112,7 +112,7 @@ public class SpringIndexerTest {
@Test
public void testRetrievingSymbolsPerDocument() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/MainClass.java").toUri().toString();
List<? extends SymbolInformation> symbols = indexer.getSymbols(docUri);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(docUri);
assertEquals(3, symbols.size());
assertTrue(containsSymbol(symbols, "@+ 'mainClass' (@SpringBootApplication <: @SpringBootConfiguration, @Configuration, @Component) MainClass", docUri, 6, 0, 6, 22));
assertTrue(containsSymbol(symbols, "@/embedded-foo-mapping", docUri, 17, 1, 17, 41));
@@ -132,7 +132,7 @@ public class SpringIndexerTest {
@Test
public void testScanningAllAnnotationsMultiModuleProjectUpfront() throws Exception {
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
assertEquals(7, allSymbols.size());
@@ -165,13 +165,13 @@ public class SpringIndexerTest {
updateFuture.get(5, TimeUnit.SECONDS);
// check for updated index per document
List<? extends SymbolInformation> symbols = indexer.getSymbols(changedDocURI);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(changedDocURI);
assertEquals(2, symbols.size());
assertTrue(containsSymbol(symbols, "@/mapping1-CHANGED", changedDocURI, 6, 1, 6, 36));
assertTrue(containsSymbol(symbols, "@/mapping2", changedDocURI, 11, 1, 11, 28));
// check for updated index in all symbols
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
assertEquals(7, allSymbols.size());
String docUri = directory.toPath().resolve("src/main/java/org/test/MainClass.java").toUri().toString();
@@ -194,11 +194,11 @@ public class SpringIndexerTest {
public void testNewDocumentCreated() throws Exception {
String createdDocURI = directory.toPath().resolve("src/main/java/org/test/CreatedClass.java").toUri().toString();
// check for document to not be created yet
List<? extends SymbolInformation> symbols = indexer.getSymbols(createdDocURI);
List<? extends WorkspaceSymbol> symbols = indexer.getSymbols(createdDocURI);
assertNotNull(symbols);
assertEquals(0, symbols.size());
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
assertEquals(7, allSymbols.size());
try {
@@ -271,7 +271,7 @@ public class SpringIndexerTest {
Assert.noElements(indexer.getSymbols(deletedDocURI));
// check for updated index in all symbols
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
assertEquals(5, allSymbols.size());
String docUri = directory.toPath().resolve("src/main/java/org/test/MainClass.java").toUri().toString();
@@ -288,7 +288,7 @@ public class SpringIndexerTest {
@Test
public void testFilterSymbolsUsingQueryString() throws Exception {
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("mapp");
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("mapp");
assertEquals(6, allSymbols.size());
@@ -306,7 +306,7 @@ public class SpringIndexerTest {
@Test
public void testFilterSymbolsUsingQueryStringSplittedResult() throws Exception {
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("@/foo-root-mapping");
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("@/foo-root-mapping");
assertEquals(1, allSymbols.size());
@@ -317,7 +317,7 @@ public class SpringIndexerTest {
@Test
public void testFilterSymbolsUsingQueryStringFullSymbolString() throws Exception {
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("@/foo-root-mapping/embedded-foo-mapping-with-root");
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("@/foo-root-mapping/embedded-foo-mapping-with-root");
assertEquals(1, allSymbols.size());
@@ -328,7 +328,7 @@ public class SpringIndexerTest {
@Test
public void testDeleteProject() throws Exception {
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
assertEquals(7, allSymbols.size());
CompletableFuture<Void> deleteProject = indexer.deleteProject(project);
@@ -338,13 +338,13 @@ public class SpringIndexerTest {
assertEquals(0, allSymbols.size());
}
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri) {
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
SymbolInformation symbol = iterator.next();
static boolean containsSymbol(List<? extends WorkspaceSymbol> symbols, String name, String uri) {
for (Iterator<? extends WorkspaceSymbol> iterator = symbols.iterator(); iterator.hasNext();) {
WorkspaceSymbol symbol = iterator.next();
if (
symbol.getName().equals(name) &&
symbol.getLocation().getUri().equals(uri)
symbol.getLocation().getLeft().getUri().equals(uri)
) {
return true;
}
@@ -353,16 +353,16 @@ public class SpringIndexerTest {
return false;
}
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
SymbolInformation symbol = iterator.next();
static boolean containsSymbol(List<? extends WorkspaceSymbol> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
for (Iterator<? extends WorkspaceSymbol> iterator = symbols.iterator(); iterator.hasNext();) {
WorkspaceSymbol symbol = iterator.next();
if (symbol.getName().equals(name)
&& symbol.getLocation().getUri().equals(uri)
&& symbol.getLocation().getRange().getStart().getLine() == startLine
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
&& symbol.getLocation().getLeft().getUri().equals(uri)
&& symbol.getLocation().getLeft().getRange().getStart().getLine() == startLine
&& symbol.getLocation().getLeft().getRange().getStart().getCharacter() == startCHaracter
&& symbol.getLocation().getLeft().getRange().getEnd().getLine() == endLine
&& symbol.getLocation().getLeft().getRange().getEnd().getCharacter() == endCharacter) {
return true;
}
}

View File

@@ -11,20 +11,15 @@
package org.springframework.ide.vscode.boot.java.utils.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.net.URI;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.FileUtils;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.TextDocumentIdentifier;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -36,7 +31,6 @@ import org.springframework.ide.vscode.boot.bootiful.SymbolProviderTestConf;
import org.springframework.ide.vscode.boot.java.utils.SymbolIndexConfig;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder;
import org.springframework.ide.vscode.commons.util.Assert;
import org.springframework.ide.vscode.commons.util.UriUtil;
import org.springframework.ide.vscode.project.harness.BootLanguageServerHarness;
import org.springframework.ide.vscode.project.harness.ProjectsHarness;
@@ -75,7 +69,7 @@ public class SpringIndexerTestSpecialCharacters {
@Test
public void testScanningAllAnnotationsSimpleProjectUpfront() throws Exception {
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
assertEquals(8, allSymbols.size());
@@ -84,24 +78,7 @@ public class SpringIndexerTestSpecialCharacters {
// String docUri = directory.toPath().resolve("src/main/java/org/test/ClassWithSpécialCharacter.java").toUri().toString();
String docUri = UriUtil.toUri(directory.toPath().resolve("src/main/java/org/test/ClassWithSpécialCharacter.java").toFile()).toString();
assertTrue(containsSymbol(allSymbols, "@Configurable", docUri, 4, 0, 4, 13));
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@Configurable", docUri, 4, 0, 4, 13));
}
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
SymbolInformation symbol = iterator.next();
if (symbol.getName().equals(name)
&& symbol.getLocation().getUri().equals(uri)
&& symbol.getLocation().getRange().getStart().getLine() == startLine
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
return true;
}
}
return false;
}
}

View File

@@ -15,12 +15,11 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.nio.file.Paths;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -84,15 +83,15 @@ public class SpringIndexerXMLProjectTest {
@Test
public void testScanningSimpleSpringXMLConfig() throws Exception {
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
assertEquals(5, allSymbols.size());
String docUri = directory.toPath().resolve("config/simple-spring-config.xml").toUri().toString();
assertTrue(containsSymbol(allSymbols, "@+ 'transactionManager' DataSourceTransactionManager", docUri, 6, 14, 6, 37));
assertTrue(containsSymbol(allSymbols, "@+ 'jdbcTemplate' JdbcTemplate", docUri, 8, 14, 8, 31));
assertTrue(containsSymbol(allSymbols, "@+ 'namedParameterJdbcTemplate' NamedParameterJdbcTemplate", docUri, 12, 14, 12, 45));
assertTrue(containsSymbol(allSymbols, "@+ 'persistenceExceptionTranslationPostProcessor' PersistenceExceptionTranslationPostProcessor", docUri, 18, 10, 18, 97));
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@+ 'transactionManager' DataSourceTransactionManager", docUri, 6, 14, 6, 37));
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@+ 'jdbcTemplate' JdbcTemplate", docUri, 8, 14, 8, 31));
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@+ 'namedParameterJdbcTemplate' NamedParameterJdbcTemplate", docUri, 12, 14, 12, 45));
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@+ 'persistenceExceptionTranslationPostProcessor' PersistenceExceptionTranslationPostProcessor", docUri, 18, 10, 18, 97));
List<? extends SymbolAddOnInformation> addon = indexer.getAdditonalInformation(docUri);
assertEquals(4, addon.size());
@@ -119,7 +118,7 @@ public class SpringIndexerXMLProjectTest {
String beansOnClasspathDocUri = directory.toPath().resolve("src/main/resources/beans.xml").toUri().toString();
assertTrue(containsSymbol(allSymbols, "@+ 'sb' SimpleBean", beansOnClasspathDocUri, 6, 14, 6, 21));
assertTrue(SpringIndexerTest.containsSymbol(allSymbols, "@+ 'sb' SimpleBean", beansOnClasspathDocUri, 6, 14, 6, 21));
addon = indexer.getAdditonalInformation(beansOnClasspathDocUri);
assertEquals(1, addon.size());
@@ -128,7 +127,7 @@ public class SpringIndexerXMLProjectTest {
@Test
public void testReindexXMLConfig() throws Exception {
List<? extends SymbolInformation> allSymbols = indexer.getAllSymbols("");
List<? extends WorkspaceSymbol> allSymbols = indexer.getAllSymbols("");
assertEquals(5, allSymbols.size());
indexer.configureIndexer(SymbolIndexConfig.builder()
@@ -187,21 +186,4 @@ public class SpringIndexerXMLProjectTest {
assertEquals(0, allSymbols.size());
}
private boolean containsSymbol(List<? extends SymbolInformation> symbols, String name, String uri, int startLine, int startCHaracter, int endLine, int endCharacter) {
for (Iterator<? extends SymbolInformation> iterator = symbols.iterator(); iterator.hasNext();) {
SymbolInformation symbol = iterator.next();
if (symbol.getName().equals(name)
&& symbol.getLocation().getUri().equals(uri)
&& symbol.getLocation().getRange().getStart().getLine() == startLine
&& symbol.getLocation().getRange().getStart().getCharacter() == startCHaracter
&& symbol.getLocation().getRange().getEnd().getLine() == endLine
&& symbol.getLocation().getRange().getEnd().getCharacter() == endCharacter) {
return true;
}
}
return false;
}
}

View File

@@ -29,8 +29,9 @@ import org.apache.commons.lang3.tuple.Pair;
import org.eclipse.lsp4j.Location;
import org.eclipse.lsp4j.Position;
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.SymbolKind;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -84,7 +85,7 @@ public class SymbolCacheOnDiscTest {
String[] files = {file1.toString(), file2.toString(), file3.toString()};
List<CachedSymbol> generatedSymbols = new ArrayList<>();
SymbolInformation symbol = new SymbolInformation("symbol1", SymbolKind.Field, new Location("docURI", new Range(new Position(3, 10), new Position(3, 20))));
WorkspaceSymbol symbol = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location("docURI", new Range(new Position(3, 10), new Position(3, 20)))));
EnhancedSymbolInformation enhancedSymbol = new EnhancedSymbolInformation(symbol, null);
generatedSymbols.add(new CachedSymbol("", timeFile1.toMillis(), enhancedSymbol));
@@ -102,7 +103,7 @@ public class SymbolCacheOnDiscTest {
assertEquals("symbol1", cachedSymbols[0].getEnhancedSymbol().getSymbol().getName());
assertEquals(SymbolKind.Field, cachedSymbols[0].getEnhancedSymbol().getSymbol().getKind());
assertEquals(new Location("docURI", new Range(new Position(3, 10), new Position(3, 20))), cachedSymbols[0].getEnhancedSymbol().getSymbol().getLocation());
assertEquals(new Location("docURI", new Range(new Position(3, 10), new Position(3, 20))), cachedSymbols[0].getEnhancedSymbol().getSymbol().getLocation().getLeft());
assertNull(cachedSymbols[0].getEnhancedSymbol().getAdditionalInformation());
Multimap<String, String> dependencies = result.getRight();
@@ -128,7 +129,7 @@ public class SymbolCacheOnDiscTest {
String[] files = {file1.toString(), file2.toString(), file3.toString()};
List<CachedSymbol> generatedSymbols = new ArrayList<>();
SymbolInformation symbol = new SymbolInformation("symbol1", SymbolKind.Field, new Location("docURI", new Range(new Position(3, 10), new Position(3, 20))));
WorkspaceSymbol symbol = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location("docURI", new Range(new Position(3, 10), new Position(3, 20)))));
EnhancedSymbolInformation enhancedSymbol = new EnhancedSymbolInformation(symbol, null);
generatedSymbols.add(new CachedSymbol("", timeFile1.toMillis(), enhancedSymbol));
@@ -152,7 +153,7 @@ public class SymbolCacheOnDiscTest {
String[] files = {file1.toString(), file2.toString(), file3.toString()};
List<CachedSymbol> generatedSymbols = new ArrayList<>();
SymbolInformation symbol = new SymbolInformation("symbol1", SymbolKind.Field, new Location("docURI", new Range(new Position(3, 10), new Position(3, 20))));
WorkspaceSymbol symbol = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location("docURI", new Range(new Position(3, 10), new Position(3, 20)))));
EnhancedSymbolInformation enhancedSymbol = new EnhancedSymbolInformation(symbol, null);
generatedSymbols.add(new CachedSymbol("", timeFile1.toMillis(), enhancedSymbol));
@@ -224,7 +225,7 @@ public class SymbolCacheOnDiscTest {
List<CachedSymbol> generatedSymbols = new ArrayList<>();
SymbolInformation symbol = new SymbolInformation("symbol1", SymbolKind.Field, new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))));
WorkspaceSymbol symbol = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20)))));
WebfluxElementsInformation addon = new WebfluxElementsInformation(new Range(new Position(4, 4), new Position(5, 5)), new Range(new Position(6, 6), new Position(7, 7)));
EnhancedSymbolInformation enhancedSymbol = new EnhancedSymbolInformation(symbol, new SymbolAddOnInformation[] {addon});
@@ -238,7 +239,7 @@ public class SymbolCacheOnDiscTest {
assertEquals("symbol1", cachedSymbols[0].getEnhancedSymbol().getSymbol().getName());
assertEquals(SymbolKind.Field, cachedSymbols[0].getEnhancedSymbol().getSymbol().getKind());
assertEquals(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))), cachedSymbols[0].getEnhancedSymbol().getSymbol().getLocation());
assertEquals(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))), cachedSymbols[0].getEnhancedSymbol().getSymbol().getLocation().getLeft());
SymbolAddOnInformation[] retrievedAddOns = cachedSymbols[0].getEnhancedSymbol().getAdditionalInformation();
assertNotNull(retrievedAddOns);
@@ -263,17 +264,17 @@ public class SymbolCacheOnDiscTest {
String doc1URI = UriUtil.toUri(file1.toFile()).toString();
List<CachedSymbol> generatedSymbols1 = new ArrayList<>();
SymbolInformation symbol1 = new SymbolInformation("symbol1", SymbolKind.Field, new Location("docURI", new Range(new Position(3, 10), new Position(3, 20))));
WorkspaceSymbol symbol1 = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location("docURI", new Range(new Position(3, 10), new Position(3, 20)))));
EnhancedSymbolInformation enhancedSymbol1 = new EnhancedSymbolInformation(symbol1, null);
generatedSymbols1.add(new CachedSymbol(doc1URI, timeFile1.toMillis(), enhancedSymbol1));
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols1, null);
List<CachedSymbol> generatedSymbols2 = new ArrayList<>();
symbol1 = new SymbolInformation("symbol1", SymbolKind.Field, new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))));
symbol1 = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20)))));
enhancedSymbol1 = new EnhancedSymbolInformation(symbol1, null);
SymbolInformation symbol2 = new SymbolInformation("symbol2", SymbolKind.Interface, new Location(doc1URI, new Range(new Position(5, 5), new Position(5, 10))));
WorkspaceSymbol symbol2 = new WorkspaceSymbol("symbol2", SymbolKind.Interface, Either.forLeft(new Location(doc1URI, new Range(new Position(5, 5), new Position(5, 10)))));
EnhancedSymbolInformation enhancedSymbol2 = new EnhancedSymbolInformation(symbol2, null);
generatedSymbols2.add(new CachedSymbol(doc1URI, timeFile1.toMillis() + 2000, enhancedSymbol1));
@@ -312,15 +313,15 @@ public class SymbolCacheOnDiscTest {
String doc3URI = UriUtil.toUri(file3.toFile()).toString();
List<CachedSymbol> generatedSymbols = new ArrayList<>();
SymbolInformation symbol1 = new SymbolInformation("symbol1", SymbolKind.Field, new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))));
WorkspaceSymbol symbol1 = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20)))));
EnhancedSymbolInformation enhancedSymbol1 = new EnhancedSymbolInformation(symbol1, null);
generatedSymbols.add(new CachedSymbol(doc1URI, timeFile1.toMillis(), enhancedSymbol1));
SymbolInformation symbol2 = new SymbolInformation("symbol2", SymbolKind.Field, new Location(doc2URI, new Range(new Position(3, 10), new Position(3, 20))));
WorkspaceSymbol symbol2 = new WorkspaceSymbol("symbol2", SymbolKind.Field, Either.forLeft(new Location(doc2URI, new Range(new Position(3, 10), new Position(3, 20)))));
EnhancedSymbolInformation enhancedSymbol2 = new EnhancedSymbolInformation(symbol2, null);
generatedSymbols.add(new CachedSymbol(doc2URI, timeFile2.toMillis(), enhancedSymbol2));
SymbolInformation symbol3 = new SymbolInformation("symbol3", SymbolKind.Field, new Location(doc3URI, new Range(new Position(3, 10), new Position(3, 20))));
WorkspaceSymbol symbol3 = new WorkspaceSymbol("symbol3", SymbolKind.Field, Either.forLeft(new Location(doc3URI, new Range(new Position(3, 10), new Position(3, 20)))));
EnhancedSymbolInformation enhancedSymbol3 = new EnhancedSymbolInformation(symbol3, null);
generatedSymbols.add(new CachedSymbol(doc3URI, timeFile3.toMillis(), enhancedSymbol3));
@@ -331,17 +332,17 @@ public class SymbolCacheOnDiscTest {
// create updated and new symbols
List<CachedSymbol> updatedSymbols = new ArrayList<>();
SymbolInformation updatedSymbol1 = new SymbolInformation("symbol1", SymbolKind.Field, new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))));
WorkspaceSymbol updatedSymbol1 = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20)))));
EnhancedSymbolInformation updatedEnhancedSymbol1 = new EnhancedSymbolInformation(updatedSymbol1, null);
SymbolInformation newSymbol1 = new SymbolInformation("symbol1-new", SymbolKind.Interface, new Location(doc1URI, new Range(new Position(5, 5), new Position(5, 10))));
WorkspaceSymbol newSymbol1 = new WorkspaceSymbol("symbol1-new", SymbolKind.Interface, Either.forLeft(new Location(doc1URI, new Range(new Position(5, 5), new Position(5, 10)))));
EnhancedSymbolInformation newEnhancedSymbol1 = new EnhancedSymbolInformation(newSymbol1, null);
updatedSymbols.add(new CachedSymbol(doc1URI, timeFile1.toMillis() + 2000, updatedEnhancedSymbol1));
updatedSymbols.add(new CachedSymbol(doc1URI, timeFile1.toMillis() + 2000, newEnhancedSymbol1));
assertTrue(file1.toFile().setLastModified(timeFile1.toMillis() + 2000));
SymbolInformation updatedSymbol2 = new SymbolInformation("symbol2-updated", SymbolKind.Field, new Location(doc2URI, new Range(new Position(3, 10), new Position(3, 20))));
WorkspaceSymbol updatedSymbol2 = new WorkspaceSymbol("symbol2-updated", SymbolKind.Field, Either.forLeft(new Location(doc2URI, new Range(new Position(3, 10), new Position(3, 20)))));
EnhancedSymbolInformation updatedEnhancedSymbol2 = new EnhancedSymbolInformation(updatedSymbol2, null);
updatedSymbols.add(new CachedSymbol(doc2URI, timeFile2.toMillis() + 3000, updatedEnhancedSymbol2));
assertTrue(file2.toFile().setLastModified(timeFile2.toMillis() + 3000));
@@ -369,7 +370,7 @@ public class SymbolCacheOnDiscTest {
private void assertSymbol(EnhancedSymbolInformation enhancedSymbol, CachedSymbol[] cachedSymbols) {
for (CachedSymbol cachedSymbol : cachedSymbols) {
SymbolInformation symbol = cachedSymbol.getEnhancedSymbol().getSymbol();
WorkspaceSymbol symbol = cachedSymbol.getEnhancedSymbol().getSymbol();
if (symbol.toString().equals(enhancedSymbol.getSymbol().toString())) {
return;
@@ -415,7 +416,7 @@ public class SymbolCacheOnDiscTest {
String doc1URI = UriUtil.toUri(file1.toFile()).toString();
List<CachedSymbol> generatedSymbols1 = new ArrayList<>();
SymbolInformation symbol1 = new SymbolInformation("symbol1", SymbolKind.Field, new Location("docURI", new Range(new Position(3, 10), new Position(3, 20))));
WorkspaceSymbol symbol1 = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location("docURI", new Range(new Position(3, 10), new Position(3, 20)))));
EnhancedSymbolInformation enhancedSymbol1 = new EnhancedSymbolInformation(symbol1, null);
generatedSymbols1.add(new CachedSymbol(doc1URI, timeFile1.toMillis(), enhancedSymbol1));
@@ -476,14 +477,14 @@ public class SymbolCacheOnDiscTest {
String doc2URI = UriUtil.toUri(file2.toFile()).toString();
List<CachedSymbol> generatedSymbols1 = new ArrayList<>();
SymbolInformation symbol1 = new SymbolInformation("symbol1", SymbolKind.Field, new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))));
WorkspaceSymbol symbol1 = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20)))));
EnhancedSymbolInformation enhancedSymbol1 = new EnhancedSymbolInformation(symbol1, null);
generatedSymbols1.add(new CachedSymbol(doc1URI, timeFile1.toMillis(), enhancedSymbol1));
cache.store(new SymbolCacheKey("somekey", "1"), files, generatedSymbols1, null);
List<CachedSymbol> generatedSymbols2 = new ArrayList<>();
SymbolInformation symbol2 = new SymbolInformation("symbol2", SymbolKind.Interface, new Location(doc2URI, new Range(new Position(5, 5), new Position(5, 10))));
WorkspaceSymbol symbol2 = new WorkspaceSymbol("symbol2", SymbolKind.Interface, Either.forLeft(new Location(doc2URI, new Range(new Position(5, 5), new Position(5, 10)))));
EnhancedSymbolInformation enhancedSymbol2 = new EnhancedSymbolInformation(symbol2, null);
generatedSymbols2.add(new CachedSymbol(doc2URI, timeFile2.toMillis(), enhancedSymbol2));
@@ -548,10 +549,10 @@ public class SymbolCacheOnDiscTest {
List<CachedSymbol> generatedSymbols = new ArrayList<>();
SymbolInformation symbol1 = new SymbolInformation("symbol1", SymbolKind.Field, new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20))));
WorkspaceSymbol symbol1 = new WorkspaceSymbol("symbol1", SymbolKind.Field, Either.forLeft(new Location(doc1URI, new Range(new Position(3, 10), new Position(3, 20)))));
EnhancedSymbolInformation enhancedSymbol1 = new EnhancedSymbolInformation(symbol1, null);
SymbolInformation symbol2 = new SymbolInformation("symbol2", SymbolKind.Field, new Location(doc2URI, new Range(new Position(5, 10), new Position(5, 20))));
WorkspaceSymbol symbol2 = new WorkspaceSymbol("symbol2", SymbolKind.Field, Either.forLeft(new Location(doc2URI, new Range(new Position(5, 10), new Position(5, 20)))));
EnhancedSymbolInformation enhancedSymbol2 = new EnhancedSymbolInformation(symbol2, null);
generatedSymbols.add(new CachedSymbol(doc1URI, timeFile1.toMillis(), enhancedSymbol1));
@@ -572,7 +573,7 @@ public class SymbolCacheOnDiscTest {
assertEquals("symbol2", cachedSymbols[0].getEnhancedSymbol().getSymbol().getName());
assertEquals(SymbolKind.Field, cachedSymbols[0].getEnhancedSymbol().getSymbol().getKind());
assertEquals(new Location(doc2URI, new Range(new Position(5, 10), new Position(5, 20))), cachedSymbols[0].getEnhancedSymbol().getSymbol().getLocation());
assertEquals(new Location(doc2URI, new Range(new Position(5, 10), new Position(5, 20))), cachedSymbols[0].getEnhancedSymbol().getSymbol().getLocation().getLeft());
assertNull(cachedSymbols[0].getEnhancedSymbol().getAdditionalInformation());
Multimap<String, String> cachedDependencies = result.getRight();