예제 #1
0
  @Override
  public void preVisit(final ASTNode node) {
    final ASTNode parent = node.getParent();
    if (parent != null && nodeScopes.containsKey(parent)) {
      Map<String, Integer> bindingsCopy = Maps.newTreeMap();
      // inherit all variables in parent scope
      for (final Entry<String, Integer> binding : nodeScopes.get(parent).entrySet()) {
        bindingsCopy.put(binding.getKey(), binding.getValue());
      }

      nodeScopes.put(node, bindingsCopy);
    } else {
      // Start from scratch
      nodeScopes.put(node, Maps.<String, Integer>newTreeMap());
    }
    super.preVisit(node);
  }
예제 #2
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.eclipse.jdt.core.dom.ASTVisitor#endVisit(org.eclipse.jdt.core
  * .dom.TypeDeclaration)
  */
 @Override
 public void endVisit(final TypeDeclaration node) {
   className.pop();
   super.endVisit(node);
 }