Package com.icona.helper

Examples of com.icona.helper.CodeStringBuilder


    public void remove(Declaration decl){
      declarations.remove(decl);
    }
   
    public String toString(){
      CodeStringBuilder sb=new CodeStringBuilder();
      for(int i=0;i<declarations.size();i++){
        if(declarations.get(i)!=null)
        sb.appendWithTabNewLine(declarations.get(i).toString()+";");//TODO the indentation is hard coded
      }
      return sb.toString();
    }
View Full Code Here


   
   
    @Override
    public String toString()
    {
      CodeStringBuilder sb=new CodeStringBuilder();
          if(constExpression==null){
            sb.append("default");
          }
          else{
            sb.append("case ");
            sb.append(constExpression)
          }
         
          sb.append(":");
          sb.append(statement);       
         
      return sb.toString();
    }
View Full Code Here

    }
   
    @Override
    public String toString()
    {
      CodeStringBuilder sb=new CodeStringBuilder();
         
          sb.append(identifier);
          sb.append(":");
          sb.append(statement);
         
      return sb.toString();
    }
View Full Code Here

      this.statement = statement;
      return true;
    }
   
    public String toString(){
      CodeStringBuilder sb=new CodeStringBuilder();
      sb.appendWithTabNewLine("{");
      CodeStringBuilder.addTab();
     
      if(statement!=null)
        sb.appendWithNewLine(statement.toString()); //TODO: To be done
     
      CodeStringBuilder.removeTab();
      sb.appendWithTabNewLine("}");
     
     
     
      return sb.toString();
     
    }
View Full Code Here

      statements.add(s);

    }
    public String toString()
    {
      CodeStringBuilder sb=new CodeStringBuilder();
      for(int i=0; i<statements.size(); i++)
      {
       
        sb.append(statements.get(i).toString());
       
      }
     
      return sb.toString();
    }
View Full Code Here

    {
      ListExpression le=null;
      if(expression.getClass()==ListExpression.class)
        le=(ListExpression)expression;
     
      CodeStringBuilder sb=new CodeStringBuilder();
     
     
      if(le!=null) sb.appendWithNewLine(le.getAllExceptLastExpressionString());
      sb.appendWithTab("if (");
      sb.append((le!=null)?le.getLastExpressionString():expression.toString());
      sb.appendWithNewLine(")");
     
      //CodeStringBuilder.addTab();
     
      if(ifStatement.hasMultipleExpressions()){
        sb.appendWithTabNewLine("{");
        CodeStringBuilder.addTab();
      }
      
     
      sb.appendWithNewLine(ifStatement.toString());
     
      if(ifStatement.hasMultipleExpressions()){
        CodeStringBuilder.removeTab();
        sb.append("}");
      }
     
     
      //CodeStringBuilder.removeTab();
     
      //sb.append("\n");
      if(elseStatement!=null)
      {
        sb.appendWithTab("else ");
        //CodeStringBuilder.addTab();
       
        boolean includeParanthesis=elseStatement.hasMultipleExpressions();//((elseStatement.getClass()==If.class && ((ListExpression)((If)elseStatement).getExpression()).isMultipleExpression()) || (elseStatement.getClass()==While.class && ((ListExpression)((While)elseStatement).getExpression()).isMultipleExpression()) || (elseStatement.getClass()==ListExpression.class && ((ListExpression)elseStatement).isMultipleExpression()));//TODO Add for loop in it;
       
        if(includeParanthesis){
          sb.appendWithTabNewLine("{");
          CodeStringBuilder.addTab();
        }
       
       
        sb.appendWithNewLine(elseStatement.toString());
       
        if(includeParanthesis){
          CodeStringBuilder.removeTab();
          sb.appendWithTabNewLine("}");
        }
       
        //CodeStringBuilder.removeTab();
      }
      return sb.toString();
     
    }
View Full Code Here

    Expression exprCondition;
    Expression exprLast;
    Statement statement;
   
    public String toString(){
      CodeStringBuilder sb=new CodeStringBuilder();
     
      ListExpression le=null;
      if(exprCondition!=null && exprCondition.getClass()==ListExpression.class)
        le=(ListExpression)exprCondition;
     
     
      if(declInit!=null){
        sb.appendWithTabNewLine("{");
        CodeStringBuilder.addTab();
        sb.appendWithNewLine(declInit.toString());
      }
      if(le!=null)
        sb.appendWithNewLine(le.getAllExceptLastExpressionString());
      sb.appendWithTab("for (");

      if(exprInit!=null)
        sb.append(((ListExpression)exprInit).getAllExpressionStringCommaSeperated());
      sb.append(";");

      if(le!=null)
        sb.append(le.getLastExpressionString());
      sb.append(";");

      if(exprLast!=null)
        sb.append(((ListExpression)exprLast).getAllExpressionStringCommaSeperated());
      sb.appendWithNewLine(")");
      if(le!=null && le.isMultipleExpression()){
        sb.appendWithTabNewLine("{");
        CodeStringBuilder.addTab();
      }

      if(statement.hasMultipleExpressions()){
        sb.appendWithTabNewLine("{");
        CodeStringBuilder.addTab();
      }
      if(statement!=null)
        sb.appendWithNewLine(statement);
      if(statement.hasMultipleExpressions()){
        CodeStringBuilder.removeTab();
        sb.appendWithTabNewLine("}");
      }
      sb.append("\n");
      if(le!=null)
        sb.appendWithNewLine(le.getAllExceptLastExpressionString());
      if(le!=null && le.isMultipleExpression()){
        CodeStringBuilder.removeTab();
        sb.appendWithTabNewLine("}");
      }

      if(declInit!=null){
        CodeStringBuilder.removeTab();
        sb.appendWithTabNewLine("}");
      }
      return sb.toString();

    }
View Full Code Here

     
      ListExpression le=null;
      if(expression.getClass()==ListExpression.class)
        le=(ListExpression)expression;
     
      CodeStringBuilder sb=new CodeStringBuilder();
      sb.appendWithTabNewLine("do");
      boolean insertParenthesis=statement.hasMultipleExpressions() || le!=null && le.isMultipleExpression();
     
      if(insertParenthesis) sb.appendWithTabNewLine("{");
     
      //CodeStringBuilder.addTab();
      sb.appendWithNewLine(statement.toString());
      //sb.append("\n");
      if(le!=null) sb.appendWithNewLine(le.getAllExceptLastExpressionString());
      if(insertParenthesis) sb.appendWithTabNewLine("}");
      //sb.append("\n");
     
      //CodeStringBuilder.removeTab();
     
      sb.appendWithTab("while (");
      sb.append((le!=null)?le.getLastExpressionString():expression.toString());
      sb.appendWithNewLine(");");
     
     
     
      return sb.toString();
    }
View Full Code Here

    }

 
    public String toString()
    {
      CodeStringBuilder sb=new CodeStringBuilder();
      sb.append("switch (");
      sb.append(expression.toString());
      sb.append(")");
      sb.append("\n");
      sb.append(switchStatement.toString());
      sb.append("\n");
      return sb.toString();
    }
View Full Code Here

    public String toString(){
      ListExpression le=null;
      if(expression.getClass()==ListExpression.class)
        le=(ListExpression)expression;
      boolean insertParenthesis=statement.hasMultipleExpressions() || le!=null && le.isMultipleExpression() ;
      CodeStringBuilder sb=new CodeStringBuilder();

      if(le!=null) sb.appendWithNewLine(le.getAllExceptLastExpressionString());
      sb.appendWithTab("while(");
      sb.append((le!=null)?le.getLastExpressionString():expression.toString());
      sb.appendWithNewLine(")");
     
      if(insertParenthesis) sb.appendWithTabNewLine("{");
     
      sb.appendWithNewLine(statement.toString());
      //sb.append("\n");
      if(le.isMultipleExpression()) sb.appendWithNewLine(le.getAllExceptLastExpressionString());
     
     
      if(insertParenthesis) sb.appendWithTabNewLine("}");
      return sb.toString();
    }
View Full Code Here

TOP

Related Classes of com.icona.helper.CodeStringBuilder

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.