本文整理汇总了Java中org.eclipse.jdt.core.dom.InfixExpression.setOperator方法的典型用法代码示例。如果您正苦于以下问题:Java InfixExpression.setOperator方法的具体用法?Java InfixExpression.setOperator怎么用?Java InfixExpression.setOperator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.InfixExpression
的用法示例。
在下文中一共展示了InfixExpression.setOperator方法的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: 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;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:22,代码来源:AdvancedQuickAssistProcessor.java
示例5: makeNewReturnStatement
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private ReturnStatement makeNewReturnStatement(ASTRewrite rewrite, USBRVisitor visitor) {
AST ast = rewrite.getAST();
ReturnStatement retVal = ast.newReturnStatement();
Expression baseExpression = (Expression) rewrite.createCopyTarget(visitor.unnecessaryStoreExpression);
Operator assignOperator = visitor.unnecessaryStoreOperator;
if (assignOperator != null && assignOperator != Operator.ASSIGN) {
InfixExpression infixExpression = ast.newInfixExpression();
infixExpression.setLeftOperand((Expression) rewrite.createCopyTarget(visitor.storedVariable));
infixExpression.setRightOperand(baseExpression);
infixExpression.setOperator(convertAssignOperatorToInfixOperator(assignOperator));
baseExpression = infixExpression;
}
retVal.setExpression(baseExpression);
return retVal;
}
示例6: 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;
}
示例7: 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);
}
示例8: 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;
}
示例9: 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);
}
示例10: 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;
}
示例11: 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;
}
示例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: addMemberCheckNull
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
@Override
protected void addMemberCheckNull(Object member, boolean addSeparator) {
ConditionalExpression cExpression= fAst.newConditionalExpression();
// member != null ?
InfixExpression infExpression= fAst.newInfixExpression();
infExpression.setLeftOperand(createMemberAccessExpression(member, true, true));
infExpression.setRightOperand(fAst.newNullLiteral());
infExpression.setOperator(Operator.NOT_EQUALS);
cExpression.setExpression(infExpression);
SumExpressionBuilder builder= new SumExpressionBuilder(null);
String[] arrayString= getContext().getTemplateParser().getBody();
for (int i= 0; i < arrayString.length; i++) {
addElement(processElement(arrayString[i], member), builder);
}
if (addSeparator)
addElement(getContext().getTemplateParser().getSeparator(), builder);
cExpression.setThenExpression(builder.getExpression());
StringLiteral literal= fAst.newStringLiteral();
literal.setLiteralValue(getContext().isSkipNulls() ? "" : "null"); //$NON-NLS-1$ //$NON-NLS-2$
cExpression.setElseExpression(literal);
ParenthesizedExpression pExpression= fAst.newParenthesizedExpression();
pExpression.setExpression(cExpression);
toStringExpressionBuilder.addExpression(pExpression);
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:29,代码来源:StringConcatenationGenerator.java
示例14: createInfixExpression
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
protected InfixExpression createInfixExpression(Expression leftOperand, Operator operator, Expression rightOperand) {
InfixExpression expression= fAst.newInfixExpression();
expression.setLeftOperand(leftOperand);
expression.setOperator(operator);
expression.setRightOperand(rightOperand);
return expression;
}
示例15: 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;
}