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


Java ExceptionUtils.isGenericExceptionClass方法代码示例

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


在下文中一共展示了ExceptionUtils.isGenericExceptionClass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findMaskedExceptions

import com.siyeh.ig.psiutils.ExceptionUtils; //导入方法依赖的package包/类
private List<PsiType> findMaskedExceptions(Set<PsiType> thrownTypes, PsiType caughtType, Set<PsiType> caughtTypes) {
  if (thrownTypes.contains(caughtType)) {
    if (ignoreThrown) {
      return Collections.emptyList();
    }
    caughtTypes.add(caughtType);
    thrownTypes.remove(caughtType);
  }
  if (onlyWarnOnRootExceptions) {
    if (!ExceptionUtils.isGenericExceptionClass(caughtType)) {
      return Collections.emptyList();
    }
  }
  final List<PsiType> maskedTypes = new ArrayList<PsiType>();
  for (PsiType typeThrown : thrownTypes) {
    if (!caughtTypes.contains(typeThrown) && caughtType.isAssignableFrom(typeThrown)) {
      caughtTypes.add(typeThrown);
      maskedTypes.add(typeThrown);
    }
  }
  return maskedTypes;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:TooBroadCatchInspectionBase.java

示例2: findMaskedExceptions

import com.siyeh.ig.psiutils.ExceptionUtils; //导入方法依赖的package包/类
private List<PsiClass> findMaskedExceptions(Set<PsiClassType> exceptionsThrown, Set<PsiType> exceptionsCaught, PsiType typeCaught) {
  if (exceptionsThrown.contains(typeCaught)) {
    if (ignoreThrown) {
      return Collections.emptyList();
    }
    exceptionsCaught.add(typeCaught);
    exceptionsThrown.remove(typeCaught);
  }
  if (onlyWarnOnRootExceptions) {
    if (!ExceptionUtils.isGenericExceptionClass(typeCaught)) {
      return Collections.emptyList();
    }
  }
  final List<PsiClass> typesMasked = new ArrayList();
  for (PsiClassType typeThrown : exceptionsThrown) {
    if (!exceptionsCaught.contains(typeThrown) && typeCaught.isAssignableFrom(typeThrown)) {
      exceptionsCaught.add(typeThrown);
      final PsiClass aClass = typeThrown.resolve();
      if (aClass != null) {
        typesMasked.add(aClass);
      }
    }
  }
  return typesMasked;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:TooBroadCatchInspection.java

示例3: visitMethod

import com.siyeh.ig.psiutils.ExceptionUtils; //导入方法依赖的package包/类
@Override
public void visitMethod(PsiMethod method) {
  super.visitMethod(method);
  final PsiReferenceList throwsList = method.getThrowsList();
  if (!throwsList.isPhysical()) {
    return;
  }
  final PsiJavaCodeReferenceElement[] throwsReferences = throwsList.getReferenceElements();
  if (throwsReferences.length == 0) {
    return;
  }
  final PsiCodeBlock body = method.getBody();
  if (body == null) {
    return;
  }
  if (ignoreLibraryOverrides && LibraryUtil.isOverrideOfLibraryMethod(method)) {
    return;
  }
  final Set<PsiType> exceptionsThrown = ExceptionUtils.calculateExceptionsThrown(body);
  final PsiClassType[] referencedExceptions = throwsList.getReferencedTypes();
  final Set<PsiType> exceptionsDeclared = new HashSet<PsiType>(referencedExceptions.length);
  ContainerUtil.addAll(exceptionsDeclared, referencedExceptions);
  final int referencedExceptionsLength = referencedExceptions.length;
  for (int i = 0; i < referencedExceptionsLength; i++) {
    final PsiClassType referencedException = referencedExceptions[i];
    if (onlyWarnOnRootExceptions) {
      if (!ExceptionUtils.isGenericExceptionClass(
        referencedException)) {
        continue;
      }
    }
    final List<SmartTypePointer> exceptionsMasked = new ArrayList<SmartTypePointer>();
    final SmartTypePointerManager pointerManager = SmartTypePointerManager.getInstance(body.getProject());
    for (PsiType exceptionThrown : exceptionsThrown) {
      if (referencedException.isAssignableFrom(exceptionThrown) && !exceptionsDeclared.contains(exceptionThrown)) {
        exceptionsMasked.add(pointerManager.createSmartTypePointer(exceptionThrown));
      }
    }
    if (!exceptionsMasked.isEmpty()) {
      final PsiJavaCodeReferenceElement throwsReference = throwsReferences[i];
      final boolean originalNeeded = exceptionsThrown.contains(referencedException);
      if (ignoreThrown && originalNeeded) {
        continue;
      }
      registerError(throwsReference, exceptionsMasked, Boolean.valueOf(originalNeeded), throwsReference);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:49,代码来源:TooBroadThrowsInspectionBase.java

示例4: visitMethod

import com.siyeh.ig.psiutils.ExceptionUtils; //导入方法依赖的package包/类
@Override
public void visitMethod(PsiMethod method) {
  super.visitMethod(method);
  final PsiReferenceList throwsList = method.getThrowsList();
  if (!throwsList.isPhysical()) {
    return;
  }
  final PsiJavaCodeReferenceElement[] throwsReferences = throwsList.getReferenceElements();
  if (throwsReferences.length == 0) {
    return;
  }
  final PsiCodeBlock body = method.getBody();
  if (body == null) {
    return;
  }
  if (ignoreInTestCode && TestUtils.isInTestCode(method)) {
    return;
  }
  if (ignoreLibraryOverrides && LibraryUtil.isOverrideOfLibraryMethod(method)) {
    return;
  }
  final Set<PsiClassType> exceptionsThrown = ExceptionUtils.calculateExceptionsThrown(body);
  final PsiClassType[] referencedExceptions = throwsList.getReferencedTypes();
  final Set<PsiClassType> exceptionsDeclared = new HashSet(referencedExceptions.length);
  ContainerUtil.addAll(exceptionsDeclared, referencedExceptions);
  final int referencedExceptionsLength = referencedExceptions.length;
  for (int i = 0; i < referencedExceptionsLength; i++) {
    final PsiClassType referencedException = referencedExceptions[i];
    if (onlyWarnOnRootExceptions) {
      if (!ExceptionUtils.isGenericExceptionClass(
        referencedException)) {
        continue;
      }
    }
    final List<SmartTypePointer> exceptionsMasked = new ArrayList();
    final SmartTypePointerManager pointerManager = SmartTypePointerManager.getInstance(body.getProject());
    for (PsiClassType exceptionThrown : exceptionsThrown) {
      if (referencedException.isAssignableFrom(exceptionThrown) && !exceptionsDeclared.contains(exceptionThrown)) {
        exceptionsMasked.add(pointerManager.createSmartTypePointer(exceptionThrown));
      }
    }
    if (!exceptionsMasked.isEmpty()) {
      final PsiJavaCodeReferenceElement throwsReference = throwsReferences[i];
      final boolean originalNeeded = exceptionsThrown.contains(referencedException);
      if (ignoreThrown && originalNeeded) {
        continue;
      }
      registerError(throwsReference, exceptionsMasked, Boolean.valueOf(originalNeeded));
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:52,代码来源:TooBroadThrowsInspection.java


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