use of org.eclipse.lsp4j.TypeHierarchyItem in project eclipse.jdt.ls by eclipse.
the class TypeHierarchyCommand method resolveTypeHierarchy.
public TypeHierarchyItem resolveTypeHierarchy(ResolveTypeHierarchyItemParams params, IProgressMonitor monitor) {
if (params == null) {
return null;
}
TypeHierarchyItem item = params.getItem();
if (item == null) {
return null;
}
Range range = item.getRange();
if (range == null) {
return null;
}
Position position = range.getStart();
String uri = item.getUri();
TypeHierarchyDirection direction = params.getDirection();
int resolve = params.getResolve();
return getTypeHierarchy(uri, position, direction, resolve, item, monitor);
}
use of org.eclipse.lsp4j.TypeHierarchyItem in project eclipse.jdt.ls by eclipse.
the class TypeHierarchyCommandTest method testTypeHierarchy.
@Test
public void testTypeHierarchy() throws Exception {
IProgressMonitor monitor = new NullProgressMonitor();
TypeHierarchyParams params = new TypeHierarchyParams();
String uriString = fJProject.getFile("src/main/java/org/sample/TestJavadoc.java").getLocationURI().toString();
TextDocumentIdentifier identifier = new TextDocumentIdentifier(uriString);
Position position = new Position(4, 20);
params.setTextDocument(identifier);
params.setResolve(1);
params.setDirection(TypeHierarchyDirection.Both);
params.setPosition(position);
TypeHierarchyItem item = fCommand.typeHierarchy(params, monitor);
assertNotNull(item);
assertEquals(item.getName(), "TestJavadoc");
assertNotNull(item.getChildren());
assertEquals(item.getChildren().size(), 0);
assertNotNull(item.getParents());
assertEquals(item.getParents().size(), 1);
assertEquals(item.getParents().get(0).getName(), "Object");
}
use of org.eclipse.lsp4j.TypeHierarchyItem in project eclipse.jdt.ls by eclipse.
the class TypeHierarchyCommandTest method testSuperTypeHierarchy.
@Test
public void testSuperTypeHierarchy() throws Exception {
IProgressMonitor monitor = new NullProgressMonitor();
TypeHierarchyParams params = new TypeHierarchyParams();
String uriString = fJProject.getFile("src/main/java/org/sample/CallHierarchy.java").getLocationURI().toString();
TextDocumentIdentifier identifier = new TextDocumentIdentifier(uriString);
Position position = new Position(7, 27);
params.setTextDocument(identifier);
params.setResolve(1);
params.setDirection(TypeHierarchyDirection.Parents);
params.setPosition(position);
TypeHierarchyItem item = fCommand.typeHierarchy(params, monitor);
assertNotNull(item);
assertEquals(item.getName(), "CallHierarchy$FooBuilder");
assertNull(item.getChildren());
assertEquals(item.getParents().size(), 2);
TypeHierarchyItem builder = item.getParents().get(0);
assertNotNull(builder);
assertEquals(builder.getName(), "Builder");
assertNull(builder.getParents());
TypeHierarchyItem object = item.getParents().get(1);
assertNotNull(object);
assertEquals(object.getName(), "Object");
assertNull(object.getParents());
}
Aggregations