{
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,