Changed highlighting range and attributes of useless elvis operator

This commit is contained in:
Valentin Kipyatkov
2015-06-01 22:22:17 +03:00
parent 11290ae9e7
commit aefe0dd192
14 changed files with 26 additions and 21 deletions
@@ -8,7 +8,7 @@ fun testBinary2() {
}
fun testElvis1() {
<!USELESS_ELVIS!>todo()<!> <!UNREACHABLE_CODE!>?: ""<!>
todo() <!USELESS_ELVIS, UNREACHABLE_CODE!>?: ""<!>
}
fun testElvis2(s: String?) {
@@ -50,6 +50,6 @@ fun test(arr: Array<Int>) {
}
while (true) {
<!USELESS_ELVIS!>break<!> <!UNREACHABLE_CODE!>?: null<!>
break <!USELESS_ELVIS, UNREACHABLE_CODE!>?: null<!>
}
}
@@ -4,6 +4,6 @@ fun foo() {
val x: Int? = null
bar(x ?: 0)
if (x != null) bar(<!USELESS_ELVIS!>x<!> ?: <!DEBUG_INFO_SMARTCAST!>x<!>)
if (x != null) bar(x <!USELESS_ELVIS!>?: <!DEBUG_INFO_SMARTCAST!>x<!><!>)
bar(<!TYPE_MISMATCH!>x<!>)
}
@@ -5,12 +5,12 @@ fun <T: Any?> test1(t: Any?): Any {
}
fun <T: Any> test2(t: Any?): Any {
return <!UNCHECKED_CAST, USELESS_ELVIS!>t as T<!> ?: ""
return <!UNCHECKED_CAST!>t as T<!> <!USELESS_ELVIS!>?: ""<!>
}
fun <T: Any?> test3(t: Any?): Any {
if (t != null) {
return <!USELESS_ELVIS!>t<!> ?: ""
return t <!USELESS_ELVIS!>?: ""<!>
}
return 1
@@ -25,21 +25,21 @@ fun test() {
// platform type with no annotation
val platformJ = J.staticJ
val v0 = platformNN <!USELESS_ELVIS!>?:<!> J()
platformNN <!USELESS_ELVIS!>?:<!> J()
val v0 = platformNN <!USELESS_ELVIS!>?: J()<!>
platformNN <!USELESS_ELVIS!>?: J()<!>
platformN ?: J()
platformJ ?: J()
if (platformNN != null) {
<!USELESS_ELVIS!>platformNN<!> ?: J()
platformNN <!USELESS_ELVIS!>?: J()<!>
}
if (platformN != null) {
<!USELESS_ELVIS!>platformN<!> ?: J()
platformN <!USELESS_ELVIS!>?: J()<!>
}
if (platformJ != null) {
<!USELESS_ELVIS!>platformJ<!> ?: J()
platformJ <!USELESS_ELVIS!>?: J()<!>
}
}
@@ -18,10 +18,10 @@ fun test() {
// @NotNull platform type
val platformNN = J.staticNN
foo(platformNN <!USELESS_ELVIS!>?:<!> "")
foo(platformNN <!USELESS_ELVIS!>?: ""<!>)
val bar = Bar()
bar(platformNN <!USELESS_ELVIS!>?:<!> "")
bar(platformNN <!USELESS_ELVIS!>?: ""<!>)
}
fun foo(a: Any) {}