PT #171932358 Flag for detailed java type data for sub/super types

This commit is contained in:
BoykoAlex
2020-04-02 13:35:11 -04:00
parent 99a33547c4
commit 3bddccd57f
16 changed files with 140 additions and 70 deletions

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Pivotal, Inc.
* Copyright (c) 2019, 2020 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -144,8 +144,8 @@ public class JavaLangugeClientTest {
@Test
public void map_Subtypes() throws Exception {
List<TypeDescriptorData> data = client
.javaSubTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "java.util.Map", false))
.get(10, TimeUnit.SECONDS);
.javaSubTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "java.util.Map", false, false))
.get(10, TimeUnit.SECONDS).stream().map(e -> e.getLeft()).collect(Collectors.toList());
assertNotNull(data);
assertTrue(data.size() > 200);
assertTrue(data.stream().filter(t -> "java.util.AbstractMap".equals(t.getFqName())).findFirst().isPresent());
@@ -154,8 +154,8 @@ public class JavaLangugeClientTest {
@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);
.javaSubTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "java.util.Map", true, false))
.get(10, TimeUnit.SECONDS).stream().map(e -> e.getLeft()).collect(Collectors.toList());
assertNotNull(data);
assertTrue(data.size() > 200);
assertTrue(data.stream().filter(t -> "java.util.Map".equals(t.getFqName())).findFirst().isPresent());
@@ -164,8 +164,8 @@ public class JavaLangugeClientTest {
@Test
public void arrayList_SuperTypes() throws Exception {
List<TypeDescriptorData> data = client
.javaSuperTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "java.util.ArrayList", false))
.get(10, TimeUnit.SECONDS);
.javaSuperTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "java.util.ArrayList", false, false))
.get(10, TimeUnit.SECONDS).stream().map(e -> e.getLeft()).collect(Collectors.toList());
assertNotNull(data);
Set<String> actual = data.stream().map(t -> t.getFqName()).collect(Collectors.toSet());
Set<String> expected = new HashSet<>(Arrays.asList(
@@ -185,8 +185,8 @@ public class JavaLangugeClientTest {
@Test
public void anonymousInnerType_SuperTypes() throws Exception {
List<TypeDescriptorData> data = client
.javaSuperTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "org.test.Application$1", false))
.get(1000000000, TimeUnit.SECONDS);
.javaSuperTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "org.test.Application$1", false, false))
.get(1000000000, TimeUnit.SECONDS).stream().map(e -> e.getLeft()).collect(Collectors.toList());
assertNotNull(data);
Set<String> actual = data.stream().map(t -> t.getFqName()).collect(Collectors.toSet());
Set<String> expected = new HashSet<>(Arrays.asList(
@@ -206,8 +206,8 @@ public class JavaLangugeClientTest {
@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);
.javaSuperTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "java.util.ArrayList", true, false))
.get(10, TimeUnit.SECONDS).stream().map(e -> e.getLeft()).collect(Collectors.toList());
assertNotNull(data);
Set<String> actual = data.stream().map(t -> t.getFqName()).collect(Collectors.toSet());
Set<String> expected = new HashSet<>(Arrays.asList(
@@ -229,7 +229,7 @@ public class JavaLangugeClientTest {
public void taskExecutorFactoryBean_SuperTypes() throws Exception {
List<TypeDescriptorData> data = client
.javaSuperTypes(new JavaTypeHierarchyParams(project.getLocationURI().toString(), "org.springframework.scheduling.config.TaskExecutorFactoryBean"))
.get(10, TimeUnit.SECONDS);
.get(10, TimeUnit.SECONDS).stream().map(e -> e.getLeft()).collect(Collectors.toList());
assertNotNull(data);
Set<String> actual = data.stream().map(t -> t.getFqName()).collect(Collectors.toSet());
Set<String> expected = new HashSet<>(Arrays.asList(

View File

@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2019 Pivotal, Inc.
* Copyright (c) 2017, 2020 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -53,6 +53,7 @@ import org.eclipse.lsp4j.Location;
import org.eclipse.lsp4j.MarkupContent;
import org.eclipse.lsp4j.MarkupKind;
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
@@ -518,17 +519,13 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La
}
@Override
public CompletableFuture<List<TypeDescriptorData>> javaSubTypes(JavaTypeHierarchyParams params) {
return CompletableFuture.supplyAsync(() ->
typeHierarchy.subTypes(params).collect(Collectors.toList())
);
public CompletableFuture<List<Either<TypeDescriptorData, TypeData>>> javaSubTypes(JavaTypeHierarchyParams params) {
return CompletableFuture.supplyAsync(() -> typeHierarchy.subTypes(params).collect(Collectors.toList()));
}
@Override
public CompletableFuture<List<TypeDescriptorData>> javaSuperTypes(JavaTypeHierarchyParams params) {
return CompletableFuture.supplyAsync(() ->
typeHierarchy.superTypes(params).collect(Collectors.toList())
);
public CompletableFuture<List<Either<TypeDescriptorData, TypeData>>> javaSuperTypes(JavaTypeHierarchyParams params) {
return CompletableFuture.supplyAsync(() -> typeHierarchy.superTypes(params).collect(Collectors.toList()));
}
@Override