private void verifyAndAddTransform(AnnotationNode annotation, Class klass) { verifyClass(annotation, klass); verifyCompilePhase(annotation, klass); addTransform(annotation, klass); }
private boolean unsupportedTupleAttribute(AnnotationNode anno, String memberName) { if (getMemberValue(anno, memberName) != null) { String tname = TupleConstructorASTTransformation.MY_TYPE_NAME; addError("Error during " + MY_TYPE_NAME + " processing: Annotation attribute '" + memberName + "' not supported for " + tname + " when used with " + MY_TYPE_NAME, anno); return true; } return false; }
@Override public void call(SourceUnit source, GeneratorContext context, ClassNode classNode) throws CompilationFailedException { AnnotationCollectorTransform.ClassChanger actt = new AnnotationCollectorTransform.ClassChanger(); actt.transformClass(classNode); } }, Phases.SEMANTIC_ANALYSIS);
@GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION) public class G3839Transform2 implements ASTTransformation, Opcodes{ public void visit(ASTNode[] nodes, SourceUnit sourceUnit) { ClassNode classNode = (ClassNode) nodes[1]; classNode.addField(new FieldNode("f2", ACC_PUBLIC, ClassHelper.OBJECT_TYPE, classNode, null)); } }
public void call(SourceUnit source, GeneratorContext context, ClassNode classNode) throws CompilationFailedException { visitor.source = source; visitor.visitClass(classNode); } }, phase.getPhaseNumber());
public void visit(ASTNode[] nodes, SourceUnit source) { init(nodes, source); AnnotatedNode parent = (AnnotatedNode) nodes[1]; AnnotationNode node = (AnnotationNode) nodes[0]; if (parent instanceof ClassNode) { ClassNode classNode = (ClassNode) parent; String propertyName = getMemberStringValue(node, "property", "instance"); boolean isLazy = memberHasValue(node, "lazy", true); boolean isStrict = !memberHasValue(node, "strict", false); createField(classNode, propertyName, isLazy, isStrict); } }
public void visit(ASTNode[] nodes, SourceUnit source) { init(nodes, source); final ClassCodeVisitorSupport visitor = createVisitor(); process(nodes, visitor); }
public static void addGlobalTransformsAfterGrab(ASTTransformationsContext context) { doAddGlobalTransforms(context, false); }
private static String getPrefix(AnnotationNode anno) { return getMemberStringValue(anno, "prefix", ""); }
public void visit(ASTNode[] nodes, SourceUnit source) { init(nodes, source); AnnotatedNode parent = (AnnotatedNode) nodes[1]; AnnotationNode node = (AnnotationNode) nodes[0]; if (parent instanceof FieldNode) { final FieldNode fieldNode = (FieldNode) parent; visitField(this, node, fieldNode); } }
public void visit(ASTNode[] nodes, SourceUnit source) { init(nodes, source); AnnotationNode annotation = (AnnotationNode) nodes[0]; AnnotatedNode parent = (AnnotatedNode) nodes[1]; if (parent instanceof ClassNode) { createSortable(annotation, (ClassNode) parent); } }
private void checkAutoClash(boolean autoFlag, AnnotatedNode parent) { if (auto && !autoFlag) { addError("Error during @" + MY_NAME + " processing. The 'auto' flag can't be false at " + "method/constructor/field level if it is true at the class level.", parent); } }
public static void createEquals(ClassNode cNode, boolean includeFields, boolean callSuper, boolean useCanEqual, List<String> excludes, List<String> includes, boolean allNames) { createEquals(cNode, includeFields, callSuper, useCanEqual, excludes, includes, allNames,false); }
public static void createToString(ClassNode cNode, boolean includeSuper, boolean includeFields, List<String> excludes, List<String> includes, boolean includeNames, boolean ignoreNulls, boolean includePackage, boolean cache, boolean includeSuperProperties, boolean allProperties) { createToString(cNode, includeSuper, includeFields, excludes, includes, includeNames, ignoreNulls, includePackage, cache, includeSuperProperties, allProperties, false, false); }
protected void checkKnownProperty(BuilderASTTransformation transform, AnnotationNode anno, String name, List<PropertyInfo> properties) { for (PropertyInfo prop: properties) { if (name.equals(prop.getName())) { return; } } transform.addError("Error during " + MY_TYPE_NAME + " processing: tried to include unknown property '" + name + "'", anno); }
public int getMemberIntValue(AnnotationNode node, String name) { Object value = getMemberValue(node, name); if (value instanceof Integer) { return (Integer) value; } return 0; }
public ClassNode getMemberClassValue(AnnotationNode node, String name) { return getMemberClassValue(node, name, null); }
@GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION) public class G3839Transform1 implements ASTTransformation, Opcodes{ public void visit(ASTNode[] nodes, SourceUnit sourceUnit) { ClassNode classNode = (ClassNode) nodes[1]; classNode.addField(new FieldNode("f1", ACC_PUBLIC, ClassHelper.OBJECT_TYPE, classNode, null)); } }
public static String getMemberStringValue(AnnotationNode node, String name) { return getMemberStringValue(node, name, null); }
@GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION) public class G3839Transform3 implements ASTTransformation, Opcodes{ public void visit(ASTNode[] nodes, SourceUnit sourceUnit) { ClassNode classNode = (ClassNode) nodes[1]; classNode.addField(new FieldNode("f3", ACC_PUBLIC, ClassHelper.OBJECT_TYPE, classNode, null)); } }