Java 类org.eclipse.jdt.core.dom.PostfixExpression 实例源码

项目:pandionj    文件:VarParser.java   
@Override
public boolean visit(PostfixExpression exp) {
    if(exp.getOperand() instanceof SimpleName) {
        String varName = exp.getOperand().toString(); 
        VariableOperation op = null;
        if(exp.getOperator() == PostfixExpression.Operator.INCREMENT)
            op = new VariableOperation(varName, VariableOperation.Type.INC);

        else if(exp.getOperator() == PostfixExpression.Operator.DECREMENT)
            op = new VariableOperation(varName, VariableOperation.Type.DEC);

        if(op != null)
            current.addOperation(op);
    }
    return true;
}
项目:junit-tools    文件:TestCasesGenerator.java   
/**
 * @param expression
 */
public void analyze(Expression expression) {
    // param == null, null == param
    if (expression.getNodeType() == ASTNode.NULL_LITERAL) {
    setNullLiteral((NullLiteral) expression);
    } else if (expression.getNodeType() == ASTNode.SIMPLE_NAME) {
    setSimpleName((SimpleName) expression);
    } else if (expression.getNodeType() == ASTNode.NUMBER_LITERAL) {
    setNumberLiteral((NumberLiteral) expression);
    } else if (expression.getNodeType() == ASTNode.PREFIX_EXPRESSION) {
    setPrefixExpression((PrefixExpression) expression);
    } else if (expression.getNodeType() == ASTNode.POSTFIX_EXPRESSION) {
    setPostfixExpression((PostfixExpression) expression);
    } else if (expression.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION
        || expression.getNodeType() == ASTNode.INFIX_EXPRESSION
        || expression.getNodeType() == ASTNode.METHOD_INVOCATION) {
    // addTestCasesToMerge(processIfExpressions(expression,
    // tmlMethod));
    } else {
    // TODO
    System.out.println("Expression could not be analyzed: "
        + expression.getNodeType() + ". Expression: "
        + expression.toString());
    }
}
项目:che    文件:AccessAnalyzer.java   
@Override
public boolean visit(PostfixExpression node) {
  Expression operand = node.getOperand();
  if (!considerBinding(resolveBinding(operand), operand)) return true;

  ASTNode parent = node.getParent();
  if (!(parent instanceof ExpressionStatement)) {
    fStatus.addError(
        RefactoringCoreMessages
            .SelfEncapsulateField_AccessAnalyzer_cannot_convert_postfix_expression,
        JavaStatusContext.create(fCUnit, SourceRangeFactory.create(node)));
    return false;
  }
  fRewriter.replace(
      node,
      createInvocation(node.getAST(), node.getOperand(), node.getOperator().toString()),
      createGroupDescription(POSTFIX_ACCESS));
  return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:ExtractTempRefactoring.java   
private static boolean isLeftValue(ASTNode node) {
    ASTNode parent= node.getParent();
    if (parent instanceof Assignment) {
        Assignment assignment= (Assignment) parent;
        if (assignment.getLeftHandSide() == node)
            return true;
    }
    if (parent instanceof PostfixExpression)
        return true;
    if (parent instanceof PrefixExpression) {
        PrefixExpression.Operator op= ((PrefixExpression) parent).getOperator();
        if (op.equals(PrefixExpression.Operator.DECREMENT))
            return true;
        if (op.equals(PrefixExpression.Operator.INCREMENT))
            return true;
        return false;
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:AccessAnalyzer.java   
@Override
public boolean visit(PostfixExpression node) {
    Expression operand= node.getOperand();
    if (!considerBinding(resolveBinding(operand), operand))
        return true;

    ASTNode parent= node.getParent();
    if (!(parent instanceof ExpressionStatement)) {
        fStatus.addError(RefactoringCoreMessages.SelfEncapsulateField_AccessAnalyzer_cannot_convert_postfix_expression,
            JavaStatusContext.create(fCUnit, SourceRangeFactory.create(node)));
        return false;
    }
    fRewriter.replace(node,
        createInvocation(node.getAST(), node.getOperand(), node.getOperator().toString()),
        createGroupDescription(POSTFIX_ACCESS));
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ExtractTempRefactoring.java   
private static boolean isLeftValue(ASTNode node) {
    ASTNode parent= node.getParent();
    if (parent instanceof Assignment) {
        Assignment assignment= (Assignment) parent;
        if (assignment.getLeftHandSide() == node)
            return true;
    }
    if (parent instanceof PostfixExpression)
        return true;
    if (parent instanceof PrefixExpression) {
        PrefixExpression.Operator op= ((PrefixExpression) parent).getOperator();
        if (op.equals(PrefixExpression.Operator.DECREMENT))
            return true;
        if (op.equals(PrefixExpression.Operator.INCREMENT))
            return true;
        return false;
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:AccessAnalyzer.java   
@Override
public boolean visit(PostfixExpression node) {
    Expression operand= node.getOperand();
    if (!considerBinding(resolveBinding(operand), operand))
        return true;

    ASTNode parent= node.getParent();
    if (!(parent instanceof ExpressionStatement)) {
        fStatus.addError(RefactoringCoreMessages.SelfEncapsulateField_AccessAnalyzer_cannot_convert_postfix_expression,
            JavaStatusContext.create(fCUnit, SourceRangeFactory.create(node)));
        return false;
    }
    fRewriter.replace(node,
        createInvocation(node.getAST(), node.getOperand(), node.getOperator().toString()),
        createGroupDescription(POSTFIX_ACCESS));
    return false;
}
项目:eclipse.jdt.ls    文件:OperatorPrecedence.java   
/**
 * Returns the precedence of the expression. Expression
 * with higher precedence are executed before expressions
 * with lower precedence.
 * i.e. in:
 * <br><code> int a= ++3--;</code></br>
 *
 * the  precedence order is
 * <ul>
 * <li>3</li>
 * <li>++</li>
 * <li>--</li>
 * <li>=</li>
 * </ul>
 * 1. 3 -(++)-> 4<br>
 * 2. 4 -(--)-> 3<br>
 * 3. 3 -(=)-> a<br>
 *
 * @param expression the expression to determine the precedence for
 * @return the precedence the higher to stronger the binding to its operand(s)
 */
public static int getExpressionPrecedence(Expression expression) {
    if (expression instanceof InfixExpression) {
        return getOperatorPrecedence(((InfixExpression)expression).getOperator());
    } else if (expression instanceof Assignment) {
        return ASSIGNMENT;
    } else if (expression instanceof ConditionalExpression) {
        return CONDITIONAL;
    } else if (expression instanceof InstanceofExpression) {
        return RELATIONAL;
    } else if (expression instanceof CastExpression) {
        return TYPEGENERATION;
    } else if (expression instanceof ClassInstanceCreation) {
        return POSTFIX;
    } else if (expression instanceof PrefixExpression) {
        return PREFIX;
    } else if (expression instanceof FieldAccess) {
        return POSTFIX;
    } else if (expression instanceof MethodInvocation) {
        return POSTFIX;
    } else if (expression instanceof ArrayAccess) {
        return POSTFIX;
    } else if (expression instanceof PostfixExpression) {
        return POSTFIX;
    }
    return Integer.MAX_VALUE;
}
项目:junit-tools    文件:TestCasesGenerator.java   
/**
 * @param expression
 */
public void setPostfixExpression(PostfixExpression expression) {
    this.postfixExpressions.add(expression);
    Expression operand = expression.getOperand();
    expressionPostfixes.put(operand, expression.getOperator());
    analyze(operand);
}
项目:che    文件:TempAssignmentFinder.java   
@Override
public boolean visit(PostfixExpression postfixExpression) {
  if (postfixExpression.getOperand() == null) return true;
  if (!(postfixExpression.getOperand() instanceof SimpleName)) return true;
  SimpleName simpleName = (SimpleName) postfixExpression.getOperand();
  if (!isNameReferenceToTemp(simpleName)) return true;

  fFirstAssignment = postfixExpression;
  return false;
}
项目:che    文件:ExtractTempRefactoring.java   
private static boolean isLeftValue(ASTNode node) {
  ASTNode parent = node.getParent();
  if (parent instanceof Assignment) {
    Assignment assignment = (Assignment) parent;
    if (assignment.getLeftHandSide() == node) return true;
  }
  if (parent instanceof PostfixExpression) return true;
  if (parent instanceof PrefixExpression) {
    PrefixExpression.Operator op = ((PrefixExpression) parent).getOperator();
    if (op.equals(PrefixExpression.Operator.DECREMENT)) return true;
    if (op.equals(PrefixExpression.Operator.INCREMENT)) return true;
    return false;
  }
  return false;
}
项目:che    文件:OperatorPrecedence.java   
/**
 * Returns the precedence of the expression. Expression with higher precedence are executed before
 * expressions with lower precedence. i.e. in: <br>
 * <code> int a= ++3--;</code></br>
 *
 * <p>the precedence order is
 *
 * <ul>
 *   <li>3
 *   <li>++
 *   <li>--
 *   <li>=
 * </ul>
 *
 * 1. 3 -(++)-> 4<br>
 * 2. 4 -(--)-> 3<br>
 * 3. 3 -(=)-> a<br>
 *
 * @param expression the expression to determine the precedence for
 * @return the precedence the higher to stronger the binding to its operand(s)
 */
public static int getExpressionPrecedence(Expression expression) {
  if (expression instanceof InfixExpression) {
    return getOperatorPrecedence(((InfixExpression) expression).getOperator());
  } else if (expression instanceof Assignment) {
    return ASSIGNMENT;
  } else if (expression instanceof ConditionalExpression) {
    return CONDITIONAL;
  } else if (expression instanceof InstanceofExpression) {
    return RELATIONAL;
  } else if (expression instanceof CastExpression) {
    return TYPEGENERATION;
  } else if (expression instanceof ClassInstanceCreation) {
    return POSTFIX;
  } else if (expression instanceof PrefixExpression) {
    return PREFIX;
  } else if (expression instanceof FieldAccess) {
    return POSTFIX;
  } else if (expression instanceof MethodInvocation) {
    return POSTFIX;
  } else if (expression instanceof ArrayAccess) {
    return POSTFIX;
  } else if (expression instanceof PostfixExpression) {
    return POSTFIX;
  }
  return Integer.MAX_VALUE;
}
项目:che    文件:GenerateForLoopAssistProposal.java   
/**
 * Creates a {@link PostfixExpression} used to increment the loop variable of a <code>for</code>
 * loop to iterate over an array.
 *
 * @param rewrite the current {@link ASTRewrite} instance
 * @param variableToIncrement the name of the variable to increment
 * @return a filled {@link PostfixExpression} realizing an incrementation of the specified
 *     variable
 */
private Expression getLinkedIncrementExpression(ASTRewrite rewrite, String variableToIncrement) {
  AST ast = rewrite.getAST();
  PostfixExpression incrementLoopVariable = ast.newPostfixExpression();
  SimpleName name = ast.newSimpleName(variableToIncrement);
  addLinkedPosition(rewrite.track(name), LinkedPositionGroup.NO_STOP, name.getIdentifier());
  incrementLoopVariable.setOperand(name);
  incrementLoopVariable.setOperator(PostfixExpression.Operator.INCREMENT);
  return incrementLoopVariable;
}
项目:Eclipse-Postfix-Code-Completion    文件:MoveInstanceMethodProcessor.java   
@Override
public final boolean visit(final PostfixExpression node) {
    final IVariableBinding binding= getFieldBinding(node.getOperand());
    if (binding != null)
        fWritten.add(binding.getKey());
    return true;
}
项目:Eclipse-Postfix-Code-Completion    文件:TempAssignmentFinder.java   
@Override
public boolean visit(PostfixExpression postfixExpression) {
    if (postfixExpression.getOperand() == null)
        return true;
    if (! (postfixExpression.getOperand() instanceof SimpleName))
        return true;
    SimpleName simpleName= (SimpleName)postfixExpression.getOperand();
    if (! isNameReferenceToTemp(simpleName))
        return true;

    fFirstAssignment= postfixExpression;
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:OperatorPrecedence.java   
/**
 * Returns the precedence of the expression. Expression
 * with higher precedence are executed before expressions
 * with lower precedence.
 * i.e. in:
 * <br><code> int a= ++3--;</code></br>
 *
 * the  precedence order is
 * <ul>
 * <li>3</li>
 * <li>++</li>
 * <li>--</li>
 * <li>=</li>
 * </ul>
 * 1. 3 -(++)-> 4<br>
 * 2. 4 -(--)-> 3<br>
 * 3. 3 -(=)-> a<br>
 *
 * @param expression the expression to determine the precedence for
 * @return the precedence the higher to stronger the binding to its operand(s)
 */
public static int getExpressionPrecedence(Expression expression) {
    if (expression instanceof InfixExpression) {
        return getOperatorPrecedence(((InfixExpression)expression).getOperator());
    } else if (expression instanceof Assignment) {
        return ASSIGNMENT;
    } else if (expression instanceof ConditionalExpression) {
        return CONDITIONAL;
    } else if (expression instanceof InstanceofExpression) {
        return RELATIONAL;
    } else if (expression instanceof CastExpression) {
        return TYPEGENERATION;
    } else if (expression instanceof ClassInstanceCreation) {
        return POSTFIX;
    } else if (expression instanceof PrefixExpression) {
        return PREFIX;
    } else if (expression instanceof FieldAccess) {
        return POSTFIX;
    } else if (expression instanceof MethodInvocation) {
        return POSTFIX;
    } else if (expression instanceof ArrayAccess) {
        return POSTFIX;
    } else if (expression instanceof PostfixExpression) {
        return POSTFIX;
    }
    return Integer.MAX_VALUE;
}
项目:Eclipse-Postfix-Code-Completion    文件:OccurrencesFinder.java   
@Override
public boolean visit(PostfixExpression node) {
    SimpleName name= getSimpleName(node.getOperand());
    if (name != null)
        addWrite(name, name.resolveBinding());
    return true;
}
项目:Eclipse-Postfix-Code-Completion    文件:GenerateForLoopAssistProposal.java   
/**
 * Creates a {@link PostfixExpression} used to increment the loop variable of a <code>for</code>
 * loop to iterate over an array.
 * 
 * @param rewrite the current {@link ASTRewrite} instance
 * @param variableToIncrement the name of the variable to increment
 * @return a filled {@link PostfixExpression} realizing an incrementation of the specified
 *         variable
 */
private Expression getLinkedIncrementExpression(ASTRewrite rewrite, String variableToIncrement) {
    AST ast= rewrite.getAST();
    PostfixExpression incrementLoopVariable= ast.newPostfixExpression();
    SimpleName name= ast.newSimpleName(variableToIncrement);
    addLinkedPosition(rewrite.track(name), LinkedPositionGroup.NO_STOP, name.getIdentifier());
    incrementLoopVariable.setOperand(name);
    incrementLoopVariable.setOperator(PostfixExpression.Operator.INCREMENT);
    return incrementLoopVariable;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:MoveInstanceMethodProcessor.java   
@Override
public final boolean visit(final PostfixExpression node) {
    final IVariableBinding binding= getFieldBinding(node.getOperand());
    if (binding != null)
        fWritten.add(binding.getKey());
    return true;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:TempAssignmentFinder.java   
@Override
public boolean visit(PostfixExpression postfixExpression) {
    if (postfixExpression.getOperand() == null)
        return true;
    if (! (postfixExpression.getOperand() instanceof SimpleName))
        return true;
    SimpleName simpleName= (SimpleName)postfixExpression.getOperand();
    if (! isNameReferenceToTemp(simpleName))
        return true;

    fFirstAssignment= postfixExpression;
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:OperatorPrecedence.java   
/**
 * Returns the precedence of the expression. Expression
 * with higher precedence are executed before expressions
 * with lower precedence.
 * i.e. in:
 * <br><code> int a= ++3--;</code></br>
 *
 * the  precedence order is
 * <ul>
 * <li>3</li>
 * <li>++</li>
 * <li>--</li>
 * <li>=</li>
 * </ul>
 * 1. 3 -(++)-> 4<br>
 * 2. 4 -(--)-> 3<br>
 * 3. 3 -(=)-> a<br>
 *
 * @param expression the expression to determine the precedence for
 * @return the precedence the higher to stronger the binding to its operand(s)
 */
public static int getExpressionPrecedence(Expression expression) {
    if (expression instanceof InfixExpression) {
        return getOperatorPrecedence(((InfixExpression)expression).getOperator());
    } else if (expression instanceof Assignment) {
        return ASSIGNMENT;
    } else if (expression instanceof ConditionalExpression) {
        return CONDITIONAL;
    } else if (expression instanceof InstanceofExpression) {
        return RELATIONAL;
    } else if (expression instanceof CastExpression) {
        return TYPEGENERATION;
    } else if (expression instanceof ClassInstanceCreation) {
        return POSTFIX;
    } else if (expression instanceof PrefixExpression) {
        return PREFIX;
    } else if (expression instanceof FieldAccess) {
        return POSTFIX;
    } else if (expression instanceof MethodInvocation) {
        return POSTFIX;
    } else if (expression instanceof ArrayAccess) {
        return POSTFIX;
    } else if (expression instanceof PostfixExpression) {
        return POSTFIX;
    }
    return Integer.MAX_VALUE;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:OccurrencesFinder.java   
@Override
public boolean visit(PostfixExpression node) {
    SimpleName name= getSimpleName(node.getOperand());
    if (name != null)
        addWrite(name, name.resolveBinding());
    return true;
}
项目:ESPSecurityPlugin    文件:SourceSinkAnalyser.java   
private boolean expressionContainsTaintedVariable(Expression node) {
    if(node instanceof SimpleName) {
        return expressionContainsTaintedVariable((SimpleName) node);
    } else if (node instanceof ArrayAccess) {
        return expressionContainsTaintedVariable((ArrayAccess)node);
    } else if (node instanceof ArrayCreation) {
        return expressionContainsTaintedVariable((ArrayCreation)node);
    } else if (node instanceof CastExpression) {
        return expressionContainsTaintedVariable((CastExpression) node);
    } else if (node instanceof ClassInstanceCreation) {
        return expressionContainsTaintedVariable((ClassInstanceCreation)node);
    } else if (node instanceof ConditionalExpression) {
        return expressionContainsTaintedVariable((ConditionalExpression)node);
    } else if(node instanceof FieldAccess) {
        return expressionContainsTaintedVariable((FieldAccess)node);
    } else if(node instanceof InfixExpression) {
        return expressionContainsTaintedVariable((InfixExpression) node);
    } else if(node instanceof MethodInvocation) {
        return expressionContainsTaintedVariable((MethodInvocation) node);
    }  else if(node instanceof ParenthesizedExpression) {
        return expressionContainsTaintedVariable((ParenthesizedExpression) node);
    } else if(node instanceof PostfixExpression) {
        return expressionContainsTaintedVariable((PostfixExpression) node);
    } else if(node instanceof PrefixExpression) {
        return expressionContainsTaintedVariable((PrefixExpression) node);
    } else if(node instanceof SuperMethodInvocation) {
        return expressionContainsTaintedVariable((SuperMethodInvocation) node);
    }

    return false;
}
项目:ESPSecurityPlugin    文件:SourceSinkAnalyser.java   
protected Collection<String> expressionToString(Expression expression) {

    Collection<String> result = new Vector<String>(1); // Will 1 be most common case?

    if(expression == null) {
        return result;
    }

    if(expression instanceof ArrayAccess) {
        result.addAll(expressionToString(((ArrayAccess) expression).getArray()));
    }  else if(expression instanceof Assignment) {
        result.addAll(expressionToString(((Assignment) expression).getLeftHandSide()));
    } else if(expression instanceof CastExpression) {
        result.addAll(expressionToString(((CastExpression) expression).getExpression()));
    }else if(expression instanceof ClassInstanceCreation) {
        // TODO determine if .getExpression() needs to be analysed.can't tell looking at docs
        result.addAll(expressionToSimpleName(CastUtils.castList(Expression.class, ((ClassInstanceCreation) expression).arguments())));
    }  else if(expression instanceof ConditionalExpression) {
        // TODO what can I put in an if statement? assignment?
        result.addAll(expressionToString(((ConditionalExpression) expression).getThenExpression()));
        result.addAll(expressionToString(((ConditionalExpression) expression).getElseExpression()));
    } else if(expression instanceof MethodInvocation) {
        result.addAll(expressionToSimpleName(CastUtils.castList(Expression.class, ((MethodInvocation) expression).arguments())));
        result.addAll(expressionToString(((MethodInvocation) expression).getExpression()));
    }  else if(expression instanceof QualifiedName) {
        result.add(((QualifiedName) expression).getName().getIdentifier());
    }  else if(expression instanceof SimpleName) {
        result.add(((SimpleName)expression).getIdentifier());
    }   else if(expression instanceof ParenthesizedExpression) {
        result.addAll(expressionToString(((ParenthesizedExpression) expression).getExpression()));
    }  else if(expression instanceof PostfixExpression) {
        result.addAll(expressionToString(((PostfixExpression) expression).getOperand()));
    }  else if(expression instanceof PrefixExpression) {
        result.addAll(expressionToString(((PrefixExpression) expression).getOperand()));
    }  else if (expression instanceof SuperMethodInvocation) {
        result.addAll(expressionToSimpleName(CastUtils.castList(Expression.class, ((SuperMethodInvocation) expression).arguments())));
    } 

    return result;
}
项目:j2d    文件:J2dVisitor.java   
@Override
public boolean visit(PostfixExpression node) {
    //System.out.println("Found: " + node.getClass());
    node.getOperand().accept(this);
    print(node.getOperator().toString());
    return false;
}
项目:pandionj    文件:TestParser.java   
@Override
public boolean visit(PostfixExpression node) {
    System.out.println("PostfixExpression (por completar): " + node.toString());
    return super.visit(node);
}
项目:SnowGraph    文件:JavaASTVisitor.java   
private void parseExpression(MethodInfo methodInfo, Expression expression) {
    if (expression == null) {
        return;
    }//System.out.println(expression.toString()+" "+Annotation.nodeClassForType(expression.getNodeType()));
    if (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) {
        List<Expression> expressions = ((ArrayInitializer) expression).expressions();
        for (Expression expression2 : expressions) {
            parseExpression(methodInfo, expression2);
        }
    }
    if (expression.getNodeType() == ASTNode.CAST_EXPRESSION) {
        parseExpression(methodInfo, ((CastExpression) expression).getExpression());
    }
    if (expression.getNodeType() == ASTNode.CONDITIONAL_EXPRESSION) {
        parseExpression(methodInfo, ((ConditionalExpression) expression).getExpression());
        parseExpression(methodInfo, ((ConditionalExpression) expression).getElseExpression());
        parseExpression(methodInfo, ((ConditionalExpression) expression).getThenExpression());
    }
    if (expression.getNodeType() == ASTNode.INFIX_EXPRESSION) {
        parseExpression(methodInfo, ((InfixExpression) expression).getLeftOperand());
        parseExpression(methodInfo, ((InfixExpression) expression).getRightOperand());
    }
    if (expression.getNodeType() == ASTNode.INSTANCEOF_EXPRESSION) {
        parseExpression(methodInfo, ((InstanceofExpression) expression).getLeftOperand());
    }
    if (expression.getNodeType() == ASTNode.PARENTHESIZED_EXPRESSION) {
        parseExpression(methodInfo, ((ParenthesizedExpression) expression).getExpression());
    }
    if (expression.getNodeType() == ASTNode.POSTFIX_EXPRESSION) {
        parseExpression(methodInfo, ((PostfixExpression) expression).getOperand());
    }
    if (expression.getNodeType() == ASTNode.PREFIX_EXPRESSION) {
        parseExpression(methodInfo, ((PrefixExpression) expression).getOperand());
    }
    if (expression.getNodeType() == ASTNode.THIS_EXPRESSION) {
        parseExpression(methodInfo, ((ThisExpression) expression).getQualifier());
    }
    if (expression.getNodeType() == ASTNode.METHOD_INVOCATION) {
        List<Expression> arguments = ((MethodInvocation) expression).arguments();
        IMethodBinding methodBinding = ((MethodInvocation) expression).resolveMethodBinding();
        if (methodBinding != null)
            methodInfo.methodCalls.add(methodBinding);
        for (Expression exp : arguments)
            parseExpression(methodInfo, exp);
        parseExpression(methodInfo, ((MethodInvocation) expression).getExpression());
    }
    if (expression.getNodeType() == ASTNode.ASSIGNMENT) {
        parseExpression(methodInfo, ((Assignment) expression).getLeftHandSide());
        parseExpression(methodInfo, ((Assignment) expression).getRightHandSide());
    }
    if (expression.getNodeType() == ASTNode.QUALIFIED_NAME) {
        if (((QualifiedName) expression).getQualifier().resolveTypeBinding() != null) {
            String name = ((QualifiedName) expression).getQualifier().resolveTypeBinding().getQualifiedName() + "." + ((QualifiedName) expression).getName().getIdentifier();
            methodInfo.fieldUsesSet.add(name);
        }
        parseExpression(methodInfo, ((QualifiedName) expression).getQualifier());
    }
}
项目:eclipse.jdt.ls    文件:Bindings.java   
/**
 * Resolve the binding (<em>not</em> the type binding) for the expression or a nested expression
 * (e.g. nested in parentheses, cast, ...).
 *
 * @param expression an expression node
 * @param goIntoCast iff <code>true</code>, go into a CastExpression's expression to resolve
 * @return the expression binding, or <code>null</code> if the expression has no binding or the
 *         binding could not be resolved
 *
 * @since 3.5
 */
public static IBinding resolveExpressionBinding(Expression expression, boolean goIntoCast) {
    //TODO: search for callers of resolve*Binding() methods and replace with call to this method

    // similar to StubUtility#getVariableNameSuggestions(int, IJavaProject, ITypeBinding, Expression, Collection)
    switch (expression.getNodeType()) {
    case ASTNode.SIMPLE_NAME:
    case ASTNode.QUALIFIED_NAME:
        return ((Name) expression).resolveBinding();

    case ASTNode.FIELD_ACCESS:
        return ((FieldAccess) expression).resolveFieldBinding();
    case ASTNode.SUPER_FIELD_ACCESS:
        return ((SuperFieldAccess) expression).resolveFieldBinding();

    case ASTNode.METHOD_INVOCATION:
        return ((MethodInvocation) expression).resolveMethodBinding();
    case ASTNode.SUPER_METHOD_INVOCATION:
        return ((SuperMethodInvocation) expression).resolveMethodBinding();
    case ASTNode.CLASS_INSTANCE_CREATION:
        return ((ClassInstanceCreation) expression).resolveConstructorBinding();

    case ASTNode.MARKER_ANNOTATION:
    case ASTNode.SINGLE_MEMBER_ANNOTATION:
    case ASTNode.NORMAL_ANNOTATION:
        return ((Annotation) expression).resolveAnnotationBinding();

    case ASTNode.ARRAY_ACCESS:
        return resolveExpressionBinding(((ArrayAccess) expression).getArray(), goIntoCast);
    case ASTNode.CAST_EXPRESSION:
        if (goIntoCast) {
            return resolveExpressionBinding(((CastExpression) expression).getExpression(), true);
        } else {
            return null;
        }
    case ASTNode.PARENTHESIZED_EXPRESSION:
        return resolveExpressionBinding(((ParenthesizedExpression) expression).getExpression(), goIntoCast);
    case ASTNode.PREFIX_EXPRESSION:
        return resolveExpressionBinding(((PrefixExpression) expression).getOperand(), goIntoCast);
    case ASTNode.POSTFIX_EXPRESSION:
        return resolveExpressionBinding(((PostfixExpression) expression).getOperand(), goIntoCast);
    default:
        return null;
    }
}
项目:eclipse.jdt.ls    文件:GetterSetterUtil.java   
/**
 * Converts an assignment, postfix expression or prefix expression into an
 * assignable equivalent expression using the getter.
 *
 * @param node
 *            the assignment/prefix/postfix node
 * @param astRewrite
 *            the astRewrite to use
 * @param getterExpression
 *            the expression to insert for read accesses or
 *            <code>null</code> if such an expression does not exist
 * @param variableType
 *            the type of the variable that the result will be assigned to
 * @param is50OrHigher
 *            <code>true</code> if a 5.0 or higher environment can be used
 * @return an expression that can be assigned to the type variableType with
 *         node being replaced by a equivalent expression using the getter
 */
public static Expression getAssignedValue(ASTNode node, ASTRewrite astRewrite, Expression getterExpression, ITypeBinding variableType, boolean is50OrHigher) {
    InfixExpression.Operator op = null;
    AST ast = astRewrite.getAST();
    if (isNotInBlock(node)) {
        return null;
    }
    if (node.getNodeType() == ASTNode.ASSIGNMENT) {
        Assignment assignment = ((Assignment) node);
        Expression rightHandSide = assignment.getRightHandSide();
        Expression copiedRightOp = (Expression) astRewrite.createCopyTarget(rightHandSide);
        if (assignment.getOperator() == Operator.ASSIGN) {
            ITypeBinding rightHandSideType = rightHandSide.resolveTypeBinding();
            copiedRightOp = createNarrowCastIfNessecary(copiedRightOp, rightHandSideType, ast, variableType, is50OrHigher);
            return copiedRightOp;
        }
        if (getterExpression != null) {
            InfixExpression infix = ast.newInfixExpression();
            infix.setLeftOperand(getterExpression);
            infix.setOperator(ASTNodes.convertToInfixOperator(assignment.getOperator()));
            ITypeBinding infixType = infix.resolveTypeBinding();
            if (NecessaryParenthesesChecker.needsParenthesesForRightOperand(rightHandSide, infix, variableType)) {
                ParenthesizedExpression p = ast.newParenthesizedExpression();
                p.setExpression(copiedRightOp);
                copiedRightOp = p;
            }
            infix.setRightOperand(copiedRightOp);
            return createNarrowCastIfNessecary(infix, infixType, ast, variableType, is50OrHigher);
        }
    } else if (node.getNodeType() == ASTNode.POSTFIX_EXPRESSION) {
        PostfixExpression po = (PostfixExpression) node;
        if (po.getOperator() == PostfixExpression.Operator.INCREMENT) {
            op = InfixExpression.Operator.PLUS;
        }
        if (po.getOperator() == PostfixExpression.Operator.DECREMENT) {
            op = InfixExpression.Operator.MINUS;
        }
    } else if (node.getNodeType() == ASTNode.PREFIX_EXPRESSION) {
        PrefixExpression pe = (PrefixExpression) node;
        if (pe.getOperator() == PrefixExpression.Operator.INCREMENT) {
            op = InfixExpression.Operator.PLUS;
        }
        if (pe.getOperator() == PrefixExpression.Operator.DECREMENT) {
            op= InfixExpression.Operator.MINUS;
        }
    }
    if (op != null && getterExpression != null) {
        return createInfixInvocationFromPostPrefixExpression(op, getterExpression, ast, variableType, is50OrHigher);
    }
    return null;
}
项目:eclipse.jdt.ls    文件:UnusedCodeFix.java   
@Override
public boolean visit(PostfixExpression node) {
    fSideEffectNodes.add(node);
    return false;
}
项目:eclipse.jdt.ls    文件:FlowAnalyzer.java   
@Override
public void endVisit(PostfixExpression node) {
    endVisitIncDecOperation(node, node.getOperand());
}
项目:junit-tools    文件:TestCasesGenerator.java   
public PostfixExpression getPostfixExpression() {
    return (PostfixExpression) getExpressionFromList(
        postfixExpressions, 0);
}
项目:junit-tools    文件:TestCasesGenerator.java   
public List<PostfixExpression> getPostfixExpressions() {
    return postfixExpressions;
}
项目:junit-tools    文件:TestCasesGenerator.java   
public PostfixExpression getPostfixExpressionSecond() {
    return (PostfixExpression) getExpressionFromList(
        postfixExpressions, 1);
}
项目:che    文件:Bindings.java   
/**
 * Resolve the binding (<em>not</em> the type binding) for the expression or a nested expression
 * (e.g. nested in parentheses, cast, ...).
 *
 * @param expression an expression node
 * @param goIntoCast iff <code>true</code>, go into a CastExpression's expression to resolve
 * @return the expression binding, or <code>null</code> if the expression has no binding or the
 *     binding could not be resolved
 * @see StubUtility#getVariableNameSuggestions(int, IJavaProject, ITypeBinding, Expression,
 *     java.util.Collection)
 * @since 3.5
 */
public static IBinding resolveExpressionBinding(Expression expression, boolean goIntoCast) {
  // TODO: search for callers of resolve*Binding() methods and replace with call to this method

  // similar to StubUtility#getVariableNameSuggestions(int, IJavaProject, ITypeBinding,
  // Expression, Collection)
  switch (expression.getNodeType()) {
    case ASTNode.SIMPLE_NAME:
    case ASTNode.QUALIFIED_NAME:
      return ((Name) expression).resolveBinding();

    case ASTNode.FIELD_ACCESS:
      return ((FieldAccess) expression).resolveFieldBinding();
    case ASTNode.SUPER_FIELD_ACCESS:
      return ((SuperFieldAccess) expression).resolveFieldBinding();

    case ASTNode.METHOD_INVOCATION:
      return ((MethodInvocation) expression).resolveMethodBinding();
    case ASTNode.SUPER_METHOD_INVOCATION:
      return ((SuperMethodInvocation) expression).resolveMethodBinding();
    case ASTNode.CLASS_INSTANCE_CREATION:
      return ((ClassInstanceCreation) expression).resolveConstructorBinding();

    case ASTNode.MARKER_ANNOTATION:
    case ASTNode.SINGLE_MEMBER_ANNOTATION:
    case ASTNode.NORMAL_ANNOTATION:
      return ((Annotation) expression).resolveAnnotationBinding();

    case ASTNode.ARRAY_ACCESS:
      return resolveExpressionBinding(((ArrayAccess) expression).getArray(), goIntoCast);
    case ASTNode.CAST_EXPRESSION:
      if (goIntoCast) {
        return resolveExpressionBinding(((CastExpression) expression).getExpression(), true);
      } else {
        return null;
      }
    case ASTNode.PARENTHESIZED_EXPRESSION:
      return resolveExpressionBinding(
          ((ParenthesizedExpression) expression).getExpression(), goIntoCast);
    case ASTNode.PREFIX_EXPRESSION:
      return resolveExpressionBinding(((PrefixExpression) expression).getOperand(), goIntoCast);
    case ASTNode.POSTFIX_EXPRESSION:
      return resolveExpressionBinding(((PostfixExpression) expression).getOperand(), goIntoCast);
    default:
      return null;
  }
}
项目:che    文件:GetterSetterUtil.java   
/**
 * Converts an assignment, postfix expression or prefix expression into an assignable equivalent
 * expression using the getter.
 *
 * @param node the assignment/prefix/postfix node
 * @param astRewrite the astRewrite to use
 * @param getterExpression the expression to insert for read accesses or <code>null</code> if such
 *     an expression does not exist
 * @param variableType the type of the variable that the result will be assigned to
 * @param is50OrHigher <code>true</code> if a 5.0 or higher environment can be used
 * @return an expression that can be assigned to the type variableType with node being replaced by
 *     a equivalent expression using the getter
 */
public static Expression getAssignedValue(
    ASTNode node,
    ASTRewrite astRewrite,
    Expression getterExpression,
    ITypeBinding variableType,
    boolean is50OrHigher) {
  InfixExpression.Operator op = null;
  AST ast = astRewrite.getAST();
  if (isNotInBlock(node)) return null;
  if (node.getNodeType() == ASTNode.ASSIGNMENT) {
    Assignment assignment = ((Assignment) node);
    Expression rightHandSide = assignment.getRightHandSide();
    Expression copiedRightOp = (Expression) astRewrite.createCopyTarget(rightHandSide);
    if (assignment.getOperator() == Operator.ASSIGN) {
      ITypeBinding rightHandSideType = rightHandSide.resolveTypeBinding();
      copiedRightOp =
          createNarrowCastIfNessecary(
              copiedRightOp, rightHandSideType, ast, variableType, is50OrHigher);
      return copiedRightOp;
    }
    if (getterExpression != null) {
      InfixExpression infix = ast.newInfixExpression();
      infix.setLeftOperand(getterExpression);
      infix.setOperator(ASTNodes.convertToInfixOperator(assignment.getOperator()));
      ITypeBinding infixType = infix.resolveTypeBinding();
      if (NecessaryParenthesesChecker.needsParenthesesForRightOperand(
          rightHandSide, infix, variableType)) {
        ParenthesizedExpression p = ast.newParenthesizedExpression();
        p.setExpression(copiedRightOp);
        copiedRightOp = p;
      }
      infix.setRightOperand(copiedRightOp);
      return createNarrowCastIfNessecary(infix, infixType, ast, variableType, is50OrHigher);
    }
  } else if (node.getNodeType() == ASTNode.POSTFIX_EXPRESSION) {
    PostfixExpression po = (PostfixExpression) node;
    if (po.getOperator() == PostfixExpression.Operator.INCREMENT)
      op = InfixExpression.Operator.PLUS;
    if (po.getOperator() == PostfixExpression.Operator.DECREMENT)
      op = InfixExpression.Operator.MINUS;
  } else if (node.getNodeType() == ASTNode.PREFIX_EXPRESSION) {
    PrefixExpression pe = (PrefixExpression) node;
    if (pe.getOperator() == PrefixExpression.Operator.INCREMENT)
      op = InfixExpression.Operator.PLUS;
    if (pe.getOperator() == PrefixExpression.Operator.DECREMENT)
      op = InfixExpression.Operator.MINUS;
  }
  if (op != null && getterExpression != null) {
    return createInfixInvocationFromPostPrefixExpression(
        op, getterExpression, ast, variableType, is50OrHigher);
  }
  return null;
}
项目:che    文件:UnusedCodeFix.java   
@Override
public boolean visit(PostfixExpression node) {
  fSideEffectNodes.add(node);
  return false;
}
项目:che    文件:RemoveDeclarationCorrectionProposal.java   
@Override
public boolean visit(PostfixExpression node) {
  fSideEffectNodes.add(node);
  return false;
}
项目:evosuite    文件:LoggingVisitor.java   
/** {@inheritDoc} */
@Override
public void endVisit(PostfixExpression node) {
    logger.warn("Method endVisitPostfixExpression for " + node + " for " + node + " not implemented!");
    super.endVisit(node);
}
项目:evosuite    文件:LoggingVisitor.java   
/** {@inheritDoc} */
@Override
public boolean visit(PostfixExpression node) {
    logger.warn("Method visitPostfixExpression for " + node + " not implemented!");
    return super.visit(node);
}