Package uk.co.badgersinfoil.metaas.impl.antlr

Examples of uk.co.badgersinfoil.metaas.impl.antlr.LinkedListTree


  public void setSuperclass(String superclassName) {
    if (superclassName == null) {
      removeExtendsClause();
      return;
    }
    LinkedListTree ext = ASTUtils.findChildByType(ast, AS3Parser.EXTENDS);
    LinkedListTree superIdent = AS3FragmentParser.parseIdent(superclassName);
    if (ext == null) {
      ext = ASTUtils.newAST(AS3Parser.EXTENDS, "extends");
      ext.appendToken(TokenBuilder.newSpace());
      // hack a space in at the right point,
      LinkedListToken sp = TokenBuilder.newSpace();
View Full Code Here


    }
  }

  private void removeExtendsClause() {
    for (ASTIterator i=new ASTIterator(ast); i.hasNext(); ) {
      LinkedListTree node = i.next();
      if (node.getType() == AS3Parser.EXTENDS) {
        i.remove();
        break;
      }
    }
  }
View Full Code Here

    }
  }

  public List getImplementedInterfaces() {
    List results = new LinkedList();
    LinkedListTree impls = ASTUtils.findChildByType(ast, AS3Parser.IMPLEMENTS);
    if (impls != null) {
      for (ASTIterator i=new ASTIterator(impls); i.hasNext(); ) {
        results.add(ASTUtils.identText(i.next()));
      }
    }
View Full Code Here

    }
    return Collections.unmodifiableList(results);
  }

  public void addImplementedInterface(String interfaceName) {
    LinkedListTree iface = AS3FragmentParser.parseIdent(interfaceName);
    LinkedListTree impls = ASTUtils.findChildByType(ast, AS3Parser.IMPLEMENTS);
    if (impls == null) {
      ASTIterator i = new ASTIterator(ast);
      i.find(AS3Parser.TYPE_BLOCK);
      impls = ASTUtils.newAST(AS3Parser.IMPLEMENTS, "implements");
      i.insertBeforeCurrent(impls);
      LinkedListToken sp = TokenBuilder.newSpace();
      impls.getStartToken().beforeInsert(sp);
    } else {
      impls.appendToken(TokenBuilder.newComma());
    }
    impls.appendToken(TokenBuilder.newSpace());
    impls.addChildWithTokens(iface);
  }
View Full Code Here

    impls.appendToken(TokenBuilder.newSpace());
    impls.addChildWithTokens(iface);
  }

  public void removeImplementedInterface(String interfaceName) {
    LinkedListTree impls = ASTUtils.findChildByType(ast, AS3Parser.IMPLEMENTS);
    int count = 0;
    for (ASTIterator i=new ASTIterator(impls); i.hasNext(); ) {
      LinkedListTree iface = i.next();
      String name = ASTUtils.identText(iface);
      if (name.equals(interfaceName)) {
        if (i.hasNext()) {
          ASTUtils.removeTrailingWhitespaceAndComma(iface.getStopToken());
        } else if (count == 0) {
          // no interfaces left, so remove the
          // 'implements' clause completely,
          ast.deleteChild(ast.getIndexOfChild(impls));
          break;
View Full Code Here

    ASTUtils.addChildWithIndentation(findTypeBlock(), field.getAST());
  }

  public ASField getField(String name) {
    for (ASTIterator i=blockIter(); i.hasNext(); ) {
      LinkedListTree member = i.next();
      if (member.getType() == AS3Parser.VAR_DEF) {
        ASField field = new ASTASField(member);
        if (field.getName().equals(name)) {
          return field;
        }
      }
View Full Code Here

  }

  public List getFields() {
    List results = new LinkedList();
    for (ASTIterator i=blockIter(); i.hasNext(); ) {
      LinkedListTree member = i.next();
      if (member.getType() == AS3Parser.VAR_DEF) {
        results.add(new ASTASField(member));
      }
    }
    return Collections.unmodifiableList(results);
  }
View Full Code Here

    return Collections.unmodifiableList(results);
  }

  public void removeField(String name) {
    for (ASTIterator i=blockIter(); i.hasNext(); ) {
      LinkedListTree member = i.next();
      if (member.getType() == AS3Parser.VAR_DEF) {
        ASField field = new ASTASField(member);
        if (field.getName().equals(name)) {
          i.remove();
          return;
        }
View Full Code Here

  public Expression getCondition() {
    return ExpressionBuilder.build(condition().getFirstChild());
  }

  public void setCondition(String expr) {
    LinkedListTree cond = AS3FragmentParser.parseCondition(expr);
    ast.setChildWithTokens(INDEX_CONDITION, cond);
  }
View Full Code Here

  public static LinkedListTree newIf(String condition) {
    return newIf(AS3FragmentParser.parseExpr(condition));
  }
  public static LinkedListTree newIf(LinkedListTree condition) {
    LinkedListTree ifStmt = ASTUtils.newAST(AS3Parser.IF, "if");
    ifStmt.appendToken(TokenBuilder.newSpace());
    ifStmt.addChildWithTokens(condition(condition));
    ifStmt.appendToken(TokenBuilder.newSpace());
    ifStmt.addChildWithTokens(ASTBuilder.newBlock());
    return ifStmt;
  }
View Full Code Here

TOP

Related Classes of uk.co.badgersinfoil.metaas.impl.antlr.LinkedListTree

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.