use of org.eclipse.che.ide.ext.java.shared.dto.model.Type in project che by eclipse.
the class TypeNode method getChildrenImpl.
@Override
protected Promise<List<Node>> getChildrenImpl() {
return createFromAsyncRequest(callback -> {
List<Node> children = new ArrayList<>();
if (compilationUnit != null && type.isPrimary()) {
for (ImportDeclaration importDeclaration : compilationUnit.getImports()) {
createNodeForAllMatches(importDeclaration.getHandleIdentifier(), children);
}
for (Type subType : compilationUnit.getTypes()) {
if (subType == type) {
continue;
}
children.add(nodeFactory.create(subType, compilationUnit, classFile, matches));
}
}
createNodeForAllMatches(type.getHandleIdentifier(), children);
for (Initializer initializer : type.getInitializers()) {
createNodeForAllMatches(initializer.getHandleIdentifier(), children);
}
for (Field field : type.getFields()) {
createNodeForAllMatches(field.getHandleIdentifier(), children);
}
final List<Node> typeNodes = type.getTypes().stream().map(subType -> nodeFactory.create(subType, compilationUnit, classFile, matches)).collect(Collectors.toList());
children.addAll(typeNodes);
final List<Node> methodNodes = type.getMethods().stream().map(method -> nodeFactory.create(method, matches, compilationUnit, classFile)).collect(Collectors.toList());
children.addAll(methodNodes);
Collections.sort(children, new NodeComparator());
callback.onSuccess(children);
});
}
use of org.eclipse.che.ide.ext.java.shared.dto.model.Type in project che by eclipse.
the class OpenImplementationPresenter method openOneImplementation.
private void openOneImplementation(ImplementationsDescriptorDTO implementationsDescriptor, NoImplementationWidget implementationWidget, TextEditor editorPartPresenter) {
int offset = editorPartPresenter.getCursorOffset();
PositionConverter.PixelCoordinates coordinates = editorPartPresenter.getPositionConverter().offsetToPixel(offset);
for (Type type : implementationsDescriptor.getImplementations()) {
implementationWidget.addItem(type);
}
implementationWidget.show(coordinates.getX(), coordinates.getY());
implementationWidget.asElement().getStyle().setWidth(600 + "px");
}
use of org.eclipse.che.ide.ext.java.shared.dto.model.Type in project che by eclipse.
the class JavaNavigation method calculateSuperTypes.
private List<Type> calculateSuperTypes(IType type) throws JavaModelException {
List<Type> superTypes = new ArrayList<>();
ITypeHierarchy superTypeHierarchy = SuperTypeHierarchyCache.getTypeHierarchy(type);
if (superTypeHierarchy != null) {
IType[] superITypes = superTypeHierarchy.getAllSupertypes(type);
for (IType iType : superITypes) {
superTypes.add(convertToDTOType(iType));
}
}
return superTypes;
}
use of org.eclipse.che.ide.ext.java.shared.dto.model.Type in project che by eclipse.
the class JavaTypeHierarchy method findSubTypes.
private void findSubTypes(IJavaElement element, List<Type> implementations) throws JavaModelException {
IType type = (IType) element;
ITypeHierarchy typeHierarchy = type.newTypeHierarchy(new NullProgressMonitor());
IType[] implTypes = typeHierarchy.getAllSubtypes(type);
for (IType implType : implTypes) {
Type dto = convertToTypeDTO(implType);
implementations.add(dto);
}
}
use of org.eclipse.che.ide.ext.java.shared.dto.model.Type in project che by eclipse.
the class JavaTypeHierarchy method getImplementations.
/**
* Get all implementations of selected Java Element.
*
* @param project
* opened project
* @param fqn
* fully qualified name of the class file
* @param offset
* cursor position
* @return descriptor of the implementations
* @throws JavaModelException
* when JavaModel has a failure
*/
public ImplementationsDescriptorDTO getImplementations(IJavaProject project, String fqn, int offset) throws JavaModelException {
ImplementationsDescriptorDTO implementationDescriptor = DtoFactory.newDto(ImplementationsDescriptorDTO.class);
IJavaElement element = getJavaElement(project, fqn, offset);
if (element == null) {
return implementationDescriptor.withImplementations(emptyList());
}
List<Type> implementations = new ArrayList<>();
implementationDescriptor.setImplementations(implementations);
switch(element.getElementType()) {
case //type
7:
findSubTypes(element, implementations);
implementationDescriptor.setMemberName(element.getElementName());
break;
case //method
9:
findTypesWithSubMethods(element, implementations);
implementationDescriptor.setMemberName(element.getElementName());
break;
default:
break;
}
return implementationDescriptor;
}
Aggregations