.append(declaration.getReturnType2().toString()) .append(" ").append(declaration.getName().getFullyQualifiedName()) .append("(");
protected void copyReturnType(final ASTRewrite rewrite, final ICompilationUnit unit, final MethodDeclaration oldMethod, final MethodDeclaration newMethod, final TypeVariableMaplet[] mapping) throws JavaModelException { Type newReturnType= null; if (mapping.length > 0) newReturnType= createPlaceholderForType(oldMethod.getReturnType2(), unit, mapping, rewrite); else newReturnType= createPlaceholderForType(oldMethod.getReturnType2(), unit, rewrite); newMethod.setReturnType2(newReturnType); }
protected void copyReturnType(final ASTRewrite rewrite, final ICompilationUnit unit, final MethodDeclaration oldMethod, final MethodDeclaration newMethod, final TypeVariableMaplet[] mapping) throws JavaModelException { Type newReturnType= null; if (mapping.length > 0) newReturnType= createPlaceholderForType(oldMethod.getReturnType2(), unit, mapping, rewrite); else newReturnType= createPlaceholderForType(oldMethod.getReturnType2(), unit, rewrite); newMethod.setReturnType2(newReturnType); }
@Override public Type<O> getReturnType() { if (isConstructor()) { return null; } return new TypeImpl<O>(parent, method.getReturnType2()); }
@Override public Type<O> getReturnType() { if (isConstructor()) { return null; } return new TypeImpl<O>(parent, method.getReturnType2()); }
/** * @param decl the method declaration * @return the return type * @deprecated Deprecated to avoid deprecated warnings */ @Deprecated private static ASTNode getReturnType(MethodDeclaration decl) { // used from API, can't eliminate return decl.getAST().apiLevel() == AST.JLS2 ? decl.getReturnType() : decl.getReturnType2(); }
@Override public boolean visit(final MethodDeclaration node) { final String name = node.getName().toString(); final Type returnType = node.getReturnType2(); methodReturnTypes.put(currentPackage + scopeName + "." + name, returnType); return super.visit(node); }
/** * @deprecated Deprecated to avoid deprecated warnings */ private static ASTNode getReturnType(MethodDeclaration decl) { // used from API, can't eliminate return (decl.getAST().apiLevel() == AST.JLS2) ? decl.getReturnType() : decl.getReturnType2(); }
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 CSTypeReferenceExpression mappedReturnType(MethodDeclaration node) { IMethodBinding overriden = getOverridedMethod(node); if (overriden != null) return mappedTypeReference (overriden.getReturnType()); return mappedTypeReference(node.getReturnType2()); }
private void changeReturnType() throws JavaModelException { if (isReturnTypeSameAsInitial()) return; replaceTypeNode(fMethDecl.getReturnType2(), fReturnTypeInfo.getNewTypeName(), fReturnTypeInfo.getNewTypeBinding()); removeExtraDimensions(fMethDecl); //Remove expression from return statement when changed to void? No, would lose information! //Could add return statement with default value and add todo comment, but compile error is better. }
private void changeReturnType() { if (isReturnTypeSameAsInitial()) return; replaceTypeNode(fMethDecl.getReturnType2(), fReturnTypeInfo.getNewTypeName(), fReturnTypeInfo.getNewTypeBinding()); removeExtraDimensions(fMethDecl); //Remove expression from return statement when changed to void? No, would lose information! //Could add return statement with default value and add todo comment, but compile error is better. }
public TypeImpl(final O origin, final Type<O> parent, final String type) { init(origin); this.parent = parent; String stub = "public class Stub { private " + type + " getType(){return null;} }"; JavaClassSource temp = (JavaClassSource) Roaster.parse(stub); List<MethodSource<JavaClassSource>> methods = temp.getMethods(); MethodDeclaration newMethod = (MethodDeclaration) methods.get(0).getInternal(); org.eclipse.jdt.core.dom.Type subtree = (org.eclipse.jdt.core.dom.Type) ASTNode.copySubtree(cu.getAST(), newMethod.getReturnType2()); this.type = subtree; }
private Statement encapsulateInvocation(MethodDeclaration declaration, MethodInvocation invocation) { final Type type= declaration.getReturnType2(); if (type == null || (type instanceof PrimitiveType && PrimitiveType.VOID.equals( ((PrimitiveType) type).getPrimitiveTypeCode()))) return invocation.getAST().newExpressionStatement(invocation); ReturnStatement statement= invocation.getAST().newReturnStatement(); statement.setExpression(invocation); return statement; }
private Statement encapsulateInvocation(MethodDeclaration declaration, MethodInvocation invocation) { final Type type= declaration.getReturnType2(); if (type == null || (type instanceof PrimitiveType && PrimitiveType.VOID.equals( ((PrimitiveType) type).getPrimitiveTypeCode()))) return invocation.getAST().newExpressionStatement(invocation); ReturnStatement statement= invocation.getAST().newReturnStatement(); statement.setExpression(invocation); return statement; }
private Statement encapsulateInvocation(MethodDeclaration declaration, MethodInvocation invocation) { final Type type= declaration.getReturnType2(); if (type == null || (type instanceof PrimitiveType && PrimitiveType.VOID.equals( ((PrimitiveType) type).getPrimitiveTypeCode()))) return invocation.getAST().newExpressionStatement(invocation); ReturnStatement statement= invocation.getAST().newReturnStatement(); statement.setExpression(invocation); return statement; }
public TypeImpl(final O origin, final Type<O> parent, final String type) { init(origin); this.parent = parent; String stub = "public class Stub { private " + type + " getType(){return null;} }"; JavaClassSource temp = (JavaClassSource) Roaster.parse(stub); List<MethodSource<JavaClassSource>> methods = temp.getMethods(); MethodDeclaration newMethod = (MethodDeclaration) methods.get(0).getInternal(); org.eclipse.jdt.core.dom.Type subtree = (org.eclipse.jdt.core.dom.Type) ASTNode.copySubtree(cu.getAST(), newMethod.getReturnType2()); this.type = subtree; }
@Override public MethodSource<O> setReturnType(final String typeName) { String stub = "public class Stub { public " + typeName + " method() {} }"; JavaClassSource temp = (JavaClassSource) Roaster.parse(stub); List<MethodSource<JavaClassSource>> methods = temp.getMethods(); org.eclipse.jdt.core.dom.Type returnType = ((MethodDeclaration) methods.get(0).getInternal()).getReturnType2(); returnType = (org.eclipse.jdt.core.dom.Type) ASTNode.copySubtree(method.getAST(), returnType); method.setReturnType2(returnType); return this; }
@Override public void endVisit(MethodDeclaration node) { if (skipNode(node)) { return; } GenericSequentialFlowInfo info = processSequential(node, node.getReturnType2()); process(info, node.parameters()); process(info, node.thrownExceptionTypes()); process(info, node.getBody()); }
@Override public void endVisit(MethodDeclaration node) { if (skipNode(node)) return; GenericSequentialFlowInfo info= processSequential(node, node.getReturnType2()); process(info, node.parameters()); process(info, node.thrownExceptionTypes()); process(info, node.getBody()); }