Search in sources :

Example 1 with StringLiteralConcatenation

use of org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation in project spoon by INRIA.

the class ParentExiter method visitCtBinaryOperator.

@Override
public <T> void visitCtBinaryOperator(CtBinaryOperator<T> operator) {
    if (child instanceof CtExpression) {
        if (operator.getLeftHandOperand() == null) {
            operator.setLeftHandOperand((CtExpression<?>) child);
            return;
        } else if (operator.getRightHandOperand() == null) {
            operator.setRightHandOperand((CtExpression<?>) child);
            return;
        } else if (jdtTreeBuilder.getContextBuilder().stack.peek().node instanceof StringLiteralConcatenation) {
            CtBinaryOperator<?> op = operator.getFactory().Core().createBinaryOperator();
            op.setKind(BinaryOperatorKind.PLUS);
            op.setLeftHandOperand(operator.getRightHandOperand());
            op.setRightHandOperand((CtExpression<?>) child);
            operator.setRightHandOperand(op);
            int[] lineSeparatorPositions = this.jdtTreeBuilder.getContextBuilder().compilationunitdeclaration.compilationResult.lineSeparatorPositions;
            SourcePosition leftPosition = op.getLeftHandOperand().getPosition();
            SourcePosition rightPosition = op.getRightHandOperand().getPosition();
            op.setPosition(op.getFactory().createSourcePosition(leftPosition.getCompilationUnit(), leftPosition.getSourceStart(), rightPosition.getSourceEnd(), lineSeparatorPositions));
            return;
        }
    }
    super.visitCtBinaryOperator(operator);
}
Also used : CtExpression(spoon.reflect.code.CtExpression) SourcePosition(spoon.reflect.cu.SourcePosition) StringLiteralConcatenation(org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation)

Aggregations

StringLiteralConcatenation (org.eclipse.jdt.internal.compiler.ast.StringLiteralConcatenation)1 CtExpression (spoon.reflect.code.CtExpression)1 SourcePosition (spoon.reflect.cu.SourcePosition)1