Package org.eclipse.dltk.ast.statements

Examples of org.eclipse.dltk.ast.statements.Statement


    if (varDecls.size() > level) {
      Declaration decl = varDecls.get(level);
      // The case that the node is inside another node
      if (decl != null) {
        if (level > 0) {
          Statement block = innerBlocks.get(level - 1);
          if (isInSameBlock(block, decl.getNode(), declNode)) {
            // replace existing declaration with a new one (leave
            // 'isGlobal' flag the same)
            decl.setNode(declNode);
            return;
View Full Code Here


  public static boolean isInSameBlock(Statement block, ASTNode oldNode,
      ASTNode newNode) {
    if (block instanceof IfStatement) {
      IfStatement ifStatement = (IfStatement) block;
      Statement oldBlock = getBlock(ifStatement, oldNode);
      Statement newBlock = getBlock(ifStatement, newNode);
      if (oldBlock != null && oldBlock == newBlock) {
        return isInSameBlock(newBlock, oldNode, newNode);
      } else {
        return false;
      }
View Full Code Here

    }
    return true;
  }

  private static Statement getBlock(IfStatement ifStatement, ASTNode node) {
    Statement falseStatement = ifStatement.getFalseStatement();
    Statement trueStatement = ifStatement.getTrueStatement();
    if (trueStatement != null
        && trueStatement.sourceStart() <= node.sourceStart()
        && trueStatement.sourceEnd() >= node.sourceEnd()) {
      return trueStatement;
    } else if (falseStatement != null
        && falseStatement.sourceStart() <= node.sourceStart()
        && falseStatement.sourceEnd() >= node.sourceEnd()) {
      return falseStatement;
View Full Code Here

    if (!declarations.isEmpty()) {
      statements.add(declarations.remove(0));
    }
    if (!statements.isEmpty()) {
      Statement s1 = (Statement) statements.get(0);
      Statement s2 = (Statement) statements.get(statements.size() - 1);
      start = s1.sourceStart();
      end = s2.sourceEnd();
    }
    List<ASTError> errors = getErrors();
    if (!errors.isEmpty()) {
      ASTError lastError = errors.get(errors.size() - 1);
      end = (end > lastError.sourceEnd()) ? end : lastError.sourceEnd();
    }
    program.setStart(start);
    program.setEnd(end);

    // Set end offset of recovered class/interface node to the end of file
    if (statements.size() > 0) {
      Statement lastStatement = statements.get(statements.size() - 1);
      if (lastStatement instanceof IRecoverable) {
        IRecoverable recoverable = (IRecoverable) lastStatement;
        if (recoverable.isRecovered()) {
          lastStatement.setEnd(end);
        }
      }
    }

    super.unrecovered_syntax_error(cur_token);
View Full Code Here

      }

      // we don't add top level statements to the program node this way
      return;
    }
    Statement node = declarations.peek();
    Block block = null;
    if (node instanceof TypeDeclaration) {
      block = ((TypeDeclaration) node).getBody();
    } else if (node instanceof MethodDeclaration) {
      block = ((MethodDeclaration) node).getBody();
View Full Code Here

    xmlWriter.startTag("TrueStatement", new HashMap<String, String>()); //$NON-NLS-1$
    s.getTrueStatement().traverse(this);
    xmlWriter.endTag("TrueStatement"); //$NON-NLS-1$

    Statement falseStatement = s.getFalseStatement();
    if (falseStatement != null) {
      xmlWriter.startTag("FalseStatement", new HashMap<String, String>()); //$NON-NLS-1$
      falseStatement.traverse(this);
      xmlWriter.endTag("FalseStatement"); //$NON-NLS-1$
    }

    return false;
  }
View Full Code Here

                            fRequestor.exitMethod(block.sourceEnd());
                        }

                    } else if (TwigCoreConstants.EXTENDS.equals(block.getName().getValue())) {

                        Statement first = block.getFirstChild();

                        if (first instanceof StringLiteral) {
                            StringLiteral parent = (StringLiteral) first;
                            String display = TwigCoreConstants.EXTENDS + " " + parent.getValue();
                            fRequestor.acceptPackage(block.sourceStart(),
View Full Code Here

          return CUP$TwigAstParser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 16: // statement ::= T_INLINE_HTML
            {
              Statement RESULT = null;
    int htmlleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left;
    int htmlright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right;
    Object html = (Object)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).value;
   
                RESULT = new InLineHtml(htmlleft, htmlright);
             
              CUP$TwigAstParser$result = new java_cup.runtime.Symbol(8/*statement*/, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, RESULT);
            }
          return CUP$TwigAstParser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 15: // statement ::= T_CONSTANT_ENCAPSED_STRING
            {
              Statement RESULT = null;
    int stringleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left;
    int stringright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right;
    String string = (String)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).value;
   
                RESULT = new StringLiteral(stringleft, stringright, string);
             
              CUP$TwigAstParser$result = new java_cup.runtime.Symbol(8/*statement*/, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, RESULT);
            }
          return CUP$TwigAstParser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 14: // statement ::= T_VARIABLE
            {
              Statement RESULT = null;
    int varleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left;
    int varright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right;
    String var = (String)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).value;
    
                  RESULT = new Variable(varleft, varright, var);
             
              CUP$TwigAstParser$result = new java_cup.runtime.Symbol(8/*statement*/, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, RESULT);
            }
          return CUP$TwigAstParser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 13: // function ::= T_VARIABLE T_OPEN_PARENTHESE inner_statement_list T_CLOSE_PARENTHESE
            {
              TwigCallExpression RESULT = null;
    int idleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-3)).left;
    int idright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-3)).right;
    String id = (String)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-3)).value;
    int openleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-2)).left;
    int openright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-2)).right;
    Object open = (Object)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-2)).value;
    int stmtleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).left;
    int stmtright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).right;
    List stmt = (List)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).value;
    int closeleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left;
    int closeright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right;
    Object close = (Object)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).value;
   
                RESULT = new TwigCallExpression(idleft, closeright, id, stmt);
             
              CUP$TwigAstParser$result = new java_cup.runtime.Symbol(9/*function*/, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-3)).left, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, RESULT);
            }
          return CUP$TwigAstParser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 12: // inner_statement ::= function
            {
              Statement RESULT = null;
    int functionleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left;
    int functionright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right;
    TwigCallExpression function = (TwigCallExpression)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).value;
   
                RESULT = function;
             
              CUP$TwigAstParser$result = new java_cup.runtime.Symbol(7/*inner_statement*/, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, RESULT);
            }
          return CUP$TwigAstParser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 11: // inner_statement ::= statement
            {
              Statement RESULT = null;
    int statementleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left;
    int statementright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right;
    Statement statement = (Statement)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).value;
    
                  RESULT = statement;
             
              CUP$TwigAstParser$result = new java_cup.runtime.Symbol(7/*inner_statement*/, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, RESULT);
            }
          return CUP$TwigAstParser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 10: // inner_statement_list ::=
            {
              List RESULT = null;
    
                  RESULT = new LinkedList();
             
              CUP$TwigAstParser$result = new java_cup.runtime.Symbol(6/*inner_statement_list*/, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, RESULT);
            }
          return CUP$TwigAstParser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 9: // inner_statement_list ::= inner_statement_list inner_statement
            {
              List RESULT = null;
    int statementListleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).left;
    int statementListright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).right;
    List statementList = (List)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).value;
    int statementleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left;
    int statementright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right;
    Statement statement = (Statement)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).value;
   
              // Ignore null statements
              if(statement != null) {
                  statementList.add(statement);
              }
              RESULT = statementList;
             
              CUP$TwigAstParser$result = new java_cup.runtime.Symbol(6/*inner_statement_list*/, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).left, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, RESULT);
            }
          return CUP$TwigAstParser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 8: // block ::= TWIG_STMT_OPEN blockname inner_statement_list TWIG_STMT_CLOSE
            {
              BlockStatement RESULT = null;
    int startleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-3)).left;
    int startright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-3)).right;
    Object start = (Object)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-3)).value;
    int nameleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-2)).left;
    int nameright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-2)).right;
    BlockName name = (BlockName)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-2)).value;
    int innerleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).left;
    int innerright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).right;
    List inner = (List)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).value;
    int endleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left;
    int endright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right;
    Object end = (Object)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).value;
   
                      BlockStatement stmt = new BlockStatement(startleft, endright, name, inner);
                        RESULT = stmt;
                   
              CUP$TwigAstParser$result = new java_cup.runtime.Symbol(2/*block*/, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-3)).left, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, RESULT);
            }
          return CUP$TwigAstParser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 7: // var ::= TWIG_VAR_OPEN inner_statement_list TWIG_VAR_CLOSE
            {
              PrintStatement RESULT = null;
    int startleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-2)).left;
    int startright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-2)).right;
    Object start = (Object)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-2)).value;
    int innerleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).left;
    int innerright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).right;
    List inner = (List)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).value;
    int endleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left;
    int endright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right;
    Object end = (Object)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).value;
   
              PrintStatement stmt = new PrintStatement(startleft, endright, inner);
              RESULT = stmt;
           
              CUP$TwigAstParser$result = new java_cup.runtime.Symbol(3/*var*/, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-2)).left, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, RESULT);
            }
          return CUP$TwigAstParser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 6: // top_statement ::= block
            {
              Statement RESULT = null;
    int bleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left;
    int bright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right;
    BlockStatement b = (BlockStatement)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).value;
   
              RESULT = b;
           
              CUP$TwigAstParser$result = new java_cup.runtime.Symbol(5/*top_statement*/, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, RESULT);
            }
          return CUP$TwigAstParser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 5: // top_statement ::= var
            {
              Statement RESULT = null;
    int vleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left;
    int vright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right;
    PrintStatement v = (PrintStatement)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).value;
   
              RESULT = v;
           
              CUP$TwigAstParser$result = new java_cup.runtime.Symbol(5/*top_statement*/, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, RESULT);
            }
          return CUP$TwigAstParser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 4: // top_statement ::= statement
            {
              Statement RESULT = null;
    int statementleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left;
    int statementright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right;
    Statement statement = (Statement)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).value;
   
              RESULT = statement;
           
              CUP$TwigAstParser$result = new java_cup.runtime.Symbol(5/*top_statement*/, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, RESULT);
            }
          return CUP$TwigAstParser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 3: // top_statement_list ::=
            {
              List RESULT = null;
    
              RESULT = new LinkedList();
           
              CUP$TwigAstParser$result = new java_cup.runtime.Symbol(4/*top_statement_list*/, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right, RESULT);
            }
          return CUP$TwigAstParser$result;

          /*. . . . . . . . . . . . . . . . . . . .*/
          case 2: // top_statement_list ::= top_statement_list top_statement
            {
              List RESULT = null;
    int sListleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).left;
    int sListright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).right;
    List sList = (List)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-1)).value;
    int statementleft = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).left;
    int statementright = ((java_cup.runtime.Symbol)CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).right;
    Statement statement = (Statement)((java_cup.runtime.Symbol) CUP$TwigAstParser$stack.elementAt(CUP$TwigAstParser$top-0)).value;
   
              if(statement != null) {
                sList.add(statement);
              }
              RESULT = sList;
View Full Code Here

     *
     * @return the first block variable or null if none available
     */
    public Variable getBlockName()
    {
        Statement first = getFirstChild();
       
        if (first == null) {
            return null;
        }
        Statement statement = first;

        if (statement instanceof Variable) {
            return (Variable) statement;
        }
        return null;
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.ast.statements.Statement

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.