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

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

Introduction

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

Prototype

ASTNode.NodeList types

To view the source code for org.eclipse.jdt.core.dom IntersectionType 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(IntersectionType node) {
    for (Iterator<Type> it = node.types().iterator(); it.hasNext();) {
        Type t = it.next();//from  w w  w.j ava2s .  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 IntersectionType t) {
    String name = "";
    for (final Object o : t.types()) {
        if (name.length() > 0)
            name += " & ";
        name += typeName((org.eclipse.jdt.core.dom.Type) o);
    }//from w  w w.  jav  a2s .  c  o  m
    return name;
}

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

License:Open Source License

@Override
public boolean visit(IntersectionType node) {
    List<Type> types = node.types();
    for (int i = 1; i < types.size(); i++)
        handleTokenBefore(types.get(i), TokenNameAND, this.options.insert_space_before_binary_operator,
                this.options.insert_space_after_binary_operator);
    return true;//from   ww  w. j  av a 2  s  . c o m
}

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

License:Apache License

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

From source file:com.j2swift.ast.DebugASTPrinter.java

License:Apache License

@Override
public boolean visit(IntersectionType node) {
    sb.print('(');
    boolean delimiterFlag = false;
    for (Type t : node.types()) {
        if (delimiterFlag) {
            sb.print(" & ");
        } else {/*from  w w w  .j  av  a2  s .c  o m*/
            delimiterFlag = true;
        }
        t.accept(this);
    }
    sb.print(')');
    return false;
}

From source file:edu.uci.ics.sourcerer.tools.java.extractor.eclipse.ReferenceExtractorVisitor.java

License:Open Source License

@SuppressWarnings("unchecked")
private String getTypeFqn(Type type) {
    if (type == null) {
        logger.log(Level.SEVERE, "Attempt to get type fqn of null type!");
        throw new NullPointerException("Attempt to get type fqn of null type!");
    }//from   ww w. j  a  va2  s.  c  o m
    ITypeBinding binding = safeResolve(type);
    if (binding == null || binding.isRecovered()) {
        if (type.isPrimitiveType()) {
            return ((PrimitiveType) type).getPrimitiveTypeCode().toString();
        } else if (type.isSimpleType()) {
            return createUnknownFqn(((SimpleType) type).getName().getFullyQualifiedName());
        } else if (type.isArrayType()) {
            ArrayType arrayType = (ArrayType) type;
            Type elementType = arrayType.getElementType();
            if (elementType == null) {
                return createUnknownFqn(BRACKETS.substring(0, 2 * arrayType.getDimensions()));
            } else {
                return getTypeFqn(elementType) + BRACKETS.substring(0, 2 * arrayType.getDimensions());
            }
        } else if (type.isParameterizedType()) {
            ParameterizedType pType = (ParameterizedType) type;
            StringBuilder fqn = new StringBuilder(getTypeFqn(pType.getType()));
            fqn.append("<");
            boolean isFirst = true;
            for (Type arg : (List<Type>) pType.typeArguments()) {
                if (isFirst) {
                    isFirst = false;
                } else {
                    fqn.append(",");
                }
                try {
                    fqn.append(getTypeFqn(arg));
                } catch (NullPointerException e) {
                    logger.log(Level.WARNING, "Eclipse NPE bug in parametrized type", e);
                    fqn.append(UNKNOWN);
                }
            }
            fqn.append(">");
            return fqn.toString();
        } else if (type.isWildcardType()) {
            WildcardType wType = (WildcardType) type;
            Type bound = wType.getBound();
            if (bound == null) {
                return "<?>";
            } else {
                return "<?" + (wType.isUpperBound() ? "+" : "-") + getTypeFqn(bound) + ">";
            }
        } else {
            if (type.isIntersectionType()) {
                IntersectionType iType = (IntersectionType) type;

                List<Type> list_types = iType.types();
                String res = "";
                for (Type tt : list_types) {
                    res += getTypeFqn(tt) + "&";
                }

                res = res.substring(0, res.length() - 1);
                return res;
            } else {
                logger.log(Level.SEVERE, "2 - Unexpected node type for unresolved type!" + type.toString());
                return UNKNOWN;
            }
        }
    } else {
        return getTypeFqn(binding);
    }
}

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

License:Open Source License

public boolean visit(IntersectionType node) {
    for (Iterator it = node.types().iterator(); it.hasNext();) {
        Type t = (Type) it.next();
        t.accept(this);
        if (it.hasNext()) {
            this.buffer.append(" & "); //$NON-NLS-1$
        }// w  w  w  . j  ava2  s  .c  o  m
    }
    return false;
}

From source file:org.mybatis.generator.eclipse.core.merge.visitors.TypeStringifier.java

License:Apache License

@SuppressWarnings("unchecked")
@Override//from  ww  w. jav a 2s. co  m
public boolean visit(IntersectionType node) {
    for (Iterator<Type> it = node.types().iterator(); it.hasNext();) {
        Type t = it.next();
        t.accept(this);
        if (it.hasNext()) {
            buffer.append(" & "); //$NON-NLS-1$
        }
    }
    return false;
}

From source file:org.whole.lang.java.util.JDTTransformerVisitor.java

License:Open Source License

@Override
public boolean visit(IntersectionType node) {
    org.whole.lang.java.model.IntersectionType intersectionType = lf.createIntersectionType(0);

    Iterator<?> iterator = node.types().iterator();
    while (iterator.hasNext()) {
        ((ASTNode) iterator.next()).accept(this);
        intersectionType.wAdd(type);//from  w w  w.  j a v  a  2 s.  c  om
    }
    type = intersectionType;

    return false;
}