mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (post-review #330)
This commit is contained in:
+1
-1
@@ -100,7 +100,7 @@ public class TryWithResourcesPostfixTemplate extends PostfixTemplate {
|
||||
@NotNull
|
||||
private static Collection<PsiClassType> getUnhandled(@NotNull PsiExpression expression) {
|
||||
assert expression.getType() != null;
|
||||
PsiMethod methodCloser = PsiUtil.getResourceCloserMethodForType((PsiClassType)expression.getType(), expression.getProject());
|
||||
PsiMethod methodCloser = PsiUtil.getResourceCloserMethodForType((PsiClassType)expression.getType());
|
||||
PsiSubstitutor substitutor = PsiUtil.resolveGenericsClassInType(expression.getType()).getSubstitutor();
|
||||
|
||||
return methodCloser != null
|
||||
|
||||
@@ -998,14 +998,15 @@ public final class PsiUtil extends PsiUtilCore {
|
||||
public static PsiMethod getResourceCloserMethod(@NotNull final PsiResourceVariable resource) {
|
||||
final PsiType resourceType = resource.getType();
|
||||
if (!(resourceType instanceof PsiClassType)) return null;
|
||||
return getResourceCloserMethodForType((PsiClassType)resourceType, resource.getProject());
|
||||
return getResourceCloserMethodForType((PsiClassType)resourceType);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiMethod getResourceCloserMethodForType(@NotNull final PsiClassType resourceType, Project project) {
|
||||
public static PsiMethod getResourceCloserMethodForType(@NotNull final PsiClassType resourceType) {
|
||||
final PsiClass resourceClass = resourceType.resolve();
|
||||
if (resourceClass == null) return null;
|
||||
|
||||
final Project project = resourceClass.getProject();
|
||||
final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
|
||||
final PsiClass autoCloseable = facade.findClass(CommonClassNames.JAVA_LANG_AUTO_CLOSEABLE, ProjectScope.getLibrariesScope(project));
|
||||
if (autoCloseable == null) return null;
|
||||
|
||||
@@ -403,13 +403,16 @@ public class ExceptionUtil {
|
||||
final boolean includeSelfCalls) {
|
||||
final JavaResolveResult result = methodCall.resolveMethodGenerics();
|
||||
final PsiMethod method = (PsiMethod)result.getElement();
|
||||
if (method == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(methodCall, PsiMethod.class);
|
||||
if (!includeSelfCalls && method == containingMethod) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final PsiSubstitutor substitutor = result.getSubstitutor();
|
||||
if (method != null && !isArrayClone(method, methodCall) && methodCall instanceof PsiMethodCallExpression) {
|
||||
if (!isArrayClone(method, methodCall) && methodCall instanceof PsiMethodCallExpression) {
|
||||
final PsiClassType[] thrownExceptions = method.getThrowsList().getReferencedTypes();
|
||||
if (thrownExceptions.length > 0) {
|
||||
final PsiFile containingFile = (containingMethod == null ? methodCall : containingMethod).getContainingFile();
|
||||
@@ -537,11 +540,11 @@ public class ExceptionUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<PsiClassType> getUnhandledExceptions(@Nullable PsiMethod method,
|
||||
PsiElement element,
|
||||
PsiElement topElement,
|
||||
@NotNull PsiSubstitutor substitutor) {
|
||||
if (method == null || isArrayClone(method, element)) {
|
||||
public static List<PsiClassType> getUnhandledExceptions(@NotNull PsiMethod method,
|
||||
PsiElement element,
|
||||
PsiElement topElement,
|
||||
@NotNull PsiSubstitutor substitutor) {
|
||||
if (isArrayClone(method, element)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final PsiClassType[] referencedTypes = method.getThrowsList().getReferencedTypes();
|
||||
|
||||
Reference in New Issue
Block a user