private static ITypeBinding getTargetTypeForReturnStmt(ReturnStatement returnStmt) { LambdaExpression enclosingLambdaExpr= ASTResolving.findEnclosingLambdaExpression(returnStmt); if (enclosingLambdaExpr != null) { IMethodBinding methodBinding= enclosingLambdaExpr.resolveMethodBinding(); return methodBinding == null ? null : methodBinding.getReturnType(); } MethodDeclaration enclosingMethodDecl= ASTResolving.findParentMethodDeclaration(returnStmt); if (enclosingMethodDecl != null) { IMethodBinding methodBinding= enclosingMethodDecl.resolveBinding(); return methodBinding == null ? null : methodBinding.getReturnType(); } return null; }
public static String getCatchBodyContent(ICompilationUnit cu, String exceptionType, String variableName, ASTNode locationInAST, String lineDelimiter) throws CoreException { String enclosingType= ""; //$NON-NLS-1$ String enclosingMethod= ""; //$NON-NLS-1$ if (locationInAST != null) { MethodDeclaration parentMethod= ASTResolving.findParentMethodDeclaration(locationInAST); if (parentMethod != null) { enclosingMethod= parentMethod.getName().getIdentifier(); locationInAST= parentMethod; } ASTNode parentType= ASTResolving.findParentType(locationInAST); if (parentType instanceof AbstractTypeDeclaration) { enclosingType= ((AbstractTypeDeclaration) parentType).getName().getIdentifier(); } } return getCatchBodyContent(cu, exceptionType, variableName, enclosingType, enclosingMethod, lineDelimiter); }
public static String getCatchBodyContent(ICompilationUnit cu, String exceptionType, String variableName, ASTNode locationInAST, String lineDelimiter) throws CoreException { String enclosingType= ""; //$NON-NLS-1$ String enclosingMethod= ""; //$NON-NLS-1$ if (locationInAST != null) { MethodDeclaration parentMethod= ASTResolving.findParentMethodDeclaration(locationInAST); if (parentMethod != null) { enclosingMethod= parentMethod.getName().getIdentifier(); locationInAST= parentMethod; } ASTNode parentType= ASTResolving.findParentType(locationInAST); if (parentType instanceof AbstractTypeDeclaration) { enclosingType= ((AbstractTypeDeclaration)parentType).getName().getIdentifier(); } } return getCatchBodyContent(cu, exceptionType, variableName, enclosingType, enclosingMethod, lineDelimiter); }
public static void addAddSafeVarargsProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { ASTNode coveringNode= problem.getCoveringNode(context.getASTRoot()); MethodDeclaration methodDeclaration= ASTResolving.findParentMethodDeclaration(coveringNode); if (methodDeclaration == null) return; IMethodBinding methodBinding= methodDeclaration.resolveBinding(); if (methodBinding == null) return; int modifiers= methodBinding.getModifiers(); if (!Modifier.isStatic(modifiers) && !Modifier.isFinal(modifiers) && ! methodBinding.isConstructor()) return; String label= CorrectionMessages.VarargsWarningsSubProcessor_add_safevarargs_label; AddSafeVarargsProposal proposal= new AddSafeVarargsProposal(label, context.getCompilationUnit(), methodDeclaration, null, IProposalRelevance.ADD_SAFEVARARGS); proposals.add(proposal); }
MethodDeclaration coveringMetod= ASTResolving.findParentMethodDeclaration(covering); if (coveringMetod == null) { return false;
/** * @param root the AST root * @param node the selected node * @return returns a message if there is a problem */ @Override public String initialize(CompilationUnit root, ASTNode node) { fASTRoot= root; if (node instanceof ReturnStatement) { fMethodDeclaration= ASTResolving.findParentMethodDeclaration(node); if (fMethodDeclaration == null) return SearchMessages.MethodExitsFinder_no_return_type_selected; return null; } Type type= ASTNodes.getTopMostType(node); if (type == null) return SearchMessages.MethodExitsFinder_no_return_type_selected; if (type.getLocationInParent() != MethodDeclaration.RETURN_TYPE2_PROPERTY) return SearchMessages.MethodExitsFinder_no_return_type_selected; fMethodDeclaration= (MethodDeclaration)type.getParent(); fExitDescription= Messages.format(SearchMessages.MethodExitsFinder_occurrence_exit_description, BasicElementLabels.getJavaElementName(fMethodDeclaration.getName().toString())); return null; }
MethodDeclaration coveringMetod = ASTResolving.findParentMethodDeclaration(covering); if (coveringMetod == null) { return false;
MethodDeclaration method= ASTResolving.findParentMethodDeclaration(node); if (method == null) return SearchMessages.ExceptionOccurrencesFinder_no_exception; MethodDeclaration method= ASTResolving.findParentMethodDeclaration(node); if (method == null) return SearchMessages.ExceptionOccurrencesFinder_no_exception;
final MethodDeclaration method= ASTResolving.findParentMethodDeclaration(covering); SimpleName[] linkedNodes= LinkedNodeFinder.findByBinding(method, variableBinding);
final MethodDeclaration method= ASTResolving.findParentMethodDeclaration(covering); SimpleName[] linkedNodes= LinkedNodeFinder.findByBinding(method, variableBinding);
MethodDeclaration coveringMethod= ASTResolving.findParentMethodDeclaration(ifStatement); if (coveringMethod == null) { return false;
targetBinding= typeBinding; arguments= ((ConstructorInvocation) selectedNode).arguments(); recursiveConstructor= ASTResolving.findParentMethodDeclaration(selectedNode).resolveBinding();
targetBinding= typeBinding; arguments= ((ConstructorInvocation) selectedNode).arguments(); recursiveConstructor= ASTResolving.findParentMethodDeclaration(selectedNode).resolveBinding();
targetBinding= typeBinding; arguments= ((ConstructorInvocation) selectedNode).arguments(); recursiveConstructor= ASTResolving.findParentMethodDeclaration(selectedNode).resolveBinding();
return; MethodDeclaration decl= ASTResolving.findParentMethodDeclaration(selectedNode); if (decl == null) { return;
return; MethodDeclaration decl= ASTResolving.findParentMethodDeclaration(selectedNode); if (decl == null) { return;
MethodDeclaration method= ASTResolving.findParentMethodDeclaration(selectedNode); if (method != null && !method.isConstructor()) { ASTRewrite rewrite= ASTRewrite.create(ast);
thenExpression= ((ReturnStatement) thenStatement).getExpression(); elseExpression= ((ReturnStatement) elseStatement).getExpression(); MethodDeclaration declaration= ASTResolving.findParentMethodDeclaration(node); if (declaration == null || declaration.isConstructor()) { return false;
thenExpression= ((ReturnStatement) thenStatement).getExpression(); elseExpression= ((ReturnStatement) elseStatement).getExpression(); MethodDeclaration declaration= ASTResolving.findParentMethodDeclaration(node); if (declaration == null || declaration.isConstructor()) { return false;
MethodDeclaration decl= ASTResolving.findParentMethodDeclaration(parent); if (decl != null && !decl.isConstructor()) { return decl.getReturnType2().resolveBinding();