예제 #1
0
 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));
   // }
 }
예제 #2
0
    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;
    }
예제 #3
0
  /**
   * @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();
  }
예제 #4
0
 public boolean visit(FunctionDeclaration functionDecl) {
   for (FormalParameter param : functionDecl.formalParameters()) {
     params.add(param.getParameterNameIdentifier().getName());
   }
   return true;
 }
예제 #5
0
 public String getElementName() {
   return fFunctionDeclaration.getFunctionName().getName();
 }