本文整理汇总了Java中org.eclipse.jdt.core.dom.InfixExpression.getLeftOperand方法的典型用法代码示例。如果您正苦于以下问题:Java InfixExpression.getLeftOperand方法的具体用法?Java InfixExpression.getLeftOperand怎么用?Java InfixExpression.getLeftOperand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.InfixExpression
的用法示例。
在下文中一共展示了InfixExpression.getLeftOperand方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
public boolean visit(InfixExpression exp) {
Operator op = exp.getOperator();
if(isCompareOperator(op)) {
String leftExp = exp.getLeftOperand().toString();
String rightExp = exp.getRightOperand().toString();
Set<String> incVars = current.getOperations(VariableOperation.Type.INC, VariableOperation.Type.DEC);
if(exp.getLeftOperand() instanceof SimpleName && incVars.contains(leftExp))
aux(leftExp, op, exp.getRightOperand());
if(exp.getRightOperand() instanceof SimpleName && incVars.contains(rightExp))
aux(rightExp, op, exp.getLeftOperand());
}
return true;
}
示例2: 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;
}
示例3: isOperatorSelected
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static int isOperatorSelected(InfixExpression infixExpression, int offset, int length) {
ASTNode left= infixExpression.getLeftOperand();
ASTNode right= infixExpression.getRightOperand();
if (isSelectingOperator(left, right, offset, length)) {
return ASTNodes.getExclusiveEnd(left);
}
List<Expression> extended= infixExpression.extendedOperands();
for (int i= 0; i < extended.size(); i++) {
left= right;
right= extended.get(i);
if (isSelectingOperator(left, right, offset, length)) {
return ASTNodes.getExclusiveEnd(left);
}
}
return -1;
}
示例4: visit
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
@Override
@SuppressFBWarnings(value = "PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS",
justification = "Fixing the duplications would not impact performance and probably harm readibility")
public boolean visit(InfixExpression node) {
if (infixToReplace != null) {
return false;
}
this.infixToReplace = node;
if (node.getOperator() == Operator.EQUALS) {
this.isEquals = true;
} else if (node.getOperator() == Operator.NOT_EQUALS) {
this.isEquals = false;
}
if (node.getLeftOperand() instanceof SimpleName) {
handleVariable((SimpleName) node.getLeftOperand());
} else if (node.getRightOperand() instanceof SimpleName) {
handleVariable((SimpleName) node.getRightOperand());
}
return true;
}
示例5: findFirstAndSecondFloat
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private boolean findFirstAndSecondFloat(ConditionalExpression node, InfixExpression condExpr) {
if (!handleTwoSimpleNames(node, condExpr)) {
// this is a if diff > 0 case
try {
if (condExpr.getLeftOperand() instanceof SimpleName) {
findDiffAndFloats((SimpleName) condExpr.getLeftOperand());
} else if (condExpr.getRightOperand() instanceof SimpleName) {
findDiffAndFloats((SimpleName) condExpr.getRightOperand());
} else {
return true; // unexpected comparison
}
floatOrDouble = getFloatOrDouble(firstFloat, secondFloat);
expressionToReplace = node;
} catch (CouldntFindDiffException e) {
return true; // keep nesting if we have a problem
}
}
return false;
}
示例6: visit
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
@SuppressFBWarnings(value = "PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS",
justification = "The extra local variables would make things more confusing.")
@Override
public boolean visit(InfixExpression node) {
if (node.getOperator() == InfixExpression.Operator.EQUALS ||
node.getOperator() == InfixExpression.Operator.NOT_EQUALS) {
Expression left = node.getLeftOperand();
Expression right = node.getRightOperand();
Object rightConst = right.resolveConstantExpressionValue();
Object leftConst = left.resolveConstantExpressionValue();
if (left instanceof MethodInvocation && rightConst instanceof Integer) {
if (rightConst.equals(0)) {
foundPotentialNewCollection((MethodInvocation) left, node);
}
} else if (right instanceof MethodInvocation && leftConst instanceof Integer) {
if (leftConst.equals(0)) {
foundPotentialNewCollection((MethodInvocation) right, node);
}
}
}
return true;
}
示例7: validateExpression
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private boolean validateExpression(ForStatement statement) {
Expression expression = statement.getExpression();
if (!(expression instanceof InfixExpression)) return false;
InfixExpression infix = (InfixExpression) expression;
Expression left = infix.getLeftOperand();
Expression right = infix.getRightOperand();
if (left instanceof SimpleName && right instanceof SimpleName) {
IVariableBinding lengthBinding = fLengthBinding;
if (lengthBinding == null) return false;
IBinding leftBinding = ((SimpleName) left).resolveBinding();
IBinding righBinding = ((SimpleName) right).resolveBinding();
if (fIndexBinding.equals(leftBinding)) {
return lengthBinding.equals(righBinding);
} else if (fIndexBinding.equals(righBinding)) {
return lengthBinding.equals(leftBinding);
}
return false;
} else if (left instanceof SimpleName) {
if (!fIndexBinding.equals(((SimpleName) left).resolveBinding())) return false;
if (!Operator.LESS.equals(infix.getOperator())) return false;
return validateLengthQuery(right);
} else if (right instanceof SimpleName) {
if (!fIndexBinding.equals(((SimpleName) right).resolveBinding())) return false;
if (!Operator.GREATER.equals(infix.getOperator())) return false;
return validateLengthQuery(left);
}
return false;
}
示例8: visit
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
@Override
public boolean visit(InfixExpression node) {
if (numberExpression == null) {
if (!isRemainderExp(node)) {
return true;
}
numberExpression = node.getLeftOperand();
}
return false;
}
示例9: handleTwoSimpleNames
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private boolean handleTwoSimpleNames(ConditionalExpression node, InfixExpression condExpr) {
if (!areNames(condExpr.getLeftOperand(), condExpr.getRightOperand())) {
return false;
}
firstFloat = (Name) condExpr.getLeftOperand();
secondFloat = (Name) condExpr.getRightOperand();
expressionToReplace = node;
floatOrDouble = getFloatOrDouble(firstFloat, secondFloat);
return true;
}
示例10: findDiffAndFloats
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void findDiffAndFloats(SimpleName diffName) throws CouldntFindDiffException {
ConditionalExpression originalLine = TraversalUtil.findClosestAncestor(diffName, ConditionalExpression.class);
if (originalLine == null || !(originalLine.getExpression() instanceof InfixExpression)) {
throw new CouldntFindDiffException();
}
Block surroundingBlock = TraversalUtil.findClosestAncestor(originalLine, Block.class);
List<Statement> blockStatements = surroundingBlock.statements();
for (int i = blockStatements.size() - 1; i >= 0; i--) {
Statement statement = blockStatements.get(i);
if (statement instanceof VariableDeclarationStatement) {
List<VariableDeclarationFragment> frags = ((VariableDeclarationStatement) statement).fragments();
// I won't fix the the diff variable if it's nested with other frags, if they exist
// but we do need to look at them
VariableDeclarationFragment fragment = frags.get(0);
if (fragment.getName().getIdentifier().equals(diffName.getIdentifier())) {
Expression initializer = fragment.getInitializer();
if (initializer instanceof InfixExpression) {
InfixExpression subtraction = (InfixExpression) initializer;
if (subtraction.getOperator() == InfixExpression.Operator.MINUS &&
areNames(subtraction.getLeftOperand(), subtraction.getRightOperand())) {
this.firstFloat = (Name) subtraction.getLeftOperand();
this.secondFloat = (Name) subtraction.getRightOperand();
if (frags.size() == 1) {
this.optionalTempVariableToDelete = (VariableDeclarationStatement) statement;
}
return;
}
}
}
}
}
throw new CouldntFindDiffException();
}
示例11: analyzeMethod
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private MethodAnalyzeResult analyzeMethod(CompilationUnit astCu,
IMethod method) {
MethodAnalyzeResult mar = new MethodAnalyzeResult();
MethodDeclaration md = JDTUtils.createMethodDeclaration(astCu, method);
if (md == null) {
return mar;
}
List<IfStatement> ifStatements = collectIfStatements(md);
int numberOfIfStatements = ifStatements.size();
mar.setIfStatements(ifStatements);
// check if only null checks
if (ifStatements.size() > 0) {
boolean onlyNullChecks = true;
for (IfStatement ifSt : ifStatements) {
Expression expression = ifSt.getExpression();
if (expression.getNodeType() == ASTNode.INFIX_EXPRESSION) {
InfixExpression infixEx = (InfixExpression) expression;
Expression leftOperand = infixEx.getLeftOperand();
Expression rightOperand = infixEx.getRightOperand();
Operator operator = infixEx.getOperator();
if (operator.equals(Operator.EQUALS)
|| operator.equals(Operator.NOT_EQUALS)) {
if (leftOperand.getNodeType() == ASTNode.NULL_LITERAL
|| rightOperand.getNodeType() == ASTNode.NULL_LITERAL) {
continue;
}
}
}
onlyNullChecks = false;
}
mar.setOnlyNullChecks(onlyNullChecks);
}
// define test priority
if (numberOfIfStatements > 6) {
mar.setTestPrio(Testprio.HIGH);
} else if (numberOfIfStatements > 3) {
mar.setTestPrio(Testprio.DEFAULT);
} else if (numberOfIfStatements > 0) {
mar.setTestPrio(Testprio.LOW);
} else {
mar.setTestPrio(null);
}
return mar;
}
示例12: validateExpression
import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private boolean validateExpression(ForStatement statement) {
Expression expression= statement.getExpression();
if (!(expression instanceof InfixExpression))
return false;
InfixExpression infix= (InfixExpression)expression;
Expression left= infix.getLeftOperand();
Expression right= infix.getRightOperand();
if (left instanceof SimpleName && right instanceof SimpleName) {
IVariableBinding lengthBinding= fLengthBinding;
if (lengthBinding == null)
return false;
IBinding leftBinding= ((SimpleName)left).resolveBinding();
IBinding righBinding= ((SimpleName)right).resolveBinding();
if (fIndexBinding.equals(leftBinding)) {
return lengthBinding.equals(righBinding);
} else if (fIndexBinding.equals(righBinding)) {
return lengthBinding.equals(leftBinding);
}
return false;
} else if (left instanceof SimpleName) {
if (!fIndexBinding.equals(((SimpleName)left).resolveBinding()))
return false;
if (!Operator.LESS.equals(infix.getOperator()))
return false;
return validateLengthQuery(right);
} else if (right instanceof SimpleName) {
if (!fIndexBinding.equals(((SimpleName)right).resolveBinding()))
return false;
if (!Operator.GREATER.equals(infix.getOperator()))
return false;
return validateLengthQuery(left);
}
return false;
}