예제 #1
0
 @Override
 public Void visitForEachStatement(ForEachStatement node) {
   writer.print("for (");
   visit(node.getLoopParameter());
   writer.print(" in ");
   visit(node.getIterator());
   writer.print(") ");
   visit(node.getBody());
   return null;
 }
예제 #2
0
  @Override
  public Void visitDeclaredIdentifier(DeclaredIdentifier node) {
    SimpleIdentifier variableName = node.getIdentifier();
    Token keyword = node.getKeyword();

    LocalVariableElementImpl element = new LocalVariableElementImpl(variableName);
    ForEachStatement statement = (ForEachStatement) node.getParent();
    int declarationEnd = node.getOffset() + node.getLength();
    int statementEnd = statement.getOffset() + statement.getLength();
    element.setVisibleRange(declarationEnd, statementEnd - declarationEnd - 1);
    element.setConst(matches(keyword, Keyword.CONST));
    element.setFinal(matches(keyword, Keyword.FINAL));

    currentHolder.addLocalVariable(element);
    variableName.setStaticElement(element);
    return super.visitDeclaredIdentifier(node);
  }
 @Override
 public R visitForEachStatement(ForEachStatement node) {
   node.visitChildren(this);
   return null;
 }