本文整理汇总了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;
}
示例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;
}
示例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);
}
}
}
示例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));
}
}
}