当前位置: 首页>>代码示例>>Java>>正文


Java InfixExpression.getRightOperand方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.InfixExpression.getRightOperand方法的典型用法代码示例。如果您正苦于以下问题:Java InfixExpression.getRightOperand方法的具体用法?Java InfixExpression.getRightOperand怎么用?Java InfixExpression.getRightOperand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.dom.InfixExpression的用法示例。


在下文中一共展示了InfixExpression.getRightOperand方法的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;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:17,代码来源:VarParser.java

示例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;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:25,代码来源:VarParser.java

示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:AdvancedQuickAssistProcessor.java

示例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;
}
 
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:24,代码来源:IsNANResolution.java

示例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;
}
 
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:21,代码来源:CompareFloatResolution.java

示例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;
}
 
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:23,代码来源:IsEmptyResolution.java

示例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;
}
 
开发者ID:eclipse,项目名称:che,代码行数:39,代码来源:ConvertForLoopOperation.java

示例8: getNextSiblingExpression

import org.eclipse.jdt.core.dom.InfixExpression; //导入方法依赖的package包/类
private static Expression getNextSiblingExpression(Expression expression) {
	InfixExpression parentInfixExpression= (InfixExpression) expression.getParent();
	Expression sibiling;
	if (expression.equals(parentInfixExpression.getLeftOperand())) {
		sibiling= parentInfixExpression.getRightOperand();
	} else if (expression.equals(parentInfixExpression.getRightOperand())) {
		if (parentInfixExpression.getParent() instanceof InfixExpression)
			sibiling= getNextSiblingExpression(parentInfixExpression);
		else
			sibiling= null;
	} else {
		sibiling= null;
	}
	return sibiling;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:AdvancedQuickAssistProcessor.java

示例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;
}
 
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:11,代码来源:CompareFloatResolution.java

示例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();
}
 
开发者ID:kjlubick,项目名称:fb-contrib-eclipse-quick-fixes,代码行数:41,代码来源:CompareFloatResolution.java

示例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;
   }
 
开发者ID:junit-tools-team,项目名称:junit-tools,代码行数:56,代码来源:MethodAnalyzer.java

示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:45,代码来源:ConvertForLoopOperation.java


注:本文中的org.eclipse.jdt.core.dom.InfixExpression.getRightOperand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。