Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Converting AST to javascript source

80 views
Skip to first unread message

wflo...@googlemail.com

unread,
Apr 10, 2013, 12:57:48 AM4/10/13
to
At the moment I'm using the AstRoot.toSource() method to generate my javascript files. But this is really slow for large js files on mobile devices (less memory), because toSource() is using a StringBuilder which holds the complete file. Is there a way to directly stream the js-code to an output file?


Example:

System.out.println("parsing js file: " + scriptUri);
Parser jsParser = new Parser();
AstRoot ast = jsParser.parse(inputStreamReader, scriptUri, 0);

System.out.println("manipulate js file: " + scriptUri);
ast.visit(new DebugInstrumentator());

System.out.println("writing js file: " + scriptUri);
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream));
writer.write(ast.toSource());
writer.close();

regards,
-cyberflohr
0 new messages