diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java index cd01d32cde50..b757e9eb45e4 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java @@ -2421,6 +2421,11 @@ public class HighlightUtil extends HighlightUtilBase { QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createAddTypeCastFix(throwable, (PsiExpression)context)); } } + + final PsiClass aClass = PsiUtil.resolveClassInClassTypeOnly(type); + if (aClass != null) { + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createExtendsListFix(aClass, throwable, true)); + } return highlightInfo; } return null; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/makeExtendsThrowable/afterThrowsNew.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/makeExtendsThrowable/afterThrowsNew.java new file mode 100644 index 000000000000..2a65087096e1 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/makeExtendsThrowable/afterThrowsNew.java @@ -0,0 +1,8 @@ +// "Make 'C' extend 'java.lang.Throwable'" "true" + +class C extends Throwable {} +class Main { + public static void main(String[] args) { + throw new C(); + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/makeExtendsThrowable/beforeThrowsNew.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/makeExtendsThrowable/beforeThrowsNew.java new file mode 100644 index 000000000000..2dc46ca063ca --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/makeExtendsThrowable/beforeThrowsNew.java @@ -0,0 +1,8 @@ +// "Make 'C' extend 'java.lang.Throwable'" "true" + +class C {} +class Main { + public static void main(String[] args) { + throw new C(); + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/MakeExtendsThrowableTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/MakeExtendsThrowableTest.java new file mode 100644 index 000000000000..76d9687b1dcb --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/MakeExtendsThrowableTest.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2013 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.quickFix; + +public class MakeExtendsThrowableTest extends LightQuickFix15TestCase { + public void test() throws Exception { doAllTests(); } + + @Override + protected String getBasePath() { + return "/codeInsight/daemonCodeAnalyzer/quickFix/makeExtendsThrowable"; + } +} +