/*
  * @see ASTVisitor#visit(FunctionInvocation)
  */
 public boolean visit(FunctionInvocation node) {
   if (node.getExpression() != null) {
     node.getExpression().accept(this);
     this.fBuffer.append("."); // $NON-NLS-1$
   }
   if (node.getAST().apiLevel() >= AST.JLS3) {
     if (!node.typeArguments().isEmpty()) {
       this.fBuffer.append("<"); // $NON-NLS-1$
       for (Iterator it = node.typeArguments().iterator(); it.hasNext(); ) {
         Type t = (Type) it.next();
         t.accept(this);
         if (it.hasNext()) {
           this.fBuffer.append(","); // $NON-NLS-1$
         }
       }
       this.fBuffer.append(">"); // $NON-NLS-1$
     }
   }
   SimpleName name = node.getName();
   if (name != null) name.accept(this);
   this.fBuffer.append("("); // $NON-NLS-1$
   for (Iterator it = node.arguments().iterator(); it.hasNext(); ) {
     Expression e = (Expression) it.next();
     e.accept(this);
     if (it.hasNext()) {
       this.fBuffer.append(","); // $NON-NLS-1$
     }
   }
   this.fBuffer.append(")"); // $NON-NLS-1$
   return false;
 }
 public boolean visit(SimpleName node) {
   if (fIgnoreBinding != null && Bindings.equals(fIgnoreBinding, node.resolveBinding()))
     return false;
   if (fIgnoreRange != null && fIgnoreRange.covers(node)) return false;
   fScope.addName(node.getIdentifier());
   return false;
 }
 public boolean visit(ThrowStatement node) {
   if (matches(node.getExpression().resolveTypeBinding())) {
     SimpleName name = fAST.newSimpleName("xxxxx"); // $NON-NLS-1$
     name.setSourceRange(node.getStartPosition(), 5);
     fResult.add(name);
   }
   return super.visit(node);
 }
 public boolean visit(SuperConstructorInvocation node) {
   if (matches(node.resolveConstructorBinding())) {
     SimpleName name = fAST.newSimpleName("xxxxx"); // $NON-NLS-1$
     name.setSourceRange(node.getStartPosition(), 5);
     fResult.add(name);
   }
   return super.visit(node);
 }
 public boolean visit(FunctionInvocation node) {
   Expression receiver = node.getExpression();
   if (receiver == null) {
     SimpleName name = node.getName();
     if (fIgnoreBinding == null
         || (name != null && !Bindings.equals(fIgnoreBinding, name.resolveBinding())))
       node.getName().accept(this);
   } else {
     receiver.accept(this);
   }
   accept(node.arguments());
   return false;
 }
  private static int getNameNodeProblemKind(IProblem[] problems, SimpleName nameNode) {
    int nameOffset = nameNode.getStartPosition();
    int nameInclEnd = nameOffset + nameNode.getLength() - 1;

    for (int i = 0; i < problems.length; i++) {
      IProblem curr = problems[i];
      if (curr.getSourceStart() == nameOffset && curr.getSourceEnd() == nameInclEnd) {
        int kind = getProblemKind(curr);
        if (kind != 0) {
          return kind;
        }
      }
    }
    return 0;
  }
 /**
  * Find all nodes connected to the given name node. If the node has a binding then all nodes
  * connected to this binding are returned. If the node has no binding, then all nodes that also
  * miss a binding and have the same name are returned.
  *
  * @param root The root of the AST tree to search
  * @param name The node to find linked nodes for
  * @return Return
  */
 public static SimpleName[] findByNode(ASTNode root, SimpleName name) {
   IBinding binding = name.resolveBinding();
   if (binding != null) {
     return findByBinding(root, binding);
   }
   SimpleName[] names = findByProblems(root, name);
   if (names != null) {
     return names;
   }
   int parentKind = name.getParent().getNodeType();
   if (parentKind == ASTNode.LABELED_STATEMENT
       || parentKind == ASTNode.BREAK_STATEMENT
       || parentKind == ASTNode.CONTINUE_STATEMENT) {
     ArrayList res = new ArrayList();
     LabelFinder nodeFinder = new LabelFinder(name, res);
     root.accept(nodeFinder);
     return (SimpleName[]) res.toArray(new SimpleName[res.size()]);
   }
   return new SimpleName[] {name};
 }
    public boolean visit(SimpleName node) {
      IBinding binding = node.resolveBinding();
      if (binding == null || binding.getKind() != fBinding.getKind()) {
        return false;
      }
      binding = getDeclaration(binding);

      if (fBinding == binding) {
        fResult.add(node);
      } else if (binding.getKind() == IBinding.METHOD) {
        IFunctionBinding curr = (IFunctionBinding) binding;
        IFunctionBinding methodBinding = (IFunctionBinding) fBinding;
        if (methodBinding.overrides(curr) || curr.overrides(methodBinding)) {
          fResult.add(node);
        }
      }
      return false;
    }
  public static SimpleName[] findByProblems(ASTNode parent, SimpleName nameNode) {
    ArrayList res = new ArrayList();

    ASTNode astRoot = parent.getRoot();
    if (!(astRoot instanceof JavaScriptUnit)) {
      return null;
    }

    IProblem[] problems = ((JavaScriptUnit) astRoot).getProblems();
    int nameNodeKind = getNameNodeProblemKind(problems, nameNode);
    if (nameNodeKind == 0) { // no problem on node
      return null;
    }

    int bodyStart = parent.getStartPosition();
    int bodyEnd = bodyStart + parent.getLength();

    String name = nameNode.getIdentifier();

    for (int i = 0; i < problems.length; i++) {
      IProblem curr = problems[i];
      int probStart = curr.getSourceStart();
      int probEnd = curr.getSourceEnd() + 1;

      if (probStart > bodyStart && probEnd < bodyEnd) {
        int currKind = getProblemKind(curr);
        if ((nameNodeKind & currKind) != 0) {
          ASTNode node = NodeFinder.perform(parent, probStart, probEnd - probStart);
          if (node instanceof SimpleName && name.equals(((SimpleName) node).getIdentifier())) {
            res.add(node);
          }
        }
      }
    }
    return (SimpleName[]) res.toArray(new SimpleName[res.size()]);
  }
 private boolean isSameLabel(SimpleName label) {
   return label != null && fLabel.getIdentifier().equals(label.getIdentifier());
 }
 /*
  * @see ASTVisitor#visit(SimpleName)
  */
 public boolean visit(SimpleName node) {
   this.fBuffer.append(node.getIdentifier());
   return false;
 }