@Override public void enter(CtElement e) { e.setPosition(position); } });
@Override public <T, U> void setValue(T element, U value) { castTarget(element).setPosition(castValue(value)); } }
@SuppressWarnings("unchecked") void enter(CtElement e, ASTNode node) { stack.push(new ASTPair(e, node)); if (!(e instanceof CtPackage) || (compilationUnitSpoon.getFile() != null && compilationUnitSpoon.getFile().getName().equals(DefaultJavaPrettyPrinter.JAVA_PACKAGE_DECLARATION))) { if (compilationunitdeclaration != null && !e.isImplicit()) { e.setPosition(this.jdtTreeBuilder.getPositionBuilder().buildPositionCtElement(e, node)); } } ASTPair pair = stack.peek(); CtElement current = pair.element; if (current instanceof CtExpression) { while (!casts.isEmpty()) { ((CtExpression<?>) current).addTypeCast(casts.remove(0).typeRef); } } try { if (e instanceof CtTypedElement && !(e instanceof CtConstructorCall) && !(e instanceof CtCatchVariable) && node instanceof Expression) { if (((CtTypedElement<?>) e).getType() == null) { ((CtTypedElement<Object>) e).setType(this.jdtTreeBuilder.getReferencesBuilder().getTypeReference(((Expression) node).resolvedType)); } } } catch (UnsupportedOperationException ignore) { // For some element, we throw an UnsupportedOperationException when we call setType(). } }
/** * Scans an abstract element. */ // auto-generated, see spoon.generating.CloneVisitorGenerator public void scanCtElement(spoon.reflect.declaration.CtElement e) { ((spoon.reflect.declaration.CtElement) (other)).setPosition(e.getPosition()); ((spoon.reflect.declaration.CtElement) (other)).setAllMetadata(e.getAllMetadata()); ((spoon.reflect.declaration.CtElement) (other)).setImplicit(e.isImplicit()); super.scanCtElement(e); }
@Override public <E> void visitCtSwitch(CtSwitch<E> switchStatement) { if (switchStatement.getSelector() == null && child instanceof CtExpression) { switchStatement.setSelector((CtExpression<E>) child); return; } if (child instanceof CtCase) { switchStatement.addCase((CtCase<E>) child); //we have all statements of the case. Update source position now child.setPosition(jdtTreeBuilder.getPositionBuilder().buildPosition((CtCase<E>) child)); return; } super.visitCtSwitch(switchStatement); }
@Override public void enter(CtElement e) { e.setPosition(position); } });
public static void clearPosition(CtElement expCloned) { expCloned.setPosition(new NoSourcePosition()); expCloned.getElements(e -> true).stream().forEach(e -> e.setPosition(new NoSourcePosition())); }
public void clearPosition(CtExpression expCloned) { expCloned.getElements(e -> true).stream().forEach(e -> e.setPosition(new NoSourcePosition())); }
e.setPosition(cf.createSourcePosition(cu, sourceStart, sourceEnd, compilationunitdeclaration.compilationResult.lineSeparatorPositions));