use of org.eclipse.che.ide.ext.java.shared.dto.model.Initializer 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.Initializer in project che by eclipse.
the class TypeNode method getMatches.
/**
* Collect all matches for this type node.
*
* @return the list of matches.
*/
public List<Match> getMatches() {
List<Match> matches = new ArrayList<>();
if (compilationUnit != null && type.isPrimary()) {
for (ImportDeclaration importDeclaration : compilationUnit.getImports()) {
addAllMatches(importDeclaration.getHandleIdentifier(), matches);
}
}
addAllMatches(type.getHandleIdentifier(), matches);
for (Initializer initializer : type.getInitializers()) {
addAllMatches(initializer.getHandleIdentifier(), matches);
}
for (Field field : type.getFields()) {
addAllMatches(field.getHandleIdentifier(), matches);
}
return matches;
}
use of org.eclipse.che.ide.ext.java.shared.dto.model.Initializer in project che by eclipse.
the class JavaNavigation method convertToDTOInitializer.
private Initializer convertToDTOInitializer(IInitializer iInitializer) throws JavaModelException {
Initializer initializer = DtoFactory.newDto(Initializer.class);
initializer.setFileRegion(convertToDTORegion(iInitializer.getSourceRange()));
initializer.setElementName(iInitializer.getElementName());
initializer.setHandleIdentifier(iInitializer.getHandleIdentifier());
initializer.setFlags(iInitializer.getFlags());
initializer.setLabel(org.eclipse.jdt.ui.JavaElementLabels.getElementLabel(iInitializer, org.eclipse.jdt.ui.JavaElementLabels.ALL_DEFAULT));
return initializer;
}
use of org.eclipse.che.ide.ext.java.shared.dto.model.Initializer in project che by eclipse.
the class JavaElementToDtoConverter method getInitializes.
private List<Initializer> getInitializes(Object parent) throws JavaModelException {
List<Initializer> result = new ArrayList<>();
Set<Object> objects = childrens.get(parent);
if (objects == null) {
return result;
}
for (Object object : objects) {
if (object instanceof IInitializer) {
IInitializer initializer = (IInitializer) object;
Initializer init = DtoFactory.newDto(Initializer.class);
init.setElementName(initializer.getElementName());
init.setHandleIdentifier(initializer.getHandleIdentifier());
init.setFlags(initializer.getFlags());
init.setLabel(JavaElementLabels.getElementLabel(initializer, JavaElementLabels.ALL_DEFAULT));
result.add(init);
}
}
return result;
}
use of org.eclipse.che.ide.ext.java.shared.dto.model.Initializer in project che by eclipse.
the class JavaNavigation method convertToDTOType.
private Type convertToDTOType(IType iType) throws JavaModelException {
List<Type> types = new ArrayList<>();
List<Method> methods = new ArrayList<>();
List<Field> fields = new ArrayList<>();
List<Initializer> initializers = new ArrayList<>();
Type type = DtoFactory.newDto(Type.class);
setRootPath(iType, type);
type.setElementName(iType.getElementName());
type.setLabel(org.eclipse.jdt.ui.JavaElementLabels.getElementLabel(iType, org.eclipse.jdt.ui.JavaElementLabels.ALL_DEFAULT));
type.setHandleIdentifier(iType.getHandleIdentifier());
type.setFlags(iType.getFlags());
type.setFileRegion(convertToDTORegion(iType.getNameRange()));
if (!iType.hasChildren()) {
type.setTypes(types);
return type;
}
IJavaElement[] children = iType.getChildren();
for (IJavaElement child : children) {
switch(child.getElementType()) {
case //type
7:
types.add(convertToDTOType((IType) child));
break;
case //field
8:
fields.add(convertToDTOField((IField) child));
break;
case //method
9:
methods.add(convertToDTOMethod((IMethod) child));
break;
case //initializer
10:
initializers.add(convertToDTOInitializer((IInitializer) child));
break;
default:
break;
}
}
type.setFields(fields);
type.setMethods(methods);
type.setInitializers(initializers);
type.setTypes(types);
return type;
}
Aggregations