Search in sources :

Example 1 with Field

use of org.eclipse.che.ide.ext.java.shared.dto.model.Field 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 Field

use of org.eclipse.che.ide.ext.java.shared.dto.model.Field 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 Field

use of org.eclipse.che.ide.ext.java.shared.dto.model.Field in project che by eclipse.

the class JavaNavigation method convertToDTOField.

private Field convertToDTOField(IField iField) throws JavaModelException {
    Field field = DtoFactory.newDto(Field.class);
    setRootPath(iField, field);
    field.setFileRegion(convertToDTORegion(iField.getNameRange()));
    field.setElementName(iField.getElementName());
    field.setHandleIdentifier(iField.getHandleIdentifier());
    field.setFlags(iField.getFlags());
    field.setLabel(org.eclipse.jdt.ui.JavaElementLabels.getElementLabel(iField, org.eclipse.jdt.ui.JavaElementLabels.ALL_DEFAULT));
    return field;
}
Also used : Field(org.eclipse.che.ide.ext.java.shared.dto.model.Field) IField(org.eclipse.jdt.core.IField)

Example 4 with Field

use of org.eclipse.che.ide.ext.java.shared.dto.model.Field in project che by eclipse.

the class JavaElementToDtoConverter method getFields.

private List<Field> getFields(Object parent) throws JavaModelException {
    List<Field> result = new ArrayList<>();
    Set<Object> objects = childrens.get(parent);
    if (objects == null) {
        return result;
    }
    for (Object object : objects) {
        if (object instanceof IField) {
            IField iField = (IField) object;
            Field field = DtoFactory.newDto(Field.class);
            field.setElementName(iField.getElementName());
            field.setHandleIdentifier(iField.getHandleIdentifier());
            field.setFlags(iField.getFlags());
            field.setLabel(JavaElementLabels.getElementLabel(iField, JavaElementLabels.ALL_DEFAULT));
            result.add(field);
        }
    }
    return result;
}
Also used : IField(org.eclipse.jdt.core.IField) Field(org.eclipse.che.ide.ext.java.shared.dto.model.Field) ArrayList(java.util.ArrayList) IField(org.eclipse.jdt.core.IField)

Example 5 with Field

use of org.eclipse.che.ide.ext.java.shared.dto.model.Field 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;
}
Also used : IJavaElement(org.eclipse.jdt.core.IJavaElement) IInitializer(org.eclipse.jdt.core.IInitializer) ArrayList(java.util.ArrayList) Method(org.eclipse.che.ide.ext.java.shared.dto.model.Method) IMethod(org.eclipse.jdt.core.IMethod) IField(org.eclipse.jdt.core.IField) IType(org.eclipse.jdt.core.IType) Field(org.eclipse.che.ide.ext.java.shared.dto.model.Field) IField(org.eclipse.jdt.core.IField) JarEntryType(org.eclipse.che.ide.ext.java.shared.JarEntry.JarEntryType) IType(org.eclipse.jdt.core.IType) Type(org.eclipse.che.ide.ext.java.shared.dto.model.Type) Initializer(org.eclipse.che.ide.ext.java.shared.dto.model.Initializer) IInitializer(org.eclipse.jdt.core.IInitializer) IMethod(org.eclipse.jdt.core.IMethod)

Aggregations

Field (org.eclipse.che.ide.ext.java.shared.dto.model.Field)5 ArrayList (java.util.ArrayList)4 Initializer (org.eclipse.che.ide.ext.java.shared.dto.model.Initializer)3 IField (org.eclipse.jdt.core.IField)3 ImportDeclaration (org.eclipse.che.ide.ext.java.shared.dto.model.ImportDeclaration)2 Type (org.eclipse.che.ide.ext.java.shared.dto.model.Type)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