try
{
IRequest<ISyntaxTreeRequestResult, ICompilationUnit> syntaxTreeRequest = this.syntaxTreeRequest.get();
boolean isBindable = false;
PackageNode pkg = null;
ClassNode classNode = null;
IMetaInfo[] metaInfos = null;
final FileNode ast = createFileNode(getRootFileSpecification());
if (this.getProject() instanceof FlexProject)
{
IASNode child = ast.getChild(0);
if (child instanceof PackageNode)
{
pkg = (PackageNode)child;
IDefinitionNode[] memberNodes = pkg.getAllMemberDefinitionNodes();
if (memberNodes.length > 0 && memberNodes[0] instanceof ClassNode)
{
classNode = (ClassNode)memberNodes[0];
memberNodes = classNode.getAllMemberNodes();
metaInfos = pkg.getMetaInfos();
for (IMetaInfo metaInfo : metaInfos)
{
String name = metaInfo.getTagName();
if (name.equals("Bindable"))
{
isBindable = true;
break;
}
}
}
if (!isBindable)
{
for (IDefinitionNode memberNode : memberNodes)
{
if (memberNode instanceof BaseDefinitionNode)
{
BaseDefinitionNode bdn = (BaseDefinitionNode)memberNode;
metaInfos = bdn.getMetaInfos();
for (IMetaInfo metaInfo : metaInfos)
{
String name = metaInfo.getTagName();
if (name.equals("Bindable"))
{
isBindable = true;
break;
}
}
if (isBindable)
break;
}
}
}
if (isBindable)
{
IExpressionNode baseNode = classNode.getBaseClassNode();
Collection<IImportNode> importNodes = new ArrayList<IImportNode>();
ast.getAllImportNodes(importNodes);
if (baseNode == null)
{
// bindable class extends Object, must switch to
// extend EventDispatcher
IdentifierNode baseClassNode = new IdentifierNode("EventDispatcher");
baseClassNode.setParent(classNode);
classNode.setBaseClass(baseClassNode);
IdentifierNode flash = new IdentifierNode("flash");
IdentifierNode events = new IdentifierNode("events");
FullNameNode flashDotEvents = new FullNameNode(flash,
new ASToken(ASToken.TOKEN_OPERATOR_MEMBER_ACCESS, 0, 0, 0, 0, "."), events);
FullNameNode fullNameNode = new FullNameNode(flashDotEvents,
new ASToken(ASToken.TOKEN_OPERATOR_MEMBER_ACCESS, 0, 0, 0, 0, "."),
baseClassNode);
ImportNode importNode = new ImportNode(fullNameNode);
ScopedBlockNode sbn = (ScopedBlockNode)pkg.getChild(1);
sbn.addChild(importNode, 0);
}
}
}
}
IRequest<IFileScopeRequestResult, ICompilationUnit> fileScopeRequest = this.fileScopeRequest.get();
if ((fileScopeRequest != null) && (fileScopeRequest.isDone()))
{
ast.reconnectDefinitions((ASFileScope)fileScopeRequest.get().getScopes()[0]);
}
else
{
getProject().clearScopeCacheForCompilationUnit(this);
ast.runPostProcess(EnumSet.of(PostProcessStep.POPULATE_SCOPE));
if (isBindable)
pkg.getASScope().addImport("flash.events.EventDispatcher");
}
final ImmutableSet<String> includedFiles = ast.getIncludeHandler().getIncludedFiles();
addScopeToProjectScope(new ASFileScope[] { ast.getFileScope() });
ast.parseRequiredFunctionBodies();
final Collection<ICompilerProblem> problemCollection = ast.getProblems();