Java Code Examples for spoon.reflect.declaration.CtMethod#getParent()
The following examples show how to use
spoon.reflect.declaration.CtMethod#getParent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: APICheckingProcessor.java From spoon-examples with GNU General Public License v2.0 | 6 votes |
@Override public boolean isToBeProcessed(CtMethod method) { // get the CtClass the method is attached to CtType parentClass = method.getParent(CtType.class); // check that the class belongs to the public API if (parentClass.getQualifiedName().contains(PACKAGE_PUBLIC_API)) { // check that the method is public if (method.isPublic()) { // check that the return type belongs to the private API CtTypeReference returnType = method.getType(); return returnType.getQualifiedName().contains(PACKAGE_PRIVATE_API); } } return false; }
Example 2
Source File: Collector.java From spoon-examples with GNU General Public License v2.0 | 5 votes |
public void collect(Launcher launcher, CtMethod<?> testMethod, List<CtLocalVariable> localVariables) { CtClass testClass = testMethod.getParent(CtClass.class); testClass.removeMethod(testMethod); CtMethod<?> clone = testMethod.clone(); instrument(clone, localVariables); testClass.addMethod(clone); System.out.println(clone); run(launcher, testClass, clone); testClass.removeMethod(clone); testClass.addMethod(testMethod); }
Example 3
Source File: EmptyMethodBodyProcessor.java From spoon-examples with GNU General Public License v2.0 | 4 votes |
public void process(CtMethod<?> element) { if (element.getParent(CtClass.class) != null && !element.getModifiers().contains(ModifierKind.ABSTRACT) && element.getBody().getStatements().isEmpty()) { emptyMethods.add(element); } }