* the class definition from the AST.
*/
private ClassDefinition extractClassDefinition(
Node targetName, Node callNode) {
JSDocInfo classInfo = NodeUtil.getBestJSDocInfo(targetName);
// name = goog.defineClass(superClass, {...}, [modifier, ...])
Node superClass = NodeUtil.getArgumentForCallOrNew(callNode, 0);
if (superClass == null ||
(!superClass.isNull() && !superClass.isQualifiedName())) {
compiler.report(JSError.make(callNode, GOOG_CLASS_SUPER_CLASS_NOT_VALID));
return null;
}
if (NodeUtil.isNullOrUndefined(superClass)
|| superClass.matchesQualifiedName("Object")) {
superClass = null;
}
Node description = NodeUtil.getArgumentForCallOrNew(callNode, 1);
if (description == null
|| !description.isObjectLit()
|| !validateObjLit(description)) {
// report bad class definition
compiler.report(JSError.make(callNode, GOOG_CLASS_DESCRIPTOR_NOT_VALID));
return null;
}
int paramCount = callNode.getChildCount() - 1;
if (paramCount > 2) {
compiler.report(JSError.make(callNode, GOOG_CLASS_UNEXPECTED_PARAMS));
return null;
}
Node constructor = extractProperty(description, "constructor");
if (classInfo != null && classInfo.isInterface()) {
if (constructor != null) {
compiler.report(JSError.make(description, GOOG_CLASS_CONSTRUCTOR_ON_INTERFACE));
return null;
}
} else if (constructor == null) {
// report missing constructor
compiler.report(JSError.make(description, GOOG_CLASS_CONSTRUCTOR_MISSING));
return null;
}
if (constructor == null) {
constructor = IR.function(
IR.name("").srcref(callNode),
IR.paramList().srcref(callNode),
IR.block().srcref(callNode));
constructor.srcref(callNode);
}
JSDocInfo info = NodeUtil.getBestJSDocInfo(constructor);
Node classModifier = null;
Node statics = null;
Node staticsProp = extractProperty(description, "statics");
if (staticsProp != null) {