mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ExceptionUtil.getThrownCheckedExceptions: accepts varargs now
This commit is contained in:
+1
-1
@@ -140,7 +140,7 @@ public class OptionalIsPresentInspection extends BaseJavaBatchLocalInspectionToo
|
||||
@Contract("null, _ -> false")
|
||||
static boolean isOptionalLambdaCandidate(PsiExpression lambdaCandidate, PsiVariable optionalVariable) {
|
||||
if(lambdaCandidate == null) return false;
|
||||
if(!ExceptionUtil.getThrownCheckedExceptions(new PsiElement[] {lambdaCandidate}).isEmpty()) return false;
|
||||
if(!ExceptionUtil.getThrownCheckedExceptions(lambdaCandidate).isEmpty()) return false;
|
||||
return PsiTreeUtil.processElements(lambdaCandidate, e -> {
|
||||
if (!(e instanceof PsiReferenceExpression)) return true;
|
||||
PsiElement element = ((PsiReferenceExpression)e).resolve();
|
||||
|
||||
+1
-1
@@ -242,7 +242,7 @@ public class Java8CollectionsApiInspection extends BaseJavaBatchLocalInspectionT
|
||||
!equivalence.expressionsAreEquivalent(value, putArguments[1])) {
|
||||
return;
|
||||
}
|
||||
if(!ExceptionUtil.getThrownCheckedExceptions(new PsiElement[] {lambdaCandidate}).isEmpty()) return;
|
||||
if(!ExceptionUtil.getThrownCheckedExceptions(lambdaCandidate).isEmpty()) return;
|
||||
if(!PsiTreeUtil.processElements(lambdaCandidate, e -> {
|
||||
if(!(e instanceof PsiReferenceExpression)) return true;
|
||||
PsiElement element = ((PsiReferenceExpression)e).resolve();
|
||||
|
||||
+1
-1
@@ -492,7 +492,7 @@ public class StreamApiMigrationInspection extends BaseJavaBatchLocalInspectionTo
|
||||
isArray = false;
|
||||
} else return;
|
||||
}
|
||||
if (!ExceptionUtil.getThrownCheckedExceptions(new PsiElement[]{body}).isEmpty()) return;
|
||||
if (!ExceptionUtil.getThrownCheckedExceptions(body).isEmpty()) return;
|
||||
|
||||
TerminalBlock tb = TerminalBlock.from(statement.getIterationParameter(), body);
|
||||
List<Operation> operations = tb.extractOperations();
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public class LambdaGenerationUtil {
|
||||
@Contract("null -> false")
|
||||
public static boolean canBeUncheckedLambda(PsiExpression lambdaCandidate) {
|
||||
if(lambdaCandidate == null) return false;
|
||||
if(!ExceptionUtil.getThrownCheckedExceptions(new PsiElement[] {lambdaCandidate}).isEmpty()) return false;
|
||||
if(!ExceptionUtil.getThrownCheckedExceptions(lambdaCandidate).isEmpty()) return false;
|
||||
return PsiTreeUtil.processElements(lambdaCandidate, e -> {
|
||||
if (!(e instanceof PsiReferenceExpression)) return true;
|
||||
PsiElement element = ((PsiReferenceExpression)e).resolve();
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -246,7 +246,7 @@ public class InlineParameterExpressionProcessor extends BaseRefactoringProcessor
|
||||
|
||||
@Override
|
||||
protected void performRefactoring(@NotNull UsageInfo[] usages) {
|
||||
final List<PsiClassType> thrownExceptions = ExceptionUtil.getThrownCheckedExceptions(new PsiElement[]{myInitializer});
|
||||
final List<PsiClassType> thrownExceptions = ExceptionUtil.getThrownCheckedExceptions(myInitializer);
|
||||
final Set<PsiVariable> varsUsedInInitializer = new HashSet<>();
|
||||
final Set<PsiJavaCodeReferenceElement> paramRefsToInline = new HashSet<>();
|
||||
final Map<PsiElement, PsiElement> replacements = new HashMap<>();
|
||||
|
||||
+1
-2
@@ -21,7 +21,6 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.colors.EditorColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -254,7 +253,7 @@ public class IntroduceConstantHandler extends BaseExpressionToFieldHandler {
|
||||
public void visitCallExpression(PsiCallExpression callExpression) {
|
||||
super.visitCallExpression(callExpression);
|
||||
if (!myCheckThrowables) return;
|
||||
final List<PsiClassType> checkedExceptions = ExceptionUtil.getThrownCheckedExceptions(new PsiElement[]{callExpression});
|
||||
final List<PsiClassType> checkedExceptions = ExceptionUtil.getThrownCheckedExceptions(callExpression);
|
||||
if (!checkedExceptions.isEmpty()) {
|
||||
myElementReference = callExpression;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ExceptionUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static List<PsiClassType> getThrownCheckedExceptions(@NotNull PsiElement[] elements) {
|
||||
public static List<PsiClassType> getThrownCheckedExceptions(@NotNull PsiElement... elements) {
|
||||
List<PsiClassType> exceptions = getThrownExceptions(elements);
|
||||
if (exceptions.isEmpty()) return exceptions;
|
||||
exceptions = filterOutUncheckedExceptions(exceptions);
|
||||
|
||||
Reference in New Issue
Block a user