private static List<AnnotationNode> getMeta(ClassNode cn) { List<AnnotationNode> meta = cn.getNodeMetaData(AnnotationCollector.class); if (meta == null) { if (cn.isPrimaryClassNode()) { meta = getTargetListFromAnnotations(cn); } else { meta = getTargetListFromClass(cn); } cn.setNodeMetaData(AnnotationCollector.class, meta); } return meta; }
private ClassNode getHelper(final ClassNode traitReceiver) { if (helperClassNotCreatedYet(traitReceiver)) { // GROOVY-7909 A Helper class in same compilation unit may have not been created when referenced // Here create a symbol as a "placeholder" and it will be resolved later. ClassNode ret = new InnerClassNode( traitReceiver, Traits.helperClassName(traitReceiver), ACC_PUBLIC | ACC_STATIC | ACC_ABSTRACT | ACC_SYNTHETIC, ClassHelper.OBJECT_TYPE, ClassNode.EMPTY_ARRAY, null ).getPlainNodeReference(); ret.setRedirect(null); traitReceiver.redirect().setNodeMetaData(UNRESOLVED_HELPER_CLASS, ret); return ret; } else { TraitHelpersTuple helpers = Traits.findHelpers(traitReceiver); return helpers.getHelper(); } }
if (privateFieldAccessors != null) node.setNodeMetaData(PRIVATE_FIELDS_ACCESSORS, privateFieldAccessors); if (privateFieldMutators != null) node.setNodeMetaData(PRIVATE_FIELDS_MUTATORS, privateFieldMutators);
node.visitContents(this); if (classNode.getNodeMetaData(ClassNodeSkip.class) == null) { classNode.setNodeMetaData(ClassNodeSkip.class, true);
node.setNodeMetaData(PRIVATE_BRIDGE_METHODS, privateBridgeMethods);
node.visitContents(this); if (classNode.getNodeMetaData(ClassNodeSkip.class)==null) { classNode.setNodeMetaData(ClassNodeSkip.class,true);
private void handleTestRuntimeJunitSetUpAndTearDownCalls() { FieldNode junitAdapterFieldNode = classNode.getDeclaredField(JUNIT_ADAPTER_FIELD_NAME); if(junitAdapterFieldNode==null) { return; } // add rule calls to junit setup/teardown only once, there might be several test mixins applied for the same class if(classNode.redirect().getNodeMetaData(JUNIT3_RULE_SETUP_TEARDOWN_APPLIED_KEY) != Boolean.TRUE) { BlockStatement setUpMethodBody = getOrCreateNoArgsMethodBody(classNode, SET_UP_METHOD); if(!hasExistingSetUp) { setUpMethodBody.getStatements().add(0, new ExpressionStatement(new MethodCallExpression(new VariableExpression("super"), SET_UP_METHOD, GrailsArtefactClassInjector.ZERO_ARGS))); } BlockStatement tearDownMethodBody = getOrCreateNoArgsMethodBody(classNode, TEAR_DOWN_METHOD); setUpMethodBody.getStatements().add(1, new ExpressionStatement(new MethodCallExpression(new FieldExpression(junitAdapterFieldNode), SET_UP_METHOD, new VariableExpression("this")))); tearDownMethodBody.addStatement(new ExpressionStatement(new MethodCallExpression(new FieldExpression(junitAdapterFieldNode), TEAR_DOWN_METHOD, new VariableExpression("this")))); if(!hasExistingTearDown) { tearDownMethodBody.addStatement(new ExpressionStatement(new MethodCallExpression(new VariableExpression("super"), TEAR_DOWN_METHOD, GrailsArtefactClassInjector.ZERO_ARGS))); } classNode.redirect().setNodeMetaData(JUNIT3_RULE_SETUP_TEARDOWN_APPLIED_KEY, Boolean.TRUE); } } }