in modules/compiler/src/java/flex2/compiler/asdoc/TopLevelClassesGenerator.java [3016:3790]
private void processMethodsForChildren(Node parent)
{
// Go deep and process excludes..
NodeList listOfChilds = parent.getChildNodes();
if (listOfChilds != null && listOfChilds.getLength() != 0)
{
for (int ix = 0; ix < listOfChilds.getLength(); ix++)
{
Node childNode = listOfChilds.item(ix);
if (childNode.getNodeType() != Node.ELEMENT_NODE)
{
continue;
}
Element child = (Element)childNode;
processMethodsForChildren(child);
}
}
if (parent.getNodeName().equals("method"))
{
String name = ((Element)parent).getAttribute("name");
String fullName = ((Element)parent).getAttribute("fullname");
if (verbose)
{
System.out.println(" #processing method: " + fullName);
}
QualifiedNameInfo qualifiedFullName = decomposeFullMethodOrFieldName(fullName);
if (asDocUtil.hidePackage(qualifiedFullName.getPackageName(), hiddenPackages))
{
return;
}
boolean isBindable = false;
if (bindableTable.get(fullName) != null)
{
isBindable = true;
}
if (!isBindable && bindableTable.get(qualifiedFullName.getFullClassName()) != null)
{
isBindable = true;
}
if (verbose)
{
System.out.println(" @@ qualifiedFullName.getFullClassName() " + qualifiedFullName.getFullClassName());
}
AsClass myClass = classTable.get(qualifiedFullName.getFullClassName());
// skip class methods in the private namespace (always)
if (myClass == null || !myClass.isInterfaceFlag())
{
// constructors are always considered public, even if they're
// not declared that way
if (qualifiedFullName.getClassNames() != null || qualifiedFullName.getClassNames().size() != 0 || !name.equals(qualifiedFullName.getClassNames().get(qualifiedFullName.getClassNames().size() - 1)))
{
if (asDocUtil.hideNamespace(qualifiedFullName.getMethodNameSpace(), namespaces))
{
return;
}
}
}
if (myClass != null)
{
Element prolog = asDocUtil.getElementByTagName(myClass.getNode(), "prolog");
if (prolog != null)
{
Element asMetadata = asDocUtil.getElementByTagName(prolog, "asMetadata");
if (asMetadata != null)
{
NodeList excludeList = asMetadata.getElementsByTagName("Exclude");
if (excludeList != null && excludeList.getLength() != 0)
{
String kind = qualifiedFullName.getGetterSetter().length() != 0 ? "property" : "method";
for (int ix = 0; ix < excludeList.getLength(); ix++)
{
Element exclude = (Element)excludeList.item(ix);
if (exclude.getAttribute("kind").equals(kind))
{
if (exclude.getAttribute("name").equals(name))
{
if (verbose)
{
System.out.println("Excluding " + kind + " " + name + " from " + myClass.getName());
}
return;
}
}
}
}
}
}
}
if (myClass == null)
{
// not an error, probably a method from a class marked @private
return;
}
else if (myClass != null && qualifiedFullName.getGetterSetter().length() != 0)
{
if (verbose)
{
System.out.println(" changing method: " + fullName + " into a field (its a getter or setter)");
}
Element apiValue = outputObject.createElement("apiValue");
apiValue.setAttribute("id", asDocUtil.formatId(fullName));
Element apiName = outputObject.createElement("apiName");
apiName.setTextContent(name);
apiValue.appendChild(apiName);
Element shortdesc = outputObject.createElement("shortdesc");
apiValue.appendChild(shortdesc);
Element prolog = outputObject.createElement("prolog");
apiValue.appendChild(prolog);
Element apiValueDetail = outputObject.createElement("apiValueDetail");
Element apiValueDef = outputObject.createElement("apiValueDef");
apiValueDetail.appendChild(apiValueDef);
boolean isOverride = Boolean.parseBoolean(((Element)parent).getAttribute("isOverride"));
if (isOverride)
{
Element apiIsOverride = outputObject.createElement("apiIsOverride");
apiValueDef.appendChild(apiIsOverride);
}
apiValue.appendChild(apiValueDetail);
Element apiProperty = outputObject.createElement("apiProperty");
apiValueDef.appendChild(apiProperty);
Element apiAccess = outputObject.createElement("apiAccess");
apiAccess.setAttribute("value", qualifiedFullName.getMethodNameSpace());
apiValueDef.appendChild(apiAccess);
if (((Element)parent).getAttribute("isStatic").equals("true"))
{
Element apiStatic = outputObject.createElement("apiStatic");
apiValueDef.appendChild(apiStatic);
}
else
{
Element apiDynamic = outputObject.createElement("apiDynamic");
apiValueDef.appendChild(apiDynamic);
}
String getterSetterFullDesc = "";
NodeList descriptionList = ((Element)parent).getElementsByTagName("description");
if (descriptionList != null && descriptionList.getLength() != 0)
{
getterSetterFullDesc = descriptionList.item(0).getTextContent();
Element apiDesc = outputObject.createElement("apiDesc");
CDATASection cdata = outputObject.createCDATASection(asDocUtil.validateText(getterSetterFullDesc, "description", fullName));
apiDesc.appendChild(cdata);
apiValueDetail.appendChild(apiDesc);
asDocUtil.convertDescToDITA(apiDesc, oldNewNamesMap);
shortdesc.setTextContent(asDocUtil.descToShortDesc(getterSetterFullDesc));
}
if (isBindable)
{
apiProperty.setAttribute("isBindable", "true");
}
processVersions((Element)parent, apiValue);
if (myClass.getFieldGetSet().get(name) == null)
{
myClass.getFieldGetSet().put(name, 0);
}
// skip method tagged with @private, even if they are public
NodeList privateChilds = ((Element)parent).getElementsByTagName("private");
if ((privateChilds != null && privateChilds.getLength() != 0) && !includePrivate)
{
if (myClass.getPrivateGetSet().get(name) == null)
{
myClass.getPrivateGetSet().put(name, 0);
}
if (qualifiedFullName.getGetterSetter().equals("Get"))
{
if (myClass.getPrivateGetSet().get(name) <= 1)
{
myClass.getPrivateGetSet().put(name, 1);
myClass.getFieldGetSet().put(name, 1);
}
else
{
myClass.getPrivateGetSet().put(name, myClass.getPrivateGetSet().get(name) + 1);
myClass.getFieldGetSet().put(name, myClass.getFieldGetSet().get(name) + 1);
}
}
else
{
myClass.getPrivateGetSet().put(name, myClass.getPrivateGetSet().get(name) + 2);
myClass.getFieldGetSet().put(name, myClass.getFieldGetSet().get(name) + 2);
}
return;
}
AsClass fieldTypeClass = null;
String type = null;
if (qualifiedFullName.getGetterSetter().equals("Get"))
{
type = ((Element)parent).getAttribute("result_type");
fieldTypeClass = classTable.get(type);
if (myClass.getFieldGetSet().get(name) <= 1)
{
myClass.getFieldGetSet().put(name, 1);
}
else
{
myClass.getFieldGetSet().put(name, myClass.getFieldGetSet().get(name) + 1);
}
}
else
{
type = ((Element)parent).getAttribute("param_types");
fieldTypeClass = classTable.get(type);
myClass.getFieldGetSet().put(name, myClass.getFieldGetSet().get(name) + 2);
}
Element apiValueAccess = outputObject.createElement("apiValueAccess");
apiValueDef.appendChild(apiValueAccess);
if (fieldTypeClass != null)
{
Element apiValueClassifier = outputObject.createElement("apiValueClassifier");
apiValueClassifier.setTextContent(fieldTypeClass.getFullName());
apiValueDef.appendChild(apiValueClassifier);
}
else
{
Element apiType = outputObject.createElement("apiType");
if (type.equals("*"))
{
apiType.setAttribute("value", "any");
}
else
{
apiType.setAttribute("value", type);
}
apiValueDef.appendChild(apiType);
}
NodeList exampleList = ((Element)parent).getElementsByTagName("example");
if (exampleList != null)
{
for (int ix = 0; ix < exampleList.getLength(); ix++)
{
Element inputExampleElement = (Element)exampleList.item(ix);
Element example = outputObject.createElement("example");
CDATASection cdata = outputObject.createCDATASection(asDocUtil.validateText(inputExampleElement.getTextContent(), "example", fullName));
example.appendChild(cdata);
apiValueDetail.appendChild(example);
asDocUtil.convertDescToDITA(example, oldNewNamesMap);
}
}
NodeList throwsList = ((Element)parent).getElementsByTagName("throws");
if (throwsList != null && throwsList.getLength() != 0)
{
for (int ix = 0; ix < throwsList.getLength(); ix++)
{
Element throwsElement = (Element)throwsList.item(ix);
apiValueDef.appendChild(createCanThrow(throwsElement, qualifiedFullName));
}
}
processCustoms((Element)parent, apiValue, false, "", "", "");
if (myClass != null)
{
if (myClass.getFieldCount() == 0)
{
Element fields = outputObject.createElement("fields");
fields.appendChild(apiValue);
myClass.setFields(fields);
myClass.setFieldCount(myClass.getFieldCount() + 1);
}
else
{
Element temp = myClass.getFields();
NodeList apiValueList = temp.getElementsByTagName("apiValue");
int numChildren = apiValueList.getLength();
Element foundField = null;
for (int ix = 0; ix < numChildren; ix++)
{
if (((Element)apiValueList.item(ix)).getElementsByTagName("apiName").item(0).getTextContent().equals(apiName.getTextContent()))
{
foundField = (Element)apiValueList.item(ix);
break;
}
}
if (foundField == null)
{
myClass.getFields().appendChild(apiValue);
myClass.setFieldCount(myClass.getFieldCount() + 1);
}
else
{
boolean replaceFlag = false;
if (getterSetterFullDesc != null && getterSetterFullDesc.trim().length() != 0)
{
Element foundApiDesc = null;
Element foundApiValueDetail = asDocUtil.getElementByTagName(foundField, "apiValueDetail");
if (foundApiValueDetail != null)
{
foundApiDesc = asDocUtil.getElementByTagName(foundApiValueDetail, "apiDesc");
if (foundApiDesc != null)
{
if (foundApiDesc.getTextContent().trim().length() == 0)
{
replaceFlag = true;
}
}
else
{
replaceFlag = true;
}
if (replaceFlag)
{
temp.replaceChild(apiValue, foundField);
}
}
}
if (!replaceFlag)
{
Element foundApiValueDef = null;
Element foundApiValueDetail = null;
Element apiType = asDocUtil.getElementByTagName(apiValueDef, "apiType");
if (apiType != null)
{
foundApiValueDetail = asDocUtil.getElementByTagName(foundField, "apiValueDetail");
if (foundApiValueDetail != null)
{
foundApiValueDef = asDocUtil.getElementByTagName(foundApiValueDetail, "apiValueDef");
if (foundApiValueDef == null)
{
foundApiValueDef = outputObject.createElement("apiValueDef");
foundApiValueDetail.appendChild(foundApiValueDef);
}
}
else
{
foundApiValueDef = outputObject.createElement("apiValueDef");
foundApiValueDetail = outputObject.createElement("apiValueDetail");
foundApiValueDetail.appendChild(foundApiValueDef);
foundField.appendChild(foundApiValueDetail);
}
if (asDocUtil.getElementByTagName(foundApiValueDef, "apiType") == null)
{
foundApiValueDef.appendChild(apiType);
}
}
else
{
Element apiValueClassifier = asDocUtil.getElementByTagName(apiValueDef, "apiValueClassifier");
if (apiValueClassifier != null)
{
foundApiValueDetail = asDocUtil.getElementByTagName(foundField, "apiValueDetail");
if (foundApiValueDetail != null)
{
foundApiValueDef = asDocUtil.getElementByTagName(foundApiValueDetail, "apiValueDef");
if (foundApiValueDef == null)
{
foundApiValueDef = outputObject.createElement("apiValueDef");
foundApiValueDetail.appendChild(foundApiValueDef);
}
}
else
{
foundApiValueDef = outputObject.createElement("apiValueDef");
foundApiValueDetail = outputObject.createElement("apiValueDetail");
foundApiValueDetail.appendChild(foundApiValueDef);
foundField.appendChild(foundApiValueDetail);
}
if (asDocUtil.getElementByTagName(foundApiValueDef, "apiValueClassifier") == null)
{
foundApiValueDef.appendChild(apiValueClassifier);
}
}
else
{
if (verbose)
{
System.out.println("Error : No type definition for " + name);
}
}
}
}
}
}
}
}
else if (myClass != null)
{
// skip method tagged with @private, even if they are public
NodeList privateChilds = ((Element)parent).getElementsByTagName("private");
if ((privateChilds != null && privateChilds.getLength() != 0) && !includePrivate)
{
return;
}
Element apiOperation = null;
Element detailNode = null;
Element defNode = null;
Element shortdesc = null;
Element prolog = null;
boolean isConstructor = false;
if (qualifiedFullName.getClassNames() != null && qualifiedFullName.getClassNames().size() != 0 && name.equals(qualifiedFullName.getClassNames().get(qualifiedFullName.getClassNames().size() - 1)))
{
apiOperation = outputObject.createElement("apiConstructor");
apiOperation.setAttribute("id", asDocUtil.formatId(fullName));
Element apiName = outputObject.createElement("apiName");
apiName.setTextContent(name);
apiOperation.appendChild(apiName);
shortdesc = outputObject.createElement("shortdesc");
apiOperation.appendChild(shortdesc);
prolog = outputObject.createElement("prolog");
apiOperation.appendChild(prolog);
detailNode = outputObject.createElement("apiConstructorDetail");
defNode = outputObject.createElement("apiConstructorDef");
detailNode.appendChild(defNode);
Element apiAccess = outputObject.createElement("apiAccess");
apiAccess.setAttribute("value", qualifiedFullName.getMethodNameSpace());
defNode.appendChild(apiAccess);
apiOperation.appendChild(detailNode);
isConstructor = true;
}
else
{
boolean isFinal = Boolean.parseBoolean(((Element)parent).getAttribute("isFinal"));
boolean isOverride = Boolean.parseBoolean(((Element)parent).getAttribute("isOverride"));
boolean isStatic = Boolean.parseBoolean(((Element)parent).getAttribute("isStatic"));
if (isOverride)
{
myClass.getMethodOverrideTable().put(name, "true");
}
apiOperation = outputObject.createElement("apiOperation");
apiOperation.setAttribute("id", asDocUtil.formatId(fullName));
Element apiName = outputObject.createElement("apiName");
apiName.setTextContent(name);
apiOperation.appendChild(apiName);
shortdesc = outputObject.createElement("shortdesc");
apiOperation.appendChild(shortdesc);
prolog = outputObject.createElement("prolog");
apiOperation.appendChild(prolog);
detailNode = outputObject.createElement("apiOperationDetail");
defNode = outputObject.createElement("apiOperationDef");
detailNode.appendChild(defNode);
Element apiAccess = outputObject.createElement("apiAccess");
apiAccess.setAttribute("value", qualifiedFullName.getMethodNameSpace());
defNode.appendChild(apiAccess);
if (isFinal)
{
Element apiFinal = outputObject.createElement("apiFinal");
defNode.appendChild(apiFinal);
}
if (isStatic)
{
Element apiStatic = outputObject.createElement("apiStatic");
defNode.appendChild(apiStatic);
}
if (isOverride)
{
Element apiIsOverride = outputObject.createElement("apiIsOverride");
defNode.appendChild(apiIsOverride);
}
apiOperation.appendChild(detailNode);
}
NodeList descriptionList = ((Element)parent).getElementsByTagName("description");
if (descriptionList != null && descriptionList.getLength() != 0)
{
String fullDesc = descriptionList.item(0).getTextContent();
// if constructor for a mxml file - lets add default description of Constructor
if (isConstructor && fullDesc.length() == 0 && myClass.getSourceFile().toLowerCase().endsWith(".mxml"))
{
fullDesc = "Constructor.";
}
Element apiDesc = outputObject.createElement("apiDesc");
CDATASection cdata = outputObject.createCDATASection(asDocUtil.validateText(fullDesc, "description", fullName));
apiDesc.appendChild(cdata);
detailNode.appendChild(apiDesc);
asDocUtil.convertDescToDITA(apiDesc, oldNewNamesMap);
shortdesc.setTextContent(asDocUtil.descToShortDesc(fullDesc));
}
NodeList exampleList = ((Element)parent).getElementsByTagName("example");
if (exampleList != null)
{
for (int ix = 0; ix < exampleList.getLength(); ix++)
{
Element inputExampleElement = (Element)exampleList.item(ix);
Element example = outputObject.createElement("example");
CDATASection cdata = outputObject.createCDATASection(asDocUtil.validateText(inputExampleElement.getTextContent(), "example", fullName));
example.appendChild(cdata);
detailNode.appendChild(example);
asDocUtil.convertDescToDITA(example, oldNewNamesMap);
}
}
NodeList throwsList = ((Element)parent).getElementsByTagName("throws");
if (throwsList != null && throwsList.getLength() != 0)
{
for (int ix = 0; ix < throwsList.getLength(); ix++)
{
Element throwsElement = (Element)throwsList.item(ix);
defNode.appendChild(createCanThrow(throwsElement, myClass.getDecompName()));
}
}
NodeList authorList = ((Element)parent).getElementsByTagName("author");
if (authorList != null && authorList.getLength() != 0)
{
String author = authorList.item(0).getTextContent();
if (!author.equals(""))
{
Element authorElement = outputObject.createElement("author");
authorElement.setTextContent(author);
prolog.appendChild(authorElement);
}
}
processVersions((Element)parent, apiOperation);
if (!isConstructor)
{
NodeList returnList = ((Element)parent).getElementsByTagName("return");
Element apiReturn = outputObject.createElement("apiReturn");
if (returnList != null && returnList.getLength() != 0)
{
Element apiDesc = outputObject.createElement("apiDesc");
CDATASection cdata = outputObject.createCDATASection(asDocUtil.validateText(returnList.item(0).getTextContent(), "return", fullName));
apiDesc.appendChild(cdata);
apiReturn.appendChild(apiDesc);
defNode.appendChild(apiReturn);
asDocUtil.convertDescToDITA(apiDesc, oldNewNamesMap);
}
else
{
defNode.appendChild(apiReturn);
}
String returnType = ((Element)parent).getAttribute("result_type");
AsClass returnClass = classTable.get(returnType);
if (returnClass != null)
{
Element apiOperationClassifier = outputObject.createElement("apiOperationClassifier");
apiOperationClassifier.setTextContent(returnClass.getFullName());
apiReturn.appendChild(apiOperationClassifier);
}
else if (returnType.equals("*"))
{
Element apiType = outputObject.createElement("apiType");
apiType.setAttribute("value", "any");
apiReturn.appendChild(apiType);
}
else
{
Element apiType = outputObject.createElement("apiType");
apiType.setAttribute("value", returnType);
apiReturn.appendChild(apiType);
}
}
String paramNames = ((Element)parent).getAttribute("param_names");
String paramTypes = ((Element)parent).getAttribute("param_types");
String paramDefaults = ((Element)parent).getAttribute("param_defaults");
processCustoms((Element)parent, apiOperation, true, paramNames, paramTypes, paramDefaults, myClass);
NodeList eventList = ((Element)parent).getElementsByTagName("event");
if (eventList != null && eventList.getLength() != 0)
{
for (int ix = 0; ix < eventList.getLength(); ix++)
{
String fullEventStr = eventList.item(ix).getTextContent();
String eventCommentStr = "";
int nextSpaceIndex = fullEventStr.indexOf(" ");
String eventClassStr = null;
if (nextSpaceIndex == -1)
{
eventClassStr = "Event";
eventCommentStr = fullEventStr;
nextSpaceIndex = fullEventStr.length() - 1;
}
String eventName = fullEventStr.substring(0, nextSpaceIndex);
/*
* var apiEvent = <apiEvent
* id={formatId(method.@fullname)} generated="true">
* <apiItemName>{eventName}</apiItemName>
* <apiEventDetail/> </apiEvent>;
*/
if (eventClassStr == null)
{
int lastSpaceIndex = nextSpaceIndex + 1;
nextSpaceIndex = fullEventStr.indexOf(" ", lastSpaceIndex);
if (nextSpaceIndex == -1)
{
eventClassStr = "Event";
eventCommentStr = fullEventStr.substring(lastSpaceIndex);
}
else
{
eventClassStr = fullEventStr.substring(lastSpaceIndex, nextSpaceIndex);
eventCommentStr = fullEventStr.substring(nextSpaceIndex + 1);
}
}
if (eventClassStr != null && eventClassStr.indexOf(':') == -1 && eventClassStr.indexOf('.') != -1)
{
int periodIndex = eventClassStr.lastIndexOf('.');
eventClassStr = eventClassStr.substring(0, periodIndex) + ':' + eventClassStr.substring(periodIndex + 1);
}
AsClass eventClass = classTable.get(eventClassStr);
if (eventClass == null)
{
if (verbose)
{
System.out.println(" Can not resolve event name: " + eventClassStr + " looking in flash.events");
}
eventClass = classTable.get("flash.events:" + eventClassStr);
if (eventClass == null)
{
if (verbose)
{
System.out.println(" Can not resolve event name: " + eventClassStr + " looking in air.update.events");
}
eventClass = classTable.get("air.update.events:" + eventClassStr);
}
}
String eventId = asDocUtil.formatId(fullName) + "_" + eventName;
String eventComment = asDocUtil.validateText(eventCommentStr, "event", fullName);
Element adobeApiEvent = outputObject.createElement("adobeApiEvent");
adobeApiEvent.setAttribute("id", eventId);
Element apiName2 = outputObject.createElement("apiName");
apiName2.setTextContent(eventName);
adobeApiEvent.appendChild(apiName2);
adobeApiEvent.appendChild(outputObject.createElement("prolog"));
Element adobeApiEventDetail = outputObject.createElement("adobeApiEventDetail");
adobeApiEvent.appendChild(adobeApiEventDetail);
Element adobeApiEventDef = outputObject.createElement("adobeApiEventDef");
adobeApiEventDetail.appendChild(adobeApiEventDef);
Element apiDesc = outputObject.createElement("apiDesc");
CDATASection cdata = outputObject.createCDATASection(eventComment);
apiDesc.appendChild(cdata);
adobeApiEventDetail.appendChild(apiDesc);
if (eventClass != null)
{
Element adobeApiEventClassifier = outputObject.createElement("adobeApiEventClassifier");
adobeApiEventClassifier.setTextContent(eventClass.getFullName());
adobeApiEventDef.appendChild(adobeApiEventClassifier);
}
Element apiGeneratedEvent = outputObject.createElement("apiGeneratedEvent");
adobeApiEventDef.appendChild(apiGeneratedEvent);
asDocUtil.convertDescToDITA(apiDesc, oldNewNamesMap);
Element shortdesc2 = outputObject.createElement("shortdesc");
shortdesc2.setTextContent(asDocUtil.descToShortDesc(eventComment));
adobeApiEvent.appendChild(shortdesc2);
apiOperation.appendChild(adobeApiEvent);
if (verbose)
{
System.out.println("event handling for methods added event " + eventName + " to method " + fullName);
}
}
}
if (isConstructor)
{
Element constructors = null;
if (myClass.getConstructorCount() == 0)
{
constructors = outputObject.createElement("constructors");
myClass.setConstructors(constructors);
}
myClass.getConstructors().appendChild(apiOperation);
myClass.setConstructorCount(myClass.getConstructorCount() + 1);
}
else
{
Element methods = null;
if (myClass.getMethodCount() == 0)
{
methods = outputObject.createElement("methods");
myClass.setMethods(methods);
}
myClass.getMethods().appendChild(apiOperation);
myClass.setMethodCount(myClass.getMethodCount() + 1);
}
}
else
{
if (verbose)
{
System.out.println("can't find method for class: " + qualifiedFullName.getFullClassName());
}
}
if (verbose)
{
System.out.println(" done processing method: " + fullName);
}
}
}