本文整理了Java中org.codehaus.groovy.ast.AnnotationNode.setMember()
方法的一些代码示例,展示了AnnotationNode.setMember()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AnnotationNode.setMember()
方法的具体详情如下:
包路径:org.codehaus.groovy.ast.AnnotationNode
类名称:AnnotationNode
方法名:setMember
暂无
代码示例来源:origin: org.codehaus.groovy/groovy
private static void mergeParameters(AnnotationNode to, AnnotationNode from) {
for (String name : from.getMembers().keySet()) {
if (to.getMember(name) == null) {
to.setMember(name, from.getMember(name));
}
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
private void extractGrab(Expression init, ConstantExpression ce) {
if (ce.getValue() instanceof AnnotationNode) {
AnnotationNode annotation = (AnnotationNode) ce.getValue();
if ((init != null) && (annotation.getMember("initClass") != null)) {
annotation.setMember("initClass", init);
}
String name = annotation.getClassNode().getName();
if ((GRAB_CLASS_NAME.equals(name))
|| (allowShortGrab && GRAB_SHORT_NAME.equals(name))
|| (grabAliases.contains(name))) {
grabAnnotations.add(annotation);
}
if ((GRABEXCLUDE_CLASS_NAME.equals(name))
|| (allowShortGrabExcludes && GRABEXCLUDE_SHORT_NAME.equals(name))
|| (grabExcludeAliases.contains(name))) {
grabExcludeAnnotations.add(annotation);
}
if ((GRABCONFIG_CLASS_NAME.equals(name))
|| (allowShortGrabConfig && GRABCONFIG_SHORT_NAME.equals(name))
|| (grabConfigAliases.contains(name))) {
grabConfigAnnotations.add(annotation);
}
if ((GRABRESOLVER_CLASS_NAME.equals(name))
|| (allowShortGrabResolver && GRABRESOLVER_SHORT_NAME.equals(name))
|| (grabResolverAliases.contains(name))) {
grabResolverAnnotations.add(annotation);
}
}
}
代码示例来源:origin: spockframework/spock
private void addFieldMetadata(Field field) {
AnnotationNode ann = new AnnotationNode(nodeCache.FieldMetadata);
ann.setMember(FieldMetadata.NAME, new ConstantExpression(field.getName()));
ann.setMember(FieldMetadata.ORDINAL, new ConstantExpression(field.getOrdinal()));
ann.setMember(FieldMetadata.LINE, new ConstantExpression(field.getAst().getLineNumber()));
ann.setMember(FieldMetadata.INITIALIZER, new ConstantExpression(field.hasInitialExpression()));
field.getAst().addAnnotation(ann);
}
代码示例来源:origin: spockframework/spock
private void addFeatureMetadata(FeatureMethod feature) {
AnnotationNode ann = new AnnotationNode(nodeCache.FeatureMetadata);
ann.setMember(FeatureMetadata.NAME, new ConstantExpression(feature.getName()));
ann.setMember(FeatureMetadata.ORDINAL, new ConstantExpression(feature.getOrdinal()));
ann.setMember(FeatureMetadata.LINE, new ConstantExpression(feature.getAst().getLineNumber()));
ann.setMember(FeatureMetadata.BLOCKS, blockAnnElems = new ListExpression());
ListExpression paramNames = new ListExpression();
for (Parameter param : feature.getAst().getParameters())
paramNames.addExpression(new ConstantExpression(param.getName()));
ann.setMember(FeatureMetadata.PARAMETER_NAMES, paramNames);
feature.getAst().addAnnotation(ann);
}
代码示例来源:origin: spockframework/spock
private void addSpecMetadata(Spec spec) {
AnnotationNode ann = new AnnotationNode(nodeCache.SpecMetadata);
String pathname = spec.getAst().getModule().getContext().getName();
String filename = new File(pathname).getName();
ann.setMember(SpecMetadata.FILENAME, new ConstantExpression(filename));
ann.setMember(SpecMetadata.LINE, new ConstantExpression(spec.getAst().getLineNumber()));
spec.getAst().addAnnotation(ann);
}
代码示例来源:origin: org.codehaus.groovy/groovy
if (an.getClassNode().hasMethod(name, Parameter.EMPTY_ARRAY)) {
unusedNames.remove(name);
an.setMember(name, aliasAnnotationUsage.getMember(name));
代码示例来源:origin: spockframework/spock
private void addBlockMetadata(Block block, BlockKind kind) {
AnnotationNode blockAnn = new AnnotationNode(nodeCache.BlockMetadata);
blockAnn.setMember(BlockMetadata.KIND, new PropertyExpression(
new ClassExpression(nodeCache.BlockKind), kind.name()));
ListExpression textExprs = new ListExpression();
for (String text : block.getDescriptions())
textExprs.addExpression(new ConstantExpression(text));
blockAnn.setMember(BlockMetadata.TEXTS, textExprs);
blockAnnElems.addExpression(new AnnotationConstantExpression(blockAnn));
}
代码示例来源:origin: org.codehaus.groovy/groovy
protected void addTypeCheckingInfoAnnotation(final MethodNode node) {
// TypeChecked$TypeCheckingInfo can not be applied on constructors
if (node instanceof ConstructorNode) return;
// if a returned inferred type is available and no @TypeCheckingInfo is on node, then add an
// annotation to the method node
ClassNode rtype = getInferredReturnType(node);
if (rtype != null && node.getAnnotations(TYPECHECKING_INFO_NODE).isEmpty()) {
AnnotationNode anno = new AnnotationNode(TYPECHECKING_INFO_NODE);
anno.setMember("version", CURRENT_SIGNATURE_PROTOCOL);
SignatureCodec codec = SignatureCodecFactory.getCodec(CURRENT_SIGNATURE_PROTOCOL_VERSION, getTransformLoader());
String genericsSignature = codec.encode(rtype);
if (genericsSignature != null) {
ConstantExpression signature = new ConstantExpression(genericsSignature);
signature.setType(STRING_TYPE);
anno.setMember("inferredType", signature);
node.addAnnotation(anno);
}
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
RetentionPolicy value = r.value();
setRetentionPolicy(value, node);
node.setMember("value", new PropertyExpression(
new ClassExpression(ClassHelper.makeWithoutCaching(RetentionPolicy.class, false)),
value.toString()));
new ClassExpression(ClassHelper.ELEMENT_TYPE_TYPE), element.name()));
node.setMember("value", elementExprs);
} else {
Method[] declaredMethods;
if (valueExpression == null)
continue;
node.setMember(declaredMethod.getName(), valueExpression);
} catch (IllegalAccessException | InvocationTargetException e) {
代码示例来源:origin: org.codehaus.groovy/groovy
helper.addAnnotation(new AnnotationNode(COMPILESTATIC_CLASSNODE));
MethodNode serializeClass = collector.getClassNode().getMethod("serializeClass", Parameter.EMPTY_ARRAY);
collector.setMember("serializeClass", new ClassExpression(helper.getPlainNodeReference()));
代码示例来源:origin: org.codehaus.groovy/groovy
public void visit(ASTNode[] nodes, SourceUnit source) {
init(nodes, source);
AnnotatedNode parent = (AnnotatedNode) nodes[1];
AnnotationNode anno = (AnnotationNode) nodes[0];
if (!MY_TYPE.equals(anno.getClassNode())) return;
if (parent instanceof ClassNode) {
ClassNode cNode = (ClassNode) parent;
if (!checkNotInterface(cNode, MY_TYPE_NAME)) return;
ClassNode exception = getMemberClassValue(anno, "exception");
if (exception != null && Undefined.isUndefinedException(exception)) {
exception = null;
}
String message = getMemberStringValue(anno, "message");
Expression code = anno.getMember("code");
if (code != null && !(code instanceof ClosureExpression)) {
addError("Expected closure value for annotation parameter 'code'. Found " + code, cNode);
return;
}
createMethods(cNode, exception, message, (ClosureExpression) code);
if (code != null) {
anno.setMember("code", new ClosureExpression(Parameter.EMPTY_ARRAY, EmptyStatement.INSTANCE));
}
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
protected AnnotationNode annotation(AST annotationNode) {
annotationBeingDef = true;
AST node = annotationNode.getFirstChild();
String name = qualifiedName(node);
AnnotationNode annotatedNode = new AnnotationNode(ClassHelper.make(name));
configureAST(annotatedNode, annotationNode);
while (true) {
node = node.getNextSibling();
if (isType(ANNOTATION_MEMBER_VALUE_PAIR, node)) {
AST memberNode = node.getFirstChild();
String param = identifier(memberNode);
Expression expression = expression(memberNode.getNextSibling());
if (annotatedNode.getMember(param) != null) {
throw new ASTRuntimeException(memberNode, "Annotation member '" + param + "' has already been associated with a value");
}
annotatedNode.setMember(param, expression);
} else {
break;
}
}
annotationBeingDef = false;
return annotatedNode;
}
代码示例来源:origin: org.codehaus.groovy/groovy
anno.setMember("pre", new ClosureExpression(Parameter.EMPTY_ARRAY, EmptyStatement.INSTANCE));
anno.setMember("post", new ClosureExpression(Parameter.EMPTY_ARRAY, EmptyStatement.INSTANCE));
代码示例来源:origin: org.codehaus.groovy/groovy
anno.setMember("pre", new ClosureExpression(Parameter.EMPTY_ARRAY, EmptyStatement.INSTANCE));
anno.setMember("post", new ClosureExpression(Parameter.EMPTY_ARRAY, EmptyStatement.INSTANCE));
代码示例来源:origin: crashub/crash
private void handle(String name, AnnotatedNode annotated) {
for (AnnotationNode ann : (List<AnnotationNode>)annotated.getAnnotations()) {
if (ann.getClassNode().getName().endsWith(Argument.class.getName())) {
Expression expr = ann.getMember("name");
if (expr == null) {
expr = new ConstantExpression(name);
ann.setMember("name", expr);
}
}
}
}
}
代码示例来源:origin: org.codehaus.groovy/groovy
listExp.addExpression(attrExp);
if (annotation != null) {
annotation.setMember(attrName, listExp);
代码示例来源:origin: org.springframework.boot/spring-boot-cli
private void disableGrabResolvers(List<? extends AnnotatedNode> nodes) {
for (AnnotatedNode classNode : nodes) {
List<AnnotationNode> annotations = classNode.getAnnotations();
for (AnnotationNode node : new ArrayList<>(annotations)) {
if (node.getClassNode().getNameWithoutPackage()
.equals("GrabResolver")) {
node.setMember("initClass", new ConstantExpression(false));
}
}
}
}
代码示例来源:origin: org.crashub/crash.shell
private void handle(String name, AnnotatedNode annotated) {
for (AnnotationNode ann : (List<AnnotationNode>)annotated.getAnnotations()) {
if (ann.getClassNode().getName().endsWith(Argument.class.getName())) {
Expression expr = ann.getMember("name");
if (expr == null) {
expr = new ConstantExpression(name);
ann.setMember("name", expr);
}
}
}
}
}
代码示例来源:origin: com.github.corda.crash/crash.shell
private void handle(String name, AnnotatedNode annotated) {
for (AnnotationNode ann : (List<AnnotationNode>)annotated.getAnnotations()) {
if (ann.getClassNode().getName().endsWith(Argument.class.getName())) {
Expression expr = ann.getMember("name");
if (expr == null) {
expr = new ConstantExpression(name);
ann.setMember("name", expr);
}
}
}
}
}
代码示例来源:origin: org.springframework.boot/spring-boot-cli
private void addDependencyManagementBom(ModuleNode node, String module) {
AnnotatedNode annotated = getAnnotatedNode(node);
if (annotated != null) {
AnnotationNode bom = getAnnotation(annotated);
List<Expression> expressions = new ArrayList<>(
getConstantExpressions(bom.getMember("value")));
expressions.add(new ConstantExpression(module));
bom.setMember("value", new ListExpression(expressions));
}
}
内容来源于网络,如有侵权,请联系作者删除!