unhandledExceptions = new ArrayList<>(ExceptionUtil.collectUnhandledExceptions(tryStatement.getParent(), parent));
+ return !unhandledExceptions.isEmpty();
+ }
+
+ private static boolean notFinishedCatches(PsiCatchSection[] catchSections) {
+ return getAvailableCatchSections(catchSections)
+ .map(catchSection -> catchSection.getParameter())
+ .noneMatch(parameter -> parameter != null && parameter.getTypeElement() != null);
+ }
+
+
+ @Nls
+ @NotNull
+ @Override
+ public String getFamilyName() {
+ return QuickFixBundle.message("add.exception.to.existing.catch.family");
+ }
+
+ @NotNull
+ @Override
+ public String getText() {
+ return getFamilyName();
+ }
+}
diff --git a/java/java-impl/src/intentionDescriptions/AddExceptionToExistingCatchAction/after.java.template b/java/java-impl/src/intentionDescriptions/AddExceptionToExistingCatchAction/after.java.template
new file mode 100644
index 000000000000..62c5a478d26d
--- /dev/null
+++ b/java/java-impl/src/intentionDescriptions/AddExceptionToExistingCatchAction/after.java.template
@@ -0,0 +1,13 @@
+class A extends Exception {}
+class B extends A {}
+class C extends A {}
+
+class Test {
+ public static void main(String[] args) {
+ try {
+ throw new A();
+ } catch (A e) {
+ } catch (C e) {
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-impl/src/intentionDescriptions/AddExceptionToExistingCatchAction/before.java.template b/java/java-impl/src/intentionDescriptions/AddExceptionToExistingCatchAction/before.java.template
new file mode 100644
index 000000000000..8e6b97c3e4b3
--- /dev/null
+++ b/java/java-impl/src/intentionDescriptions/AddExceptionToExistingCatchAction/before.java.template
@@ -0,0 +1,13 @@
+class A extends Exception {}
+class B extends A {}
+class C extends A {}
+
+class Test {
+ public static void main(String[] args) {
+ try {
+ throw new A();
+ } catch (B e) {
+ } catch (C e) {
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-impl/src/intentionDescriptions/AddExceptionToExistingCatchAction/description.html b/java/java-impl/src/intentionDescriptions/AddExceptionToExistingCatchAction/description.html
new file mode 100644
index 000000000000..39607fce2352
--- /dev/null
+++ b/java/java-impl/src/intentionDescriptions/AddExceptionToExistingCatchAction/description.html
@@ -0,0 +1,6 @@
+
+
+Intention to add exception to existing catch clause
+
+
+
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addExceptionToExistingCatch/afterReplace.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addExceptionToExistingCatch/afterReplace.java
new file mode 100644
index 000000000000..18215ff69151
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addExceptionToExistingCatch/afterReplace.java
@@ -0,0 +1,16 @@
+// "Add exception to existing catch clause" "true"
+import java.io.IOException;
+
+class A extends Exception {}
+class B extends A {}
+class C extends A {}
+
+class Test {
+ public static void main(String[] args) {
+ try {
+ throw new A();
+ } catch (A e) {
+ } catch (C e) {
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addExceptionToExistingCatch/afterSimple.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addExceptionToExistingCatch/afterSimple.java
new file mode 100644
index 000000000000..8db6762d32ab
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addExceptionToExistingCatch/afterSimple.java
@@ -0,0 +1,11 @@
+// "Add exception to existing catch clause" "true"
+import java.io.IOException;
+
+class Test {
+ public static void main(String[] args) {
+ try {
+ throw new IOException();
+ } catch (IndexOutOfBoundsException | IOException e) {
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addExceptionToExistingCatch/beforeReplace.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addExceptionToExistingCatch/beforeReplace.java
new file mode 100644
index 000000000000..07fd991f4f64
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addExceptionToExistingCatch/beforeReplace.java
@@ -0,0 +1,16 @@
+// "Add exception to existing catch clause" "true"
+import java.io.IOException;
+
+class A extends Exception {}
+class B extends A {}
+class C extends A {}
+
+class Test {
+ public static void main(String[] args) {
+ try {
+ throw new A();
+ } catch (B e) {
+ } catch (C e) {
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addExceptionToExistingCatch/beforeSimple.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addExceptionToExistingCatch/beforeSimple.java
new file mode 100644
index 000000000000..dc22faae4118
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/addExceptionToExistingCatch/beforeSimple.java
@@ -0,0 +1,11 @@
+// "Add exception to existing catch clause" "true"
+import java.io.IOException;
+
+class Test {
+ public static void main(String[] args) {
+ try {
+ throw new IOException();
+ } catch (IndexOutOfBoundsException e) {
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/quickFix/AddExceptionToExistingCatchTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/quickFix/AddExceptionToExistingCatchTest.java
new file mode 100644
index 000000000000..eddbeb80acee
--- /dev/null
+++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/quickFix/AddExceptionToExistingCatchTest.java
@@ -0,0 +1,16 @@
+// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+package com.intellij.java.codeInsight.daemon.quickFix;
+
+import com.intellij.codeInsight.daemon.LightIntentionActionTestCase;
+
+public class AddExceptionToExistingCatchTest extends LightIntentionActionTestCase {
+ public void test() { doAllTests(); }
+
+ @Override
+ protected String getBasePath() {
+ return "/codeInsight/daemonCodeAnalyzer/quickFix/addExceptionToExistingCatch";
+ }
+
+
+}
+