當前位置: 首頁>>代碼示例>>Java>>正文


Java ExpressionUtils.isVariableLessThanComparison方法代碼示例

本文整理匯總了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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:40,代碼來源:ManualArrayToCollectionCopyInspection.java

示例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));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:56,代碼來源:ManualArrayCopyInspection.java


注:本文中的com.siyeh.ig.psiutils.ExpressionUtils.isVariableLessThanComparison方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。