spoon.reflect.code.CtThisAccess Java Examples
The following examples show how to use
spoon.reflect.code.CtThisAccess.
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: InvocationResolver.java From astor with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("rawtypes") public static InvocationMatching mapImplicitInvocation(CtClass ctClassMP, CtAbstractInvocation inv0) { if (inv0 instanceof CtInvocation) { CtInvocation invocation0 = (CtInvocation) inv0; CtExpression tpr = invocation0.getTarget(); if (tpr instanceof CtThisAccess) { CtThisAccess<?> targetthis = (CtThisAccess) tpr; CtTypeReference tpref = targetthis.getType(); if (ctClassMP.isSubtypeOf(tpref)) return InvocationMatching.TARGET_SAME_TYPE; else if (chechSignatures(ctClassMP.getAllExecutables(), invocation0.getExecutable(), false)) { return InvocationMatching.SAME_SIGNATURE_FROM_DIFF_TYPE; } else { log.debug("Signature " + invocation0.getExecutable().getSignature()); log.debug( "Not compatible: " + ctClassMP.getQualifiedName() + " with " + (tpref.getQualifiedName())); return InvocationMatching.TARGET_INCOMPATIBLE; } } else { log.debug("Explicit target " + tpr); return InvocationMatching.TARGET_IS_VARIABLE; } } else { if (inv0 instanceof CtConstructorCall) { return InvocationMatching.CONTRUCTOR; } return InvocationMatching.OTHER; } }
Example #2
Source File: ReachableVariableVisitor.java From nopol with GNU General Public License v2.0 | 4 votes |
@Override public <T> void visitCtThisAccess(CtThisAccess<T> thisAccess) { /* this method has to be implemented by the non abstract class */ }
Example #3
Source File: SupportOperators.java From astor with GNU General Public License v2.0 | 4 votes |
public static List<CtInvocation> retrieveInvocationsFromMethod(CtTypeReference variableToReplaceType, CtClass classUnderAnalysis, ModificationPoint point) { List<CtInvocation> newInvocations = new ArrayList<>(); boolean isParentMethodStatic = isParentMethodStatic(point.getCodeElement()); List allMethods = SupportOperators.getAllMethodsFromClass(classUnderAnalysis); CtThisAccess<Object> createThisAccess = MutationSupporter.getFactory() .createThisAccess(MutationSupporter.getFactory().Type().objectType(), true); for (Object omethod : allMethods) { if (!(omethod instanceof CtMethod)) continue; CtMethod anotherMethod = (CtMethod) omethod; if (isParentMethodStatic && // !anotherMethod.getModifiers().contains(ModifierKind.STATIC)) { // if the modification point is in a static method, the method to call must be // static continue; } if (anotherMethod.getSimpleName().startsWith(VarReplacementByMethodCallOp.META_METHOD_LABEL)) // It's a meta-method, discard continue; boolean compatibleReturnTypes = SupportOperators.checkIsSubtype(anotherMethod.getType(), variableToReplaceType); if (compatibleReturnTypes) { List<CtInvocation> newInvToMethods = createRealInvocationsAllPosibilities(point, anotherMethod, createThisAccess); newInvocations.addAll(newInvToMethods); } } return newInvocations; }
Example #4
Source File: LabelFinder.java From gumtree-spoon-ast-diff with Apache License 2.0 | 4 votes |
@Override public <T> void visitCtThisAccess(CtThisAccess<T> thisAccess) { label = thisAccess.toString(); }