本文整理汇总了Java中org.codehaus.groovy.ast.AnnotationNode.setMember方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationNode.setMember方法的具体用法?Java AnnotationNode.setMember怎么用?Java AnnotationNode.setMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.ast.AnnotationNode
的用法示例。
在下文中一共展示了AnnotationNode.setMember方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
/**
* Implementation method of the alias annotation processor. This method will
* get the list of annotations we aliased from the collector and adds it to
* aliasAnnotationUsage. The method will also map all members from
* aliasAnnotationUsage to the aliased nodes. Should a member stay unmapped,
* we will ad an error. Further processing of those members is done by the
* annotations.
*
* @param collector reference to the annotation with {@link AnnotationCollector}
* @param aliasAnnotationUsage reference to the place of usage of the alias
* @param aliasAnnotated reference to the node that has been annotated by the alias
* @param source source unit for error reporting
* @return list of the new AnnotationNodes
*/
public List<AnnotationNode> visit(AnnotationNode collector, AnnotationNode aliasAnnotationUsage, AnnotatedNode aliasAnnotated, SourceUnit source) {
List<AnnotationNode> ret = getTargetAnnotationList(collector, aliasAnnotationUsage, source);
Set<String> unusedNames = new HashSet<String>(aliasAnnotationUsage.getMembers().keySet());
for (AnnotationNode an: ret) {
for (String name : aliasAnnotationUsage.getMembers().keySet()) {
if (an.getClassNode().hasMethod(name, Parameter.EMPTY_ARRAY)) {
unusedNames.remove(name);
an.setMember(name, aliasAnnotationUsage.getMember(name));
}
}
}
if (!unusedNames.isEmpty()) {
String message = "Annotation collector got unmapped names "+unusedNames.toString()+".";
addError(message, aliasAnnotationUsage, source);
}
return ret;
}
示例2: addTypeCheckingInfoAnnotation
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
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);
}
}
}
示例3: visit
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
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(new Parameter[0], EmptyStatement.INSTANCE));
}
}
}
示例4: annotation
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
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;
}
示例5: disableGrabResolvers
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void disableGrabResolvers(List<? extends AnnotatedNode> nodes) {
for (AnnotatedNode classNode : nodes) {
List<AnnotationNode> annotations = classNode.getAnnotations();
for (AnnotationNode node : new ArrayList<AnnotationNode>(annotations)) {
if (node.getClassNode().getNameWithoutPackage()
.equals("GrabResolver")) {
node.setMember("initClass", new ConstantExpression(false));
}
}
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:ArchiveCommand.java
示例6: transformGrabAnnotation
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void transformGrabAnnotation(AnnotationNode grabAnnotation) {
grabAnnotation.setMember("initClass", new ConstantExpression(false));
String value = getValue(grabAnnotation);
if (value != null && !isConvenienceForm(value)) {
applyGroupAndVersion(grabAnnotation, value);
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:ResolveDependencyCoordinatesTransformation.java
示例7: addDependencyManagementBom
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void addDependencyManagementBom(ModuleNode node, String module) {
AnnotatedNode annotated = getAnnotatedNode(node);
if (annotated != null) {
AnnotationNode bom = getAnnotation(annotated);
List<Expression> expressions = new ArrayList<Expression>(
getConstantExpressions(bom.getMember("value")));
expressions.add(new ConstantExpression(module));
bom.setMember("value", new ListExpression(expressions));
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:GenericBomAstTransformation.java
示例8: mergeParameters
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
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));
}
}
}
示例9: extractGrab
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
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);
}
}
}
示例10: setMember
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void setMember(AnnotationNode annotation, String name, String value) {
ConstantExpression expression = new ConstantExpression(value);
annotation.setMember(name, expression);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:5,代码来源:ResolveDependencyCoordinatesTransformation.java
示例11: visit
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
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;
boolean includeFields = memberHasValue(anno, "includeFields", true);
boolean includeProperties = !memberHasValue(anno, "includeProperties", false);
boolean includeSuperProperties = memberHasValue(anno, "includeSuperProperties", true);
boolean useSetters = memberHasValue(anno, "useSetters", true);
List<String> excludes = getMemberStringList(anno, "excludes");
List<String> includes = getMemberStringList(anno, "includes");
boolean allNames = memberHasValue(anno, "allNames", true);
if (!checkIncludeExcludeUndefinedAware(anno, excludes, includes, MY_TYPE_NAME)) return;
if (!checkPropertyList(cNode, includes, "includes", anno, MY_TYPE_NAME, includeFields, includeSuperProperties, false)) return;
if (!checkPropertyList(cNode, excludes, "excludes", anno, MY_TYPE_NAME, includeFields, includeSuperProperties, false)) return;
// if @Immutable is found, let it pick up options and do work so we'll skip
if (hasAnnotation(cNode, ImmutableASTTransformation.MY_TYPE)) return;
Expression pre = anno.getMember("pre");
if (pre != null && !(pre instanceof ClosureExpression)) {
addError("Expected closure value for annotation parameter 'pre'. Found " + pre, cNode);
return;
}
Expression post = anno.getMember("post");
if (post != null && !(post instanceof ClosureExpression)) {
addError("Expected closure value for annotation parameter 'post'. Found " + post, cNode);
return;
}
createConstructor(cNode, includeFields, includeProperties, includeSuperProperties, useSetters, excludes, includes, (ClosureExpression) pre, (ClosureExpression) post, source, allNames);
if (pre != null) {
anno.setMember("pre", new ClosureExpression(new Parameter[0], EmptyStatement.INSTANCE));
}
if (post != null) {
anno.setMember("post", new ClosureExpression(new Parameter[0], EmptyStatement.INSTANCE));
}
}
}
示例12: visit
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
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;
boolean includeFields = memberHasValue(anno, "includeFields", true);
boolean includeProperties = !memberHasValue(anno, "includeProperties", false);
boolean includeSuperFields = memberHasValue(anno, "includeSuperFields", true);
boolean includeSuperProperties = memberHasValue(anno, "includeSuperProperties", true);
boolean callSuper = memberHasValue(anno, "callSuper", true);
boolean force = memberHasValue(anno, "force", true);
boolean defaults = !memberHasValue(anno, "defaults", false);
boolean useSetters = memberHasValue(anno, "useSetters", true);
List<String> excludes = getMemberStringList(anno, "excludes");
List<String> includes = getMemberStringList(anno, "includes");
boolean allNames = memberHasValue(anno, "allNames", true);
if (!checkIncludeExcludeUndefinedAware(anno, excludes, includes, MY_TYPE_NAME)) return;
if (!checkPropertyList(cNode, includes, "includes", anno, MY_TYPE_NAME, includeFields, includeSuperProperties, false, includeSuperFields)) return;
if (!checkPropertyList(cNode, excludes, "excludes", anno, MY_TYPE_NAME, includeFields, includeSuperProperties, false, includeSuperFields)) return;
// if @Immutable is found, let it pick up options and do work so we'll skip
if (hasAnnotation(cNode, ImmutableASTTransformation.MY_TYPE)) return;
Expression pre = anno.getMember("pre");
if (pre != null && !(pre instanceof ClosureExpression)) {
addError("Expected closure value for annotation parameter 'pre'. Found " + pre, cNode);
return;
}
Expression post = anno.getMember("post");
if (post != null && !(post instanceof ClosureExpression)) {
addError("Expected closure value for annotation parameter 'post'. Found " + post, cNode);
return;
}
createConstructor(this, cNode, includeFields, includeProperties, includeSuperFields, includeSuperProperties,
callSuper, force, excludes, includes, useSetters, defaults, allNames, sourceUnit,
(ClosureExpression) pre, (ClosureExpression) post);
if (pre != null) {
anno.setMember("pre", new ClosureExpression(new Parameter[0], EmptyStatement.INSTANCE));
}
if (post != null) {
anno.setMember("post", new ClosureExpression(new Parameter[0], EmptyStatement.INSTANCE));
}
}
}
示例13: createDelegatesToAnnotation
import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private AnnotationNode createDelegatesToAnnotation(ClassNode target) {
AnnotationNode delegatesTo = new AnnotationNode(DELEGATES_TO_TYPE);
delegatesTo.addMember("value", new ClassExpression(getRwClassOf(target)));
delegatesTo.setMember("strategy", constX(Closure.DELEGATE_ONLY));
return delegatesTo;
}