assert fileScope.isDefinitionTag(definitionTag);
// An <fx:Definition> tag will create a new class.
// Save off the current class definition and scope
// because we're going to change them before recursing down.
ClassDefinition oldClassDefinition = currentClassDefinition;
TypeScope oldClassScope = currentClassScope;
// Walk the attributes looking for 'name'.
IMXMLTagAttributeData[] definitionTagAttrs = definitionTag.getAttributeDatas();
String definitionName = null;
int nameStart = -1;
int nameEnd = -1;
for (IMXMLTagAttributeData attr : definitionTagAttrs)
{
if ((!(attr instanceof IMXMLNamespaceAttributeData)) && (attr.hasValue()))
{
if ((attr.getURI() == null) && (ATTRIBUTE_NAME.equals(attr.getName())))
{
if (definitionName == null)
{
definitionName = attr.getRawValue();
nameStart = attr.getValueStart() + 1;
nameEnd = attr.getValueEnd() - 1;
}
// TODO create problem if definition name has already been set.
}
}
}
// We expect one child tag inside <fx:Definition>.
IMXMLTagData firstChild = definitionTag.getFirstChild(true);
if (firstChild != null)
{
// TODO create problem if there is more than one child tag
// in a definition.
IMXMLTagData secondChild = firstChild.getNextSibling(true);
if (secondChild != null)
return;
// This child tag specifies the base class of the definition class.
String baseClassQName = fileScope.resolveTagToQualifiedName(firstChild);
// TODO create problem if we can't resolve the base class name.
if (baseClassQName == null)
return;
// Add a class definition for the definition class to the file scope.
// The file scope will handle resolving a tag like <fx:MyDefinition>
// to the class for <fx:Definition name="MyDefinition">.
ClassDefinition fxDefinitionClassDefinition =
fileScope.addFXDefinition(qname, definitionTag, definitionName, baseClassQName);
fxDefinitionClassDefinition.setLocation(firstChild);
fxDefinitionClassDefinition.setNameLocation(nameStart, nameEnd);
// Set up the "context" for building definitions inside the definition class.
currentClassDefinition = fxDefinitionClassDefinition;
currentClassScope = (TypeScope)fxDefinitionClassDefinition.getContainedScope();
// add the definitions inside the definition tag to the definition class scope.
processTag(firstChild);
}