@java.lang.Override public void set(spoon.reflect.code.CtExpression replace) { this.element.setTarget(replace); } }
@SuppressWarnings("unchecked") @Override public <T, U> U getValue(T element) { return ((U) ((Object) (castTarget(element).getTarget()))); }
@Override public <T, E extends CtExpression<?>> void scanCtTargetedExpression(CtTargetedExpression<T, E> targetedExpression) { if (child instanceof CtExpression) { targetedExpression.setTarget((E) child); return; } super.scanCtTargetedExpression(targetedExpression); }
@Override public <T, U> void setValue(T element, U value) { castTarget(element).setTarget(castValue(value)); } }
@Override public <T, E extends CtExpression<?>> void scanCtTargetedExpression(CtTargetedExpression<T, E> targetedExpression) { if (!this.jdtTreeBuilder.context.target.isEmpty() && this.jdtTreeBuilder.context.target.peek() == targetedExpression) { targetedExpression.setTarget((E) child); return; } super.scanCtTargetedExpression(targetedExpression); }
private void guardStageMethodCalls() { cxt.allNodes().forEach(node -> { List<CtInvocation<?>> invocations = node.filterBlocksForBuildingDeps((CtInvocation<?> inv) -> true); invocations.forEach(invocation -> { // the case when the declaring type is out of classpath, // to avoid NPE on the next line if (invocation.getExecutable().getDeclaringType() == null) return; CtExecutable<?> declaration = invocation.getExecutable().getDeclaration(); if (declaration == null || !(declaration instanceof CtMethod)) return; CtMethod<?> method = (CtMethod<?>) declaration; StageModel stage = cxt.getStageModelByStageMethod(method); if (stage != null && stage != node) { CtTargetedExpression guardedInvocation = stage.guardedStageMethodCall((CtInvocation) invocation, method); CtExpression<?> target = invocation.getTarget(); guardedInvocation.setTarget(target); if (target != null) target.setParent(guardedInvocation); invocation.replace(guardedInvocation); } }); }); }