Java 类org.eclipse.jdt.core.dom.WildcardType 实例源码

项目:2uml    文件:ResolverImpl.java   
protected boolean tryToResolve(Type type) {
    boolean result = false;

    if (underResolution.getResolverMap().containsKey(type)) {
        result = true;
    } else {
        if (type.isPrimitiveType()) {
            result = tryToResolve((PrimitiveType)type);
        } else if (type.isQualifiedType()) {
            result = tryToResolve((QualifiedType)type);
        } else if (type.isArrayType()) {
            result = tryToResolve(((ArrayType)type).getElementType());
        } else if (type.isSimpleType()) {
            result = tryToResolve((SimpleType)type);
        } else if (type.isParameterizedType()) {
            result = tryToResolve((ParameterizedType)type);
        } else if (type.isWildcardType()) {
            result = tryToResolve((WildcardType)type);
        } else {
            CoreActivator.log(IStatus.INFO, "Type not handled " + type.toString());
        }
    }
    return result;
}
项目:eclipse.jdt.ls    文件:FlowAnalyzer.java   
@Override
public void endVisit(WildcardType node) {
    if (skipNode(node)) {
        return;
    }
    assignFlowInfo(node, node.getBound());
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ASTFlattener.java   
@Override
public boolean visit(WildcardType node) {
    this.fBuffer.append("?");//$NON-NLS-1$
    Type bound= node.getBound();
    if (bound != null) {
        if (node.isUpperBound()) {
            this.fBuffer.append(" extends ");//$NON-NLS-1$
        } else {
            this.fBuffer.append(" super ");//$NON-NLS-1$
        }
        bound.accept(this);
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NaiveASTFlattener.java   
public boolean visit(WildcardType node) {
    this.buffer.append("?");//$NON-NLS-1$
    Type bound = node.getBound();
    if (bound != null) {
        if (node.isUpperBound()) {
            this.buffer.append(" extends ");//$NON-NLS-1$
        } else {
            this.buffer.append(" super ");//$NON-NLS-1$
        }
        bound.accept(this);
    }
    return false;
}
项目:srcrepo    文件:JDTDelegateBindingFactory.java   
public Binding getBindingForWildCardType(final WildcardType type) {
    Binding result = null;
    ITypeBinding binding = type.resolveBinding();
    if (binding == null) {
        if (this.logJDTBindingsIssues) {
            MoDiscoLogger.logWarning("*** WARNING : binding '" //$NON-NLS-1$
                    + type.toString() + "' unresolved.", JavaActivator //$NON-NLS-1$
                    .getDefault());
        }
        result = new UnresolvedBinding(type.toString());
    } else {
        result = new Binding(binding.getQualifiedName());
    }
    return result;
}
项目:j2d    文件:J2dVisitor.java   
@Override
public boolean visit(WildcardType node) {
    //System.out.println("Found: " + node.getClass() + " " + node);
    //println();
    ASTNode parent = node.getParent();
    while (parent instanceof ParameterizedType) {
        parent = parent.getParent();
    }
    //if (parent instanceof FieldDeclaration) {
        print("JavaObject");
        return false;
    //}
    /*String ident = genId();
    additionalTemplateParams.add(ident);

    print(ident);
    if (node.getBound() != null) {
        StringWriter sw = new StringWriter();
        pushWriter(sw);
        node.getBound().accept(this);
        popWriter();
        String append;
        if (node.isUpperBound()) {
            append =  "is(" + ident + " : " + sw + ")";
        } else {
            append = "is(" + sw + " : " + ident + ")";
        }
        if (constraints.length() > 0) {
            constraints += " && " + append;
        } else {
            constraints = append;
        }
    }
    return false;*/
}
项目:2uml    文件:ResolverResultImpl.java   
@Override
public Classifier getRootClassifier() {
    Classifier rootClassifier;
    if (rootType.isParameterizedType()) {
        // TODO enhance this
        rootClassifier = resolverMap.get(((ParameterizedType)rootType).getType());
    } else if (rootType.isArrayType()) {
        rootClassifier = resolverMap.get(((ArrayType)rootType).getElementType());
    } else if (rootType.isWildcardType()) {
        rootClassifier = resolverMap.get(((WildcardType)rootType).getBound());
    } else {
        rootClassifier = resolverMap.get(rootType);
    }
    return rootClassifier;
}
项目:2uml    文件:ResolverImpl.java   
protected boolean tryToResolve(WildcardType parameterizedType) {
    boolean result = true;
    if (parameterizedType.getBound() != null) {
        result = tryToResolve(parameterizedType.getBound());
    }
    return result;
}
项目:evosuite    文件:LoggingVisitor.java   
/** {@inheritDoc} */
@Override
public void endVisit(WildcardType node) {
    logger.warn("Method endVisitWildcardType for " + node + " for " + node + " not implemented!");
    super.endVisit(node);
}
项目:evosuite    文件:LoggingVisitor.java   
/** {@inheritDoc} */
@Override
public boolean visit(WildcardType node) {
    logger.warn("Method visitWildcardType for " + node + " not implemented!");
    return super.visit(node);
}
项目:Beagle    文件:NotRecursingAstVisitor.java   
@Override
public boolean visit(final WildcardType node) {
    return false;
}
项目:Beagle    文件:InstrumentableAstNodeLister.java   
@Override
public boolean visit(final WildcardType node) {
    // not instrumentable, contains no instrumentable nodes
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:FlowAnalyzer.java   
@Override
public void endVisit(WildcardType node) {
    if (skipNode(node))
        return;
    assignFlowInfo(node, node.getBound());
}
项目:Eclipse-Postfix-Code-Completion    文件:AstMatchingNodeFinder.java   
@Override
public boolean visit(WildcardType node) {
    if (node.subtreeMatch(fMatcher, fNodeToMatch))
        return matches(node);
    return super.visit(node);
}
项目:Eclipse-Postfix-Code-Completion    文件:GenericVisitor.java   
@Override
public void endVisit(WildcardType node) {
    endVisitNode(node);
}
项目:Eclipse-Postfix-Code-Completion    文件:GenericVisitor.java   
@Override
public boolean visit(WildcardType node) {
    return visitNode(node);
}
项目:Eclipse-Postfix-Code-Completion    文件:Util.java   
private static void getFullyQualifiedName(Type type, StringBuffer buffer) {
    switch (type.getNodeType()) {
        case ASTNode.ARRAY_TYPE:
            ArrayType arrayType = (ArrayType) type;
            getFullyQualifiedName(arrayType.getElementType(), buffer);
            for (int i = 0, length = arrayType.getDimensions(); i < length; i++) {
                buffer.append('[');
                buffer.append(']');
            }
            break;
        case ASTNode.PARAMETERIZED_TYPE:
            ParameterizedType parameterizedType = (ParameterizedType) type;
            getFullyQualifiedName(parameterizedType.getType(), buffer);
            buffer.append('<');
            Iterator iterator = parameterizedType.typeArguments().iterator();
            boolean isFirst = true;
            while (iterator.hasNext()) {
                if (!isFirst)
                    buffer.append(',');
                else
                    isFirst = false;
                Type typeArgument = (Type) iterator.next();
                getFullyQualifiedName(typeArgument, buffer);
            }
            buffer.append('>');
            break;
        case ASTNode.PRIMITIVE_TYPE:
            buffer.append(((PrimitiveType) type).getPrimitiveTypeCode().toString());
            break;
        case ASTNode.QUALIFIED_TYPE:
            buffer.append(((QualifiedType) type).getName().getFullyQualifiedName());
            break;
        case ASTNode.SIMPLE_TYPE:
            buffer.append(((SimpleType) type).getName().getFullyQualifiedName());
            break;
        case ASTNode.WILDCARD_TYPE:
            buffer.append('?');
            WildcardType wildcardType = (WildcardType) type;
            Type bound = wildcardType.getBound();
            if (bound == null) return;
            if (wildcardType.isUpperBound()) {
                buffer.append(" extends "); //$NON-NLS-1$
            } else {
                buffer.append(" super "); //$NON-NLS-1$
            }
            getFullyQualifiedName(bound, buffer);
            break;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaStatementPostfixContext.java   
private Type createType(String typeSig, AST ast) {
    int sigKind = Signature.getTypeSignatureKind(typeSig);
       switch (sigKind) {
           case Signature.BASE_TYPE_SIGNATURE:
               return ast.newPrimitiveType(PrimitiveType.toCode(Signature.toString(typeSig)));
           case Signature.ARRAY_TYPE_SIGNATURE:
               Type elementType = createType(Signature.getElementType(typeSig), ast);
               return ast.newArrayType(elementType, Signature.getArrayCount(typeSig));
           case Signature.CLASS_TYPE_SIGNATURE:
               String erasureSig = Signature.getTypeErasure(typeSig);

               String erasureName = Signature.toString(erasureSig);
               if (erasureSig.charAt(0) == Signature.C_RESOLVED) {
                   erasureName = addImport(erasureName);
               }

               Type baseType= ast.newSimpleType(ast.newName(erasureName));
               String[] typeArguments = Signature.getTypeArguments(typeSig);
               if (typeArguments.length > 0) {
                   ParameterizedType type = ast.newParameterizedType(baseType);
                   List argNodes = type.typeArguments();
                   for (int i = 0; i < typeArguments.length; i++) {
                       String curr = typeArguments[i];
                       if (containsNestedCapture(curr)) {
                           argNodes.add(ast.newWildcardType());
                       } else {
                           argNodes.add(createType(curr, ast));
                       }
                   }
                   return type;
               }
               return baseType;
           case Signature.TYPE_VARIABLE_SIGNATURE:
               return ast.newSimpleType(ast.newSimpleName(Signature.toString(typeSig)));
           case Signature.WILDCARD_TYPE_SIGNATURE:
               WildcardType wildcardType= ast.newWildcardType();
               char ch = typeSig.charAt(0);
               if (ch != Signature.C_STAR) {
                   Type bound= createType(typeSig.substring(1), ast);
                   wildcardType.setBound(bound, ch == Signature.C_EXTENDS);
               }
               return wildcardType;
           case Signature.CAPTURE_TYPE_SIGNATURE:
               return createType(typeSig.substring(1), ast);
       }

       return ast.newSimpleType(ast.newName("java.lang.Object"));
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:FlowAnalyzer.java   
@Override
public void endVisit(WildcardType node) {
    if (skipNode(node))
        return;
    assignFlowInfo(node, node.getBound());
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AstMatchingNodeFinder.java   
@Override
public boolean visit(WildcardType node) {
    if (node.subtreeMatch(fMatcher, fNodeToMatch))
        return matches(node);
    return super.visit(node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:HierarchicalASTVisitor.java   
@Override
public boolean visit(WildcardType node) {
    return visit((Type)node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:HierarchicalASTVisitor.java   
@Override
public void endVisit(WildcardType node) {
    endVisit((Type)node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:GenericVisitor.java   
@Override
public boolean visit(WildcardType node) {
    return visitNode(node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:GenericVisitor.java   
@Override
public void endVisit(WildcardType node) {
    endVisitNode(node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:Util.java   
private static void getFullyQualifiedName(Type type, StringBuffer buffer) {
    switch (type.getNodeType()) {
        case ASTNode.ARRAY_TYPE:
            ArrayType arrayType = (ArrayType) type;
            getFullyQualifiedName(arrayType.getElementType(), buffer);
            for (int i = 0, length = arrayType.getDimensions(); i < length; i++) {
                buffer.append('[');
                buffer.append(']');
            }
            break;
        case ASTNode.PARAMETERIZED_TYPE:
            ParameterizedType parameterizedType = (ParameterizedType) type;
            getFullyQualifiedName(parameterizedType.getType(), buffer);
            buffer.append('<');
            Iterator iterator = parameterizedType.typeArguments().iterator();
            boolean isFirst = true;
            while (iterator.hasNext()) {
                if (!isFirst)
                    buffer.append(',');
                else
                    isFirst = false;
                Type typeArgument = (Type) iterator.next();
                getFullyQualifiedName(typeArgument, buffer);
            }
            buffer.append('>');
            break;
        case ASTNode.PRIMITIVE_TYPE:
            buffer.append(((PrimitiveType) type).getPrimitiveTypeCode().toString());
            break;
        case ASTNode.QUALIFIED_TYPE:
            buffer.append(((QualifiedType) type).getName().getFullyQualifiedName());
            break;
        case ASTNode.SIMPLE_TYPE:
            buffer.append(((SimpleType) type).getName().getFullyQualifiedName());
            break;
        case ASTNode.WILDCARD_TYPE:
            buffer.append('?');
            WildcardType wildcardType = (WildcardType) type;
            Type bound = wildcardType.getBound();
            if (bound == null) return;
            if (wildcardType.isUpperBound()) {
                buffer.append(" extends "); //$NON-NLS-1$
            } else {
                buffer.append(" super "); //$NON-NLS-1$
            }
            getFullyQualifiedName(bound, buffer);
            break;
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaStatementPostfixContext.java   
private Type createType(String typeSig, AST ast) {
    int sigKind = Signature.getTypeSignatureKind(typeSig);
       switch (sigKind) {
           case Signature.BASE_TYPE_SIGNATURE:
               return ast.newPrimitiveType(PrimitiveType.toCode(Signature.toString(typeSig)));
           case Signature.ARRAY_TYPE_SIGNATURE:
               Type elementType = createType(Signature.getElementType(typeSig), ast);
               return ast.newArrayType(elementType, Signature.getArrayCount(typeSig));
           case Signature.CLASS_TYPE_SIGNATURE:
               String erasureSig = Signature.getTypeErasure(typeSig);

               String erasureName = Signature.toString(erasureSig);
               if (erasureSig.charAt(0) == Signature.C_RESOLVED) {
                   erasureName = addImport(erasureName);
               }

               Type baseType= ast.newSimpleType(ast.newName(erasureName));
               String[] typeArguments = Signature.getTypeArguments(typeSig);
               if (typeArguments.length > 0) {
                   ParameterizedType type = ast.newParameterizedType(baseType);
                   List argNodes = type.typeArguments();
                   for (int i = 0; i < typeArguments.length; i++) {
                       String curr = typeArguments[i];
                       if (containsNestedCapture(curr)) {
                           argNodes.add(ast.newWildcardType());
                       } else {
                           argNodes.add(createType(curr, ast));
                       }
                   }
                   return type;
               }
               return baseType;
           case Signature.TYPE_VARIABLE_SIGNATURE:
               return ast.newSimpleType(ast.newSimpleName(Signature.toString(typeSig)));
           case Signature.WILDCARD_TYPE_SIGNATURE:
               WildcardType wildcardType= ast.newWildcardType();
               char ch = typeSig.charAt(0);
               if (ch != Signature.C_STAR) {
                   Type bound= createType(typeSig.substring(1), ast);
                   wildcardType.setBound(bound, ch == Signature.C_EXTENDS);
               }
               return wildcardType;
           case Signature.CAPTURE_TYPE_SIGNATURE:
               return createType(typeSig.substring(1), ast);
       }

       return ast.newSimpleType(ast.newName("java.lang.Object"));
}
项目:eclipse-i18ntools    文件:ASTNodeFinder.java   
@Override
public boolean visit(final WildcardType node) {
    return this.internalVisit(node);
}
项目:eclipse-optimus    文件:JavaCodeHelper.java   
/**
 * Return true if {@code firstType} as Type object is equals to {@code
 * secondType} as fully qualified String
 * 
 * @param type1
 *            first type as Type object
 * @param type2
 *            second type as fully qualified String
 * @return true if {@code firstType} is equals to {@code secondType}
 */
public static boolean areTypesEquals(Type type1, String type2) {

    // Check if type1 and type2 are not null before method
    // execution
    if (type1 == null || type2 == null) {
        return false;
    }

    type2 = type2.trim();

    /* Remove the generic information from type 2 is this one exists */
    type2 = (type2.indexOf('<') != -1) ? type2.substring(0, type2.indexOf('<')) : type2;

    if (type1 instanceof SimpleType) {
        // Case when type1 is a simple type (MyObject)
        String type1Name = ((SimpleType) type1).getName().getFullyQualifiedName();
        String simpleType1Name = (type1Name.lastIndexOf('.') != -1) ? type1Name
                .substring(type1Name.lastIndexOf('.') + 1) : type1Name;
        String simpleType2Name = (type2.lastIndexOf('.') != -1) ? type2.substring(type2
                .lastIndexOf('.') + 1) : type2;

        return simpleType1Name.equals(simpleType2Name);
    } else if (type1 instanceof QualifiedType) {
        // Case when type1 is a qualified type (net.atos.xa.MyObject)
        return (((QualifiedType) type1).getName().getFullyQualifiedName().equals(type2));
    } else if (type1 instanceof PrimitiveType) {
        // Case when type1 is a primitive type (int, boolean, void, ...)
        return ((PrimitiveType) type1).getPrimitiveTypeCode().toString().equals(type2);
    } else if (type1 instanceof ArrayType) {
        ArrayType arrayType = (ArrayType) type1;
        // Case when type1 is an array (int[], MyObject[],...)
        return type2.endsWith("[]")
                && areTypesEquals(ASTArrayTypeHelper.getComponentType(arrayType), type2.substring(0,
                        type2.lastIndexOf('[')));
    } else if (type1 instanceof ParameterizedType) {
        // Case when type1 is a parametrized type (MyObject<Integer>,
        // Map<List,String>,...)

        // Check the main type
        return areTypesEquals(((ParameterizedType) type1).getType(), type2);
    } else if (type1 instanceof WildcardType) {
        // Case when type1 is a wildcard type (? , ? extends MyObject,
        // ...)
        if (((WildcardType) type1).getBound() == null) {
            return type2.equals("?");
        } else {
            StringTokenizer st = new StringTokenizer(type2, " ");

            if (!st.nextToken().trim().equals("?")) {
                return false;
            }

            if (((WildcardType) type1).isUpperBound()) {
                return st.nextToken().trim().equalsIgnoreCase("extends")
                        && areTypesEquals(((WildcardType) type1).getBound(), st.nextToken());
            } else {
                return st.nextToken().trim().equalsIgnoreCase("super")
                        && areTypesEquals(((WildcardType) type1).getBound(), st.nextToken());
            }
        }
    }

    return false;
}
项目:srcrepo    文件:IBindingFactory.java   
/**
 * Returns the MoDisco {@link Binding} corresponding to the JDT WildcardType
 * {@code type}.
 * 
 * @param type
 *            the JDT WildcardType object.
 * @return the MoDisco {@code Binding}.
 */
Binding getBindingForWildCardType(WildcardType type);