use of org.mozilla.javascript.CompilerEnvirons in project hackpad by dropbox.
the class ParserTest method parse.
private AstRoot parse(String string, boolean jsdoc) {
CompilerEnvirons environment = new CompilerEnvirons();
TestErrorReporter testErrorReporter = new TestErrorReporter(null, null);
environment.setErrorReporter(testErrorReporter);
environment.setRecordingComments(true);
environment.setRecordingLocalJsDocComments(jsdoc);
Parser p = new Parser(environment, testErrorReporter);
AstRoot script = p.parse(string, null, 0);
assertTrue(testErrorReporter.hasEncounteredAllErrors());
assertTrue(testErrorReporter.hasEncounteredAllWarnings());
return script;
}
use of org.mozilla.javascript.CompilerEnvirons in project hackpad by dropbox.
the class ParserTest method parseAsReader.
private AstRoot parseAsReader(String string) throws IOException {
CompilerEnvirons environment = new CompilerEnvirons();
TestErrorReporter testErrorReporter = new TestErrorReporter(null, null);
environment.setErrorReporter(testErrorReporter);
environment.setRecordingComments(true);
environment.setRecordingLocalJsDocComments(true);
Parser p = new Parser(environment, testErrorReporter);
AstRoot script = p.parse(new StringReader(string), null, 0);
assertTrue(testErrorReporter.hasEncounteredAllErrors());
assertTrue(testErrorReporter.hasEncounteredAllWarnings());
return script;
}
use of org.mozilla.javascript.CompilerEnvirons 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;
}
use of org.mozilla.javascript.CompilerEnvirons 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;
}
use of org.mozilla.javascript.CompilerEnvirons in project whole by wholeplatform.
the class RhinoTransformerVisitor method transform.
public static IEntity transform(IPersistenceProvider pp) throws Exception {
CompilerEnvirons compilerEnvirons = CompilerEnvirons.ideEnvirons();
compilerEnvirons.setLanguageVersion(Context.VERSION_1_8);
Parser parser = new Parser(compilerEnvirons);
AstRoot astRoot = parser.parse(new InputStreamReader(pp.getInputStream(), pp.getEncoding()), "http://whole.sourceforge.net/test.js", 0);
ModelBuilderOperation mop = new ModelBuilderOperation();
RhinoTransformerVisitor visitor = new RhinoTransformerVisitor(mop);
astRoot.visit(visitor);
return mop.wGetResult();
}
Aggregations