Add "Remove annotation" quickfix for @Throws override mismatch
This commit is contained in:
@@ -50,6 +50,7 @@ import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.*
|
||||
import org.jetbrains.kotlin.resolve.konan.diagnostics.ErrorsNative.INCOMPATIBLE_THROWS_OVERRIDE
|
||||
import org.jetbrains.kotlin.resolve.konan.diagnostics.ErrorsNative.MISSING_EXCEPTION_IN_THROWS_ON_SUSPEND
|
||||
import org.jetbrains.kotlin.resolve.konan.diagnostics.ErrorsNative.THROWS_LIST_EMPTY
|
||||
|
||||
@@ -656,5 +657,6 @@ class QuickFixRegistrar : QuickFixContributor {
|
||||
|
||||
MISSING_EXCEPTION_IN_THROWS_ON_SUSPEND.registerFactory(AddExceptionToThrowsFix)
|
||||
THROWS_LIST_EMPTY.registerFactory(RemoveAnnotationFix)
|
||||
INCOMPATIBLE_THROWS_OVERRIDE.registerFactory(RemoveAnnotationFix)
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package kotlin
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
public annotation class Throws(vararg val exceptionClasses: KClass<out Throwable>)
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Remove annotation" "true"
|
||||
|
||||
class MyException : Throwable()
|
||||
|
||||
interface Base {
|
||||
@Throws(Throwable::class)
|
||||
fun foo()
|
||||
}
|
||||
|
||||
class Derived : Base {
|
||||
<caret>@Throws(MyException::class)
|
||||
override fun foo() {}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Remove annotation" "true"
|
||||
|
||||
class MyException : Throwable()
|
||||
|
||||
interface Base {
|
||||
@Throws(Throwable::class)
|
||||
fun foo()
|
||||
}
|
||||
|
||||
class Derived : Base {
|
||||
override fun foo() {}
|
||||
}
|
||||
+5
@@ -830,6 +830,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul
|
||||
public void testRemoveEmptyThrows() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/fixNativeThrowsErrors/removeEmptyThrows/");
|
||||
}
|
||||
|
||||
@TestMetadata("removeThrowsOnIncompatibleOverride")
|
||||
public void testRemoveThrowsOnIncompatibleOverride() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/fixNativeThrowsErrors/removeThrowsOnIncompatibleOverride/");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/multiModuleQuickFix/makeOverridenMemberOpen")
|
||||
|
||||
Reference in New Issue
Block a user