PT #164474609: Light TypeDescriptorData and caching super, sub-types

This commit is contained in:
BoykoAlex
2019-03-08 11:26:00 -05:00
parent ee67cf914d
commit 91d9838fff
32 changed files with 5932 additions and 633 deletions

View File

@@ -1,12 +1,5 @@
{
"fqName": "java.util.Map",
"bindingKey": "Ljava/util/Map;",
"clazz": false,
"annotation": false,
"interfaze": true,
"enam": false,
"superClassName": "java.lang.Object",
"superInterfaceNames": [],
"fields": [],
"methods": [
{
@@ -713,6 +706,13 @@
"isOwn": false
}
},
"fqName": "java.util.Map",
"clazz": false,
"annotation": false,
"interfaze": true,
"enam": false,
"superClassName": "java.lang.Object",
"superInterfaceNames": [],
"flags": 1537,
"name": "Map",
"handleIdentifier": "\u003dtest-webflux-project/\\/Library\\/Java\\/JavaVirtualMachines\\/jdk1.8.0_151.jdk\\/Contents\\/Home\\/jre\\/lib\\/rt.jar\u003cjava.util(Map.class[Map",

View File

@@ -1,11 +1,5 @@
{
"fqName": "org.test.NestedRouter3",
"bindingKey": "Lorg/test/NestedRouter3;",
"clazz": true,
"annotation": false,
"interfaze": false,
"enam": false,
"superInterfaceNames": [],
"fields": [],
"methods": [
{
@@ -62,6 +56,12 @@
"isOwn": true
}
},
"fqName": "org.test.NestedRouter3",
"clazz": true,
"annotation": false,
"interfaze": false,
"enam": false,
"superInterfaceNames": [],
"flags": 1,
"name": "NestedRouter3",
"handleIdentifier": "\u003dtest-webflux-project/src\\/main\\/java\u003corg.test{NestedRouter3.java[NestedRouter3",

View File

@@ -1,11 +1,5 @@
{
"fqName": "org.test.Quote",
"bindingKey": "Lorg/test/Quote;",
"clazz": true,
"annotation": false,
"interfaze": false,
"enam": false,
"superInterfaceNames": [],
"fields": [
{
"bindingKey": "Lorg/test/Quote;.MATH_CONTEXT",
@@ -267,6 +261,12 @@
"isOwn": true
}
},
"fqName": "org.test.Quote",
"clazz": true,
"annotation": false,
"interfaze": false,
"enam": false,
"superInterfaceNames": [],
"flags": 1,
"name": "Quote",
"handleIdentifier": "\u003dtest-webflux-project/src\\/main\\/java\u003corg.test{Quote.java[Quote",

View File

@@ -1,12 +1,5 @@
{
"fqName": "org.springframework.boot.autoconfigure.web.ServerProperties",
"bindingKey": "Lorg/springframework/boot/autoconfigure/web/ServerProperties;",
"clazz": true,
"annotation": false,
"interfaze": false,
"enam": false,
"superClassName": "java.lang.Object",
"superInterfaceNames": [],
"fields": [
{
"bindingKey": "Lorg/springframework/boot/autoconfigure/web/ServerProperties;.port",
@@ -625,6 +618,13 @@
"isOwn": false
}
},
"fqName": "org.springframework.boot.autoconfigure.web.ServerProperties",
"clazz": true,
"annotation": false,
"interfaze": false,
"enam": false,
"superClassName": "java.lang.Object",
"superInterfaceNames": [],
"flags": 1,
"name": "ServerProperties",
"handleIdentifier": "\u003dtest-webflux-project/\\/Users\\/aboyko\\/.m2\\/repository\\/org\\/springframework\\/boot\\/spring-boot-autoconfigure\\/2.0.0.RELEASE\\/spring-boot-autoconfigure-2.0.0.RELEASE.jar\u003corg.springframework.boot.autoconfigure.web(ServerProperties.class[ServerProperties",

View File

@@ -29,6 +29,7 @@ import org.springframework.ide.vscode.commons.protocol.java.JavaDataParams;
import org.springframework.ide.vscode.commons.protocol.java.JavaSearchParams;
import org.springframework.ide.vscode.commons.protocol.java.JavaTypeHierarchyParams;
import org.springframework.ide.vscode.commons.protocol.java.TypeData;
import org.springframework.ide.vscode.commons.protocol.java.TypeDescriptorData;
import org.springframework.tooling.ls.eclipse.commons.STS4LanguageClientImpl;
public class JavaLangugeClientTest {
@@ -87,32 +88,32 @@ public class JavaLangugeClientTest {
@Test
public void fuzzyFindTypesIncludingSysLibs() throws Exception {
List<String> data = client
List<TypeDescriptorData> data = client
.javaSearchTypes(new JavaSearchParams(project.getLocationURI().toString(), "util.Map", true, true))
.get(100, TimeUnit.SECONDS);
assertNotNull(data);
assertEquals(500, data.size());
List<String> closeMatches = data.stream().filter(t -> t.contains("util.Map")).collect(Collectors.toList());
List<String> closeMatches = data.stream().map(t -> t.getFqName()).filter(t -> t.contains("util.Map")).collect(Collectors.toList());
assertEquals(2, closeMatches.size());
assertNotNull(closeMatches.stream().filter(t -> "java.util.Map".equals(t)).findFirst().orElse(null));
}
@Test
public void fuzzyFindTypesExcludingSysLibs() throws Exception {
List<String> data = client
List<TypeDescriptorData> data = client
.javaSearchTypes(new JavaSearchParams(project.getLocationURI().toString(), "util.Map", true, false))
.get(10, TimeUnit.SECONDS);
assertNotNull(data);
assertEquals(186, data.size());
// TestUtils.saveJsonData("search-util-map.json", data);
List<String> closeMatches = data.stream().filter(t -> t.contains("util.Map")).collect(Collectors.toList());
TestUtils.saveJsonData("search-util-map.json", data);
List<String> closeMatches = data.stream().map(t -> t.getFqName()).filter(t -> t.contains("util.Map")).collect(Collectors.toList());
assertEquals(1, closeMatches.size());
assertEquals("io.netty.util.Mapping", closeMatches.get(0));
}
@Test
public void fuzzyFindAllTypesExcludingSysLibs() throws Exception {
List<String> data = client
List<TypeDescriptorData> data = client
.javaSearchTypes(new JavaSearchParams(project.getLocationURI().toString(), "", true, false))
.get(1000, TimeUnit.SECONDS);
assertNotNull(data);
@@ -141,18 +142,28 @@ public class JavaLangugeClientTest {
@Test
public void map_Subtypes() throws Exception {
List<TypeData> data = client
.javaSubTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "java.util.Map"))
List<TypeDescriptorData> data = client
.javaSubTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "java.util.Map", false))
.get(10, TimeUnit.SECONDS);
assertNotNull(data);
assertTrue(data.size() > 200);
assertTrue(data.stream().filter(t -> "java.util.AbstractMap".equals(t.getFqName())).findFirst().isPresent());
}
@Test
public void map_Subtypes_with_Itself() throws Exception {
List<TypeDescriptorData> data = client
.javaSubTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "java.util.Map", true))
.get(10, TimeUnit.SECONDS);
assertNotNull(data);
assertTrue(data.size() > 200);
assertTrue(data.stream().filter(t -> "java.util.Map".equals(t.getFqName())).findFirst().isPresent());
}
@Test
public void arrayList_SuperTypes() throws Exception {
List<TypeData> data = client
.javaSuperTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "java.util.ArrayList"))
List<TypeDescriptorData> data = client
.javaSuperTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "java.util.ArrayList", false))
.get(10, TimeUnit.SECONDS);
assertNotNull(data);
Set<String> actual = data.stream().map(t -> t.getFqName()).collect(Collectors.toSet());
@@ -170,11 +181,33 @@ public class JavaLangugeClientTest {
assertEquals(expected, actual);
}
@Test
public void arrayList_SuperTypes_with_Itself() throws Exception {
List<TypeDescriptorData> data = client
.javaSuperTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "java.util.ArrayList", true))
.get(10, TimeUnit.SECONDS);
assertNotNull(data);
Set<String> actual = data.stream().map(t -> t.getFqName()).collect(Collectors.toSet());
Set<String> expected = new HashSet<>(Arrays.asList(
"java.util.ArrayList",
"java.util.List",
"java.util.RandomAccess",
"java.lang.Cloneable",
"java.io.Serializable",
"java.util.AbstractList",
"java.util.Collection",
"java.lang.Object",
"java.util.AbstractCollection",
"java.lang.Iterable"
));
assertEquals(expected, actual);
}
@Test
public void taskExecutorFactoryBean_SuperTypes() throws Exception {
List<TypeData> data = client
List<TypeDescriptorData> data = client
.javaSuperTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "org.springframework.scheduling.config.TaskExecutorFactoryBean"))
.get(100000, TimeUnit.SECONDS);
.get(10, TimeUnit.SECONDS);
assertNotNull(data);
Set<String> actual = data.stream().map(t -> t.getFqName()).collect(Collectors.toSet());
Set<String> expected = new HashSet<>(Arrays.asList(