当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationNode.getMember方法代码示例

本文整理汇总了Java中org.codehaus.groovy.ast.AnnotationNode.getMember方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationNode.getMember方法的具体用法?Java AnnotationNode.getMember怎么用?Java AnnotationNode.getMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.groovy.ast.AnnotationNode的用法示例。


在下文中一共展示了AnnotationNode.getMember方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: changeBaseScriptTypeFromPackageOrImport

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void changeBaseScriptTypeFromPackageOrImport(final SourceUnit source, final AnnotatedNode parent, final AnnotationNode node) {
    Expression value = node.getMember("value");
    ClassNode scriptType;
    if (value == null) {
        scriptType = BASE_SCRIPT_TYPE;
    } else {
        if (!(value instanceof ClassExpression)) {
            addError("Annotation " + MY_TYPE_NAME + " member 'value' should be a class literal.", value);
            return;
        }
        scriptType = value.getType();
    }
    List<ClassNode> classes = source.getAST().getClasses();
    for (ClassNode classNode : classes) {
        if (classNode.isScriptBody()) {
            changeBaseScriptType(source, parent, classNode, scriptType, node);
        }
    }
}
 
开发者ID:remkop,项目名称:picocli,代码行数:20,代码来源:PicocliScriptASTTransformation.java

示例2: changeBaseScriptTypeFromDeclaration

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void changeBaseScriptTypeFromDeclaration(final SourceUnit source, final DeclarationExpression de, final AnnotationNode node) {
    if (de.isMultipleAssignmentDeclaration()) {
        addError("Annotation " + MY_TYPE_NAME + " not supported with multiple assignment notation.", de);
        return;
    }

    if (!(de.getRightExpression() instanceof EmptyExpression)) {
        addError("Annotation " + MY_TYPE_NAME + " not supported with variable assignment.", de);
        return;
    }
    Expression value = node.getMember("value");
    if (value != null) {
        addError("Annotation " + MY_TYPE_NAME + " cannot have member 'value' if used on a declaration.", value);
        return;
    }

    ClassNode cNode = de.getDeclaringClass();
    ClassNode baseScriptType = de.getVariableExpression().getType().getPlainNodeReference();
    de.setRightExpression(new VariableExpression("this"));

    changeBaseScriptType(source, de, cNode, baseScriptType, node);
}
 
开发者ID:remkop,项目名称:picocli,代码行数:23,代码来源:PicocliScriptASTTransformation.java

示例3: applyGroupAndVersion

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void applyGroupAndVersion(AnnotationNode annotation, String module) {
	if (module != null) {
		setMember(annotation, "module", module);
	}
	else {
		Expression expression = annotation.getMembers().get("module");
		module = (String) ((ConstantExpression) expression).getValue();
	}
	if (annotation.getMember("group") == null) {
		setMember(annotation, "group", this.resolutionContext
				.getArtifactCoordinatesResolver().getGroupId(module));
	}
	if (annotation.getMember("version") == null) {
		setMember(annotation, "version", this.resolutionContext
				.getArtifactCoordinatesResolver().getVersion(module));
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:ResolveDependencyCoordinatesTransformation.java

示例4: getTargetListFromValue

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private List<AnnotationNode> getTargetListFromValue(AnnotationNode collector, AnnotationNode aliasAnnotationUsage, SourceUnit source) {
    Expression memberValue = collector.getMember("value");
    if (memberValue == null) {
        return Collections.emptyList();
    }
    if (!(memberValue instanceof ListExpression)) {
        addError("Annotation collector expected a list of classes, but got a "+memberValue.getClass(), collector, source);
        return Collections.emptyList();
    }
    ListExpression memberListExp = (ListExpression) memberValue;
    List<Expression> memberList = memberListExp.getExpressions();
    if (memberList.isEmpty()) {
        return Collections.emptyList();
    }
    List<AnnotationNode> ret = new ArrayList<AnnotationNode>();
    for (Expression e : memberList) {
        AnnotationNode toAdd = new AnnotationNode(e.getType());
        toAdd.setSourcePosition(aliasAnnotationUsage);
        ret.add(toAdd);
    }
    return ret;
}
 
开发者ID:apache,项目名称:groovy,代码行数:23,代码来源:AnnotationCollectorTransform.java

示例5: changeBaseScriptTypeFromDeclaration

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void changeBaseScriptTypeFromDeclaration(final DeclarationExpression de, final AnnotationNode node) {
    if (de.isMultipleAssignmentDeclaration()) {
        addError("Annotation " + MY_TYPE_NAME + " not supported with multiple assignment notation.", de);
        return;
    }

    if (!(de.getRightExpression() instanceof EmptyExpression)) {
        addError("Annotation " + MY_TYPE_NAME + " not supported with variable assignment.", de);
        return;
    }
    Expression value = node.getMember("value");
    if (value != null) {
        addError("Annotation " + MY_TYPE_NAME + " cannot have member 'value' if used on a declaration.", value);
        return;
    }

    ClassNode cNode = de.getDeclaringClass();
    ClassNode baseScriptType = de.getVariableExpression().getType().getPlainNodeReference();
    de.setRightExpression(new VariableExpression("this"));

    changeBaseScriptType(de, cNode, baseScriptType);
}
 
开发者ID:apache,项目名称:groovy,代码行数:23,代码来源:BaseScriptASTTransformation.java

示例6: getMemberStringList

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
public static List<String> getMemberStringList(AnnotationNode anno, String name) {
    Expression expr = anno.getMember(name);
    if (expr == null) {
        return null;
    }
    if (expr instanceof ListExpression) {
        List<String> list = new ArrayList<String>();
        final ListExpression listExpression = (ListExpression) expr;
        if (isUndefinedMarkerList(listExpression)) {
            return null;
        }
        for (Expression itemExpr : listExpression.getExpressions()) {
            if (itemExpr != null && itemExpr instanceof ConstantExpression) {
                Object value = ((ConstantExpression) itemExpr).getValue();
                if (value != null) list.add(value.toString());
            }
        }
        return list;
    }
    return tokenize(getMemberStringValue(anno, name));
}
 
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:AbstractASTTransformation.java

示例7: getMemberList

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
@Deprecated
public List<String> getMemberList(AnnotationNode anno, String name) {
    List<String> list;
    Expression expr = anno.getMember(name);
    if (expr != null && expr instanceof ListExpression) {
        list = new ArrayList<String>();
        final ListExpression listExpression = (ListExpression) expr;
        for (Expression itemExpr : listExpression.getExpressions()) {
            if (itemExpr != null && itemExpr instanceof ConstantExpression) {
                Object value = ((ConstantExpression) itemExpr).getValue();
                if (value != null) list.add(value.toString());
            }
        }
    } else {
        list = tokenize(getMemberStringValue(anno, name));
    }
    return list;
}
 
开发者ID:apache,项目名称:groovy,代码行数:19,代码来源:AbstractASTTransformation.java

示例8: inferClosureParameterTypes

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
/**
 * This method is responsible for performing type inference on closure argument types whenever code like this is
 * found: <code>foo.collect { it.toUpperCase() }</code>.
 * In this case, the type checker tries to find if the <code>collect</code> method has its {@link Closure} argument
 * annotated with {@link groovy.transform.stc.ClosureParams}. If yes, then additional type inference can be performed
 * and the type of <code>it</code> may be inferred.
 *
 * @param receiver
 * @param arguments
 * @param expression a closure expression for which the argument types should be inferred
 * @param param the parameter where to look for a {@link groovy.transform.stc.ClosureParams} annotation.
 * @param selectedMethod the method accepting a closure
 */
protected void inferClosureParameterTypes(final ClassNode receiver, final Expression arguments, final ClosureExpression expression, final Parameter param, final MethodNode selectedMethod) {
    List<AnnotationNode> annotations = param.getAnnotations(CLOSUREPARAMS_CLASSNODE);
    if (annotations!=null && !annotations.isEmpty()) {
        for (AnnotationNode annotation : annotations) {
            Expression hintClass = annotation.getMember("value");
            Expression options = annotation.getMember("options");
            Expression resolverClass = annotation.getMember("conflictResolutionStrategy");
            if (hintClass instanceof ClassExpression) {
                doInferClosureParameterTypes(receiver, arguments, expression, selectedMethod, hintClass, resolverClass, options);
            }
        }
    } else if (isSAMType(param.getOriginType())) {
        // SAM coercion
        inferSAMType(param, receiver, selectedMethod, InvocationWriter.makeArgumentList(arguments), expression);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:30,代码来源:StaticTypeCheckingVisitor.java

示例9: getValue

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private String getValue(AnnotationNode annotation) {
	Expression expression = annotation.getMember("value");
	if (expression instanceof ConstantExpression) {
		Object value = ((ConstantExpression) expression).getValue();
		return (value instanceof String ? (String) value : null);
	}
	return null;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:ResolveDependencyCoordinatesTransformation.java

示例10: changeBaseScriptTypeFromPackageOrImport

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void changeBaseScriptTypeFromPackageOrImport(final SourceUnit source, final AnnotatedNode parent, final AnnotationNode node) {
    Expression value = node.getMember("value");
    if (!(value instanceof ClassExpression)) {
        addError("Annotation " + MY_TYPE_NAME + " member 'value' should be a class literal.", value);
        return;
    }
    List<ClassNode> classes = source.getAST().getClasses();
    for (ClassNode classNode : classes) {
        if (classNode.isScriptBody()) {
            changeBaseScriptType(parent, classNode, value.getType());
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:14,代码来源:BaseScriptASTTransformation.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 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);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:28,代码来源:PackageScopeASTTransformation.java

示例12: collectSelfTypes

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
/**
 * Collects all the self types that a type should extend or implement, given
 * the traits is implements.
 * @param receiver a class node that may implement a trait
 * @param selfTypes a collection where the list of self types will be written
 * @param checkInterfaces should the interfaces that the node implements be collected too
 * @param checkSuper should we collect from the superclass too
 * @return the selfTypes collection itself
 * @since 2.4.0
 */
public static LinkedHashSet<ClassNode> collectSelfTypes(
        ClassNode receiver,
        LinkedHashSet<ClassNode> selfTypes,
        boolean checkInterfaces,
        boolean checkSuper) {
    if (Traits.isTrait(receiver)) {
        List<AnnotationNode> annotations = receiver.getAnnotations(SELFTYPE_CLASSNODE);
        for (AnnotationNode annotation : annotations) {
            Expression value = annotation.getMember("value");
            if (value instanceof ClassExpression) {
                selfTypes.add(value.getType());
            } else if (value instanceof ListExpression) {
                List<Expression> expressions = ((ListExpression) value).getExpressions();
                for (Expression expression : expressions) {
                    if (expression instanceof ClassExpression) {
                        selfTypes.add(expression.getType());
                    }
                }
            }
        }
    }
    if (checkInterfaces) {
        ClassNode[] interfaces = receiver.getInterfaces();
        for (ClassNode anInterface : interfaces) {
            collectSelfTypes(anInterface, selfTypes, true, checkSuper);
        }
    }

    if (checkSuper) {
        ClassNode superClass = receiver.getSuperClass();
        if (superClass != null) {
            collectSelfTypes(superClass, selfTypes, checkInterfaces, true);
        }
    }
    return selfTypes;
}
 
开发者ID:apache,项目名称:groovy,代码行数:47,代码来源:Traits.java

示例13: getClassAnnotationParameter

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
protected static ClassNode getClassAnnotationParameter(AnnotationNode node, String parameterName, ClassNode defaultValue) {
    Expression member = node.getMember(parameterName);
    if (member != null) {
        if (member instanceof ClassExpression) {
            try {
                return member.getType();
            } catch (Exception e) {
                internalError("Expecting class value for " + parameterName + " annotation parameter. Found " + member + "member");
            }
        } else {
            internalError("Expecting class value for " + parameterName + " annotation parameter. Found " + member + "member");
        }
    }
    return defaultValue;
}
 
开发者ID:apache,项目名称:groovy,代码行数:16,代码来源:AbstractInterruptibleASTTransformation.java

示例14: checkForAutoDownload

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void checkForAutoDownload(AnnotationNode node) {
    Object val = node.getMember(AUTO_DOWNLOAD_SETTING);
    if (val == null || !(val instanceof ConstantExpression)) return;
    Object autoDownloadValue = ((ConstantExpression)val).getValue();
    if (!(autoDownloadValue instanceof Boolean)) return;
    autoDownload = (Boolean) autoDownloadValue;
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:GrabAnnotationTransformation.java

示例15: checkForDisableChecksums

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void checkForDisableChecksums(AnnotationNode node) {
    Object val = node.getMember(DISABLE_CHECKSUMS_SETTING);
    if (val == null || !(val instanceof ConstantExpression)) return;
    Object disableChecksumsValue = ((ConstantExpression)val).getValue();
    if (!(disableChecksumsValue instanceof Boolean)) return;
    disableChecksums = (Boolean) disableChecksumsValue;
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:GrabAnnotationTransformation.java


注:本文中的org.codehaus.groovy.ast.AnnotationNode.getMember方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。