本文整理汇总了Java中spoon.reflect.reference.CtTypeReference.setPackage方法的典型用法代码示例。如果您正苦于以下问题:Java CtTypeReference.setPackage方法的具体用法?Java CtTypeReference.setPackage怎么用?Java CtTypeReference.setPackage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spoon.reflect.reference.CtTypeReference
的用法示例。
在下文中一共展示了CtTypeReference.setPackage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cloneMethodTest
import spoon.reflect.reference.CtTypeReference; //导入方法依赖的package包/类
public static CtMethod cloneMethodTest(CtMethod method, String suffix) {
CtMethod cloned_method = cloneMethod(method, suffix);
CtAnnotation testAnnotation = cloned_method.getAnnotations().stream()
.filter(annotation -> annotation.toString().contains("Test"))
.findFirst().orElse(null);
if (testAnnotation != null) {
cloned_method.removeAnnotation(testAnnotation);
}
testAnnotation = method.getFactory().Core().createAnnotation();
CtTypeReference<Object> ref = method.getFactory().Core().createTypeReference();
ref.setSimpleName("Test");
CtPackageReference refPackage = method.getFactory().Core().createPackageReference();
refPackage.setSimpleName("org.junit");
ref.setPackage(refPackage);
testAnnotation.setAnnotationType(ref);
Map<String, Object> elementValue = new HashMap<>();
elementValue.put("timeout", timeOutInMs);
testAnnotation.setElementValues(elementValue);
cloned_method.addAnnotation(testAnnotation);
return cloned_method;
}
示例2: cloneMethodTest
import spoon.reflect.reference.CtTypeReference; //导入方法依赖的package包/类
protected CtMethod cloneMethodTest(CtMethod method, String suffix, int timeOut) {
CtMethod cloned_method = cloneMethod(method,suffix);
CtAnnotation testAnnotation = cloned_method.getAnnotations().stream()
.filter(annotation -> annotation.toString().contains("Test"))
.findFirst().orElse(null);
if(testAnnotation != null) {
cloned_method.removeAnnotation(testAnnotation);
}
testAnnotation = getFactory().Core().createAnnotation();
CtTypeReference<Object> ref = getFactory().Core().createTypeReference();
ref.setSimpleName("Test");
CtPackageReference refPackage = getFactory().Core().createPackageReference();
refPackage.setSimpleName("org.junit");
ref.setPackage(refPackage);
testAnnotation.setAnnotationType(ref);
Map<String, Object> elementValue = new HashMap<String, Object>();
elementValue.put("timeout", timeOut);
testAnnotation.setElementValues(elementValue);
cloned_method.addAnnotation(testAnnotation);
ampclasses.add(cloned_method.getDeclaringType());
return cloned_method;
}