processPrimitiveEntry(node);
}
private void processPrimitiveEntry(Node node)
{
Type type = nodeTypeResolver.resolveType(node, document);
Primitive primitive = initPrimitiveValue(type, node);
CDATANode cdata = null;
if (node instanceof CDATANode)
cdata = (CDATANode)node;
else
cdata = getTextContent(node.getChildren(), false);
if (cdata != null)
{
processTextInitializer(cdata.image, type, cdata.inCDATA, cdata.beginLine);
}
else
{
// NOTE: our scanner gives us identical representations for <tag/> and <tag></tag>. Here is one place where
// that's suboptimal for usability. TODO worth doing something about?
if (!topLevel)
{
if (typeTable.stringType.isAssignableTo(type))
{
processTextInitializer("", type, true, node.beginLine);
}
else
{
log(node.beginLine, new InitializerRequired());
}
}
}
processStateAttributes(node, primitive);
String id = (String)getLanguageAttributeValue(node, StandardDefs.PROP_ID);
if (id != null || topLevel || primitive.isDeclarationEnsured())
{
if (primitive.getValue() != null)
{
if(node.comment == null)
{
node.comment = "";
}
// if generate ast if false, lets not scan the tokens here because they will be scanned later in asc scanner.
// we will go the velocity template route
if(!mxmlConfiguration.getGenerateAbstractSyntaxTree())
{
primitive.comment = node.comment;
}
else
{
primitive.comment = MxmlCommentUtil.commentToXmlComment(node.comment);
}
registerModel(id, primitive, topLevel);
}
else
{
// Note: primitives are currently the only kind of MXML tag that can be declared without initializing.
// TODO still, we should generalize 'register' to include uninitialized declarations
boolean autogenerated = false;
if (id == null)
{
// anon id has been generated
autogenerated = true;
id = primitive.getId();
}
String tempComment = null;
if(node.comment == null)
{
node.comment = "";
}
// if generate ast if false, lets not scan the tokens here because they will be scanned later in asc scanner.
// we will go the velocity template route
if(!mxmlConfiguration.getGenerateAbstractSyntaxTree())
{
tempComment = node.comment;
}
else
{
tempComment = MxmlCommentUtil.commentToXmlComment(node.comment);
}
document.addDeclaration(id, type.getName(), node.beginLine, true, topLevel, autogenerated, primitive.getBindabilityEnsured(), tempComment);
}
}
}