Search in sources :

Example 1 with ImportDeclaration

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);
    });
}
Also used : AsyncPromiseHelper.createFromAsyncRequest(org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper.createFromAsyncRequest) Inject(com.google.inject.Inject) Flags(org.eclipse.che.ide.ext.java.client.util.Flags) JavaResources(org.eclipse.che.ide.ext.java.client.JavaResources) NotNull(javax.validation.constraints.NotNull) Collectors(java.util.stream.Collectors) Nullable(org.eclipse.che.commons.annotation.Nullable) ArrayList(java.util.ArrayList) Assisted(com.google.inject.assistedinject.Assisted) ImportDeclaration(org.eclipse.che.ide.ext.java.shared.dto.model.ImportDeclaration) Promise(org.eclipse.che.api.promises.client.Promise) NodePresentation(org.eclipse.che.ide.ui.smartTree.presentation.NodePresentation) List(java.util.List) Match(org.eclipse.che.ide.ext.java.shared.dto.search.Match) Initializer(org.eclipse.che.ide.ext.java.shared.dto.model.Initializer) Node(org.eclipse.che.ide.api.data.tree.Node) CompilationUnit(org.eclipse.che.ide.ext.java.shared.dto.model.CompilationUnit) Type(org.eclipse.che.ide.ext.java.shared.dto.model.Type) Map(java.util.Map) Field(org.eclipse.che.ide.ext.java.shared.dto.model.Field) SVGResource(org.vectomatic.dom.svg.ui.SVGResource) ClassFile(org.eclipse.che.ide.ext.java.shared.dto.model.ClassFile) Collections(java.util.Collections) Field(org.eclipse.che.ide.ext.java.shared.dto.model.Field) Type(org.eclipse.che.ide.ext.java.shared.dto.model.Type) Initializer(org.eclipse.che.ide.ext.java.shared.dto.model.Initializer) Node(org.eclipse.che.ide.api.data.tree.Node) ArrayList(java.util.ArrayList) ImportDeclaration(org.eclipse.che.ide.ext.java.shared.dto.model.ImportDeclaration)

Example 2 with ImportDeclaration

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;
}
Also used : Field(org.eclipse.che.ide.ext.java.shared.dto.model.Field) Initializer(org.eclipse.che.ide.ext.java.shared.dto.model.Initializer) ArrayList(java.util.ArrayList) ImportDeclaration(org.eclipse.che.ide.ext.java.shared.dto.model.ImportDeclaration) Match(org.eclipse.che.ide.ext.java.shared.dto.search.Match)

Example 3 with ImportDeclaration

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);
        }
    }
}
Also used : ImportDeclaration(org.eclipse.che.ide.ext.java.shared.dto.model.ImportDeclaration) IImportDeclaration(org.eclipse.jdt.core.IImportDeclaration) IImportDeclaration(org.eclipse.jdt.core.IImportDeclaration)

Aggregations

ImportDeclaration (org.eclipse.che.ide.ext.java.shared.dto.model.ImportDeclaration)3 ArrayList (java.util.ArrayList)2 Field (org.eclipse.che.ide.ext.java.shared.dto.model.Field)2 Initializer (org.eclipse.che.ide.ext.java.shared.dto.model.Initializer)2 Match (org.eclipse.che.ide.ext.java.shared.dto.search.Match)2 Inject (com.google.inject.Inject)1 Assisted (com.google.inject.assistedinject.Assisted)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 NotNull (javax.validation.constraints.NotNull)1 Promise (org.eclipse.che.api.promises.client.Promise)1 AsyncPromiseHelper.createFromAsyncRequest (org.eclipse.che.api.promises.client.callback.AsyncPromiseHelper.createFromAsyncRequest)1 Nullable (org.eclipse.che.commons.annotation.Nullable)1 Node (org.eclipse.che.ide.api.data.tree.Node)1 JavaResources (org.eclipse.che.ide.ext.java.client.JavaResources)1 Flags (org.eclipse.che.ide.ext.java.client.util.Flags)1 ClassFile (org.eclipse.che.ide.ext.java.shared.dto.model.ClassFile)1 CompilationUnit (org.eclipse.che.ide.ext.java.shared.dto.model.CompilationUnit)1