mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
suggest to extend class from Throwable when it participates in throw statement (IDEA-118215)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 <caret>C();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Make 'C' extend 'java.lang.Throwable'" "true"
|
||||
|
||||
class C {}
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
throw new <caret>C();
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user