Package org.eclipse.jdt.core.dom

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


     *   current object and the new value are the same; if not, assign the
     *   checkpoint object of the current object to the checkpoint of the new
     *   value.
     */
    private Statement _createSetCheckpointInvocation(AST ast) {
        InfixExpression test = ast.newInfixExpression();

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

        InfixExpression condition2 = ast.newInfixExpression();
        condition2.setLeftOperand(ast.newSimpleName(CHECKPOINT_NAME));
        condition2.setOperator(InfixExpression.Operator.NOT_EQUALS);

        MethodInvocation getCheckpoint = ast.newMethodInvocation();
        getCheckpoint.setExpression(ast.newSimpleName("newValue"));
        getCheckpoint.setName(ast
                .newSimpleName(_getGetCheckpointMethodName(false)));
        condition2.setRightOperand(getCheckpoint);

        test.setLeftOperand(condition1);
        test.setOperator(InfixExpression.Operator.CONDITIONAL_AND);
        test.setRightOperand(condition2);

View Full Code Here


                root)));

        if (!isInterface) {
            // The test.
            IfStatement test = ast.newIfStatement();
            InfixExpression testExpression = ast.newInfixExpression();
            testExpression.setLeftOperand(ast.newSimpleName(CHECKPOINT_NAME));
            testExpression.setOperator(InfixExpression.Operator.NOT_EQUALS);
            testExpression.setRightOperand(ast.newSimpleName("checkpoint"));
            test.setExpression(testExpression);

            // The "then" branch of the test.
            Block thenBranch = ast.newBlock();
            test.setThenStatement(thenBranch);

            Block body = ast.newBlock();
            body.statements().add(test);
            method.setBody(body);

            // Backup the old checkpoint.
            VariableDeclarationFragment fragment = ast
                    .newVariableDeclarationFragment();
            fragment.setName(ast.newSimpleName("oldCheckpoint"));
            fragment.setInitializer(ast.newSimpleName(CHECKPOINT_NAME));

            VariableDeclarationStatement tempDeclaration = ast
                    .newVariableDeclarationStatement(fragment);
            tempDeclaration.setType(createType(ast, checkpointType));
            thenBranch.statements().add(tempDeclaration);

            // Record the old checkpoint if the new checkpoint is not null.
            // If it is null, it is impossible to roll back to the previous
            // checkpoint.
            IfStatement testNewCheckpoint = ast.newIfStatement();
            InfixExpression testNull = ast.newInfixExpression();
            testNull.setLeftOperand(ast.newSimpleName("checkpoint"));
            testNull.setOperator(InfixExpression.Operator.NOT_EQUALS);
            testNull.setRightOperand(ast.newNullLiteral());
            testNewCheckpoint.setExpression(testNull);

            Block testNewCheckpointBody = ast.newBlock();
            testNewCheckpoint.setThenStatement(testNewCheckpointBody);
View Full Code Here

        } else {
            rightHand = (Expression) ASTNode.copySubtree(ast, rightHand);

            if (isSpecial && type.getName().equals(String.class.getName())
                    && !type.equals(rightHandType)) {
                InfixExpression extraPlus = ast.newInfixExpression();
                extraPlus.setLeftOperand(ast.newStringLiteral());
                extraPlus.setOperator(InfixExpression.Operator.PLUS);
                extraPlus.setRightOperand(rightHand);
                rightHand = extraPlus;
            }
        }

        invocation.arguments().add(rightHand);
View Full Code Here

  boolean isStringContant(Expression arg) {
    if(arg instanceof StringLiteral) {
      return true;
    } else
    if(arg instanceof InfixExpression) {
      InfixExpression infixExpr = (InfixExpression) arg;
      if(!isStringContant(infixExpr.getLeftOperand())) return false;
      if(!isStringContant(infixExpr.getRightOperand())) return false;
           
      for(Iterator iter2 = infixExpr.extendedOperands().iterator(); iter2.hasNext(); ) {
        if(!isStringContant((Expression) iter2.next())) {
          return false;
        }
      }
      return true;
View Full Code Here

     */
    public static boolean isStringContant(Expression arg, CompilationUnit unit, IResource resource) {
        if (arg instanceof StringLiteral) {
            return true;
        } else if (arg instanceof InfixExpression) {
            InfixExpression infixExpr = (InfixExpression) arg;
            if (!isStringContant(infixExpr.getLeftOperand(), unit, resource)) return false;
            if (!isStringContant(infixExpr.getRightOperand(), unit, resource)) return false;
            for (Iterator iter2 = infixExpr.extendedOperands().iterator(); iter2.hasNext();) {
                if (!isStringContant((Expression) iter2.next(), unit, resource)) {
                    return false;
                }
            }
            return true;
View Full Code Here

    } else
//    if(arg instanceof SimpleName) {
//      // find out if the name is final...
//    } else
    if(arg instanceof InfixExpression) {
      InfixExpression infixExpr = (InfixExpression) arg;
      if(!isStringContant(infixExpr.getLeftOperand(), cu, resource)) return false;
      if(!isStringContant(infixExpr.getRightOperand(), cu, resource)) return false;
           
      for(Iterator iter2 = infixExpr.extendedOperands().iterator(); iter2.hasNext(); ) {
        if(!isStringContant((Expression) iter2.next(), cu, resource)) {
          return false;
        }
      }
      return true;
View Full Code Here

    } else
    if ( e instanceof InfixExpression && ( ((InfixExpression)e).getOperator() == InfixExpression.Operator.PLUS ) ) {
      /**
       * Follow arguments of a string concatenation.
       * */
      InfixExpression ie   = (InfixExpression) e;
      Expression leftExpr  = ie.getLeftOperand();
      Expression rightExpr = ie.getRightOperand();
      HistoryDefinitionLocation concatDL;
      if(!first){
      concatDL = new HistoryDefinitionLocation(
          e.toString(),
          resource,
          cu.getLineNumber(e.getStartPosition()),
          e,
          parent, HistoryDefinitionLocation.STRING_CONCAT);
      }
      else
      concatDL=parent;
     
      if(registerExpansion(concatDL)) {
        processExpression(concatDL, leftExpr,  cu, resource, stack, monitor, HistoryDefinitionLocation.COPY,false);
        processExpression(concatDL, rightExpr, cu, resource, stack, monitor, HistoryDefinitionLocation.COPY,false);
        if(ie.extendedOperands() != null) {
            for(Iterator iter = ie.extendedOperands().iterator(); iter.hasNext(); ) {
                Expression ext_e = (Expression) iter.next();
               
                processExpression(concatDL, ext_e, cu, resource, stack, monitor, HistoryDefinitionLocation.COPY,false);                     
            }
        }
View Full Code Here

     
      // finish the job       
      monitor.done();
      }
    else if(covering instanceof InfixExpression){
      InfixExpression infixExpr = (InfixExpression) covering;
      HistoryDefinitionLocation dl = new HistoryDefinitionLocation(
          infixExpr.toString(),
          (IFile)resource,
          unit.getLineNumber(0),
          covering,null, HistoryDefinitionLocation.STRING_CONCAT);
     
      processExpression(dl, infixExpr, unit, resource, new LinkedList<MethodInvocation>(), monitor, HistoryDefinitionLocation.INITIAL,true);
View Full Code Here

     */
    public static boolean isStringContant(Expression arg, CompilationUnit unit, IResource resource) {
        if (arg instanceof StringLiteral) {
            return true;
        } else if (arg instanceof InfixExpression) {
            InfixExpression infixExpr = (InfixExpression) arg;
            if (!isStringContant(infixExpr.getLeftOperand(), unit, resource)) return false;
            if (!isStringContant(infixExpr.getRightOperand(), unit, resource)) return false;
            for (Iterator iter2 = infixExpr.extendedOperands().iterator(); iter2.hasNext();) {
                if (!isStringContant((Expression) iter2.next(), unit, resource)) {
                    return false;
                }
            }
            return true;
View Full Code Here

  private void rewriteExpressions(CompilationUnit node, SearchMatch match,
      RefactoringStatus status, ASTRewrite astRewrite,
      ImportRewrite importRewrite) {
    final ASTNode result = NodeFinder.perform(node, match.getOffset(),
        match.getLength());
    final InfixExpression ie = Util.getInfixExpression(result);
    if (ie == null) // there is none.
      return;
    else if (Util.inNeedOfTransformation(ie.getOperator())) {
      // Get the fully qualified type name.
      final String fqn = this.getFullyQualifiedName(((Name) result)
          .resolveBinding().getJavaElement());
      this.rewriteInfixExpression(astRewrite, importRewrite, ie, fqn);
    }
View Full Code Here

TOP

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

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.