本文整理汇总了Java中org.eclipse.jdt.core.dom.InfixExpression.Operator方法的典型用法代码示例。如果您正苦于以下问题:Java InfixExpression.Operator方法的具体用法?Java InfixExpression.Operator怎么用?Java InfixExpression.Operator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.InfixExpression
的用法示例。
在下文中一共展示了InfixExpression.Operator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isAcumulationAssign
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static boolean isAcumulationAssign(Assignment assignment, InfixExpression.Operator op, Predicate<Expression> acceptExpression) {
if(!(
assignment.getRightHandSide() instanceof InfixExpression &&
assignment.getLeftHandSide() instanceof SimpleName &&
assignment.getOperator() == Assignment.Operator.ASSIGN))
return false;
InfixExpression exp = (InfixExpression) assignment.getRightHandSide();
if(exp.getOperator() != op)
return false;
String assignVar = assignment.getLeftHandSide().toString();
if( exp.getLeftOperand() instanceof SimpleName &&
exp.getLeftOperand().toString().equals(assignVar) &&
acceptExpression.test(exp.getRightOperand()))
return true;
if( exp.getRightOperand() instanceof SimpleName &&
exp.getRightOperand().toString().equals(assignVar) &&
acceptExpression.test(exp.getLeftOperand()))
return true;
return false;
}
示例2: isAssociative
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static boolean isAssociative(InfixExpression.Operator operator, ITypeBinding infixExprType, boolean isAllOperandsHaveSameType) {
if (operator == InfixExpression.Operator.PLUS) {
return isStringType(infixExprType) || isIntegerType(infixExprType) && isAllOperandsHaveSameType;
}
if (operator == InfixExpression.Operator.TIMES) {
return isIntegerType(infixExprType) && isAllOperandsHaveSameType;
}
if (operator == InfixExpression.Operator.CONDITIONAL_AND
|| operator == InfixExpression.Operator.CONDITIONAL_OR
|| operator == InfixExpression.Operator.AND
|| operator == InfixExpression.Operator.OR
|| operator == InfixExpression.Operator.XOR) {
return true;
}
return false;
}
示例3: getInfixExpressionType
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
/**
* Returns the type of infix expression based on its operands and operator.
*
* @param operator the operator of infix expression
* @param leftOperandType the type of left operand of infix expression
* @param rightOperandType the type of right operand of infix expression
* @return the type of infix expression if the type of both the operands is same or if the type
* of either operand of a + operator is String, <code>null</code> otherwise.
*
* @since 3.9
*/
private static ITypeBinding getInfixExpressionType(InfixExpression.Operator operator, ITypeBinding leftOperandType, ITypeBinding rightOperandType) {
if (leftOperandType == rightOperandType) {
return leftOperandType;
}
if (operator == InfixExpression.Operator.PLUS) {
if (isStringType(leftOperandType)) {
return leftOperandType;
} else if (isStringType(rightOperandType)) {
return rightOperandType;
}
}
// If the left and right operand types are different, we assume that parentheses are needed.
// This is to avoid complications of numeric promotions and for readability of complicated code.
return null;
}
示例4: isAssociative
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static boolean isAssociative(
InfixExpression.Operator operator,
ITypeBinding infixExprType,
boolean isAllOperandsHaveSameType) {
if (operator == InfixExpression.Operator.PLUS)
return isStringType(infixExprType)
|| isIntegerType(infixExprType) && isAllOperandsHaveSameType;
if (operator == InfixExpression.Operator.TIMES)
return isIntegerType(infixExprType) && isAllOperandsHaveSameType;
if (operator == InfixExpression.Operator.CONDITIONAL_AND
|| operator == InfixExpression.Operator.CONDITIONAL_OR
|| operator == InfixExpression.Operator.AND
|| operator == InfixExpression.Operator.OR
|| operator == InfixExpression.Operator.XOR) return true;
return false;
}
示例5: getInfixExpressionType
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
/**
* Returns the type of infix expression based on its operands and operator.
*
* @param operator the operator of infix expression
* @param leftOperandType the type of left operand of infix expression
* @param rightOperandType the type of right operand of infix expression
* @return the type of infix expression if the type of both the operands is same or if the type of
* either operand of a + operator is String, <code>null</code> otherwise.
* @since 3.9
*/
private static ITypeBinding getInfixExpressionType(
InfixExpression.Operator operator,
ITypeBinding leftOperandType,
ITypeBinding rightOperandType) {
if (leftOperandType == rightOperandType) {
return leftOperandType;
}
if (operator == InfixExpression.Operator.PLUS) {
if (isStringType(leftOperandType)) {
return leftOperandType;
} else if (isStringType(rightOperandType)) {
return rightOperandType;
}
}
// If the left and right operand types are different, we assume that parentheses are needed.
// This is to avoid complications of numeric promotions and for readability of complicated code.
return null;
}
示例6: 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;
}
示例7: getInfixExpressionType
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
/**
* Returns the type of infix expression based on its operands and operator.
*
* @param operator the operator of infix expression
* @param leftOperandType the type of left operand of infix expression
* @param rightOperandType the type of right operand of infix expression
* @return the type of infix expression if the type of both the operands is same or if the type
* of either operand of a + operator is String, <code>null</code> otherwise.
*
* @since 3.9
*/
private static ITypeBinding getInfixExpressionType(InfixExpression.Operator operator, ITypeBinding leftOperandType, ITypeBinding rightOperandType) {
if (leftOperandType == rightOperandType) {
return leftOperandType;
}
if (operator == InfixExpression.Operator.PLUS) {
if (isStringType(leftOperandType)) {
return leftOperandType;
} else if (isStringType(rightOperandType)) {
return rightOperandType;
}
}
// If the left and right operand types are different, we assume that parentheses are needed.
// This is to avoid complications of numeric promotions and for readability of complicated code.
return null;
}
示例8: needsParentesis
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private boolean needsParentesis(ASTNode node) {
if (!(node.getParent() instanceof InfixExpression))
return false;
if (node instanceof InstanceofExpression)
return true;
if (node instanceof InfixExpression) {
InfixExpression expression = (InfixExpression) node;
InfixExpression.Operator operator = expression.getOperator();
InfixExpression parentExpression = (InfixExpression) node.getParent();
InfixExpression.Operator parentOperator = parentExpression.getOperator();
if (parentOperator == operator)
return false;
return true;
}
return false;
}
示例9: isCompareOperator
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private boolean isCompareOperator(InfixExpression.Operator op) {
return
op == InfixExpression.Operator.LESS ||
op == InfixExpression.Operator.LESS_EQUALS ||
op == InfixExpression.Operator.GREATER ||
op == InfixExpression.Operator.GREATER_EQUALS ||
op == InfixExpression.Operator.NOT_EQUALS;
}
示例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: isLegalInfixOperator
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
public static boolean isLegalInfixOperator(InfixExpression.Operator op) {
return op == InfixExpression.Operator.EQUALS
|| op == InfixExpression.Operator.NOT_EQUALS
|| op == InfixExpression.Operator.GREATER
|| op == InfixExpression.Operator.LESS
|| op == InfixExpression.Operator.GREATER_EQUALS
|| op == InfixExpression.Operator.LESS_EQUALS;
}
示例12: isSuspiciousInfixOperator
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
public static boolean isSuspiciousInfixOperator(InfixExpression.Operator op) {
return false;
// op == InfixExpression.Operator.AND ||
// op == InfixExpression.Operator.OR ;
// commented for version 1
/*
* || op == InfixExpression.Operator.GREATER || op ==
* InfixExpression.Operator.GREATER_EQUALS || op ==
* InfixExpression.Operator.LESS || op ==
* InfixExpression.Operator.LESS_EQUALS || op ==
* InfixExpression.Operator.XOR;
*/
}
示例13: isOperatorAssociative
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static boolean isOperatorAssociative(InfixExpression.Operator operator) {
return operator == InfixExpression.Operator.PLUS
|| operator == InfixExpression.Operator.TIMES
|| operator == InfixExpression.Operator.XOR
|| operator == InfixExpression.Operator.OR
|| operator == InfixExpression.Operator.AND
|| operator == InfixExpression.Operator.CONDITIONAL_OR
|| operator == InfixExpression.Operator.CONDITIONAL_AND;
}
示例14: 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);
}
示例15: isOperatorAssociative
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static boolean isOperatorAssociative(InfixExpression.Operator operator) {
return operator == InfixExpression.Operator.PLUS
|| operator == InfixExpression.Operator.TIMES
|| operator == InfixExpression.Operator.XOR
|| operator == InfixExpression.Operator.OR
|| operator == InfixExpression.Operator.AND
|| operator == InfixExpression.Operator.CONDITIONAL_OR
|| operator == InfixExpression.Operator.CONDITIONAL_AND;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:10,代码来源:AssociativeInfixExpressionFragment.java