本文整理汇总了Java中org.codehaus.groovy.ast.AnnotationNode.getMembers方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationNode.getMembers方法的具体用法?Java AnnotationNode.getMembers怎么用?Java AnnotationNode.getMembers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.ast.AnnotationNode
的用法示例。
在下文中一共展示了AnnotationNode.getMembers方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
public void visit(ASTNode[] nodes, SourceUnit source) {
AnnotationNode annotationInformation = (AnnotationNode) nodes[0];
Map<String,Expression> members = annotationInformation.getMembers();
Expression extensions = members.get("extensions");
AnnotatedNode node = (AnnotatedNode) nodes[1];
StaticTypeCheckingVisitor visitor = null;
if (node instanceof ClassNode) {
ClassNode classNode = (ClassNode) node;
visitor = newVisitor(source, classNode);
visitor.setCompilationUnit(compilationUnit);
addTypeCheckingExtensions(visitor, extensions);
visitor.initialize();
visitor.visitClass(classNode);
} else if (node instanceof MethodNode) {
MethodNode methodNode = (MethodNode) node;
visitor = newVisitor(source, methodNode.getDeclaringClass());
visitor.setCompilationUnit(compilationUnit);
addTypeCheckingExtensions(visitor, extensions);
visitor.setMethodsToBeVisited(Collections.singleton(methodNode));
visitor.initialize();
visitor.visitMethod(methodNode);
} else {
source.addError(new SyntaxException(STATIC_ERROR_PREFIX + "Unimplemented node type",
node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()));
}
if (visitor != null) {
visitor.performSecondPass();
}
}
示例2: hasClosureMember
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private static boolean hasClosureMember(AnnotationNode annotation) {
Map<String, Expression> members = annotation.getMembers();
for (Map.Entry<String, Expression> member : members.entrySet()) {
if (member.getValue() instanceof ClosureExpression) return true;
if (member.getValue() instanceof ClassExpression) {
ClassExpression classExpression = (ClassExpression) member.getValue();
Class<?> typeClass = classExpression.getType().isResolved() ? classExpression.getType().redirect().getTypeClass() : null;
if (typeClass != null && GeneratedClosure.class.isAssignableFrom(typeClass)) return true;
}
}
return false;
}
示例3: visit
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
public void visit(GroovyCodeVisitor visitor) {
AnnotationNode node = (AnnotationNode) getValue();
Map<String, Expression> attrs = node.getMembers();
for (Expression expr : attrs.values()) {
expr.visit(visitor);
}
super.visit(visitor);
}
示例4: visit
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
public AnnotationNode visit(AnnotationNode node) {
this.annotation = node;
this.reportClass = node.getClassNode();
if (!isValidAnnotationClass(node.getClassNode())) {
addError("class " + node.getClassNode().getName() + " is not an annotation");
return node;
}
// check if values have been passed for all annotation attributes that don't have defaults
if (!checkIfMandatoryAnnotationValuesPassed(node)) {
return node;
}
// if enum constants have been used, check if they are all valid
if (!checkIfValidEnumConstsAreUsed(node)) {
return node;
}
Map<String, Expression> attributes = node.getMembers();
for (Map.Entry<String, Expression> entry : attributes.entrySet()) {
String attrName = entry.getKey();
Expression attrExpr = transformInlineConstants(entry.getValue());
entry.setValue(attrExpr);
ClassNode attrType = getAttributeType(node, attrName);
visitExpression(attrName, attrExpr, attrType);
}
VMPluginFactory.getPlugin().configureAnnotation(node);
return this.annotation;
}
示例5: checkIfValidEnumConstsAreUsed
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private boolean checkIfValidEnumConstsAreUsed(AnnotationNode node) {
Map<String, Expression> attributes = node.getMembers();
for (Map.Entry<String, Expression> entry : attributes.entrySet()) {
if (!validateEnumConstant(entry.getValue()))
return false;
}
return true;
}
示例6: checkIfMandatoryAnnotationValuesPassed
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private boolean checkIfMandatoryAnnotationValuesPassed(AnnotationNode node) {
boolean ok = true;
Map attributes = node.getMembers();
ClassNode classNode = node.getClassNode();
for (MethodNode mn : classNode.getMethods()) {
String methodName = mn.getName();
// if the annotation attribute has a default, getCode() returns a ReturnStatement with the default value
if (mn.getCode() == null && !attributes.containsKey(methodName)) {
addError("No explicit/default value found for annotation attribute '" + methodName + "'", node);
ok = false;
}
}
return ok;
}
示例7: printAnnotation
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void printAnnotation(PrintWriter out, AnnotationNode annotation) {
out.print("@" + annotation.getClassNode().getName().replace('$', '.') + "(");
boolean first = true;
Map<String, Expression> members = annotation.getMembers();
for (Map.Entry<String, Expression> entry : members.entrySet()) {
String key = entry.getKey();
if (first) first = false;
else out.print(", ");
out.print(key + "=" + getAnnotationValue(entry.getValue()).replace('$', '.'));
}
out.print(") ");
}
示例8: copyMembers
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private static void copyMembers(final AnnotationNode from, final AnnotationNode to) {
Map<String, Expression> members = from.getMembers();
copyMembers(members, to);
}
示例9: visit
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
@Override
public void visit(final ASTNode[] nodes, final SourceUnit source) {
AnnotationNode annotationInformation = (AnnotationNode) nodes[0];
AnnotatedNode node = (AnnotatedNode) nodes[1];
StaticTypeCheckingVisitor visitor = null;
Map<String,Expression> members = annotationInformation.getMembers();
Expression extensions = members.get("extensions");
if (node instanceof ClassNode) {
ClassNode classNode = (ClassNode) node;
visitor = newVisitor(source, classNode);
visitor.setCompilationUnit(compilationUnit);
addTypeCheckingExtensions(visitor, extensions);
classNode.putNodeMetaData(WriterControllerFactory.class, factory);
node.putNodeMetaData(STATIC_COMPILE_NODE, !visitor.isSkipMode(node));
visitor.initialize();
visitor.visitClass(classNode);
} else if (node instanceof MethodNode) {
MethodNode methodNode = (MethodNode) node;
ClassNode declaringClass = methodNode.getDeclaringClass();
visitor = newVisitor(source, declaringClass);
visitor.setCompilationUnit(compilationUnit);
addTypeCheckingExtensions(visitor, extensions);
methodNode.putNodeMetaData(STATIC_COMPILE_NODE, !visitor.isSkipMode(node));
if (declaringClass.getNodeMetaData(WriterControllerFactory.class) == null) {
declaringClass.putNodeMetaData(WriterControllerFactory.class, factory);
}
visitor.setMethodsToBeVisited(Collections.singleton(methodNode));
visitor.initialize();
visitor.visitMethod(methodNode);
} else {
source.addError(new SyntaxException(STATIC_ERROR_PREFIX + "Unimplemented node type",
node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()));
}
if (visitor != null) {
visitor.performSecondPass();
}
StaticCompilationTransformer transformer = new StaticCompilationTransformer(source, visitor);
if (node instanceof ClassNode) {
transformer.visitClass((ClassNode) node);
} else if (node instanceof MethodNode) {
transformer.visitMethod((MethodNode) node);
}
}