Google 网上论坛不再支持新的 Usenet 帖子或订阅项。历史内容仍可供查看。

Converting AST to javascript source

已查看 81 次
跳至第一个未读帖子

wflo...@googlemail.com

未读,
2013年4月10日 00:57:482013/4/10
收件人
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 个新帖子