org.eclipse.jdt.core.dom.QualifiedType Java Examples
The following examples show how to use
org.eclipse.jdt.core.dom.QualifiedType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RefactoringUtility.java From JDeodorant with MIT License | 6 votes |
private static boolean isQualifiedType(Type type) { if(type instanceof SimpleType) { SimpleType simpleType = (SimpleType)type; Name name = simpleType.getName(); if(name instanceof QualifiedName) { return true; } } else if(type instanceof QualifiedType) { QualifiedType qualifiedType = (QualifiedType)type; Type qualifier = qualifiedType.getQualifier(); return isQualifiedType(qualifier); } else if(type instanceof ArrayType) { ArrayType arrayType = (ArrayType)type; Type elementType = arrayType.getElementType(); return isQualifiedType(elementType); } else if(type instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType)type; Type erasureType = parameterizedType.getType(); return isQualifiedType(erasureType); } return false; }
Example #2
Source File: ASTNodes.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * 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; }
Example #3
Source File: ReferencedClassesParser.java From BUILD_file_generator with Apache License 2.0 | 5 votes |
/** * @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; }
Example #4
Source File: StyledStringVisitor.java From JDeodorant with MIT License | 5 votes |
private void handleType(Type type) { if (type instanceof PrimitiveType) { visit((PrimitiveType) type); } else if (type instanceof ArrayType) { visit((ArrayType) type); } else if (type instanceof SimpleType) { visit((SimpleType) type); } else if (type instanceof QualifiedType) { visit((QualifiedType) type); } else if (type instanceof ParameterizedType) { visit((ParameterizedType) type); } else if (type instanceof WildcardType) { visit((WildcardType) type); } }
Example #5
Source File: StyledStringVisitor.java From JDeodorant with MIT License | 5 votes |
public boolean visit(QualifiedType type) { /* * QualifiedType: Type . SimpleName */ activateDiffStyle(type); handleType(type.getQualifier()); appendPeriod(); handleExpression(type.getName()); deactivateDiffStyle(type); return false; }
Example #6
Source File: BindingSignatureVisitor.java From JDeodorant with MIT License | 5 votes |
private void handleType(Type type) { if (type instanceof PrimitiveType) { visit((PrimitiveType) type); } else if (type instanceof ArrayType) { visit((ArrayType) type); } else if (type instanceof SimpleType) { visit((SimpleType) type); } else if (type instanceof QualifiedType) { visit((QualifiedType) type); } else if (type instanceof ParameterizedType) { visit((ParameterizedType) type); } else if (type instanceof WildcardType) { visit((WildcardType) type); } }
Example #7
Source File: Visitor.java From RefactoringMiner with MIT License | 5 votes |
public boolean visit(QualifiedType node) { types.add(node.toString()); if(current.getUserObject() != null) { AnonymousClassDeclarationObject anonymous = (AnonymousClassDeclarationObject)current.getUserObject(); anonymous.getTypes().add(node.toString()); } return false; }
Example #8
Source File: JavaASTFlattener.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public boolean visit(final QualifiedType node) { node.getQualifier().accept(this); this.appendToBuffer("."); node.getName().accept(this); return false; }
Example #9
Source File: ASTUtil.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
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 ""; } }
Example #10
Source File: FlowAnalyzer.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public void endVisit(QualifiedType node) { if (skipNode(node)) { return; } processSequential(node, node.getQualifier(), node.getName()); }
Example #11
Source File: JsonDeserializeAdder.java From SparkBuilderGenerator with MIT License | 5 votes |
private TypeLiteral createBuilderClassReferenceLiteral(AST ast, CompilationUnitModificationDomain compilationUnitModificationDomain, TypeDeclaration builderType) { String originalClassName = compilationUnitModificationDomain.getOriginalType().getName().toString(); String builderClassName = builderType.getName().toString(); QualifiedType qualifiedType = ast.newQualifiedType(ast.newSimpleType(ast.newSimpleName(originalClassName)), ast.newSimpleName(builderClassName)); TypeLiteral typeLiteral = ast.newTypeLiteral(); typeLiteral.setType(qualifiedType); return typeLiteral; }
Example #12
Source File: ReferencedClassesParserTest.java From BUILD_file_generator with Apache License 2.0 | 5 votes |
@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"); }
Example #13
Source File: ReferencedClassesParser.java From BUILD_file_generator with Apache License 2.0 | 5 votes |
@Override public boolean visit(QualifiedType node) { addType( node.resolveBinding(), extractClassNameFromQualifiedName(extractTypeNameWithoutGenerics(node)), node.getStartPosition()); return true; }
Example #14
Source File: ASTUtil.java From spotbugs with GNU Lesser General Public License v2.1 | 4 votes |
private static String getPrettyTypeName(QualifiedType type) { return type.resolveBinding().getQualifiedName(); }
Example #15
Source File: MoveInnerToTopRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(final QualifiedType node) { Assert.isNotNull(node); return false; }
Example #16
Source File: FlowAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public void endVisit(QualifiedType node) { if (skipNode(node)) return; processSequential(node, node.getQualifier(), node.getName()); }
Example #17
Source File: AstMatchingNodeFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(QualifiedType node) { if (node.subtreeMatch(fMatcher, fNodeToMatch)) return matches(node); return super.visit(node); }
Example #18
Source File: GenericVisitor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public void endVisit(QualifiedType node) { endVisitNode(node); }
Example #19
Source File: GenericVisitor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(QualifiedType node) { return visitNode(node); }
Example #20
Source File: ImportReferencesCollector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(QualifiedType node) { doVisitNode(node.getQualifier()); visitAnnotations(node); return false; }
Example #21
Source File: Util.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
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; } }
Example #22
Source File: BindingSignatureVisitor.java From JDeodorant with MIT License | 4 votes |
public boolean visit(QualifiedType type) { handleType(type.getQualifier()); handleExpression(type.getName()); return false; }