Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.InfixExpression


     *
     * @param text literal text
     * @return string concatenation expression
     */
    public InfixExpressionBuilder buildStringConcatenation(String text) {
        InfixExpression expr = getAST().newInfixExpression();
        StringLiteral strlit = getAST().newStringLiteral();
        strlit.setLiteralValue(text);
        expr.setOperator(Operator.PLUS);
        return new InfixExpressionBuilder(this, expr, strlit);
    }
View Full Code Here


     *
     * @param op operator
     * @return expression
     */
    public InfixExpressionBuilder buildInfix(Operator op) {
        InfixExpression infixex = getAST().newInfixExpression();
        infixex.setOperator(op);
        return new InfixExpressionBuilder(this, infixex);
    }
View Full Code Here

     * @param name local variable or field name
     * @param op operator
     * @return expression
     */
    public InfixExpressionBuilder buildNameOp(String name, Operator op) {
        InfixExpression infixex = getAST().newInfixExpression();
        infixex.setOperator(op);
        return new InfixExpressionBuilder(this, infixex, getAST().newSimpleName(name));
    }
View Full Code Here

     * @param name index variable name
     * @param array array name
     * @param block statement body block
     */
    public void addIndexedForStatement(String name, String array, BlockBuilder block) {
        InfixExpression test = m_ast.newInfixExpression();
        test.setOperator(Operator.LESS);
        test.setLeftOperand(m_ast.newSimpleName(name));
        FieldAccess access = m_ast.newFieldAccess();
        access.setExpression(m_ast.newSimpleName(array));
        access.setName(m_ast.newSimpleName("length"));
        test.setRightOperand(access);
        PrefixExpression post = m_ast.newPrefixExpression();
        post.setOperator(PrefixExpression.Operator.INCREMENT);
        post.setOperand(m_ast.newSimpleName(name));
        addForStatement(name, m_ast.newPrimitiveType(PrimitiveType.INT), m_ast.newNumberLiteral("0"), test,
            post, block);
View Full Code Here

  @Test
  public void testSimpleBinop() throws Exception {
    CompilationUnit simple = EclipseTACSimpleTestDriver.parseCode("SimpleBinop", SIMPLE_BINOP);
    MethodDeclaration m = EclipseTACSimpleTestDriver.getFirstMethod(simple);
    EclipseTAC tac = new EclipseTAC(m.resolveBinding());
    InfixExpression infix = (InfixExpression) EclipseTACSimpleTestDriver.getLastStatementReturn(m).getExpression();
    TACInstruction instr = tac.instruction(infix);
    Assert.assertTrue(instr != null);
    Assert.assertTrue(instr instanceof BinaryOperation);
    BinaryOperation binop = (BinaryOperation) instr;
    Assert.assertEquals(tac.variable(infix.getLeftOperand()), binop.getOperand1());
    Assert.assertEquals(tac.variable(infix.getRightOperand()), binop.getOperand2());
  }
View Full Code Here

    protected void repairBug(ASTRewrite rewrite, CompilationUnit workingUnit, BugInstance bug) throws BugResolutionException {
        assert rewrite != null;
        assert workingUnit != null;
        assert bug != null;

        InfixExpression oddnessCheck = findOddnessCheck(getASTNode(workingUnit, bug.getPrimarySourceLineAnnotation()));
        if (oddnessCheck == null) {
            throw new BugResolutionException("No matching oddness check found at the specified source line.");
        }
        Expression numberExpression = findNumberExpression(oddnessCheck);
        if (numberExpression == null) {
            throw new BugResolutionException();
        }
        InfixExpression correctOddnessCheck = createCorrectOddnessCheck(rewrite, numberExpression);
        rewrite.replace(oddnessCheck, correctOddnessCheck, null);
    }
View Full Code Here

    protected static boolean isRemainderExp(Expression remainderExp) {
        while (remainderExp instanceof ParenthesizedExpression) {
            remainderExp = ((ParenthesizedExpression) remainderExp).getExpression();
        }
        if (remainderExp instanceof InfixExpression) {
            InfixExpression exp = ((InfixExpression) remainderExp);
            return REMAINDER.equals(exp.getOperator()) && isNumber(exp.getRightOperand(), 2);
        }
        return false;
    }
View Full Code Here

    protected InfixExpression createCorrectOddnessCheck(ASTRewrite rewrite, Expression numberExpression) {
        assert rewrite != null;
        assert numberExpression != null;

        final AST ast = rewrite.getAST();
        InfixExpression andOddnessCheck = ast.newInfixExpression();
        ParenthesizedExpression parenthesizedExpression = ast.newParenthesizedExpression();
        InfixExpression andExpression = ast.newInfixExpression();

        andExpression.setLeftOperand((Expression) rewrite.createMoveTarget(numberExpression));
        andExpression.setOperator(AND);
        andExpression.setRightOperand(ast.newNumberLiteral("1"));
        parenthesizedExpression.setExpression(andExpression);
        andOddnessCheck.setLeftOperand(parenthesizedExpression);
        andOddnessCheck.setOperator(EQUALS);
        andOddnessCheck.setRightOperand(ast.newNumberLiteral("1"));
View Full Code Here

            String fieldName, Type fieldType, int indices, boolean special) {
        Block block = ast.newBlock();

        // Test if the checkpoint object is not null.
        IfStatement ifStatement = ast.newIfStatement();
        InfixExpression testExpression = ast.newInfixExpression();

        InfixExpression condition1 = ast.newInfixExpression();
        condition1.setLeftOperand(ast.newSimpleName(CHECKPOINT_NAME));
        condition1.setOperator(InfixExpression.Operator.NOT_EQUALS);
        condition1.setRightOperand(ast.newNullLiteral());

        InfixExpression condition2 = ast.newInfixExpression();
        MethodInvocation getTimestamp = ast.newMethodInvocation();
        getTimestamp.setExpression(ast.newSimpleName(CHECKPOINT_NAME));
        getTimestamp.setName(ast.newSimpleName("getTimestamp"));
        condition2.setLeftOperand(getTimestamp);
        condition2.setOperator(InfixExpression.Operator.GREATER);
        condition2.setRightOperand(ast.newNumberLiteral("0"));

        testExpression.setLeftOperand(condition1);
        testExpression.setOperator(InfixExpression.Operator.CONDITIONAL_AND);
        testExpression.setRightOperand(condition2);
        ifStatement.setExpression(testExpression);
View Full Code Here

                body.statements().add(superRestoreStatement);
            } else {
                // Restore the previous checkpoint, if necessary.
                IfStatement restoreCheckpoint = ast.newIfStatement();

                InfixExpression timestampTester = ast.newInfixExpression();
                timestampTester.setLeftOperand(ast.newSimpleName("timestamp"));
                timestampTester
                        .setOperator(InfixExpression.Operator.LESS_EQUALS);

                MethodInvocation topTimestamp = ast.newMethodInvocation();
                topTimestamp.setExpression(ast
                        .newSimpleName(CHECKPOINT_RECORD_NAME));
                topTimestamp.setName(ast.newSimpleName("getTopTimestamp"));
                timestampTester.setRightOperand(topTimestamp);
                restoreCheckpoint.setExpression(timestampTester);

                Block restoreBlock = ast.newBlock();
                restoreCheckpoint.setThenStatement(restoreBlock);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.InfixExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.