Support 'suppress for statement' quick fix

#KT-3319 Fixed
This commit is contained in:
Andrey Breslav
2013-09-23 00:20:30 +04:00
parent 5b9d10d74e
commit fc70a65f99
94 changed files with 1064 additions and 40 deletions
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(false<caret>!! && true)
}
@@ -0,0 +1,8 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
[ann] ""<caret>!!
}
annotation class ann
@@ -0,0 +1,7 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("Foo", "UNNECESSARY_NOT_NULL_ASSERTION")] ""<caret>!!
}
annotation class ann
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo(a: Array<Int>) {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
a[1<caret>!!]
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(""<caret>!! as String)
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(""<caret>!! as? String)
}
@@ -0,0 +1,7 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
var x = 0
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(x = 1<caret>!!)
}
@@ -0,0 +1,8 @@
// "Suppress 'REDUNDANT_NULLABLE' for statement " "true"
fun foo() {
[suppress("REDUNDANT_NULLABLE")]
call("": String?<caret>?)
}
fun call(s: String?) {}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(""<caret>!! : String)
}
@@ -0,0 +1,7 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
do {}
while (true<caret>!!)
}
@@ -0,0 +1,10 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo(a: C) {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
a.foo(""<caret>!!)
}
class C {
fun foo(a: Any) {}
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(1<caret>!! ?: 0)
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(1<caret>!! == 2)
}
@@ -0,0 +1,8 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
for (i in list()<caret>!!) {}
}
fun list(): List<Int> = throw Exception()
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
if (true<caret>!!) {}
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(1<caret>!! in (1..2))
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(1<caret>!! plus 2)
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(""<caret>!! is String)
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
@label""<caret>!!
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(1<caret>!! < 2)
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(1<caret>!! * 2)
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(false<caret>!! || true)
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(""<caret>!!)
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(1<caret>!! + 2)
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
""<caret>!!
}
@@ -0,0 +1,11 @@
// "Suppress 'REDUNDANT_NULLABLE' for statement " "true"
fun foo() {
var v = Box<String?>()
[suppress("REDUNDANT_NULLABLE")]
(v: Box<String?<caret>?>)++
}
class Box<T> {
fun inc() = this
}
@@ -0,0 +1,11 @@
// "Suppress 'REDUNDANT_NULLABLE' for statement " "true"
fun foo() {
var v = Box<String?>()
[suppress("REDUNDANT_NULLABLE")]
++(v: Box<String?<caret>?>)
}
class Box<T> {
fun inc() = this
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
(1<caret>!! .. 2)
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo(): Any {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
return ""<caret>!!
}
@@ -0,0 +1,10 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo(a: C) {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
a?.foo(""<caret>!!)
}
class C {
fun foo(a: Any) {}
}
@@ -0,0 +1,8 @@
// "Suppress 'UNUSED_EXPRESSION' for statement " "true"
fun foo() {
[suppress("UNUSED_EXPRESSION")]
a
}
val a = 1
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
"${""<caret>!!}"
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo(): Any {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
throw Exception(""<caret>!!)
}
@@ -0,0 +1,11 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
try {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
""<caret>!!
}
finally {
}
}
@@ -0,0 +1,8 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo(a: Any) {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
when (a) {
""<caret>!! -> {}
}
}
@@ -0,0 +1,8 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
when (1) {
in 1<caret>!!..2 -> {}
}
}
@@ -0,0 +1,8 @@
// "Suppress 'REDUNDANT_NULLABLE' for statement " "true"
fun foo() {
[suppress("REDUNDANT_NULLABLE")]
when ("") {
is Any?<caret>? -> {}
}
}
@@ -0,0 +1,8 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
when (""<caret>!!) {
is Any -> {}
}
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("UNNECESSARY_NOT_NULL_ASSERTION")]
while (true<caret>!!) {}
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
false<caret>!! && true
}
@@ -0,0 +1,7 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[ann] ""<caret>!!
}
annotation class ann
@@ -0,0 +1,7 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
[suppress("Foo")] ""<caret>!!
}
annotation class ann
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo(a: Array<Int>) {
a[1<caret>!!]
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
""<caret>!! as String
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
""<caret>!! as? String
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
var x = 0
x = 1<caret>!!
}
@@ -0,0 +1,7 @@
// "Suppress 'REDUNDANT_NULLABLE' for statement " "true"
fun foo() {
call("": String?<caret>?)
}
fun call(s: String?) {}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
""<caret>!! : String
}
@@ -0,0 +1,6 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
do {}
while (true<caret>!!)
}
@@ -0,0 +1,9 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo(a: C) {
a.foo(""<caret>!!)
}
class C {
fun foo(a: Any) {}
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
1<caret>!! ?: 0
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
1<caret>!! == 2
}
@@ -0,0 +1,7 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
for (i in list()<caret>!!) {}
}
fun list(): List<Int> = throw Exception()
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
if (true<caret>!!) {}
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
1<caret>!! in (1..2)
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
1<caret>!! plus 2
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
""<caret>!! is String
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
@label""<caret>!!
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
1<caret>!! < 2
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
1<caret>!! * 2
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
false<caret>!! || true
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
(""<caret>!!)
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
1<caret>!! + 2
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
""<caret>!!
}
@@ -0,0 +1,10 @@
// "Suppress 'REDUNDANT_NULLABLE' for statement " "true"
fun foo() {
var v = Box<String?>()
(v: Box<String?<caret>?>)++
}
class Box<T> {
fun inc() = this
}
@@ -0,0 +1,10 @@
// "Suppress 'REDUNDANT_NULLABLE' for statement " "true"
fun foo() {
var v = Box<String?>()
++(v: Box<String?<caret>?>)
}
class Box<T> {
fun inc() = this
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
1<caret>!! .. 2
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo(): Any {
return ""<caret>!!
}
@@ -0,0 +1,9 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo(a: C) {
a?.foo(""<caret>!!)
}
class C {
fun foo(a: Any) {}
}
@@ -0,0 +1,7 @@
// "Suppress 'UNUSED_EXPRESSION' for statement " "true"
fun foo() {
a
}
val a = 1
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
"${""<caret>!!}"
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo(): Any {
throw Exception(""<caret>!!)
}
@@ -0,0 +1,10 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
try {
""<caret>!!
}
finally {
}
}
@@ -0,0 +1,7 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo(a: Any) {
when (a) {
""<caret>!! -> {}
}
}
@@ -0,0 +1,7 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
when (1) {
in 1<caret>!!..2 -> {}
}
}
@@ -0,0 +1,7 @@
// "Suppress 'REDUNDANT_NULLABLE' for statement " "true"
fun foo() {
when ("") {
is Any?<caret>? -> {}
}
}
@@ -0,0 +1,7 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
when (""<caret>!!) {
is Any -> {}
}
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "true"
fun foo() {
while (true<caret>!!) {}
}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "false"
// ACTION: Remove unnecessary non-null assertion (!!)
[suppress("FOO"<caret>!!)]
fun foo() {}
@@ -0,0 +1,5 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "false"
// ACTION: Remove unnecessary non-null assertion (!!)
open class Base(s: String)
class Child: Base(""<caret>!!)
@@ -0,0 +1,4 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "false"
// ACTION: Remove unnecessary non-null assertion (!!)
fun foo(s: String = ""<caret>!!) {}
@@ -0,0 +1,4 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "false"
// ACTION: Remove unnecessary non-null assertion (!!)
fun foo() = ""<caret>!!
@@ -0,0 +1,9 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "false"
// ACTION: Disable 'Split Property Declaration'
// ACTION: Edit intention settings
// ACTION: Remove unnecessary non-null assertion (!!)
// ACTION: Split property declaration
fun foo() {
val bar = ""<caret>!!
}
@@ -0,0 +1,4 @@
// "Suppress 'REDUNDANT_NULLABLE' for statement " "false"
// ACTION: Remove redundant '?'
fun foo(s: String?<caret>?) {}
@@ -0,0 +1,10 @@
// "Suppress 'REDUNDANT_NULLABLE' for statement " "false"
// ACTION: Remove redundant '?'
fun foo() {
any {
(x: String?<caret>?) ->
}
}
fun any(a: Any?) {}
@@ -0,0 +1,4 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for statement " "false"
// ACTION: Remove unnecessary non-null assertion (!!)
val foo = ""<caret>!!
@@ -0,0 +1,10 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for object <anonymous>" "false"
// ACTION: Remove unnecessary non-null assertion (!!)
fun foo() {
object : Base(""<caret>!!) {
}
}
open class Base(s: Any)
@@ -0,0 +1,13 @@
// "Suppress 'UNNECESSARY_NOT_NULL_ASSERTION' for object <anonymous>" "false"
// ACTION: Disable 'Split Property Declaration'
// ACTION: Edit intention settings
// ACTION: Remove unnecessary non-null assertion (!!)
// ACTION: Split property declaration
fun foo() {
val a = object : Base(""<caret>!!) {
}
}
open class Base(s: Any)
@@ -0,0 +1,5 @@
// "Suppress 'REDUNDANT_NULLABLE' for statement " "false"
// ACTION: Remove redundant '?'
open class Base<T>
class Child: Base<String?<caret>?>()