private boolean hasNoExplicitAutoFinal(AnnotatedNode node) { return node.getAnnotations(MY_TYPE).isEmpty(); } }
public static boolean hasAnnotation(AnnotatedNode node, ClassNode annotation) { List annots = node.getAnnotations(annotation); return (annots != null && !annots.isEmpty()); } }
public boolean isAnnotatedBy(ASTNode node, ClassNode annotation) { return node instanceof AnnotatedNode && !((AnnotatedNode)node).getAnnotations(annotation).isEmpty(); }
/** * Adds the annotation to the internal target list if a match is found. * * @param node the node to be processed */ public void visitAnnotations(AnnotatedNode node) { super.visitAnnotations(node); for (AnnotationNode annotation : node.getAnnotations()) { if (transforms.containsKey(annotation)) { targetNodes.add(new ASTNode[]{annotation, node}); } } }
private void printAnnotations(PrintWriter out, AnnotatedNode annotated) { if (!java5) return; for (AnnotationNode annotation : annotated.getAnnotations()) { printAnnotation(out, annotation); } }
private boolean isEnabled(final AnnotatedNode node) { if (node == null) return false; List<AnnotationNode> annotations = node.getAnnotations(MY_TYPE); if (annotations != null) { // any explicit false for enabled disables functionality // this allows, for example, configscript to set all // classes to true and one class to be explicitly disabled for (AnnotationNode anno : annotations) { // abort if explicit false found if (memberHasValue(anno, "enabled", false)) return false; } } return true; }
public static AnnotationNode getAnnotation(ASTNode node, Class<?> annotationType) { if (!(node instanceof AnnotatedNode)) return null; AnnotatedNode annotated = (AnnotatedNode)node; @SuppressWarnings("unchecked") List<AnnotationNode> annotations = annotated.getAnnotations(); for (AnnotationNode a : annotations) if (a.getClassNode().getName().equals(annotationType.getName())) return a; return null; }
public void visitAnnotations(AnnotatedNode node) { List<AnnotationNode> annotations = node.getAnnotations(); if (annotations.isEmpty()) return; for (AnnotationNode an : annotations) { // skip built-in properties if (an.isBuiltIn()) continue; for (Map.Entry<String, Expression> member : an.getMembers().entrySet()) { member.setValue(transform(member.getValue())); } } }
public void visitAnnotations(AnnotatedNode node) { List<AnnotationNode> annotations = node.getAnnotations(); if (annotations.isEmpty()) return; for (AnnotationNode an : annotations) { // skip built-in properties if (an.isBuiltIn()) continue; for (Map.Entry<String, Expression> member : an.getMembers().entrySet()) { member.getValue().visit(this); } } }
public List<AnnotationNode> getAnnotations() { if (redirect!=null) return redirect.getAnnotations(); lazyClassInit(); return super.getAnnotations(); }
public void visitAnnotations(AnnotatedNode node) { List<AnnotationNode> annotations = node.getAnnotations(); if (annotations.isEmpty()) return; for (AnnotationNode an : annotations) { // skip built-in properties if (an.isBuiltIn()) continue; for (Map.Entry<String, Expression> member : an.getMembers().entrySet()) { Expression annMemberValue = member.getValue(); annMemberValue.visit(this); } } } }
public List<AnnotationNode> getAnnotations(ClassNode type) { if (redirect!=null) return redirect.getAnnotations(type); lazyClassInit(); return super.getAnnotations(type); }
/** * Convenience method to see if an annotated node is {@code @Vetoable}. * * @param node the node to check * @return true if the node is constrained */ public static boolean hasVetoableAnnotation(AnnotatedNode node) { for (AnnotationNode annotation : node.getAnnotations()) { if (constrainedClassNode.equals(annotation.getClassNode())) { return true; } } return false; }
/** * Convenience method to see if an annotated node is {@code @Bindable}. * * @param node the node to check * @return true if the node is bindable */ public static boolean hasBindableAnnotation(AnnotatedNode node) { for (AnnotationNode annotation : node.getAnnotations()) { if (boundClassNode.equals(annotation.getClassNode())) { return true; } } return false; }
@Override public void visitAnnotations(AnnotatedNode node) { super.visitAnnotations(node); for (AnnotationNode an : node.getAnnotations()) { addToCache(an.getClassNode()); } } @Override
public void visit(ASTNode[] nodes, final SourceUnit source) { if (nodes.length != 2 || !(nodes[0] instanceof AnnotationNode) || !(nodes[1] instanceof AnnotatedNode)) { throw new RuntimeException("Internal error: expecting [AnnotationNode, AnnotatedNode] but got: " + Arrays.asList(nodes)); } AnnotatedNode parent = (AnnotatedNode) nodes[1]; File f = new File("temp/log.txt"); try { ResourceGroovyMethods.append(f, parent.getClass().getSimpleName() + " " + parent.getAnnotations().get(0).getMember("value").getText() + " "); } catch (IOException e) { e.printStackTrace(); } } }
public void visitAnnotations(AnnotatedNode node) { List<AnnotationNode> annotationMap = node.getAnnotations(); if (annotationMap.isEmpty()) return; visitNode(node); for (AnnotationNode annotationNode : annotationMap) { visitNode(annotationNode); } }
@Override @SuppressWarnings("unchecked") public void visitAnnotations(AnnotatedNode node) { for (AnnotationNode an : node.getAnnotations()) { ClassNode cn = an.getClassNode(); // this comparison should be good enough, and also works in phase conversion if (cn.getNameWithoutPackage().equals(Inspect.class.getSimpleName())) { ConstantExpression name = (ConstantExpression)an.getMember("value"); if (name == null || !(name.getValue() instanceof String)) throw new AstInspectorException("@Inspect must have a String argument"); addNode(markedNodes, (String)name.getValue(), node); break; } } super.visitAnnotations(node); }
private void visitAnnotations(AnnotatedNode targetNode, AnnotatedNode sourceNode, Object visitor) { for (AnnotationNode an : sourceNode.getAnnotations()) { // skip built-in properties if (an.isBuiltIn()) continue; if (an.hasSourceRetention()) continue; AnnotationVisitor av = getAnnotationVisitor(targetNode, an, visitor); visitAnnotationAttributes(an, av); av.visitEnd(); } }
public void visit(ASTNode[] nodes, SourceUnit source) { init(nodes, source); AnnotatedNode parent = (AnnotatedNode) nodes[1]; AnnotationNode node = (AnnotationNode) nodes[0]; boolean legacyMode = LEGACY_TYPE_NAME.equals(node.getClassNode().getName()); if (!MY_TYPE.equals(node.getClassNode()) && !legacyMode) return; Expression value = node.getMember("value"); if (parent instanceof ClassNode) { List<groovy.transform.PackageScopeTarget> targets; if (value == null) targets = Collections.singletonList(legacyMode ? PackageScopeTarget.FIELDS : PackageScopeTarget.CLASS); else targets = determineTargets(value); visitClassNode((ClassNode) parent, targets); parent.getAnnotations(); } else { if (value != null) { addError("Error during " + MY_TYPE_NAME + " processing: " + TARGET_CLASS_NAME + " only allowed at class level.", parent); return; } if (parent instanceof MethodNode) { visitMethodNode((MethodNode) parent); } else if (parent instanceof FieldNode) { visitFieldNode((FieldNode) parent); } } }