本文整理汇总了Java中org.codehaus.groovy.ast.Parameter.getInitialExpression方法的典型用法代码示例。如果您正苦于以下问题:Java Parameter.getInitialExpression方法的具体用法?Java Parameter.getInitialExpression怎么用?Java Parameter.getInitialExpression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.ast.Parameter
的用法示例。
在下文中一共展示了Parameter.getInitialExpression方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformClosureExpression
import org.codehaus.groovy.ast.Parameter; //导入方法依赖的package包/类
protected Expression transformClosureExpression(ClosureExpression ce) {
boolean oldInClosure = inClosure;
inClosure = true;
Parameter[] paras = ce.getParameters();
if (paras != null) {
for (Parameter para : paras) {
ClassNode t = para.getType();
resolveOrFail(t, ce);
visitAnnotations(para);
if (para.hasInitialExpression()) {
Object initialVal = para.getInitialExpression();
if (initialVal instanceof Expression) {
para.setInitialExpression(transform((Expression) initialVal));
}
}
visitAnnotations(para);
}
}
Statement code = ce.getCode();
if (code != null) code.visit(this);
inClosure = oldInClosure;
return ce;
}
示例2: visitConstructor
import org.codehaus.groovy.ast.Parameter; //导入方法依赖的package包/类
@Override
public void visitConstructor(final ConstructorNode node) {
if (shouldSkipMethodNode(node)) {
// method has already been visited by a static type checking visitor
return;
}
for (Parameter parameter : node.getParameters()) {
if (parameter.getInitialExpression()!=null) {
parameter.getInitialExpression().visit(this);
}
}
super.visitConstructor(node);
}
示例3: startMethodInference
import org.codehaus.groovy.ast.Parameter; //导入方法依赖的package包/类
protected void startMethodInference(final MethodNode node, ErrorCollector collector) {
if (isSkipMode(node)) return;
// second, we must ensure that this method MUST be statically checked
// for example, in a mixed mode where only some methods are statically checked
// we must not visit a method which used dynamic dispatch.
// We do not check for an annotation because some other AST transformations
// may use this visitor without the annotation being explicitly set
if (!typeCheckingContext.methodsToBeVisited.isEmpty() && !typeCheckingContext.methodsToBeVisited.contains(node)) return;
// alreadyVisitedMethods prevents from visiting the same method multiple times
// and prevents from infinite loops
if (typeCheckingContext.alreadyVisitedMethods.contains(node)) return;
typeCheckingContext.alreadyVisitedMethods.add(node);
typeCheckingContext.pushErrorCollector(collector);
final boolean osc = typeCheckingContext.isInStaticContext;
try {
typeCheckingContext.isInStaticContext = node.isStatic();
super.visitMethod(node);
for (Parameter parameter : node.getParameters()) {
if (parameter.getInitialExpression()!=null) {
parameter.getInitialExpression().visit(this);
}
}
/*
ClassNode rtype = getInferredReturnType(node);
if (rtype == null) {
storeInferredReturnType(node, node.getReturnType());
}
addTypeCheckingInfoAnnotation(node);
*/
} finally {
typeCheckingContext.isInStaticContext = osc;
}
typeCheckingContext.popErrorCollector();
node.putNodeMetaData(ERROR_COLLECTOR, collector);
}
示例4: correctToGenericsSpec
import org.codehaus.groovy.ast.Parameter; //导入方法依赖的package包/类
public static MethodNode correctToGenericsSpec(Map<String,ClassNode> genericsSpec, MethodNode mn) {
ClassNode correctedType = correctToGenericsSpecRecurse(genericsSpec, mn.getReturnType());
Parameter[] origParameters = mn.getParameters();
Parameter[] newParameters = new Parameter[origParameters.length];
for (int i = 0; i < origParameters.length; i++) {
Parameter origParameter = origParameters[i];
newParameters[i] = new Parameter(correctToGenericsSpecRecurse(genericsSpec, origParameter.getType()), origParameter.getName(), origParameter.getInitialExpression());
}
return new MethodNode(mn.getName(), mn.getModifiers(), correctedType, newParameters, mn.getExceptions(), mn.getCode());
}
示例5: cloneParamsWithDefaultValues
import org.codehaus.groovy.ast.Parameter; //导入方法依赖的package包/类
static Parameter[] cloneParamsWithDefaultValues(Parameter[] source) {
Parameter[] result = new Parameter[source.length];
for (int i = 0; i < source.length; i++) {
Parameter srcParam = source[i];
Parameter dstParam = new Parameter(srcParam.getOriginType(), srcParam.getName(), srcParam.getInitialExpression());
result[i] = dstParam;
}
return result;
}
示例6: createFieldCopy
import org.codehaus.groovy.ast.Parameter; //导入方法依赖的package包/类
private static FieldNode createFieldCopy(ClassNode buildee, Parameter param) {
Map<String,ClassNode> genericsSpec = createGenericsSpec(buildee);
extractSuperClassGenerics(param.getType(), buildee, genericsSpec);
ClassNode correctedParamType = correctToGenericsSpecRecurse(genericsSpec, param.getType());
return new FieldNode(param.getName(), ACC_PRIVATE, correctedParamType, buildee, param.getInitialExpression());
}