本文整理匯總了Java中com.siyeh.ig.psiutils.ExpressionUtils.isVariableLessThanComparison方法的典型用法代碼示例。如果您正苦於以下問題:Java ExpressionUtils.isVariableLessThanComparison方法的具體用法?Java ExpressionUtils.isVariableLessThanComparison怎麽用?Java ExpressionUtils.isVariableLessThanComparison使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.siyeh.ig.psiutils.ExpressionUtils
的用法示例。
在下文中一共展示了ExpressionUtils.isVariableLessThanComparison方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visitForStatement
import com.siyeh.ig.psiutils.ExpressionUtils; //導入方法依賴的package包/類
@Override
public void visitForStatement(
@NotNull PsiForStatement statement) {
super.visitForStatement(statement);
final PsiStatement initialization = statement.getInitialization();
if (!(initialization instanceof PsiDeclarationStatement)) {
return;
}
final PsiDeclarationStatement declaration =
(PsiDeclarationStatement)initialization;
final PsiElement[] declaredElements =
declaration.getDeclaredElements();
if (declaredElements.length != 1) {
return;
}
final PsiElement declaredElement = declaredElements[0];
if (!(declaredElement instanceof PsiLocalVariable)) {
return;
}
final PsiLocalVariable variable = (PsiLocalVariable)declaredElement;
final PsiExpression initialValue = variable.getInitializer();
if (initialValue == null) {
return;
}
final PsiExpression condition = statement.getCondition();
if (!ExpressionUtils.isVariableLessThanComparison(condition,
variable)) {
return;
}
final PsiStatement update = statement.getUpdate();
if (!VariableAccessUtils.variableIsIncremented(variable, update)) {
return;
}
final PsiStatement body = statement.getBody();
if (!bodyIsArrayToCollectionCopy(body, variable, true)) {
return;
}
registerStatementError(statement);
}
示例2: visitForStatement
import com.siyeh.ig.psiutils.ExpressionUtils; //導入方法依賴的package包/類
@Override
public void visitForStatement(
@NotNull PsiForStatement statement) {
super.visitForStatement(statement);
final PsiStatement initialization = statement.getInitialization();
if (!(initialization instanceof PsiDeclarationStatement)) {
return;
}
final PsiDeclarationStatement declaration =
(PsiDeclarationStatement)initialization;
final PsiElement[] declaredElements =
declaration.getDeclaredElements();
if (declaredElements.length != 1) {
return;
}
final PsiElement declaredElement = declaredElements[0];
if (!(declaredElement instanceof PsiLocalVariable)) {
return;
}
final PsiLocalVariable variable = (PsiLocalVariable)declaredElement;
final PsiExpression initialValue = variable.getInitializer();
if (initialValue == null) {
return;
}
final PsiStatement update = statement.getUpdate();
final boolean decrement;
if (VariableAccessUtils.variableIsIncremented(variable, update)) {
decrement = false;
}
else if (VariableAccessUtils.variableIsDecremented(variable,
update)) {
decrement = true;
}
else {
return;
}
final PsiExpression condition = statement.getCondition();
if (decrement) {
if (!ExpressionUtils.isVariableGreaterThanComparison(
condition, variable)) {
return;
}
}
else {
if (!ExpressionUtils.isVariableLessThanComparison(
condition, variable)) {
return;
}
}
final PsiStatement body = statement.getBody();
if (!bodyIsArrayCopy(body, variable, null)) {
return;
}
registerStatementError(statement, Boolean.valueOf(decrement));
}