Add inspection and quick-fix to remove empty parentheses in annotation entries

This commit is contained in:
Aleksei Semin
2018-11-10 19:01:36 +01:00
committed by Mikhail Glukhikh
parent e903b2f92a
commit 793cac02e8
18 changed files with 209 additions and 0 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.RemoveEmptyParenthesesFromAnnotationEntryInspection
@@ -0,0 +1,6 @@
annotation class MyAnnotation(val x: Int = 10)
@MyAnnotation(<caret>)
fun test() {
}
@@ -0,0 +1,6 @@
annotation class MyAnnotation(val x: Int = 10)
@MyAnnotation
fun test() {
}
@@ -0,0 +1,7 @@
@Target(AnnotationTarget.EXPRESSION)
@Retention(AnnotationRetention.SOURCE)
annotation class MyAnnotation
fun test() {
val x = @MyAnnotation(<caret>) 5
}
@@ -0,0 +1,7 @@
@Target(AnnotationTarget.EXPRESSION)
@Retention(AnnotationRetention.SOURCE)
annotation class MyAnnotation
fun test() {
val x = @MyAnnotation 5
}
@@ -0,0 +1,8 @@
annotation class MyAnnotation
@MyAnnotation(
<caret>
)
fun test() {
}
@@ -0,0 +1,6 @@
annotation class MyAnnotation
@MyAnnotation
fun test() {
}
@@ -0,0 +1,9 @@
// PROBLEM: none
// ERROR: No value passed for parameter 'x'
annotation class MyAnnotation(val x: Int)
// there is an error but the inspection is not triggered because parentheses are needed in the end
@MyAnnotation(<caret>)
fun test() {
}
@@ -0,0 +1,6 @@
annotation class MyAnnotation
@MyAnnotation(<caret>)
fun test() {
}
@@ -0,0 +1,6 @@
annotation class MyAnnotation
@MyAnnotation
fun test() {
}
@@ -0,0 +1 @@
public @interface MyJavaAnnotation {}
@@ -0,0 +1,4 @@
@MyJavaAnnotation(<caret>)
fun test() {
}
@@ -0,0 +1,4 @@
@MyJavaAnnotation
fun test() {
}