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


Java ErrorUtil類代碼示例

本文整理匯總了Java中com.siyeh.ipp.psiutils.ErrorUtil的典型用法代碼示例。如果您正苦於以下問題:Java ErrorUtil類的具體用法?Java ErrorUtil怎麽用?Java ErrorUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ErrorUtil類屬於com.siyeh.ipp.psiutils包,在下文中一共展示了ErrorUtil類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: satisfiedBy

import com.siyeh.ipp.psiutils.ErrorUtil; //導入依賴的package包/類
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiVariable)) {
    return false;
  }
  if (ErrorUtil.containsError(element)) {
    return false;
  }
  final PsiVariable var = (PsiVariable)element;
  final PsiTypeElement typeElement = var.getTypeElement();
  if (typeElement == null) {
    return false; // Could be true for enum constants.
  }

  final PsiType elementType = typeElement.getType();
  final PsiType type = var.getType();
  return elementType.getArrayDimensions() != type.getArrayDimensions();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:SimplifyVariablePredicate.java

示例2: satisfiedBy

import com.siyeh.ipp.psiutils.ErrorUtil; //導入依賴的package包/類
@Override
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiBinaryExpression)) {
    return false;
  }
  final PsiBinaryExpression expression = (PsiBinaryExpression)element;
  final IElementType tokenType = expression.getOperationTokenType();
  if (!tokenType.equals(JavaTokenType.EQEQ) &&
      !tokenType.equals(JavaTokenType.NE)) {
    return false;
  }
  final PsiExpression lhs = expression.getLOperand();
  final PsiExpression rhs = expression.getROperand();
  if (rhs == null) {
    return false;
  }
  if (!BoolUtils.isBooleanLiteral(lhs) &&
      !BoolUtils.isBooleanLiteral(rhs)) {
    return false;
  }
  final PsiType type = expression.getType();
  if (!PsiType.BOOLEAN.equals(type)) {
    return false;
  }
  return !ErrorUtil.containsError(element);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:BooleanLiteralEqualityPredicate.java

示例3: satisfiedBy

import com.siyeh.ipp.psiutils.ErrorUtil; //導入依賴的package包/類
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiMethodCallExpression)) {
    return false;
  }
  final PsiMethodCallExpression expression =
    (PsiMethodCallExpression)element;
  final PsiExpressionList argumentList = expression.getArgumentList();
  final PsiExpression[] arguments = argumentList.getExpressions();
  if (arguments.length != 1) {
    return false;
  }
  final PsiReferenceExpression methodExpression =
    expression.getMethodExpression();
  final PsiExpression qualifier =
    methodExpression.getQualifierExpression();
  if (qualifier == null) {
    return false;
  }
  @NonNls final String methodName = methodExpression.getReferenceName();
  if (!"equals".equals(methodName)) {
    return false;
  }
  return !ErrorUtil.containsError(element);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:EqualsPredicate.java

示例4: satisfiedBy

import com.siyeh.ipp.psiutils.ErrorUtil; //導入依賴的package包/類
public boolean satisfiedBy(@NotNull PsiElement element) {
  final PsiElement parent = element.getParent();
  if (!(parent instanceof PsiField)) {
    return false;
  }
  if (element instanceof PsiComment &&
      element == parent.getFirstChild()) {
    return false;
  }
  final PsiField field = (PsiField)parent;
  final PsiExpression initializer = field.getInitializer();
  if (initializer == null) {
    return false;
  }
  final PsiClass containingClass = field.getContainingClass();
  if (containingClass == null || containingClass.isInterface()) {
    return false;
  }
  return !ErrorUtil.containsError(field);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:SplitDeclarationAndInitializationPredicate.java

示例5: checkSwitchStatement

import com.siyeh.ipp.psiutils.ErrorUtil; //導入依賴的package包/類
public static boolean checkSwitchStatement(@NotNull PsiSwitchStatement switchStatement) {
  final PsiExpression expression = switchStatement.getExpression();
  if (expression == null) {
    return false;
  }
  final PsiCodeBlock body = switchStatement.getBody();
  if (body == null) {
    return false;
  }
  if (ErrorUtil.containsError(switchStatement)) {
    return false;
  }
  boolean hasLabel = false;
  final PsiStatement[] statements = body.getStatements();
  for (PsiStatement statement : statements) {
    if (statement instanceof PsiSwitchLabelStatement) {
      hasLabel = true;
      break;
    }
  }
  return hasLabel;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:SwitchPredicate.java

示例6: satisfiedBy

import com.siyeh.ipp.psiutils.ErrorUtil; //導入依賴的package包/類
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiJavaToken)) {
    return false;
  }
  final PsiJavaToken token = (PsiJavaToken)element;
  if (token.getTokenType() != JavaTokenType.IF_KEYWORD) {
    return false;
  }
  final PsiElement parent = element.getParent();
  if (!(parent instanceof PsiIfStatement)) {
    return false;
  }
  final PsiIfStatement statement = (PsiIfStatement)parent;
  if (ErrorUtil.containsError(statement)) {
    return false;
  }
  return SwitchUtils.getSwitchExpression(statement, 0) != null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:IfToSwitchPredicate.java

示例7: satisfiedBy

import com.siyeh.ipp.psiutils.ErrorUtil; //導入依賴的package包/類
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiConditionalExpression)) {
    return false;
  }
  final PsiConditionalExpression condition =
    (PsiConditionalExpression)element;
  PsiExpression thenExpression = condition.getThenExpression();
  PsiExpression elseExpression = condition.getElseExpression();
  if (thenExpression == null || elseExpression == null) {
    return false;
  }
  thenExpression = ParenthesesUtils.stripParentheses(thenExpression);
  elseExpression = ParenthesesUtils.stripParentheses(elseExpression);
  if (thenExpression == null || elseExpression == null) {
    return false;
  }
  @NonNls final String thenText = thenExpression.getText();
  @NonNls final String elseText = elseExpression.getText();
  if ("true".equals(elseText) && "false".equals(thenText)) {
    return !ErrorUtil.containsError(element);
  }
  else if ("true".equals(thenText) && "false".equals(elseText)) {
    return !ErrorUtil.containsError(element);
  }
  return false;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:RemoveConditionalPredicate.java

示例8: satisfiedBy

import com.siyeh.ipp.psiutils.ErrorUtil; //導入依賴的package包/類
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiJavaToken)) {
    return false;
  }
  final PsiJavaToken token = (PsiJavaToken)element;
  final IElementType tokenType = token.getTokenType();
  if (!JavaTokenType.FOR_KEYWORD.equals(tokenType)) {
    return false;
  }
  final PsiElement parent = element.getParent();
  if (!(parent instanceof PsiForeachStatement)) {
    return false;
  }
  final PsiForeachStatement foreachStatement = (PsiForeachStatement)parent;
  final PsiExpression iteratedValue = foreachStatement.getIteratedValue();
  if (iteratedValue == null) {
    return false;
  }
  final PsiType type = iteratedValue.getType();
  if (!InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_LANG_ITERABLE)) {
    return false;
  }
  return !ErrorUtil.containsError(foreachStatement);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:IterableForEachLoopPredicate.java

示例9: processIntention

import com.siyeh.ipp.psiutils.ErrorUtil; //導入依賴的package包/類
@Override
public void processIntention(@NotNull PsiElement element) {
  final PsiReturnStatement returnStatement = (PsiReturnStatement)element;
  final PsiExpression returnValue = returnStatement.getReturnValue();
  if (returnValue == null || ErrorUtil.containsDeepError(returnValue)) {
    return;
  }
  final String newStatementText = buildIf(returnValue, true, new StringBuilder()).toString();
  final Project project = returnStatement.getProject();
  final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory();
  final PsiBlockStatement blockStatement = (PsiBlockStatement)elementFactory.createStatementFromText("{" + newStatementText + "}", returnStatement);
  final PsiElement parent = returnStatement.getParent();
  for (PsiStatement st : blockStatement.getCodeBlock().getStatements()) {
    CodeStyleManager.getInstance(project).reformat(parent.addBefore(st, returnStatement));
  }
  PsiReplacementUtil.replaceStatement(returnStatement, "return false;");
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:ConvertToNestedIfIntention.java

示例10: satisfiedBy

import com.siyeh.ipp.psiutils.ErrorUtil; //導入依賴的package包/類
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiBinaryExpression)) {
    return false;
  }
  final PsiBinaryExpression expression = (PsiBinaryExpression)element;
  final IElementType tokenType = expression.getOperationTokenType();
  if (!tokenType.equals(JavaTokenType.EQEQ) &&
      !tokenType.equals(JavaTokenType.NE)) {
    return false;
  }
  final PsiExpression lhs = expression.getLOperand();
  final PsiExpression rhs = expression.getROperand();
  if (rhs == null) {
    return false;
  }
  if (!BoolUtils.isBooleanLiteral(lhs) &&
      !BoolUtils.isBooleanLiteral(rhs)) {
    return false;
  }
  final PsiType type = expression.getType();
  if (!PsiType.BOOLEAN.equals(type)) {
    return false;
  }
  return !ErrorUtil.containsError(element);
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:26,代碼來源:BooleanLiteralEqualityPredicate.java

示例11: processIntention

import com.siyeh.ipp.psiutils.ErrorUtil; //導入依賴的package包/類
@Override
public void processIntention(@NotNull PsiElement element) {
  final PsiReturnStatement returnStatement = (PsiReturnStatement)element;
  final PsiExpression returnValue = returnStatement.getReturnValue();
  if (returnValue == null || ErrorUtil.containsDeepError(returnValue)) {
    return;
  }
  final String newStatementText = buildIf(returnValue, new StringBuilder()).toString();
  final Project project = returnStatement.getProject();
  final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory();
  final PsiBlockStatement blockStatement = (PsiBlockStatement)elementFactory.createStatementFromText("{" + newStatementText + "}", returnStatement);
  final PsiElement parent = returnStatement.getParent();
  for (PsiStatement st : blockStatement.getCodeBlock().getStatements()) {
    CodeStyleManager.getInstance(project).reformat(parent.addBefore(st, returnStatement));
  }
  replaceStatement("return false;", returnStatement);
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:18,代碼來源:ConvertToNestedIfIntention.java

示例12: satisfiedBy

import com.siyeh.ipp.psiutils.ErrorUtil; //導入依賴的package包/類
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiJavaToken)) {
    return false;
  }
  final PsiJavaToken token = (PsiJavaToken)element;
  if (token.getTokenType() != JavaTokenType.IF_KEYWORD) {
    return false;
  }
  final PsiElement parent = element.getParent();
  if (!(parent instanceof PsiIfStatement)) {
    return false;
  }
  final PsiIfStatement statement = (PsiIfStatement)parent;
  if (ErrorUtil.containsError(statement)) {
    return false;
  }
  return SwitchUtils.getSwitchExpression(statement) != null;
}
 
開發者ID:consulo,項目名稱:consulo-java,代碼行數:19,代碼來源:IfToSwitchPredicate.java

示例13: satisfiedBy

import com.siyeh.ipp.psiutils.ErrorUtil; //導入依賴的package包/類
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiBinaryExpression)) {
    return false;
  }
  final PsiBinaryExpression expression = (PsiBinaryExpression)element;
  final PsiExpression rhs = expression.getROperand();
  if (rhs == null) {
    return false;
  }
  if (!ComparisonUtils.isComparison((PsiExpression)element)) {
    return false;
  }
  return !ErrorUtil.containsError(element);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:ComparisonPredicate.java

示例14: satisfiedBy

import com.siyeh.ipp.psiutils.ErrorUtil; //導入依賴的package包/類
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiPolyadicExpression)) {
    return false;
  }
  final PsiPolyadicExpression expression = (PsiPolyadicExpression)element;
  final IElementType tokenType = expression.getOperationTokenType();
  if (!tokenType.equals(JavaTokenType.ANDAND) &&
      !tokenType.equals(JavaTokenType.OROR)) {
    return false;
  }
  return !ErrorUtil.containsError(element);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:ConjunctionPredicate.java

示例15: satisfiedBy

import com.siyeh.ipp.psiutils.ErrorUtil; //導入依賴的package包/類
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiMethodCallExpression)) {
    return false;
  }
  final PsiMethodCallExpression expression =
    (PsiMethodCallExpression)element;
  final PsiExpressionList args = expression.getArgumentList();
  final int numExpressions = args.getExpressions().length;
  if (numExpressions < 1 || numExpressions > 2) {
    return false;
  }
  final PsiReferenceExpression methodExpression =
    expression.getMethodExpression();
  @NonNls final String methodName = methodExpression.getReferenceName();
  if (!("assertTrue".equals(methodName) ||
        "assertFalse".equals(methodName) ||
        "assertNull".equals(methodName))) {
    return false;
  }
  final PsiMethod method = expression.resolveMethod();
  if (method == null) {
    return false;
  }
  final PsiClass targetClass = method.getContainingClass();
  if (targetClass == null) {
    return false;
  }
  final String qualifiedName = targetClass.getQualifiedName();
  if (!"junit.framework.Assert".equals(qualifiedName) &&
      !"org.junit.Assert".equals(qualifiedName)) {
    return false;
  }
  return !ErrorUtil.containsError(element);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:35,代碼來源:AssertLiteralPredicate.java


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