Example usage for org.eclipse.jdt.core.dom UnionType types

List of usage examples for org.eclipse.jdt.core.dom UnionType types

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom UnionType types.

Prototype

ASTNode.NodeList types

To view the source code for org.eclipse.jdt.core.dom UnionType types.

Click Source Link

Document

The list of types (element type: Type ).

Usage

From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java

License:Open Source License

@Override
public boolean visit(UnionType node) {
    for (Iterator<Type> it = node.types().iterator(); it.hasNext();) {
        Type t = it.next();//w  ww. j a va 2  s  .  c o m
        t.accept(this);
        if (it.hasNext()) {
            this.fBuffer.append("|");//$NON-NLS-1$
        }
    }
    return false;
}

From source file:boa.datagen.util.Java7Visitor.java

License:Apache License

protected String typeName(final UnionType t) {
    String name = "";
    for (final Object o : t.types()) {
        if (name.length() > 0)
            name += " | ";
        name += typeName((org.eclipse.jdt.core.dom.Type) o);
    }//from  ww  w.  j  av a2  s.  c o  m
    return name;
}

From source file:com.bsiag.eclipse.jdt.java.formatter.linewrap.WrapPreparator.java

License:Open Source License

@Override
public boolean visit(UnionType node) {
    List<Type> types = node.types();
    if (this.options.wrap_before_or_operator_multicatch && !types.isEmpty()) {
        for (Type type : types) {
            if (this.wrapIndexes.isEmpty()) {
                this.wrapIndexes.add(this.tm.firstIndexIn(type, -1));
            } else {
                this.wrapIndexes.add(this.tm.firstIndexBefore(type, TokenNameOR));
            }//from ww  w . ja va2s .com
        }
        this.wrapParentIndex = this.tm.firstIndexBefore(node, TokenNameLPAREN);
        this.wrapGroupEnd = this.tm.lastIndexIn(types.get(types.size() - 1), -1);
        handleWrap(this.options.alignment_for_union_type_in_multicatch);
    } else {
        handleArguments(types, this.options.alignment_for_union_type_in_multicatch);
    }
    return true;
}

From source file:com.bsiag.eclipse.jdt.java.formatter.SpacePreparator.java

License:Open Source License

@Override
public boolean visit(UnionType node) {
    List<Type> types = node.types();
    for (int i = 1; i < types.size(); i++)
        handleTokenBefore(types.get(i), TokenNameOR, this.options.insert_space_before_binary_operator,
                this.options.insert_space_after_binary_operator);
    return true;//from  w w w  . j av  a2  s.co  m
}

From source file:com.google.devtools.j2objc.util.ASTUtil.java

License:Apache License

@SuppressWarnings("unchecked")
public static List<Type> getTypes(UnionType unionType) {
    return unionType.types();
}

From source file:com.google.googlejavaformat.java.JavaInputAstVisitor.java

License:Apache License

/** Helper method for {@link UnionType}s. */
private static void walkUnionTypes(List<Type> types, UnionType node) {
    for (ASTNode type : (List<ASTNode>) node.types()) {
        if (type.getNodeType() == ASTNode.UNION_TYPE) {
            walkUnionTypes(types, (UnionType) type);
        } else {/*ww w  .  j a v  a 2s . c  o m*/
            types.add((Type) type);
        }
    }
}

From source file:com.kodebeagle.javaparser.TypeResolver.java

License:Apache License

/**
 * @param type/*ww w  .j  a  v a  2s.  co m*/
 * @return
 */
protected String getNameOfType(final Type type) {
    String nameOfType = "";
    if (type != null) {
        if (type.isPrimitiveType()) {
            nameOfType = type.toString();
        } else if (type.isParameterizedType()) {
            nameOfType = getParametrizedType((ParameterizedType) type);
        } else if (type.isArrayType()) {
            final ArrayType array = (ArrayType) type;
            nameOfType = getNameOfType(array.getElementType()) /*+ "[]"*/;
        } else if (type.isUnionType()) {
            // TODO: this is used for exceptions till now
            // So we will just capture the first type that we encounter
            final UnionType uType = (UnionType) type;
            final StringBuffer sb = new StringBuffer();
            for (final Object unionedType : uType.types()) {
                sb.append(getNameOfType(((Type) unionedType)));
                break;
                // sb.append(" | ");
            }
            // sb.delete(sb.length() - 3, sb.length());
            nameOfType = sb.toString();
        } else if (type.isWildcardType()) {
            final WildcardType wType = (WildcardType) type;
            nameOfType = (wType.isUpperBound() ? "? extends " : "? super ") + getNameOfType(wType.getBound());
        } else {
            nameOfType = getFullyQualifiedNameFor(type.toString());
        }
    }
    return nameOfType;
}

From source file:lang.java.jdt.internal.JdtAstToRascalAstConverter.java

License:Open Source License

public boolean visit(UnionType node) {
    IValueList typesValues = new IValueList(values);
    for (Iterator types = node.types().iterator(); types.hasNext();) {
        Type type = (Type) types.next();
        typesValues.add(visitChild(type));
    }/*  w  ww  .j  a va  2 s  .c om*/

    ownValue = constructRascalNode(node, typesValues.asList());
    return false;
}

From source file:org.autorefactor.refactoring.ASTHelper.java

License:Open Source License

/**
 * Generecized version of the equivalent JDT method.
 *
 * @param node the node on which to call the equivalent JDT method
 * @return a List of abstract type declarations
 * @see UnionType#types()/*from w  w w.j a  va  2 s  .c o m*/
 */
@SuppressWarnings("unchecked")
public static List<Type> types(UnionType node) {
    return node.types();
}

From source file:org.codemucker.jmutate.ast.JAstFlattener.java

License:Open Source License

public boolean visit(UnionType node) {
    for (Iterator it = node.types().iterator(); it.hasNext();) {
        Type t = (Type) it.next();
        t.accept(this);
        if (it.hasNext()) {
            this.buffer.append('|');
        }// w ww .  j  av a  2s. c  o  m
    }
    return false;
}