/** Sets the definition of the ActionScript class to which this node refers. */ void setClassReference(FlexProject project, IClassDefinition classReference) { this.classReference = classReference; // TODO Optimize this by enumerating all interfaces one time. // Keep track of whether the class implements mx.core.IMXML, // because that affects code generation. String mxmlObjectInterface = project.getMXMLObjectInterface(); isMXMLObject = classReference.isInstanceOf(mxmlObjectInterface, project); // Keep track of whether the class implements mx.core.IVisualElementContainer, // because that affects code generation. String visualElementContainerInterface = project.getVisualElementContainerInterface(); isVisualElementContainer = classReference.isInstanceOf(visualElementContainerInterface, project); // Keep track of whether the class implements mx.core.IContainer, // because that affects code generation. String containerInterface = project.getContainerInterface(); isContainer = classReference.isInstanceOf(containerInterface, project); // Keep track of whether the class implements mx.core.IDeferredInstantiationUIComponent // because that affects code generation. String deferredInstantiationUIComponentInterface = project.getDeferredInstantiationUIComponentInterface(); isDeferredInstantiationUIComponent = classReference.isInstanceOf(deferredInstantiationUIComponentInterface, project); }
/** * Resolve the specifier name in the class definition to a member definition, and create a * specifier node based on the member type. * * @param builder MXML tree builder. * @param specifierName Specifier name. * @return A MXML specifier node. */ protected MXMLSpecifierNodeBase createSpecifierNode( MXMLTreeBuilder builder, String specifierName) { MXMLSpecifierNodeBase specifierNode = null; // Check if the attribute is a declared property, style, or event. FlexProject project = builder.getProject(); IDefinition specifierDefinition = project.resolveSpecifier(classReference, specifierName); if (specifierDefinition instanceof ISetterDefinition || specifierDefinition instanceof IVariableDefinition) { specifierNode = new MXMLPropertySpecifierNode(this); } else if (specifierDefinition instanceof IEventDefinition) { specifierNode = new MXMLEventSpecifierNode(this); } else if (specifierDefinition instanceof IStyleDefinition) { specifierNode = new MXMLStyleSpecifierNode(this); } else if (specifierDefinition instanceof IEffectDefinition) { specifierNode = new MXMLEffectSpecifierNode(this); } if (specifierNode != null) { specifierNode.setDefinition(specifierDefinition); // TODO Move this logic } // If not, dynamic classes allow new properties to be set via attributes. else if (classReference.isDynamic()) { specifierNode = new MXMLPropertySpecifierNode(this); ((MXMLPropertySpecifierNode) specifierNode) .setDynamicName(specifierName); // TODO Move this logic } return specifierNode; }
@Override public boolean visitClass(IClassDefinition definition) { if (manager.isAnnotation(definition)) return true; // find out if the class is annotated which in this context means // any metadata at all IMetaTag[] tags = definition.getAllMetaTags(); for (IMetaTag tag : tags) { validateClassAnnotation(definition, tag); } return true; }
/** Determines, and caches, the default property for the class to which this node refers. */ private IVariableDefinition getDefaultPropertyDefinition(MXMLTreeBuilder builder) { if (!defaultPropertyDefinitionInitialized) { FlexProject project = builder.getProject(); String defaultPropertyName = classReference.getDefaultPropertyName(project); if (defaultPropertyName != null) { defaultPropertyDefinition = (IVariableDefinition) project.resolveSpecifier(classReference, defaultPropertyName); } defaultPropertyDefinitionInitialized = true; } return defaultPropertyDefinition; }
protected void processResourceBundles( IClassDefinition class_definition, ICompilerProject project, Collection<ICompilerProblem> problems) { IMetaTag[] rbs = class_definition.getMetaTagsByName(IMetaAttributeConstants.ATTRIBUTE_RESOURCEBUNDLE); if (rbs != null) { for (IMetaTag meta : rbs) { if (meta instanceof ResourceBundleMetaTag) { try { ((ResourceBundleMetaTag) meta).resolveDependencies(problems, project); } catch (InterruptedException ie) { throw new CodegenInterruptedException(ie); } } } } }
@Override public String getName() { // The classReference can be null when getName() is called from toString() // in the debugger if the node is not yet fully initialized. return classReference != null ? classReference.getQualifiedName() : ""; }