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)); // } }
/** * @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(); }