String className = dataBindingInfo.getWatcherSetupUtilClassName();
String shortName = className.substring(className.lastIndexOf(DOT) + 1);
String fileName = className.replace('.', File.separatorChar) + DOT_AS;
VirtualFile emptyFile = new TextFile(EMPTY_STRING, fileName, null, MimeMappings.AS,
compilationUnit.getSource().getLastModified());
Source result = new Source(emptyFile, EMPTY_STRING, shortName, null, false, false, false);
Context cx = AbstractSyntaxTreeUtil.generateContext(symbolTable.perCompileData, result,
symbolTable.emitter, defines);
NodeFactory nodeFactory = cx.getNodeFactory();
HashSet<String> configNamespaces = new HashSet<String>();
StatementListNode configVars = AbstractSyntaxTreeUtil.parseConfigVars(cx, configNamespaces);
ProgramNode program = AbstractSyntaxTreeUtil.generateProgram(cx, configVars, EMPTY_STRING);
StatementListNode programStatementList = program.statements;
String[] watcherImports = compilationUnit.getStandardDefs().getImports();
for (int i = 0; i < watcherImports.length; i++)
{
ImportDirectiveNode importDirective = AbstractSyntaxTreeUtil.generateImport(cx, watcherImports[i]);
programStatementList = nodeFactory.statementList(programStatementList, importDirective);
}
MetaDataNode metaDataNode = AbstractSyntaxTreeUtil.generateMetaData(nodeFactory, EXCLUDE_CLASS);
programStatementList = nodeFactory.statementList(programStatementList, metaDataNode);
ClassDefinitionNode classDefinition = generateClassDefinition(cx, configNamespaces, shortName,
dataBindingInfo, compilationUnit.getStandardDefs());
programStatementList = nodeFactory.statementList(programStatementList, classDefinition);
program.statements = programStatementList;
PackageDefinitionNode packageDefinition = nodeFactory.finishPackage(cx, null);
nodeFactory.statementList(programStatementList, packageDefinition);
CompilerContext context = new CompilerContext();
context.setAscContext(cx);
result.newCompilationUnit(program, context).setSyntaxTree(program);
// Useful when comparing abstract syntax trees
//flash.swf.tools.SyntaxTreeDumper.dump(program, "/tmp/" + className + "New.xml");
As3Compiler.cleanNodeFactory(nodeFactory);