本文整理汇总了Java中spoon.reflect.declaration.CtMethod.removeAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java CtMethod.removeAnnotation方法的具体用法?Java CtMethod.removeAnnotation怎么用?Java CtMethod.removeAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spoon.reflect.declaration.CtMethod
的用法示例。
在下文中一共展示了CtMethod.removeAnnotation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cloneMethod
import spoon.reflect.declaration.CtMethod; //导入方法依赖的package包/类
protected CtMethod cloneMethod(CtMethod method, String suffix) {
count++;
CtMethod cloned_method = this.getFactory().Core().clone(method);
cloned_method.setParent(method.getParent());
//rename the clone
cloned_method.setSimpleName(method.getSimpleName()+suffix+cloneNumber);
cloneNumber++;
CtAnnotation toRemove = cloned_method.getAnnotations().stream()
.filter(annotation -> annotation.toString().contains("Override"))
.findFirst().orElse(null);
if(toRemove != null) {
cloned_method.removeAnnotation(toRemove);
}
mutatedMethod.add(cloned_method);
return cloned_method;
}
示例2: cloneMethod
import spoon.reflect.declaration.CtMethod; //导入方法依赖的package包/类
private CtMethod cloneMethod(CtMethod method) {
CtMethod cloned_method = method.getFactory().Core().clone(method);
CtAnnotation toRemove = cloned_method.getAnnotations().stream()
.filter(annotation -> annotation.toString().contains("Override"))
.findFirst().orElse(null);
if(toRemove != null) {
cloned_method.removeAnnotation(toRemove);
}
return cloned_method;
}
示例3: cloneMethod
import spoon.reflect.declaration.CtMethod; //导入方法依赖的package包/类
private static CtMethod cloneMethod(CtMethod method, String suffix) {
CtMethod cloned_method = method.clone();
//rename the clone
cloned_method.setSimpleName(method.getSimpleName() + (suffix.isEmpty() ? "" : suffix + cloneNumber));
cloneNumber++;
CtAnnotation toRemove = cloned_method.getAnnotations().stream()
.filter(annotation -> annotation.toString().contains("Override"))
.findFirst().orElse(null);
if (toRemove != null) {
cloned_method.removeAnnotation(toRemove);
}
return cloned_method;
}
示例4: cloneMethodTest
import spoon.reflect.declaration.CtMethod; //导入方法依赖的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;
}
示例5: cloneMethodTest
import spoon.reflect.declaration.CtMethod; //导入方法依赖的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;
}