本文整理汇总了Java中org.eclipse.jdt.core.dom.InfixExpression.setRightOperand方法的典型用法代码示例。如果您正苦于以下问题:Java InfixExpression.setRightOperand方法的具体用法?Java InfixExpression.setRightOperand怎么用?Java InfixExpression.setRightOperand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.InfixExpression
的用法示例。
在下文中一共展示了InfixExpression.setRightOperand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createInvocation
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private MethodInvocation createInvocation(AST ast, Expression operand, String operator) {
Expression receiver = getReceiver(operand);
MethodInvocation invocation = ast.newMethodInvocation();
invocation.setName(ast.newSimpleName(fSetter));
if (receiver != null)
invocation.setExpression((Expression) fRewriter.createCopyTarget(receiver));
InfixExpression argument = ast.newInfixExpression();
invocation.arguments().add(argument);
if ("++".equals(operator)) { // $NON-NLS-1$
argument.setOperator(InfixExpression.Operator.PLUS);
} else if ("--".equals(operator)) { // $NON-NLS-1$
argument.setOperator(InfixExpression.Operator.MINUS);
} else {
Assert.isTrue(false, "Should not happen"); // $NON-NLS-1$
}
MethodInvocation getter = ast.newMethodInvocation();
getter.setName(ast.newSimpleName(fGetter));
if (receiver != null) getter.setExpression((Expression) fRewriter.createCopyTarget(receiver));
argument.setLeftOperand(getter);
argument.setRightOperand(ast.newNumberLiteral("1")); // $NON-NLS-1$
fReferencingGetter = true;
fReferencingSetter = true;
return invocation;
}
示例2: getLinkedInfixExpression
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
/**
* Creates an {@link InfixExpression} which is linked to the group of the variableToIncrement.
*
* @param rewrite the current {@link ASTRewrite} instance
* @param variableToIncrement the name of the variable to generate the {@link InfixExpression} for
* @param rightHandSide the right hand side expression which shall be included in the {@link
* InfixExpression}
* @param operator the {@link org.eclipse.jdt.core.dom.InfixExpression.Operator} to use in the
* {@link InfixExpression} to create
* @return a filled, new {@link InfixExpression} instance
*/
private InfixExpression getLinkedInfixExpression(
ASTRewrite rewrite,
String variableToIncrement,
Expression rightHandSide,
InfixExpression.Operator operator) {
AST ast = rewrite.getAST();
InfixExpression loopExpression = ast.newInfixExpression();
SimpleName name = ast.newSimpleName(variableToIncrement);
addLinkedPosition(rewrite.track(name), LinkedPositionGroup.NO_STOP, name.getIdentifier());
loopExpression.setLeftOperand(name);
loopExpression.setOperator(operator);
loopExpression.setRightOperand(rightHandSide);
return loopExpression;
}
示例3: repairBug
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
@Override
protected void repairBug(ASTRewrite rewrite, CompilationUnit workingUnit, BugInstance bug) throws BugResolutionException {
ASTNode node = getASTNode(workingUnit, bug.getPrimarySourceLineAnnotation());
node = TraversalUtil.backtrackToBlock(node);
EnumEqualsVisitor visitor = new EnumEqualsVisitor();
node.accept(visitor);
for (ResolutionBundle bundle : visitor.resolutionBundles) {
InfixExpression newEquals = rewrite.getAST().newInfixExpression();
if (bundle.wasNegated) {
newEquals.setOperator(InfixExpression.Operator.NOT_EQUALS);
} else {
newEquals.setOperator(InfixExpression.Operator.EQUALS);
}
newEquals.setLeftOperand((Expression) rewrite.createCopyTarget(bundle.thisEnum));
newEquals.setRightOperand((Expression) rewrite.createCopyTarget(bundle.thatEnum));
rewrite.replace(bundle.badEqualsInvocation, newEquals, null);
}
}
示例4: prepareAssignment
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private Statement prepareAssignment(Expression rightHand) {
// result = PRIME*result + (...)
InfixExpression mul= fAst.newInfixExpression();
mul.setLeftOperand(fAst.newSimpleName(VARIABLE_NAME_PRIME));
mul.setRightOperand(fAst.newSimpleName(VARIABLE_NAME_RESULT));
mul.setOperator(Operator.TIMES);
Assignment ass= fAst.newAssignment();
ass.setLeftHandSide(fAst.newSimpleName(VARIABLE_NAME_RESULT));
InfixExpression plus= fAst.newInfixExpression();
plus.setLeftOperand(mul);
plus.setOperator(Operator.PLUS);
plus.setRightOperand(rightHand);
ass.setRightHandSide(plus);
return fAst.newExpressionStatement(ass);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:20,代码来源:GenerateHashCodeEqualsOperation.java
示例5: createAddQualifiedHashCode
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private Statement createAddQualifiedHashCode(IVariableBinding binding) {
MethodInvocation invoc= fAst.newMethodInvocation();
invoc.setExpression(getThisAccessForHashCode(binding.getName()));
invoc.setName(fAst.newSimpleName(METHODNAME_HASH_CODE));
InfixExpression expr= fAst.newInfixExpression();
expr.setOperator(Operator.EQUALS);
expr.setLeftOperand(getThisAccessForHashCode(binding.getName()));
expr.setRightOperand(fAst.newNullLiteral());
ConditionalExpression cexpr= fAst.newConditionalExpression();
cexpr.setThenExpression(fAst.newNumberLiteral("0")); //$NON-NLS-1$
cexpr.setElseExpression(invoc);
cexpr.setExpression(parenthesize(expr));
return prepareAssignment(parenthesize(cexpr));
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:GenerateHashCodeEqualsOperation.java
示例6: createShiftAssignment
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private Expression createShiftAssignment(Expression shift1, Expression shift2) {
// (int)(element ^ (element >>> 32));
// see implementation in Arrays.hashCode(), Double.hashCode() and
// Long.hashCode()
CastExpression ce= fAst.newCastExpression();
ce.setType(fAst.newPrimitiveType(PrimitiveType.INT));
InfixExpression unsignedShiftRight= fAst.newInfixExpression();
unsignedShiftRight.setLeftOperand(shift1);
unsignedShiftRight.setRightOperand(fAst.newNumberLiteral("32")); //$NON-NLS-1$
unsignedShiftRight.setOperator(Operator.RIGHT_SHIFT_UNSIGNED);
InfixExpression xor= fAst.newInfixExpression();
xor.setLeftOperand(shift2);
xor.setRightOperand(parenthesize(unsignedShiftRight));
xor.setOperator(InfixExpression.Operator.XOR);
ce.setExpression(parenthesize(xor));
return ce;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:21,代码来源:GenerateHashCodeEqualsOperation.java
示例7: getInversedAndOrExpression
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static Expression getInversedAndOrExpression(ASTRewrite rewrite, InfixExpression infixExpression, Operator newOperator, SimpleNameRenameProvider provider) {
InfixExpression newExpression= rewrite.getAST().newInfixExpression();
newExpression.setOperator(newOperator);
int newOperatorPrecedence= OperatorPrecedence.getOperatorPrecedence(newOperator);
//
Expression leftOperand= getInversedExpression(rewrite, infixExpression.getLeftOperand(), provider);
newExpression.setLeftOperand(parenthesizeIfRequired(leftOperand, newOperatorPrecedence));
Expression rightOperand= getInversedExpression(rewrite, infixExpression.getRightOperand(), provider);
newExpression.setRightOperand(parenthesizeIfRequired(rightOperand, newOperatorPrecedence));
List<Expression> extraOperands= infixExpression.extendedOperands();
List<Expression> newExtraOperands= newExpression.extendedOperands();
for (int i= 0; i < extraOperands.size(); i++) {
Expression extraOperand= getInversedExpression(rewrite, extraOperands.get(i), provider);
newExtraOperands.add(parenthesizeIfRequired(extraOperand, newOperatorPrecedence));
}
return newExpression;
}
示例8: combineOperands
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static Expression combineOperands(ASTRewrite rewrite, Expression existing, Expression originalNode, boolean removeParentheses, Operator operator) {
if (existing == null && removeParentheses) {
while (originalNode instanceof ParenthesizedExpression) {
originalNode= ((ParenthesizedExpression)originalNode).getExpression();
}
}
Expression newRight= (Expression)rewrite.createMoveTarget(originalNode);
if (originalNode instanceof InfixExpression) {
((InfixExpression)newRight).setOperator(((InfixExpression)originalNode).getOperator());
}
if (existing == null) {
return newRight;
}
AST ast= rewrite.getAST();
InfixExpression infix= ast.newInfixExpression();
infix.setOperator(operator);
infix.setLeftOperand(existing);
infix.setRightOperand(newRight);
return infix;
}
示例9: newInfixExpression
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
public static Expression newInfixExpression(AST ast, Operator operator, ArrayList<Expression> operands) {
if (operands.size() == 1) {
return operands.get(0);
}
InfixExpression result= ast.newInfixExpression();
result.setOperator(operator);
result.setLeftOperand(operands.get(0));
result.setRightOperand(operands.get(1));
result.extendedOperands().addAll(operands.subList(2, operands.size()));
return result;
}
示例10: createInfixInvocationFromPostPrefixExpression
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static Expression createInfixInvocationFromPostPrefixExpression(InfixExpression.Operator operator, Expression getterExpression, AST ast, ITypeBinding variableType, boolean is50OrHigher) {
InfixExpression infix = ast.newInfixExpression();
infix.setLeftOperand(getterExpression);
infix.setOperator(operator);
NumberLiteral number = ast.newNumberLiteral();
number.setToken("1"); //$NON-NLS-1$
infix.setRightOperand(number);
ITypeBinding infixType = infix.resolveTypeBinding();
return createNarrowCastIfNessecary(infix, infixType, ast, variableType, is50OrHigher);
}
示例11: newInfixExpression
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
public static Expression newInfixExpression(
AST ast, Operator operator, ArrayList<Expression> operands) {
if (operands.size() == 1) return operands.get(0);
InfixExpression result = ast.newInfixExpression();
result.setOperator(operator);
result.setLeftOperand(operands.get(0));
result.setRightOperand(operands.get(1));
result.extendedOperands().addAll(operands.subList(2, operands.size()));
return result;
}
示例12: createInfixInvocationFromPostPrefixExpression
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static Expression createInfixInvocationFromPostPrefixExpression(
InfixExpression.Operator operator,
Expression getterExpression,
AST ast,
ITypeBinding variableType,
boolean is50OrHigher) {
InfixExpression infix = ast.newInfixExpression();
infix.setLeftOperand(getterExpression);
infix.setOperator(operator);
NumberLiteral number = ast.newNumberLiteral();
number.setToken("1"); // $NON-NLS-1$
infix.setRightOperand(number);
ITypeBinding infixType = infix.resolveTypeBinding();
return createNarrowCastIfNessecary(infix, infixType, ast, variableType, is50OrHigher);
}
示例13: visit
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
@Override
public boolean visit(Assignment node) {
Expression leftHandSide = node.getLeftHandSide();
if (!considerBinding(resolveBinding(leftHandSide), leftHandSide)) return true;
checkParent(node);
Expression rightHandSide = node.getRightHandSide();
if (!fIsFieldFinal) {
// Write access.
AST ast = node.getAST();
MethodInvocation invocation = ast.newMethodInvocation();
invocation.setName(ast.newSimpleName(fSetter));
fReferencingSetter = true;
Expression receiver = getReceiver(leftHandSide);
if (receiver != null)
invocation.setExpression((Expression) fRewriter.createCopyTarget(receiver));
List<Expression> arguments = invocation.arguments();
if (node.getOperator() == Assignment.Operator.ASSIGN) {
arguments.add((Expression) fRewriter.createCopyTarget(rightHandSide));
} else {
// This is the compound assignment case: field+= 10;
InfixExpression exp = ast.newInfixExpression();
exp.setOperator(ASTNodes.convertToInfixOperator(node.getOperator()));
MethodInvocation getter = ast.newMethodInvocation();
getter.setName(ast.newSimpleName(fGetter));
fReferencingGetter = true;
if (receiver != null)
getter.setExpression((Expression) fRewriter.createCopyTarget(receiver));
exp.setLeftOperand(getter);
Expression rhs = (Expression) fRewriter.createCopyTarget(rightHandSide);
if (NecessaryParenthesesChecker.needsParenthesesForRightOperand(
rightHandSide, exp, leftHandSide.resolveTypeBinding())) {
ParenthesizedExpression p = ast.newParenthesizedExpression();
p.setExpression(rhs);
rhs = p;
}
exp.setRightOperand(rhs);
arguments.add(exp);
}
fRewriter.replace(node, invocation, createGroupDescription(WRITE_ACCESS));
}
rightHandSide.accept(this);
return false;
}
示例14: createInvocation
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private MethodInvocation createInvocation(AST ast, Expression operand, String operator) {
Expression receiver= getReceiver(operand);
MethodInvocation invocation= ast.newMethodInvocation();
invocation.setName(ast.newSimpleName(fSetter));
if (receiver != null)
invocation.setExpression((Expression)fRewriter.createCopyTarget(receiver));
InfixExpression argument= ast.newInfixExpression();
invocation.arguments().add(argument);
if ("++".equals(operator)) { //$NON-NLS-1$
argument.setOperator(InfixExpression.Operator.PLUS);
} else if ("--".equals(operator)) { //$NON-NLS-1$
argument.setOperator(InfixExpression.Operator.MINUS);
} else {
Assert.isTrue(false, "Should not happen"); //$NON-NLS-1$
}
MethodInvocation getter= ast.newMethodInvocation();
getter.setName(ast.newSimpleName(fGetter));
if (receiver != null)
getter.setExpression((Expression)fRewriter.createCopyTarget(receiver));
argument.setLeftOperand(getter);
argument.setRightOperand(ast.newNumberLiteral("1")); //$NON-NLS-1$
fReferencingGetter= true;
fReferencingSetter= true;
return invocation;
}
示例15: getInversedInfixExpression
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static Expression getInversedInfixExpression(ASTRewrite rewrite, InfixExpression expression, InfixExpression.Operator newOperator, SimpleNameRenameProvider provider) {
InfixExpression newExpression= rewrite.getAST().newInfixExpression();
newExpression.setOperator(newOperator);
newExpression.setLeftOperand(getRenamedNameCopy(provider, rewrite, expression.getLeftOperand()));
newExpression.setRightOperand(getRenamedNameCopy(provider, rewrite, expression.getRightOperand()));
return newExpression;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:8,代码来源:AdvancedQuickAssistProcessor.java