Search in sources :

Example 1 with NodeTransformer

use of org.mozilla.javascript.NodeTransformer in project pentaho-kettle by pentaho.

the class ScriptDialog method parseVariables.

// This could be useful for further improvements
public static ScriptNode parseVariables(Context cx, Scriptable scope, String source, String sourceName, int lineno, Object securityDomain) {
    // Interpreter compiler = new Interpreter();
    CompilerEnvirons evn = new CompilerEnvirons();
    // evn.setLanguageVersion(Context.VERSION_1_5);
    evn.setOptimizationLevel(-1);
    evn.setGeneratingSource(true);
    evn.setGenerateDebugInfo(true);
    ErrorReporter errorReporter = new ToolErrorReporter(false);
    Parser p = new Parser(evn, errorReporter);
    // IOException
    ScriptNode tree = p.parse(source, "", 0);
    new NodeTransformer().transform(tree);
    // Script result = (Script)compiler.compile(scope, evn, tree, p.getEncodedSource(),false, null);
    return tree;
}
Also used : ToolErrorReporter(org.mozilla.javascript.tools.ToolErrorReporter) ErrorReporter(org.mozilla.javascript.ErrorReporter) NodeTransformer(org.mozilla.javascript.NodeTransformer) CompilerEnvirons(org.mozilla.javascript.CompilerEnvirons) ToolErrorReporter(org.mozilla.javascript.tools.ToolErrorReporter) ScriptNode(org.mozilla.javascript.ast.ScriptNode) Parser(org.mozilla.javascript.Parser)

Example 2 with NodeTransformer

use of org.mozilla.javascript.NodeTransformer in project pentaho-kettle by pentaho.

the class ScriptValuesModDialog method parseVariables.

// This could be useful for further improvements
public static ScriptNode parseVariables(Context cx, Scriptable scope, String source, String sourceName, int lineno, Object securityDomain) {
    // Interpreter compiler = new Interpreter();
    CompilerEnvirons evn = new CompilerEnvirons();
    // evn.setLanguageVersion(Context.VERSION_1_5);
    evn.setOptimizationLevel(-1);
    evn.setGeneratingSource(true);
    evn.setGenerateDebugInfo(true);
    ErrorReporter errorReporter = new ToolErrorReporter(false);
    Parser p = new Parser(evn, errorReporter);
    // IOException
    ScriptNode tree = p.parse(source, "", 0);
    new NodeTransformer().transform(tree);
    // Script result = (Script)compiler.compile(scope, evn, tree, p.getEncodedSource(),false, null);
    return tree;
}
Also used : ToolErrorReporter(org.mozilla.javascript.tools.ToolErrorReporter) ErrorReporter(org.mozilla.javascript.ErrorReporter) NodeTransformer(org.mozilla.javascript.NodeTransformer) CompilerEnvirons(org.mozilla.javascript.CompilerEnvirons) ToolErrorReporter(org.mozilla.javascript.tools.ToolErrorReporter) ScriptNode(org.mozilla.javascript.ast.ScriptNode) Parser(org.mozilla.javascript.Parser)

Aggregations

CompilerEnvirons (org.mozilla.javascript.CompilerEnvirons)2 ErrorReporter (org.mozilla.javascript.ErrorReporter)2 NodeTransformer (org.mozilla.javascript.NodeTransformer)2 Parser (org.mozilla.javascript.Parser)2 ScriptNode (org.mozilla.javascript.ast.ScriptNode)2 ToolErrorReporter (org.mozilla.javascript.tools.ToolErrorReporter)2