Package org.mozilla.javascript.ast

Examples of org.mozilla.javascript.ast.VariableDeclaration


               
                if (node instanceof VariableDeclaration || node instanceof ExpressionStatement) {

                   
                    if (node instanceof VariableDeclaration) {
                        VariableDeclaration declaration = (VariableDeclaration) node;
                        String source = declaration.toSource();
                        String name = source.substring(0, source.indexOf("=")).trim();
                        name = name.substring(name.indexOf("var") + 3).trim();
                        String value = source.substring(source.indexOf("=") + 1).trim();
                       
                        TMLScriptVariableDeclaration tmlScriptVarDec = new TMLScriptVariableDeclaration(tmlScriptScope, name);
                        tmlScriptVarDec.setValue(value);
                        tmlScriptVarDec.setOffset(declaration.getAbsolutePosition());
                       
                        tmlScriptScope.getVariableDeclarations().add(tmlScriptVarDec);
                    } else if (node instanceof ExpressionStatement) {
                        ExpressionStatement expressionStatement = (ExpressionStatement) node;
                        String source = expressionStatement.getExpression().toSource();
View Full Code Here


    return prop;
  }

  @Override
  public AstNode variableDeclaration(boolean statement, Iterable<NameValue<AstNode>> vars) {
    VariableDeclaration varDecl = new VariableDeclaration();
    varDecl.setIsStatement(statement);
    for (NameValue<AstNode> v : vars) {
      VariableInitializer var = new VariableInitializer();
      var.setTarget(name(v.getName()));
      var.setInitializer(v.getValue());
      varDecl.addVariable(var);
    }
    return varDecl;
  }
View Full Code Here

    return varDecl;
  }

  @Override
  public AstNode variableDeclaration(boolean statement, CharSequence name, AstNode init) {
    VariableDeclaration vars = new VariableDeclaration();
    vars.setIsStatement(statement);
    VariableInitializer var = new VariableInitializer();
    var.setTarget(name(name));
    var.setInitializer(init);
    vars.addVariable(var);
    return vars;
  }
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.ast.VariableDeclaration

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.