use of org.codehaus.groovy.ast.MixinNode in project groovy by apache.
the class AntlrParserPlugin method innerClassDef.
protected void innerClassDef(AST classDef) {
List<AnnotationNode> annotations = new ArrayList<AnnotationNode>();
if (isType(TRAIT_DEF, classDef)) {
annotations.add(new AnnotationNode(ClassHelper.make("groovy.transform.Trait")));
}
AST node = classDef.getFirstChild();
int modifiers = Opcodes.ACC_PUBLIC;
if (isType(MODIFIERS, node)) {
modifiers = modifiers(node, annotations, modifiers);
checkNoInvalidModifier(classDef, "Class", modifiers, Opcodes.ACC_SYNCHRONIZED, "synchronized");
node = node.getNextSibling();
}
String name = identifier(node);
node = node.getNextSibling();
GenericsType[] genericsType = null;
if (isType(TYPE_PARAMETERS, node)) {
genericsType = makeGenericsType(node);
node = node.getNextSibling();
}
ClassNode superClass = null;
if (isType(EXTENDS_CLAUSE, node)) {
superClass = makeTypeWithArguments(node);
node = node.getNextSibling();
}
ClassNode[] interfaces = ClassNode.EMPTY_ARRAY;
if (isType(IMPLEMENTS_CLAUSE, node)) {
interfaces = interfaces(node);
node = node.getNextSibling();
}
// TODO read mixins
MixinNode[] mixins = {};
ClassNode outerClass = classNode;
boolean syntheticPublic = ((modifiers & Opcodes.ACC_SYNTHETIC) != 0);
modifiers &= ~Opcodes.ACC_SYNTHETIC;
if (classNode != null) {
name = classNode.getNameWithoutPackage() + "$" + name;
String fullName = dot(classNode.getPackageName(), name);
if (classNode.isInterface()) {
modifiers |= Opcodes.ACC_STATIC;
}
classNode = new InnerClassNode(classNode, fullName, modifiers, superClass, interfaces, mixins);
} else {
classNode = new ClassNode(dot(getPackageName(), name), modifiers, superClass, interfaces, mixins);
}
classNode.addAnnotations(annotations);
classNode.setGenericsTypes(genericsType);
classNode.setSyntheticPublic(syntheticPublic);
configureAST(classNode, classDef);
// we put the class already in output to avoid the most inner classes
// will be used as first class later in the loader. The first class
// there determines what GCL#parseClass for example will return, so we
// have here to ensure it won't be the inner class
output.addClass(classNode);
int oldClassCount = innerClassCounter;
assertNodeType(OBJBLOCK, node);
objectBlock(node);
classNode = outerClass;
innerClassCounter = oldClassCount;
}
Aggregations