constructorNode.setCode(code); constructorNode.setSyntheticPublic(syntheticPublic); constructorNode.addAnnotations(annotations); configureAST(constructorNode, constructorDef);
private void addConstructorUnlessAlreadyExisting(ClassNode classNode, ConstructorNode consNode, boolean copyConstructorAnnotations, boolean copyParameterAnnotations) { Parameter[] origParams = consNode.getParameters(); if (consNode.isPrivate()) return; Parameter[] params = new Parameter[origParams.length]; Map<String, ClassNode> genericsSpec = createGenericsSpec(classNode); extractSuperClassGenerics(classNode, classNode.getSuperClass(), genericsSpec); List<Expression> theArgs = buildParams(origParams, params, genericsSpec, copyParameterAnnotations); if (isExisting(classNode, params)) return; ConstructorNode added = addGeneratedConstructor(classNode, consNode.getModifiers(), params, consNode.getExceptions(), block(ctorSuperS(args(theArgs)))); if (copyConstructorAnnotations) { added.addAnnotations(copyAnnotatedNodeAnnotations(consNode, MY_TYPE_NAME)); } }
protected void constructorDef(AST constructorDef) { List annotations = new ArrayList(); AST node = constructorDef.getFirstChild(); int modifiers = Opcodes.ACC_PUBLIC; if (isType(MODIFIERS, node)) { modifiers = modifiers(node, annotations, modifiers); node = node.getNextSibling(); } assertNodeType(PARAMETERS, node); Parameter[] parameters = parameters(node); if (parameters == null) parameters = Parameter.EMPTY_ARRAY; node = node.getNextSibling(); ClassNode[] exceptions= ClassNode.EMPTY_ARRAY; if (isType(LITERAL_throws, node)) { AST throwsNode = node.getFirstChild(); List exceptionList = new ArrayList(); throwsList(throwsNode, exceptionList); exceptions = (ClassNode[]) exceptionList.toArray(exceptions); node = node.getNextSibling(); } assertNodeType(SLIST, node); Statement code = statementList(node); ConstructorNode constructorNode = classNode.addConstructor(modifiers, parameters, exceptions, code); constructorNode.addAnnotations(annotations); configureAST(constructorNode, constructorDef); }
protected void constructorDef(AST constructorDef) { List annotations = new ArrayList(); AST node = constructorDef.getFirstChild(); int modifiers = Opcodes.ACC_PUBLIC; if (isType(MODIFIERS, node)) { modifiers = modifiers(node, annotations, modifiers); node = node.getNextSibling(); } assertNodeType(PARAMETERS, node); Parameter[] parameters = parameters(node); if (parameters == null) parameters = Parameter.EMPTY_ARRAY; node = node.getNextSibling(); ClassNode[] exceptions= ClassNode.EMPTY_ARRAY; if (isType(LITERAL_throws, node)) { AST throwsNode = node.getFirstChild(); List exceptionList = new ArrayList(); throwsList(throwsNode, exceptionList); exceptions = (ClassNode[]) exceptionList.toArray(exceptions); node = node.getNextSibling(); } assertNodeType(SLIST, node); Statement code = statementList(node); ConstructorNode constructorNode = classNode.addConstructor(modifiers, parameters, exceptions, code); constructorNode.addAnnotations(annotations); configureAST(constructorNode, constructorDef); }
protected void constructorDef(AST constructorDef) { List annotations = new ArrayList(); AST node = constructorDef.getFirstChild(); int modifiers = Opcodes.ACC_PUBLIC; if (isType(MODIFIERS, node)) { modifiers = modifiers(node, annotations, modifiers); node = node.getNextSibling(); } assertNodeType(PARAMETERS, node); Parameter[] parameters = parameters(node); if (parameters == null) parameters = Parameter.EMPTY_ARRAY; node = node.getNextSibling(); ClassNode[] exceptions= ClassNode.EMPTY_ARRAY; if (isType(LITERAL_throws, node)) { AST throwsNode = node.getFirstChild(); List exceptionList = new ArrayList(); throwsList(throwsNode, exceptionList); exceptions = (ClassNode[]) exceptionList.toArray(exceptions); node = node.getNextSibling(); } assertNodeType(SLIST, node); Statement code = statementList(node); ConstructorNode constructorNode = classNode.addConstructor(modifiers, parameters, exceptions, code); constructorNode.addAnnotations(annotations); configureAST(constructorNode, constructorDef); }
constructorNode.setCode(code); constructorNode.setSyntheticPublic(syntheticPublic); constructorNode.addAnnotations(annotations); configureAST(constructorNode, constructorDef);