本文整理汇总了Java中org.eclipse.jdt.core.dom.Assignment.Operator类的典型用法代码示例。如果您正苦于以下问题:Java Operator类的具体用法?Java Operator怎么用?Java Operator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Operator类属于org.eclipse.jdt.core.dom.Assignment包,在下文中一共展示了Operator类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeNewReturnStatement
import org.eclipse.jdt.core.dom.Assignment.Operator; //导入依赖的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;
}
示例2: createInfixInvocationFromPostPrefixExpression
import org.eclipse.jdt.core.dom.Assignment.Operator; //导入依赖的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);
}
示例3: createInfixInvocationFromPostPrefixExpression
import org.eclipse.jdt.core.dom.Assignment.Operator; //导入依赖的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);
}
示例4: createInfixInvocationFromPostPrefixExpression
import org.eclipse.jdt.core.dom.Assignment.Operator; //导入依赖的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);
}
示例5: convertAssignOperatorToInfixOperator
import org.eclipse.jdt.core.dom.Assignment.Operator; //导入依赖的package包/类
private InfixExpression.Operator convertAssignOperatorToInfixOperator(Operator assignOperator) {
if (assignOperator == Operator.PLUS_ASSIGN) {
return InfixExpression.Operator.PLUS;
} else if (assignOperator == Operator.TIMES_ASSIGN) {
return InfixExpression.Operator.TIMES;
} else if (assignOperator == Operator.MINUS_ASSIGN) {
return InfixExpression.Operator.MINUS;
} else if (assignOperator == Operator.DIVIDE_ASSIGN) {
return InfixExpression.Operator.DIVIDE;
} else if (assignOperator == Operator.REMAINDER_ASSIGN) {
return InfixExpression.Operator.REMAINDER;
} else if (assignOperator == Operator.LEFT_SHIFT_ASSIGN) {
return InfixExpression.Operator.LEFT_SHIFT;
} else if (assignOperator == Operator.RIGHT_SHIFT_SIGNED_ASSIGN) {
return InfixExpression.Operator.RIGHT_SHIFT_SIGNED;
} else if (assignOperator == Operator.RIGHT_SHIFT_UNSIGNED_ASSIGN) {
return InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED;
} else if (assignOperator == Operator.RIGHT_SHIFT_UNSIGNED_ASSIGN) {
return InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED;
} else if (assignOperator == Operator.BIT_AND_ASSIGN) {
return InfixExpression.Operator.AND;
} else if (assignOperator == Operator.BIT_OR_ASSIGN) {
return InfixExpression.Operator.OR;
} else if (assignOperator == Operator.BIT_XOR_ASSIGN) {
return InfixExpression.Operator.XOR;
}
return null;
}
示例6: getAssignedValue
import org.eclipse.jdt.core.dom.Assignment.Operator; //导入依赖的package包/类
/**
* 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;
}
示例7: getAssignedValue
import org.eclipse.jdt.core.dom.Assignment.Operator; //导入依赖的package包/类
/**
* 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;
}
示例8: getAssignedValue
import org.eclipse.jdt.core.dom.Assignment.Operator; //导入依赖的package包/类
/**
* 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;
}
示例9: getAssignedValue
import org.eclipse.jdt.core.dom.Assignment.Operator; //导入依赖的package包/类
/**
* 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.needsParentheses(copiedRightOp, infix, InfixExpression.RIGHT_OPERAND_PROPERTY)) {
//TODO: this introduces extra parentheses as the new "infix" node doesn't have bindings
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;
}