current = new ClassDef(className, source);
classes.put(className, current);
// class def object
checkState(args.get(1) instanceof ObjectLiteral, node, "Ext.define arg[1] must be object");
ObjectLiteral obj = (ObjectLiteral) args.get(1);
for (ObjectProperty prop : obj.getElements()) {
String name = nameOf(prop.getLeft());
switch (name) {
// ExtJS core class def
case "extend":
// string literal only
current.setExtend(stringLiteral(prop.getRight()));
break;
case "override":
// string literal only
current.setOverride(stringLiteral(prop.getRight()));
break;
case "requires":
// array of string literals only
current.setRequires(arrayStringLiteral(prop.getRight()));
break;
case "require":
// complain if we found 'require' this almost certainly should be 'requires'
log.warn(String.format("Found 'require' and probably should be 'requires' in: %s#%s", source, prop.getLineno()));
break;
case "uses":
// array of string literals only
current.setUses(arrayStringLiteral(prop.getRight()));
break;
case "alternateClassName": {
// string literal or array of string literals
current.getAlternateClassName().addAll(stringLiterals(prop.getRight()));
break;
}
case "alias": {
// string literal or array of string literals
current.getAlias().addAll(stringLiterals(prop.getRight()));
break;
}
case "xtype": {
// string literal only
current.getAlias().add("widget." + stringLiteral(prop.getRight()));
break;
}
case "mixins": {
// array of strings, or object
List<String> mixins = Lists.newArrayList();
if (prop.getRight() instanceof ArrayLiteral) {
mixins.addAll(arrayStringLiteral(prop.getRight()));
}
else if (prop.getRight() instanceof ObjectLiteral) {
ObjectLiteral child = (ObjectLiteral) prop.getRight();
for (ObjectProperty element : child.getElements()) {
mixins.add(stringLiteral(element.getRight()));
}
}
else {
throw reportError(prop.getRight(), "Expected array or object literal only");