Skip to content

Commit

Permalink
BindableFirstPassEvaluator: moved imports for IEventDispatcher out be…
Browse files Browse the repository at this point in the history
…cause class info wasn't ready yet, BindableSecondPassEvaluator: moved imports for IEventDispatcher here because class info is populated (closes #32)
  • Loading branch information
joshtynjala committed Apr 18, 2016
1 parent 6e2ea29 commit c4854ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,20 +249,6 @@ public Value evaluate(Context context, ClassDefinitionNode node)
{
bindableInfo.setClassName(NodeMagic.getUnqualifiedClassName(node));
classMap.put(NodeMagic.getClassName(node), bindableInfo);
//for some reason, bindableInfo.getClassInfo() returns null
//at this point, so we need to get it a different way.
ClassInfo classInfo = typeTable.getSymbolTable().getTypeAnalyzer().analyzeClass(context, new MultiName(NameFormatter.toColon(NodeMagic.getClassName(node))));
if(classInfo.implementsInterface(standardDefs.PACKAGE_FLASH_EVENTS, GenerativeExtension.IEVENT_DISPATCHER))
{
NodeMagic.addImport(context, node, NameFormatter.toDot(standardDefs.CLASS_EVENT));
NodeMagic.addImport(context, node, NameFormatter.toDot(standardDefs.CLASS_EVENTDISPATCHER));
NodeMagic.addImport(context, node, NameFormatter.toDot(standardDefs.INTERFACE_IEVENTDISPATCHER));
}
else
{
NodeMagic.addImport(context, node, NameFormatter.toDot(standardDefs.CLASS_STARLING_EVENT));
NodeMagic.addImport(context, node, NameFormatter.toDot(standardDefs.CLASS_STARLING_EVENTDISPATCHER));
}
NodeMagic.addImport(context, node, NameFormatter.toDot(standardDefs.CLASS_BINDINGMANAGER));
}
}
Expand Down Expand Up @@ -486,20 +472,6 @@ public void registerBindableVariable(Context context, ClassDefinitionNode classN
bInfo = new BindableInfo(context, typeTable.getSymbolTable());
bInfo.setClassName(NodeMagic.getUnqualifiedClassName(classNode));
classMap.put(NodeMagic.getClassName(classNode), bInfo);

ClassInfo classInfo = bInfo.getClassInfo();
if(classInfo.implementsInterface(StandardDefs.PACKAGE_FLASH_EVENTS,
GenerativeExtension.IEVENT_DISPATCHER))
{
NodeMagic.addImport(context, classNode, NameFormatter.toDot(standardDefs.CLASS_EVENT));
NodeMagic.addImport(context, classNode, NameFormatter.toDot(standardDefs.CLASS_EVENTDISPATCHER));
NodeMagic.addImport(context, classNode, NameFormatter.toDot(standardDefs.INTERFACE_IEVENTDISPATCHER));
}
else
{
NodeMagic.addImport(context, classNode, NameFormatter.toDot(standardDefs.CLASS_STARLING_EVENT));
NodeMagic.addImport(context, classNode, NameFormatter.toDot(standardDefs.CLASS_STARLING_EVENTDISPATCHER));
}
NodeMagic.addImport(context, classNode, NameFormatter.toDot(standardDefs.CLASS_BINDINGMANAGER));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import flex2.compiler.mxml.lang.StandardDefs;
import flex2.compiler.util.CompilerMessage;
import flex2.compiler.util.MultiName;
import flex2.compiler.util.NameFormatter;
import flex2.compiler.util.QName;
import macromedia.asc.parser.ArgumentListNode;
import macromedia.asc.parser.AttributeListNode;
Expand Down Expand Up @@ -237,14 +238,20 @@ public Value evaluate(Context context, ClassDefinitionNode node)
break;
}
}
boolean implementsFlashEventDispatcher = classInfo.implementsInterface(standardDefs.PACKAGE_FLASH_EVENTS, GenerativeExtension.IEVENT_DISPATCHER);
if (!extendsStarlingEventDispatcher &&
!classInfo.implementsInterface(standardDefs.PACKAGE_FLASH_EVENTS, GenerativeExtension.IEVENT_DISPATCHER))
!implementsFlashEventDispatcher)
{
//until we figure out how to automatically force a class to
//extend EventDispatcher, we need to use a compiler error
//instead.
context.localizedError2(node.pos(), new BindableClassDoesNotExtendEventDispatcher(classInfo.getClassName()));
}

if(implementsFlashEventDispatcher)
{
NodeMagic.addImport(context, node, NameFormatter.toDot(standardDefs.INTERFACE_IEVENTDISPATCHER));
}

if (bindableInfo.getRequiresStaticEventDispatcher() &&
(!classInfo.definesVariable(STATIC_EVENT_DISPATCHER) &&
Expand Down

0 comments on commit c4854ae

Please sign in to comment.