Add "Remove annotation" quickfix for empty @Throws
This commit is contained in:
@@ -51,6 +51,7 @@ 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.MISSING_EXCEPTION_IN_THROWS_ON_SUSPEND
|
||||
import org.jetbrains.kotlin.resolve.konan.diagnostics.ErrorsNative.THROWS_LIST_EMPTY
|
||||
|
||||
class QuickFixRegistrar : QuickFixContributor {
|
||||
override fun registerQuickFixes(quickFixes: QuickFixes) {
|
||||
@@ -654,5 +655,6 @@ class QuickFixRegistrar : QuickFixContributor {
|
||||
CONFLICTING_JVM_DECLARATIONS.registerFactory(AddJvmNameAnnotationFix)
|
||||
|
||||
MISSING_EXCEPTION_IN_THROWS_ON_SUSPEND.registerFactory(AddExceptionToThrowsFix)
|
||||
THROWS_LIST_EMPTY.registerFactory(RemoveAnnotationFix)
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// ERROR: @Throws must have non-empty class list
|
||||
// ACTION: Make internal
|
||||
// ACTION: Make private
|
||||
// ACTION: Remove annotation
|
||||
|
||||
// No compilation error => no quickfix.
|
||||
<caret>@Throws()
|
||||
|
||||
Vendored
+1
@@ -2,6 +2,7 @@
|
||||
// ERROR: @Throws must have non-empty class list
|
||||
// ACTION: Make internal
|
||||
// ACTION: Make private
|
||||
// ACTION: Remove annotation
|
||||
|
||||
// No compilation error => no quickfix.
|
||||
<caret>@Throws
|
||||
|
||||
+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>)
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// "Remove annotation" "true"
|
||||
|
||||
<caret>@Throws
|
||||
fun removeEmptyThrows() {}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
// "Remove annotation" "true"
|
||||
|
||||
fun removeEmptyThrows() {}
|
||||
+5
@@ -825,6 +825,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul
|
||||
public void testAllFilesPresentInFixNativeThrowsErrors() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/multiModuleQuickFix/fixNativeThrowsErrors"), Pattern.compile("^([^\\.]+)$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("removeEmptyThrows")
|
||||
public void testRemoveEmptyThrows() throws Exception {
|
||||
runTest("idea/testData/multiModuleQuickFix/fixNativeThrowsErrors/removeEmptyThrows/");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/multiModuleQuickFix/makeOverridenMemberOpen")
|
||||
|
||||
Reference in New Issue
Block a user