use of org.eclipse.che.ide.ext.java.shared.dto.model.ImportDeclaration 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.ImportDeclaration 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.ImportDeclaration in project che by eclipse.
the class JavaElementToDtoConverter method addImport.
private void addImport(List<ImportDeclaration> result, Set<Object> imports) throws JavaModelException {
for (Object im : imports) {
if (im instanceof IImportDeclaration) {
IImportDeclaration dec = (IImportDeclaration) im;
ImportDeclaration importDeclaration = DtoFactory.newDto(ImportDeclaration.class);
importDeclaration.setFlags(dec.getFlags());
importDeclaration.setHandleIdentifier(dec.getHandleIdentifier());
importDeclaration.setElementName(dec.getElementName());
result.add(importDeclaration);
}
}
}
Aggregations