protected void findOccurrences() { fDescription = Messages.format(EXIT_POINT_OF, fFunctionDeclaration.getFunctionName().getName()); fFunctionDeclaration.accept(this); // TODO : check execution path to determine if the last bracket // is also a possible exit path // Block block= fMethodDeclaration.getBody(); // if (block != null) { // List statements= block.statements(); // if (statements.size() > 0) { // Statement last= (Statement)statements.get(statements.size() - 1); // int maxVariableId= LocalVariableIndex.perform(fMethodDeclaration); // FlowContext flowContext= new FlowContext(0, maxVariableId + 1); // flowContext.setConsiderAccessMode(false); // flowContext.setComputeMode(FlowContext.ARGUMENTS); // InOutFlowAnalyzer flowAnalyzer= new InOutFlowAnalyzer(flowContext); // FlowInfo info= flowAnalyzer.perform(new ASTNode[] {last}); // if (!info.isNoReturn() && !isVoid) { // if (!info.isPartialReturn()) // return; // } // } int offset = fFunctionDeclaration.getEnd() - 1; fResult.add(new OccurrenceLocation(offset, 1, getOccurrenceType(null), fDescription)); // } }
public boolean apply(ASTNode node) { // stops when found - that's the reason to use ApplyAll if (exists) return false; if (node.getType() == ASTNode.CLASS_DECLARATION) { // do nothing never catch method names } else if (node.getType() == ASTNode.FUNCTION_DECLARATION) { FunctionDeclaration functionDeclaration = (FunctionDeclaration) node; Identifier identifier = functionDeclaration.getFunctionName(); if (identifier.getName().equalsIgnoreCase(name)) { exists = true; } } return true; }
/** * @param path * @return true if the given path indicates a global variable */ public static boolean localVariableAlreadyExists( FunctionDeclaration functionDeclaration, final String name) { assert functionDeclaration != null && name != null; final LocalVariableSearcher checkLocalVariable = new LocalVariableSearcher(name); functionDeclaration.accept(checkLocalVariable); return checkLocalVariable.localVariableAlreadyExists(); }
public boolean visit(FunctionDeclaration functionDecl) { for (FormalParameter param : functionDecl.formalParameters()) { params.add(param.getParameterNameIdentifier().getName()); } return true; }
public String getElementName() { return fFunctionDeclaration.getFunctionName().getName(); }