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

项目:eclipse.jdt.ls    文件:ASTNodes.java   
/**
 * For {@link Name} or {@link Type} nodes, returns the topmost {@link Type} node
 * that shares the same type binding as the given node.
 *
 * @param node an ASTNode
 * @return the normalized {@link Type} node or the original node
 */
public static ASTNode getNormalizedNode(ASTNode node) {
    ASTNode current= node;
    // normalize name
    if (QualifiedName.NAME_PROPERTY.equals(current.getLocationInParent())) {
        current= current.getParent();
    }
    // normalize type
    if (QualifiedType.NAME_PROPERTY.equals(current.getLocationInParent())
            || SimpleType.NAME_PROPERTY.equals(current.getLocationInParent())
            || NameQualifiedType.NAME_PROPERTY.equals(current.getLocationInParent())) {
        current= current.getParent();
    }
    // normalize parameterized types
    if (ParameterizedType.TYPE_PROPERTY.equals(current.getLocationInParent())) {
        current= current.getParent();
    }
    return current;
}
项目:che    文件:ASTNodes.java   
/**
 * For {@link Name} or {@link org.eclipse.jdt.core.dom.Type} nodes, returns the topmost {@link
 * org.eclipse.jdt.core.dom.Type} node that shares the same type binding as the given node.
 *
 * @param node an ASTNode
 * @return the normalized {@link org.eclipse.jdt.core.dom.Type} node or the original node
 */
public static ASTNode getNormalizedNode(ASTNode node) {
  ASTNode current = node;
  // normalize name
  if (QualifiedName.NAME_PROPERTY.equals(current.getLocationInParent())) {
    current = current.getParent();
  }
  // normalize type
  if (QualifiedType.NAME_PROPERTY.equals(current.getLocationInParent())
      || SimpleType.NAME_PROPERTY.equals(current.getLocationInParent())
      || NameQualifiedType.NAME_PROPERTY.equals(current.getLocationInParent())) {
    current = current.getParent();
  }
  // normalize parameterized types
  if (ParameterizedType.TYPE_PROPERTY.equals(current.getLocationInParent())) {
    current = current.getParent();
  }
  return current;
}
项目:Eclipse-Postfix-Code-Completion    文件:ASTNodes.java   
/**
 * For {@link Name} or {@link Type} nodes, returns the topmost {@link Type} node
 * that shares the same type binding as the given node.
 * 
 * @param node an ASTNode
 * @return the normalized {@link Type} node or the original node
 */
public static ASTNode getNormalizedNode(ASTNode node) {
    ASTNode current= node;
    // normalize name
    if (QualifiedName.NAME_PROPERTY.equals(current.getLocationInParent())) {
        current= current.getParent();
    }
    // normalize type
    if (QualifiedType.NAME_PROPERTY.equals(current.getLocationInParent())
            || SimpleType.NAME_PROPERTY.equals(current.getLocationInParent())
            || NameQualifiedType.NAME_PROPERTY.equals(current.getLocationInParent())) {
        current= current.getParent();
    }
    // normalize parameterized types
    if (ParameterizedType.TYPE_PROPERTY.equals(current.getLocationInParent())) {
        current= current.getParent();
    }
    return current;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ASTNodes.java   
public static ASTNode getNormalizedNode(ASTNode node) {
    ASTNode current= node;
    // normalize name
    if (QualifiedName.NAME_PROPERTY.equals(current.getLocationInParent())) {
        current= current.getParent();
    }
    // normalize type
    if (QualifiedType.NAME_PROPERTY.equals(current.getLocationInParent()) ||
        SimpleType.NAME_PROPERTY.equals(current.getLocationInParent())) {
        current= current.getParent();
    }
    // normalize parameterized types
    if (ParameterizedType.TYPE_PROPERTY.equals(current.getLocationInParent())) {
        current= current.getParent();
    }
    return current;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ASTNodes.java   
public static SimpleType getLeftMostSimpleType(QualifiedType type) {
    final SimpleType[] result= new SimpleType[1];
    ASTVisitor visitor= new ASTVisitor() {
        @Override
        public boolean visit(QualifiedType qualifiedType) {
            Type left= qualifiedType.getQualifier();
            if (left instanceof SimpleType)
                result[0]= (SimpleType)left;
            else
                left.accept(this);
            return false;
        }
    };
    type.accept(visitor);
    return result[0];
}
项目:eclipse-tapestry5-plugin    文件:EclipseUtils.java   
public static String toClassName(IProject project, Type type)
{
    Name name = null;

    if (type instanceof SimpleType)
    {
        name = ((SimpleType) type).getName();
    }
    else if (type instanceof QualifiedType)
    {
        name = ((QualifiedType) type).getName();
    }
    else if (type instanceof ParameterizedType)
    {
        return toClassName(project, ((ParameterizedType) type).getType());
    }
    else
    {
        //  Unsupported type, i.e., primitive types are not supported at the moment
        return null;
    }

    return name.isQualifiedName()
             ? name.getFullyQualifiedName()
             : tryResolveFQNameFromImports(project, type.getRoot(), name.getFullyQualifiedName());
}
项目: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;
}
项目:2uml    文件:ResolverImpl.java   
protected boolean tryToResolve(QualifiedType qualifiedType) {
    boolean result = false;

    if (underResolution.getResolverMap().containsKey(qualifiedType)) {
        result = true;
    } else {
        String qualifiedName = qualifiedType.getName().getFullyQualifiedName();
        Classifier classifier = searchClassifierInModels(qualifiedName);
        if (classifier != null) {
            underResolution.getResolverMap().put(qualifiedType, classifier);
            result = true;
        }
    }
    // No sub types to resolve
    return result;
}
项目:eclipse-optimus    文件:JavaCodeHelper.java   
/**
 * Return a name instance from a Type instance
 */
public static Name getName(Type t) {
    if (t.isArrayType()) {
        ArrayType arrayType = (ArrayType) t;
        return getName(ASTArrayTypeHelper.getComponentType(arrayType));
    } else if (t.isParameterizedType()) {
        return getName(((ParameterizedType) t).getType());
    } else if (t.isPrimitiveType()) {
        return null;
    } else if (t.isQualifiedType()) {
        return ((QualifiedType) t).getName();
    } else if (t.isSimpleType()) {
        return ((SimpleType) t).getName();
    }

    return null;
}
项目:BUILD_file_generator    文件:ReferencedClassesParser.java   
@Override
public boolean visit(QualifiedType node) {
  addType(
      node.resolveBinding(),
      extractClassNameFromQualifiedName(extractTypeNameWithoutGenerics(node)),
      node.getStartPosition());
  return true;
}
项目:BUILD_file_generator    文件:ReferencedClassesParser.java   
/**
 * @return a String representation of 'type'. Handles qualified, simple and parameterized types.
 */
@Nullable
private String getNameOfType(Type type) {
  if (type instanceof QualifiedType) {
    return extractTypeNameWithoutGenerics((QualifiedType) type);
  }
  if (type instanceof SimpleType) {
    return ((SimpleType) type).getName().getFullyQualifiedName();
  }
  if (type instanceof ParameterizedType) {
    return getNameOfType(((ParameterizedType) type).getType());
  }
  return null;
}
项目:BUILD_file_generator    文件:ReferencedClassesParserTest.java   
@Test
public void testExtractTypeNameWithoutGenerics() {
  AST ast = AST.newAST(AST.JLS4);
  org.eclipse.jdt.core.dom.SimpleName entry = ast.newSimpleName("Entry");
  ParameterizedType map = ast.newParameterizedType(ast.newSimpleType(ast.newSimpleName("Map")));
  map.typeArguments().add(ast.newSimpleType(ast.newSimpleName("Foo")));
  QualifiedType type = ast.newQualifiedType(map, entry);
  assertThat(type.toString()).isEqualTo("Map<Foo>.Entry");
  assertThat(ReferencedClassesParser.extractTypeNameWithoutGenerics(type)).isEqualTo("Map.Entry");
}
项目:eclipse.jdt.ls    文件:FlowAnalyzer.java   
@Override
public void endVisit(QualifiedType node) {
    if (skipNode(node)) {
        return;
    }
    processSequential(node, node.getQualifier(), node.getName());
}
项目:Eclipse-Postfix-Code-Completion    文件:PotentialProgrammingProblemsFix.java   
private static SimpleName getSelectedName(CompilationUnit compilationUnit, IProblemLocation problem) {
    final ASTNode selection= problem.getCoveredNode(compilationUnit);
    if (selection == null)
        return null;

    Name name= null;
    if (selection instanceof SimpleType) {
        name= ((SimpleType) selection).getName();
    } else if (selection instanceof NameQualifiedType) {
        name= ((NameQualifiedType) selection).getName();
    } else if (selection instanceof QualifiedType) {
        name= ((QualifiedType) selection).getName();
    } else if (selection instanceof ParameterizedType) {
        final ParameterizedType type= (ParameterizedType) selection;
        final Type raw= type.getType();
        if (raw instanceof SimpleType)
            name= ((SimpleType) raw).getName();
        else if (raw instanceof NameQualifiedType)
            name= ((NameQualifiedType) raw).getName();
        else if (raw instanceof QualifiedType)
            name= ((QualifiedType) raw).getName();
    } else if (selection instanceof Name) {
        name= (Name) selection;
    }
    if (name == null)
        return null;

    if (name.isSimpleName()) {
        return (SimpleName)name;
    } else {
        return ((QualifiedName)name).getName();
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ASTFlattener.java   
@Override
public boolean visit(QualifiedType node) {
    node.getQualifier().accept(this);
    this.fBuffer.append(".");//$NON-NLS-1$
    node.getName().accept(this);
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavadocHover.java   
private static IBinding resolveBinding(ASTNode node) {
    if (node instanceof SimpleName) {
        // workaround for https://bugs.eclipse.org/62605 (constructor name resolves to type, not method)
        SimpleName simpleName= (SimpleName) node;
        StructuralPropertyDescriptor loc= simpleName.getLocationInParent();
        while (loc == QualifiedType.NAME_PROPERTY || loc == QualifiedName.NAME_PROPERTY|| loc == SimpleType.NAME_PROPERTY || loc == ParameterizedType.TYPE_PROPERTY) {
            node= node.getParent();
            loc= node.getLocationInParent();
        }
        if (loc == ClassInstanceCreation.TYPE_PROPERTY) {
            ClassInstanceCreation cic= (ClassInstanceCreation) node.getParent();
            IMethodBinding constructorBinding= cic.resolveConstructorBinding();
            if (constructorBinding == null)
                return null;
            ITypeBinding declaringClass= constructorBinding.getDeclaringClass();
            if (!declaringClass.isAnonymous())
                return constructorBinding;
            ITypeBinding superTypeDeclaration= declaringClass.getSuperclass().getTypeDeclaration();
            return resolveSuperclassConstructor(superTypeDeclaration, constructorBinding);
        }
        return simpleName.resolveBinding();

    } else if (node instanceof SuperConstructorInvocation) {
        return ((SuperConstructorInvocation) node).resolveConstructorBinding();
    } else if (node instanceof ConstructorInvocation) {
        return ((ConstructorInvocation) node).resolveConstructorBinding();
    } else {
        return null;
    }
}
项目:FindBug-for-Domino-Designer    文件:ASTUtil.java   
private static String getPrettyTypeName(Type type) {
    if (type.isArrayType()) {
        return getPrettyTypeName((ArrayType) type);
    } else if (type.isParameterizedType()) {
        return getPrettyTypeName((ParameterizedType) type);
    } else if (type.isPrimitiveType()) {
        return getPrettyTypeName((PrimitiveType) type);
    } else if (type.isQualifiedType()) {
        return getPrettyTypeName((QualifiedType) type);
    } else if (type.isSimpleType()) {
        return getPrettyTypeName((SimpleType) type);
    } else {
        return "";
    }
}
项目:j2d    文件:J2dVisitor.java   
@Override
public boolean visit(QualifiedType node) {
    node.getQualifier().accept(this);
    print(".");
    node.getName().accept(this);
    return false;
}
项目:eclipse.jdt.ls    文件:ImportReferencesCollector.java   
@Override
public boolean visit(QualifiedType node) {
    doVisitNode(node.getQualifier());
    visitAnnotations(node);
    return false;
}
项目:che    文件:ImportReferencesCollector.java   
@Override
public boolean visit(QualifiedType node) {
  doVisitNode(node.getQualifier());
  visitAnnotations(node);
  return false;
}
项目:evosuite    文件:LoggingVisitor.java   
/** {@inheritDoc} */
@Override
public void endVisit(QualifiedType node) {
    logger.warn("Method endVisitQualifiedType for " + node + " for " + node + " not implemented!");
    super.endVisit(node);
}
项目:evosuite    文件:LoggingVisitor.java   
/** {@inheritDoc} */
@Override
public boolean visit(QualifiedType node) {
    logger.warn("Method visitQualifiedType for " + node + " not implemented!");
    return super.visit(node);
}
项目:Beagle    文件:NotRecursingAstVisitor.java   
@Override
public boolean visit(final QualifiedType node) {
    return false;
}
项目:Beagle    文件:InstrumentableAstNodeLister.java   
@Override
public boolean visit(final QualifiedType node) {
    // not instrumentable, contains no instrumentable nodes
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:MoveInnerToTopRefactoring.java   
@Override
public boolean visit(final QualifiedType node) {
    Assert.isNotNull(node);
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:FlowAnalyzer.java   
@Override
public void endVisit(QualifiedType node) {
    if (skipNode(node))
        return;
    processSequential(node, node.getQualifier(), node.getName());
}
项目:Eclipse-Postfix-Code-Completion    文件:AstMatchingNodeFinder.java   
@Override
public boolean visit(QualifiedType node) {
    if (node.subtreeMatch(fMatcher, fNodeToMatch))
        return matches(node);
    return super.visit(node);
}
项目:Eclipse-Postfix-Code-Completion    文件:GenericVisitor.java   
@Override
public void endVisit(QualifiedType node) {
    endVisitNode(node);
}
项目:Eclipse-Postfix-Code-Completion    文件:GenericVisitor.java   
@Override
public boolean visit(QualifiedType node) {
    return visitNode(node);
}
项目:Eclipse-Postfix-Code-Completion    文件:ImportReferencesCollector.java   
@Override
public boolean visit(QualifiedType node) {
    doVisitNode(node.getQualifier());
    visitAnnotations(node);
    return false;
}
项目: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-Juno38    文件:MoveInnerToTopRefactoring.java   
@Override
public boolean visit(final QualifiedType node) {
    Assert.isNotNull(node);
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:FlowAnalyzer.java   
@Override
public void endVisit(QualifiedType node) {
    if (skipNode(node))
        return;
    processSequential(node, node.getQualifier(), node.getName());
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AstMatchingNodeFinder.java   
@Override
public boolean visit(QualifiedType node) {
    if (node.subtreeMatch(fMatcher, fNodeToMatch))
        return matches(node);
    return super.visit(node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:HierarchicalASTVisitor.java   
@Override
public boolean visit(QualifiedType node) {
    return visit((Type)node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:HierarchicalASTVisitor.java   
@Override
public void endVisit(QualifiedType node) {
    endVisit((Type)node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:GenericVisitor.java   
@Override
public boolean visit(QualifiedType node) {
    return visitNode(node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:GenericVisitor.java   
@Override
public void endVisit(QualifiedType node) {
    endVisitNode(node);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ImportReferencesCollector.java   
@Override
public boolean visit(QualifiedType node) {
    // nothing to do here, let the qualifier be visited
    return true;
}
项目: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;
    }
}