Refine search
for (Object modifier : declaration.modifiers()) { if (modifier instanceof org.eclipse.jdt.core.dom.Annotation) { org.eclipse.jdt.core.dom.Annotation annotation = (org.eclipse.jdt.core.dom.Annotation)modifier; String qualifiedAnnotationName = annotation.resolveTypeBinding().getQualifiedName(); if (!"java.lang.Override".equals(qualifiedAnnotationName) && !"java.lang.SuppressWarnings".equals(qualifiedAnnotationName)) annotations.add(annotation); .append(declaration.getReturnType2().toString()) .append(" ").append(declaration.getName().getFullyQualifiedName()) .append("(");
private void performSearch() { fResult= new ArrayList<>(); markReferences(); if (!fResult.isEmpty()) { Type returnType= fMethodDeclaration.getReturnType2(); if (returnType != null) { String desc= Messages.format(SearchMessages.MethodExitsFinder_occurrence_return_description, BasicElementLabels.getJavaElementName(fMethodDeclaration.getName().toString())); fResult.add(new OccurrenceLocation(returnType.getStartPosition(), returnType.getLength(), 0, desc)); } } }
private Type copyType(final Type type) { switch (type.getNodeType()) { case ARRAY_TYPE: final ArrayType arrayType = (ArrayType) type; return ast.newArrayType( copyType(arrayType.getElementType()), arrayType.getDimensions()); case PRIMITIVE_TYPE: final Code code = ((PrimitiveType) type).getPrimitiveTypeCode(); return ast.newPrimitiveType(code); case QUALIFIED_TYPE: return type(type.resolveBinding().getQualifiedName()); case SIMPLE_TYPE: final SimpleType sType = (SimpleType) type; return ast.newSimpleType(copy(sType.getName())); } throw new NotImplementedException(null, "Unknown type for type " + type); }
/** * Process return type of a {@link MethodDeclaration}. * * @param methodDeclaration - the method declaration. * @param methodMetadata - the method meta data. */ protected void processReturnTypeOfMethodDeclaration( MethodDeclaration methodDeclaration, MethodMetadata methodMetadata ) { Type type = methodDeclaration.getReturnType2(); if (type.isPrimitiveType()) { methodMetadata.setReturnType(FieldMetadata.primitiveType(((PrimitiveType)type).getPrimitiveTypeCode().toString())); } if (type.isSimpleType()) { methodMetadata.setReturnType(FieldMetadata.simpleType(JavaMetadataUtil.getName(((SimpleType)type).getName()))); } }
public EssentialsGeneratedMethod(final MethodDeclaration methodDeclaration, final String methodName, final String internalName) { this.methodDeclaration = methodDeclaration; this.methodName = methodName; this.internalName = internalName; final Type type = methodDeclaration.getReturnType2(); this.returnType = type; if (type != null) { if (type.isParameterizedType()) { final ParameterizedType parameterizedType = (ParameterizedType) type; final Type myType = parameterizedType.getType(); if (myType != null && myType.isSimpleType() && ((SimpleType) myType).getName().getFullyQualifiedName().equals("List")) { this.multiType = true; } } else if (type.isArrayType()) { this.multiType = true; } } }
/** * All types should be ensured first via this method. We first check to see if * the binding is resolvable (not null) If it is not null we ensure the type * from the binding (the happy case) If the type is null we recover what we know * (for example, the name of a simple type) In the worst case we return the * {@link #unknownType()} */ private Type ensureTypeFromDomType(org.eclipse.jdt.core.dom.Type domType) { ITypeBinding binding = domType.resolveBinding(); if (binding != null) return ensureTypeFromTypeBinding(binding); if (domType.isSimpleType()) return ensureTypeNamedInUnknownNamespace(((SimpleType) domType).getName().toString()); if (domType.isParameterizedType()) return ensureTypeNamedInUnknownNamespace( ((org.eclipse.jdt.core.dom.ParameterizedType) domType).getType().toString()); return unknownType(); }
static boolean hasReference(MethodDeclaration node) { try { SuperThisReferenceFinder finder= new SuperThisReferenceFinder(); ClassInstanceCreation cic= (ClassInstanceCreation) node.getParent().getParent(); finder.fFunctionalInterface= cic.getType().resolveBinding(); finder.fMethodDeclaration= node; node.accept(finder); } catch (AbortSearchException e) { return true; } return false; }
private int getDimensions(ArrayType parent) { if (parent.getAST().apiLevel() >= JLS8_INTERNAL) { return ((List) getOriginalValue(parent, ArrayType.DIMENSIONS_PROPERTY)).size(); } Type t = (Type) getOriginalValue(parent, INTERNAL_ARRAY_COMPONENT_TYPE_PROPERTY); int dimensions = 1; // always include this array type while (t.isArrayType()) { dimensions++; t = (Type) getOriginalValue(t, INTERNAL_ARRAY_COMPONENT_TYPE_PROPERTY); } return dimensions; }
@Override public boolean isPrimitive() { if (type.isArrayType()) { return ((ArrayType) type).getElementType().isPrimitiveType(); } return type.isPrimitiveType(); }
public static String getTypeName(Type type, int extraDimensions) { ITypeBinding binding = type.resolveBinding(); if (binding != null) { return binding.getQualifiedName(); } String typeToString = type.toString(); for(int i=0; i<extraDimensions; i++) { typeToString += "[]"; } return typeToString; }
private boolean isSupportedConstantType(Type type) { return type.isPrimitiveType() || type.resolveBinding().getQualifiedName().equals(String.class.getCanonicalName()); }
@Override public String toString() { return type.toString(); }
@Override public boolean visit(final VariableDeclarationStatement node) { final ASTNode parent = node.getParent(); for (final Object fragment : node.fragments()) { final VariableDeclarationFragment frag = (VariableDeclarationFragment) fragment; variableScopes.put(parent, new Variable(frag.getName() .getIdentifier(), node.getType().toString(), ScopeType.SCOPE_LOCAL)); } return false; }
@Override public boolean visit(CastExpression node) { if ("java.lang.ClassCastException".equals(fException.getQualifiedName())) { //$NON-NLS-1$ Type type= node.getType(); fResult.add(new OccurrenceLocation(type.getStartPosition(), type.getLength(), 0, fDescription)); } return super.visit(node); }
private static void addExceptionToThrows(AST ast, MethodDeclaration methodDeclaration, ASTRewrite rewrite, Type type2) { ITypeBinding binding = type2.resolveBinding(); if (binding == null || isNotYetThrown(binding, methodDeclaration.thrownExceptionTypes())) { Type newType = (Type) ASTNode.copySubtree(ast, type2); ListRewrite listRewriter = rewrite.getListRewrite(methodDeclaration, MethodDeclaration.THROWN_EXCEPTION_TYPES_PROPERTY); listRewriter.insertLast(newType, null); } }
@Override public boolean isParameterized() { if (type.isArrayType()) { return ((ArrayType) type).getElementType().isParameterizedType(); } return type.isParameterizedType(); }
public void endVisit(Type node) { if (node.isParameterizedType()) { // retain already parameterized types ImmutableTypeVariable2 typeVariable= fTCModel.makeImmutableTypeVariable(node.resolveBinding(), /*no boxing*/null); setConstraintVariable(node, typeVariable); } else { TypeVariable2 typeVariable= fTCModel.makeTypeVariable(node); setConstraintVariable(node, typeVariable); } }
public SM_Type resolveType(Type type, SM_Project project) { ITypeBinding binding = type.resolveBinding(); if (binding == null || binding.getPackage() == null) // instanceof String[] returns null package return null; SM_Package pkg = findPackage(binding.getPackage().getName(), project); if (pkg !=null) { return findType(binding.getName(), pkg); } return null; }
private QualifiedType createQualifiedType(TypeReference typeReference, long[] positions, org.eclipse.jdt.internal.compiler.ast.Annotation[][] typeAnnotations, char[][] tokens, int index, Type qualifier) { SimpleName simpleName = createSimpleName(typeReference, positions, tokens, index); QualifiedType qualifiedType = new QualifiedType(this.ast); qualifiedType.setQualifier(qualifier); qualifiedType.setName(simpleName); int start = qualifier.getStartPosition(); int end = simpleName.getStartPosition() + simpleName.getLength() - 1; setSourceRangeAnnotationsAndRecordNodes(typeReference, qualifiedType, typeAnnotations, index, start, end); return qualifiedType; }