FIR: implement LT positioning in diagnostic tests, fix LT strategies
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
annotation class A() {
|
annotation class A() {
|
||||||
<!ANNOTATION_CLASS_MEMBER!><!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED{PSI}!>constructor(s: Nothing?)<!><!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED{LT}!><!> {}<!>
|
<!ANNOTATION_CLASS_MEMBER!><!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor(s: Nothing?)<!> {}<!>
|
||||||
<!ANNOTATION_CLASS_MEMBER!>init {}<!>
|
<!ANNOTATION_CLASS_MEMBER!>init {}<!>
|
||||||
<!ANNOTATION_CLASS_MEMBER!>fun foo() {}<!>
|
<!ANNOTATION_CLASS_MEMBER!>fun foo() {}<!>
|
||||||
<!ANNOTATION_CLASS_MEMBER!>val bar: Nothing?<!>
|
<!ANNOTATION_CLASS_MEMBER!>val bar: Nothing?<!>
|
||||||
|
|||||||
+7
-7
@@ -1,6 +1,6 @@
|
|||||||
<!CONFLICTING_OVERLOADS{LT}!><!CONFLICTING_OVERLOADS{PSI}!>fun test(x: Int)<!> {}<!>
|
<!CONFLICTING_OVERLOADS!>fun test(x: Int)<!> {}
|
||||||
|
|
||||||
<!CONFLICTING_OVERLOADS{LT}!><!CONFLICTING_OVERLOADS{PSI}!>fun test(y: Int)<!> {}<!>
|
<!CONFLICTING_OVERLOADS!>fun test(y: Int)<!> {}
|
||||||
|
|
||||||
fun test() {}
|
fun test() {}
|
||||||
|
|
||||||
@@ -17,9 +17,9 @@ fun test(z: Int, c: Char) {}
|
|||||||
}<!>
|
}<!>
|
||||||
|
|
||||||
<!REDECLARATION!>class B : A {
|
<!REDECLARATION!>class B : A {
|
||||||
<!CONFLICTING_OVERLOADS{LT}!><!CONFLICTING_OVERLOADS{PSI}!>override fun rest(s: String)<!> {}<!>
|
<!CONFLICTING_OVERLOADS!>override fun rest(s: String)<!> {}
|
||||||
|
|
||||||
<!CONFLICTING_OVERLOADS{LT}!><!CONFLICTING_OVERLOADS{PSI}!>fun rest(s: String)<!> {}<!>
|
<!CONFLICTING_OVERLOADS!>fun rest(s: String)<!> {}
|
||||||
|
|
||||||
fun rest(l: Long) {}
|
fun rest(l: Long) {}
|
||||||
|
|
||||||
@@ -45,11 +45,11 @@ fun <T : Int> kek(t: T) {}
|
|||||||
fun lol(a: Array<Int>) {}
|
fun lol(a: Array<Int>) {}
|
||||||
fun lol(a: Array<Boolean>) {}
|
fun lol(a: Array<Boolean>) {}
|
||||||
|
|
||||||
<!CONFLICTING_OVERLOADS{LT}!><!CONFLICTING_OVERLOADS{PSI}!>fun <T> mem(t: T)<!> where T : () -> Boolean, T : String {}<!>
|
<!CONFLICTING_OVERLOADS!>fun <T> mem(t: T)<!> where T : () -> Boolean, T : String {}
|
||||||
<!CONFLICTING_OVERLOADS{LT}!><!CONFLICTING_OVERLOADS{PSI}!>fun <T> mem(t: T)<!> where T : String, T : () -> Boolean {}<!>
|
<!CONFLICTING_OVERLOADS!>fun <T> mem(t: T)<!> where T : String, T : () -> Boolean {}
|
||||||
|
|
||||||
class M {
|
class M {
|
||||||
<!REDECLARATION{LT}!>companion <!REDECLARATION{PSI}!>object<!> {}<!>
|
companion <!REDECLARATION!>object<!> {}
|
||||||
<!REDECLARATION!>val Companion = object : Any {}<!>
|
<!REDECLARATION!>val Companion = object : Any {}<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
<!CONSTRUCTOR_IN_INTERFACE{LT}!>interface <!CONSTRUCTOR_IN_INTERFACE{PSI}!>A(val s: String)<!><!>
|
interface <!CONSTRUCTOR_IN_INTERFACE!>A(val s: String)<!>
|
||||||
|
|
||||||
<!CONSTRUCTOR_IN_INTERFACE{LT}!>interface <!CONSTRUCTOR_IN_INTERFACE{PSI}!>B constructor(val s: String)<!><!>
|
interface <!CONSTRUCTOR_IN_INTERFACE!>B constructor(val s: String)<!>
|
||||||
|
|
||||||
interface C {
|
interface C {
|
||||||
<!CONSTRUCTOR_IN_INTERFACE{LT}!><!CONSTRUCTOR_IN_INTERFACE{PSI}!>constructor(val s: String)<!> {}<!>
|
<!CONSTRUCTOR_IN_INTERFACE!>constructor(val s: String)<!> {}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+15
-15
@@ -2,14 +2,14 @@ class B
|
|||||||
class C
|
class C
|
||||||
|
|
||||||
class A() {
|
class A() {
|
||||||
constructor(a: Int) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{LT}!><!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{PSI}!>this<!>("test")<!> {}
|
constructor(a: Int) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>("test") {}
|
||||||
constructor(a: String) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{LT}!><!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{PSI}!>this<!>(10)<!> {}
|
constructor(a: String) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(10) {}
|
||||||
|
|
||||||
constructor(a: Boolean) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{LT}!><!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{PSI}!>this<!>('\n')<!> {}
|
constructor(a: Boolean) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>('\n') {}
|
||||||
constructor(a: Char) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{LT}!><!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{PSI}!>this<!>(0.0)<!> {}
|
constructor(a: Char) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(0.0) {}
|
||||||
constructor(a: Double) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{LT}!><!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{PSI}!>this<!>(false)<!> {}
|
constructor(a: Double) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(false) {}
|
||||||
|
|
||||||
constructor(b: B) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{LT}!><!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{PSI}!>this<!>(3.14159265)<!> {}
|
constructor(b: B) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(3.14159265) {}
|
||||||
|
|
||||||
constructor(c: C) : this() {}
|
constructor(c: C) : this() {}
|
||||||
constructor(a: List<Int>) : this(C()) {}
|
constructor(a: List<Int>) : this(C()) {}
|
||||||
@@ -17,7 +17,7 @@ class A() {
|
|||||||
|
|
||||||
class D {
|
class D {
|
||||||
constructor(i: Boolean) {}
|
constructor(i: Boolean) {}
|
||||||
constructor(i: Int) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{LT}!><!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{PSI}!>this<!>(3)<!> {}
|
constructor(i: Int) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(3) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class E<T> {
|
class E<T> {
|
||||||
@@ -25,7 +25,7 @@ class E<T> {
|
|||||||
// selection of the proper constructor
|
// selection of the proper constructor
|
||||||
// but a type mismatch for the first
|
// but a type mismatch for the first
|
||||||
// argument
|
// argument
|
||||||
constructor(e: T, i: Int) : <!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>this<!>(i, 10)<!> {}
|
constructor(e: T, i: Int) : <!INAPPLICABLE_CANDIDATE!>this<!>(i, 10) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class I<T> {
|
class I<T> {
|
||||||
@@ -33,7 +33,7 @@ class I<T> {
|
|||||||
// selection of the proper constructor
|
// selection of the proper constructor
|
||||||
// but a type mismatch for the first
|
// but a type mismatch for the first
|
||||||
// argument
|
// argument
|
||||||
constructor(e: T, i: Int) : <!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>this<!>(i, 10)<!>
|
constructor(e: T, i: Int) : <!INAPPLICABLE_CANDIDATE!>this<!>(i, 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
class J<T> {
|
class J<T> {
|
||||||
@@ -42,20 +42,20 @@ class J<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class F(s: String) {
|
class F(s: String) {
|
||||||
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED{PSI}!>constructor(i: Boolean)<!><!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED{LT}!><!> {}
|
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor(i: Boolean)<!> {}
|
||||||
constructor(i: Int) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{LT}!><!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{PSI}!>this<!>(3)<!> {}
|
constructor(i: Int) : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>(3) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class G(x: Int) {
|
class G(x: Int) {
|
||||||
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED{PSI}!>constructor()<!><!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED{LT}!><!> {}
|
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor()<!> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class H(x: Int) {
|
class H(x: Int) {
|
||||||
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED{PSI}!>constructor()<!><!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED{LT}!><!>
|
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor()<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
class K(x: Int) {
|
class K(x: Int) {
|
||||||
constructor() : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{LT}!><!CYCLIC_CONSTRUCTOR_DELEGATION_CALL{PSI}!>this<!>()<!> {}
|
constructor() : <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class M {
|
class M {
|
||||||
@@ -63,5 +63,5 @@ class M {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class U : M {
|
class U : M {
|
||||||
<!INAPPLICABLE_CANDIDATE{PSI}!>constructor()<!><!INAPPLICABLE_CANDIDATE{LT}!><!>
|
<!INAPPLICABLE_CANDIDATE!>constructor()<!>
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
enum class A {
|
enum class A {
|
||||||
A(1), B(2), C("test");
|
A(1), B(2), C("test");
|
||||||
|
|
||||||
constructor(x: Int) : <!DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR{LT}!><!DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR{PSI}!>super<!>()<!>
|
constructor(x: Int) : <!DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR!>super<!>()
|
||||||
constructor(t: String) : this(10)
|
constructor(t: String) : this(10)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -3,16 +3,16 @@ class A(x: Int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class B : A {
|
class B : A {
|
||||||
<!EXPLICIT_DELEGATION_CALL_REQUIRED, NONE_APPLICABLE{PSI}!>constructor()<!><!NONE_APPLICABLE{LT}!><!>
|
<!EXPLICIT_DELEGATION_CALL_REQUIRED, NONE_APPLICABLE!>constructor()<!>
|
||||||
constructor(z: String) : this()
|
constructor(z: String) : this()
|
||||||
}
|
}
|
||||||
|
|
||||||
<!SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR!>class C : A(20) {
|
<!SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR!>class C : A(20) {
|
||||||
<!EXPLICIT_DELEGATION_CALL_REQUIRED, NONE_APPLICABLE{PSI}!>constructor()<!><!NONE_APPLICABLE{LT}!><!>
|
<!EXPLICIT_DELEGATION_CALL_REQUIRED, NONE_APPLICABLE!>constructor()<!>
|
||||||
constructor(z: String) : this()
|
constructor(z: String) : this()
|
||||||
}<!>
|
}<!>
|
||||||
|
|
||||||
class D() : A(20) {
|
class D() : A(20) {
|
||||||
<!NONE_APPLICABLE{PSI}, PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED{PSI}!>constructor(x: Int)<!><!NONE_APPLICABLE{LT}, PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED{LT}!><!>
|
<!NONE_APPLICABLE, PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED!>constructor(x: Int)<!>
|
||||||
constructor(z: String) : this()
|
constructor(z: String) : this()
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -7,10 +7,10 @@ class A {
|
|||||||
class B(other: B = <!NO_THIS!>this<!>)
|
class B(other: B = <!NO_THIS!>this<!>)
|
||||||
|
|
||||||
class C() {
|
class C() {
|
||||||
constructor(x: Int) : <!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>this<!>({
|
constructor(x: Int) : <!INAPPLICABLE_CANDIDATE!>this<!>({
|
||||||
val a = 10
|
val a = 10
|
||||||
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>
|
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>
|
||||||
})<!> {}
|
}) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
class D {
|
class D {
|
||||||
|
|||||||
+4
-4
@@ -6,19 +6,19 @@ object A {
|
|||||||
interface X
|
interface X
|
||||||
|
|
||||||
val a = object : Any() {
|
val a = object : Any() {
|
||||||
<!LOCAL_OBJECT_NOT_ALLOWED{LT}!><!LOCAL_OBJECT_NOT_ALLOWED{PSI}!>object D<!> {
|
<!LOCAL_OBJECT_NOT_ALLOWED!>object D<!> {
|
||||||
<!LOCAL_OBJECT_NOT_ALLOWED!>object G<!>
|
<!LOCAL_OBJECT_NOT_ALLOWED!>object G<!>
|
||||||
<!LOCAL_INTERFACE_NOT_ALLOWED!>interface Z<!>
|
<!LOCAL_INTERFACE_NOT_ALLOWED!>interface Z<!>
|
||||||
}<!>
|
}
|
||||||
|
|
||||||
<!LOCAL_INTERFACE_NOT_ALLOWED!>interface Y<!>
|
<!LOCAL_INTERFACE_NOT_ALLOWED!>interface Y<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
fun b() {
|
fun b() {
|
||||||
<!LOCAL_OBJECT_NOT_ALLOWED{LT}!><!LOCAL_OBJECT_NOT_ALLOWED{PSI}!>object E<!> {
|
<!LOCAL_OBJECT_NOT_ALLOWED!>object E<!> {
|
||||||
<!LOCAL_OBJECT_NOT_ALLOWED!>object F<!>
|
<!LOCAL_OBJECT_NOT_ALLOWED!>object F<!>
|
||||||
<!LOCAL_INTERFACE_NOT_ALLOWED!>interface M<!>
|
<!LOCAL_INTERFACE_NOT_ALLOWED!>interface M<!>
|
||||||
}<!>
|
}
|
||||||
|
|
||||||
<!LOCAL_INTERFACE_NOT_ALLOWED!>interface N<!>
|
<!LOCAL_INTERFACE_NOT_ALLOWED!>interface N<!>
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -1,11 +1,11 @@
|
|||||||
class A {
|
class A {
|
||||||
<!REDECLARATION{LT}!>companion <!REDECLARATION{PSI}!>object<!> {
|
companion <!REDECLARATION!>object<!> {
|
||||||
|
|
||||||
}<!>
|
}
|
||||||
|
|
||||||
<!MANY_COMPANION_OBJECTS{LT}, REDECLARATION{LT}!>companion <!MANY_COMPANION_OBJECTS{PSI}, REDECLARATION{PSI}!>object<!> {
|
companion <!MANY_COMPANION_OBJECTS, REDECLARATION!>object<!> {
|
||||||
|
|
||||||
}<!>
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class B {
|
class B {
|
||||||
@@ -13,7 +13,7 @@ class B {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<!MANY_COMPANION_OBJECTS{LT}!>companion <!MANY_COMPANION_OBJECTS{PSI}!>object B<!> {
|
companion <!MANY_COMPANION_OBJECTS!>object B<!> {
|
||||||
|
|
||||||
}<!>
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -28,9 +28,9 @@ sealed class P {
|
|||||||
|
|
||||||
class K : P()
|
class K : P()
|
||||||
|
|
||||||
<!REDECLARATION{LT}!><!REDECLARATION{PSI}!>object B<!> {
|
<!REDECLARATION!>object B<!> {
|
||||||
class I : <!SEALED_SUPERTYPE!>P<!>()
|
class I : <!SEALED_SUPERTYPE!>P<!>()
|
||||||
}<!>
|
}
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
class L : <!SEALED_SUPERTYPE_IN_LOCAL_CLASS!>P<!>()
|
class L : <!SEALED_SUPERTYPE_IN_LOCAL_CLASS!>P<!>()
|
||||||
|
|||||||
+7
-7
@@ -1,15 +1,15 @@
|
|||||||
<!TYPE_PARAMETERS_IN_OBJECT{LT}!><!TYPE_PARAMETERS_IN_OBJECT{PSI}!>object A<!><T, K : T> {
|
<!TYPE_PARAMETERS_IN_OBJECT!>object A<!><T, K : T> {
|
||||||
<!TYPE_PARAMETERS_IN_OBJECT{LT}!><!TYPE_PARAMETERS_IN_OBJECT{PSI}!>object B<!><L><!>
|
<!TYPE_PARAMETERS_IN_OBJECT!>object B<!><L>
|
||||||
}<!>
|
}
|
||||||
|
|
||||||
class N {
|
class N {
|
||||||
<!TYPE_PARAMETERS_IN_OBJECT{LT}!>companion <!TYPE_PARAMETERS_IN_OBJECT{PSI}!>object<!><T> {
|
companion <!TYPE_PARAMETERS_IN_OBJECT!>object<!><T> {
|
||||||
|
|
||||||
}<!>
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
<!LOCAL_OBJECT_NOT_ALLOWED{LT}, TYPE_PARAMETERS_IN_OBJECT{LT}!><!LOCAL_OBJECT_NOT_ALLOWED{PSI}, TYPE_PARAMETERS_IN_OBJECT{PSI}!>object M<!><H> {
|
<!LOCAL_OBJECT_NOT_ALLOWED, TYPE_PARAMETERS_IN_OBJECT!>object M<!><H> {
|
||||||
|
|
||||||
}<!>
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
annotation class A(
|
annotation class A(
|
||||||
<!VAR_ANNOTATION_PARAMETER{LT}!><!VAR_ANNOTATION_PARAMETER{PSI}!>var<!> a: Int<!>,
|
<!VAR_ANNOTATION_PARAMETER!>var<!> a: Int,
|
||||||
<!MISSING_VAL_ON_ANNOTATION_PARAMETER!>b: String<!>
|
<!MISSING_VAL_ON_ANNOTATION_PARAMETER!>b: String<!>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ fun test() {
|
|||||||
}
|
}
|
||||||
b.foo()
|
b.foo()
|
||||||
|
|
||||||
<!LOCAL_OBJECT_NOT_ALLOWED{LT}!><!LOCAL_OBJECT_NOT_ALLOWED{PSI}!>object B<!> {
|
<!LOCAL_OBJECT_NOT_ALLOWED!>object B<!> {
|
||||||
fun foo() {}
|
fun foo() {}
|
||||||
}<!>
|
}
|
||||||
B.foo()
|
B.foo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -4,14 +4,14 @@ fun foo(p: Int) {
|
|||||||
val a = arrayOf(1, 2, 3)
|
val a = arrayOf(1, 2, 3)
|
||||||
val b = arrayOf(3, 2, 1)
|
val b = arrayOf(3, 2, 1)
|
||||||
|
|
||||||
if (<!ARRAY_EQUALITY_OPERATOR_CAN_BE_REPLACED_WITH_EQUALS{LT}!>a <!ARRAY_EQUALITY_OPERATOR_CAN_BE_REPLACED_WITH_EQUALS{PSI}!>==<!> b<!>) { }
|
if (a <!ARRAY_EQUALITY_OPERATOR_CAN_BE_REPLACED_WITH_EQUALS!>==<!> b) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testsFromIdea() {
|
fun testsFromIdea() {
|
||||||
val a = arrayOf("a")
|
val a = arrayOf("a")
|
||||||
val b = a
|
val b = a
|
||||||
val c: Any? = null
|
val c: Any? = null
|
||||||
<!ARRAY_EQUALITY_OPERATOR_CAN_BE_REPLACED_WITH_EQUALS{LT}!>a <!ARRAY_EQUALITY_OPERATOR_CAN_BE_REPLACED_WITH_EQUALS{PSI}!>==<!> b<!>
|
a <!ARRAY_EQUALITY_OPERATOR_CAN_BE_REPLACED_WITH_EQUALS!>==<!> b
|
||||||
a == c
|
a == c
|
||||||
<!ARRAY_EQUALITY_OPERATOR_CAN_BE_REPLACED_WITH_EQUALS{LT}!>a <!ARRAY_EQUALITY_OPERATOR_CAN_BE_REPLACED_WITH_EQUALS{PSI}!>!=<!> b<!>
|
a <!ARRAY_EQUALITY_OPERATOR_CAN_BE_REPLACED_WITH_EQUALS!>!=<!> b
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -23,7 +23,7 @@ operator fun C.plusAssign(a: Any) {}
|
|||||||
fun testOperatorAssignment() {
|
fun testOperatorAssignment() {
|
||||||
val c = C()
|
val c = C()
|
||||||
c += ""
|
c += ""
|
||||||
<!CAN_BE_VAL{LT}!><!CAN_BE_VAL{PSI}!>var<!> c1 = C()<!>
|
<!CAN_BE_VAL!>var<!> c1 = C()
|
||||||
<!ASSIGN_OPERATOR_AMBIGUITY!>c1 += ""<!>
|
<!ASSIGN_OPERATOR_AMBIGUITY!>c1 += ""<!>
|
||||||
|
|
||||||
var a = 1
|
var a = 1
|
||||||
@@ -33,7 +33,7 @@ fun testOperatorAssignment() {
|
|||||||
|
|
||||||
|
|
||||||
fun destructuringDeclaration() {
|
fun destructuringDeclaration() {
|
||||||
<!CAN_BE_VAL{LT}!><!CAN_BE_VAL{PSI}!>var<!> (v1, <!UNUSED_VARIABLE!>v2<!>) = getPair()<!>
|
<!CAN_BE_VAL!>var<!> (v1, <!UNUSED_VARIABLE!>v2<!>) = getPair()
|
||||||
print(v1)
|
print(v1)
|
||||||
|
|
||||||
var (v3, <!VARIABLE_NEVER_READ!>v4<!>) = getPair()
|
var (v3, <!VARIABLE_NEVER_READ!>v4<!>) = getPair()
|
||||||
@@ -49,11 +49,11 @@ fun destructuringDeclaration() {
|
|||||||
|
|
||||||
val (<!UNUSED_VARIABLE!>a<!>, <!UNUSED_VARIABLE!>b<!>, <!UNUSED_VARIABLE!>c<!>) = Triple(1, 1, 1)
|
val (<!UNUSED_VARIABLE!>a<!>, <!UNUSED_VARIABLE!>b<!>, <!UNUSED_VARIABLE!>c<!>) = Triple(1, 1, 1)
|
||||||
|
|
||||||
<!CAN_BE_VAL{LT}!><!CAN_BE_VAL{PSI}!>var<!> (<!UNUSED_VARIABLE!>x<!>, <!UNUSED_VARIABLE!>y<!>, <!UNUSED_VARIABLE!>z<!>) = Triple(1, 1, 1)<!>
|
<!CAN_BE_VAL!>var<!> (<!UNUSED_VARIABLE!>x<!>, <!UNUSED_VARIABLE!>y<!>, <!UNUSED_VARIABLE!>z<!>) = Triple(1, 1, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stackOverflowBug() {
|
fun stackOverflowBug() {
|
||||||
<!CAN_BE_VAL{LT}, VARIABLE_NEVER_READ{LT}!><!CAN_BE_VAL{PSI}!>var<!> <!VARIABLE_NEVER_READ{PSI}!>a<!>: Int<!>
|
<!VARIABLE_NEVER_READ{LT}!><!CAN_BE_VAL!>var<!> <!VARIABLE_NEVER_READ{PSI}!>a<!>: Int<!>
|
||||||
<!ASSIGNED_VALUE_IS_NEVER_READ!>a<!> = 1
|
<!ASSIGNED_VALUE_IS_NEVER_READ!>a<!> = 1
|
||||||
for (i in 1..10)
|
for (i in 1..10)
|
||||||
print(i)
|
print(i)
|
||||||
@@ -71,8 +71,8 @@ fun smth(flag: Boolean) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun withAnnotation(p: List<Any>) {
|
fun withAnnotation(p: List<Any>) {
|
||||||
<!CAN_BE_VAL{LT}!>@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
<!CAN_BE_VAL{PSI}!>var<!> v = p as List<String><!>
|
<!CAN_BE_VAL!>var<!> v = p as List<String>
|
||||||
print(v)
|
print(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ fun listReceiver(p: List<String>) {}
|
|||||||
fun withInitializer() {
|
fun withInitializer() {
|
||||||
<!VARIABLE_NEVER_READ{LT}!>var <!VARIABLE_NEVER_READ{PSI}!>v1<!> = 1<!>
|
<!VARIABLE_NEVER_READ{LT}!>var <!VARIABLE_NEVER_READ{PSI}!>v1<!> = 1<!>
|
||||||
var v2 = 2
|
var v2 = 2
|
||||||
<!CAN_BE_VAL{LT}!><!CAN_BE_VAL{PSI}!>var<!> v3 = 3<!>
|
<!CAN_BE_VAL!>var<!> v3 = 3
|
||||||
<!ASSIGNED_VALUE_IS_NEVER_READ!>v1<!> = 1
|
<!ASSIGNED_VALUE_IS_NEVER_READ!>v1<!> = 1
|
||||||
<!ASSIGNED_VALUE_IS_NEVER_READ!>v2<!>++ // todo mark this UNUSED_CHANGED_VALUES
|
<!ASSIGNED_VALUE_IS_NEVER_READ!>v2<!>++ // todo mark this UNUSED_CHANGED_VALUES
|
||||||
print(v3)
|
print(v3)
|
||||||
@@ -102,7 +102,7 @@ fun test() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
<!CAN_BE_VAL{LT}, VARIABLE_NEVER_READ{LT}!><!CAN_BE_VAL{PSI}!>var<!> <!VARIABLE_NEVER_READ{PSI}!>a<!>: Int<!>
|
<!VARIABLE_NEVER_READ{LT}!><!CAN_BE_VAL!>var<!> <!VARIABLE_NEVER_READ{PSI}!>a<!>: Int<!>
|
||||||
val bool = true
|
val bool = true
|
||||||
if (bool) <!ASSIGNED_VALUE_IS_NEVER_READ!>a<!> = 4 else <!ASSIGNED_VALUE_IS_NEVER_READ!>a<!> = 42
|
if (bool) <!ASSIGNED_VALUE_IS_NEVER_READ!>a<!> = 4 else <!ASSIGNED_VALUE_IS_NEVER_READ!>a<!> = 42
|
||||||
<!UNUSED_VARIABLE{LT}!>val <!UNUSED_VARIABLE{PSI}!>b<!>: String<!>
|
<!UNUSED_VARIABLE{LT}!>val <!UNUSED_VARIABLE{PSI}!>b<!>: String<!>
|
||||||
@@ -130,7 +130,7 @@ fun assignedTwice(p: Int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun main(args: Array<String?>) {
|
fun main(args: Array<String?>) {
|
||||||
<!CAN_BE_VAL{LT}!><!CAN_BE_VAL{PSI}!>var<!> a: String?<!>
|
<!CAN_BE_VAL!>var<!> a: String?
|
||||||
<!UNUSED_VARIABLE{LT}!>val <!UNUSED_VARIABLE{PSI}!>unused<!> = 0<!>
|
<!UNUSED_VARIABLE{LT}!>val <!UNUSED_VARIABLE{PSI}!>unused<!> = 0<!>
|
||||||
|
|
||||||
if (args.size == 1) {
|
if (args.size == 1) {
|
||||||
@@ -153,7 +153,7 @@ fun lambda() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun lambdaInitialization() {
|
fun lambdaInitialization() {
|
||||||
<!CAN_BE_VAL{LT}, VARIABLE_NEVER_READ{LT}!><!CAN_BE_VAL{PSI}!>var<!> <!VARIABLE_NEVER_READ{PSI}!>a<!>: Int<!>
|
<!VARIABLE_NEVER_READ{LT}!><!CAN_BE_VAL!>var<!> <!VARIABLE_NEVER_READ{PSI}!>a<!>: Int<!>
|
||||||
|
|
||||||
run {
|
run {
|
||||||
<!ASSIGNED_VALUE_IS_NEVER_READ!>a<!> = 20
|
<!ASSIGNED_VALUE_IS_NEVER_READ!>a<!> = 20
|
||||||
@@ -161,7 +161,7 @@ fun lambdaInitialization() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun notAssignedWhenNotUsed(p: Int) {
|
fun notAssignedWhenNotUsed(p: Int) {
|
||||||
<!CAN_BE_VAL{LT}!><!CAN_BE_VAL{PSI}!>var<!> v: Int<!>
|
<!CAN_BE_VAL!>var<!> v: Int
|
||||||
if (p > 0) {
|
if (p > 0) {
|
||||||
v = 1
|
v = 1
|
||||||
print(v)
|
print(v)
|
||||||
|
|||||||
Vendored
+1
-1
@@ -52,7 +52,7 @@ fun foo() {
|
|||||||
<!UNUSED_VARIABLE{LT}!>val <!UNUSED_VARIABLE{PSI}!>piFloat<!>: <!REDUNDANT_EXPLICIT_TYPE!>Float<!> = 3.14f<!>
|
<!UNUSED_VARIABLE{LT}!>val <!UNUSED_VARIABLE{PSI}!>piFloat<!>: <!REDUNDANT_EXPLICIT_TYPE!>Float<!> = 3.14f<!>
|
||||||
<!UNUSED_VARIABLE{LT}!>val <!UNUSED_VARIABLE{PSI}!>piDouble<!>: <!REDUNDANT_EXPLICIT_TYPE!>Double<!> = 3.14<!>
|
<!UNUSED_VARIABLE{LT}!>val <!UNUSED_VARIABLE{PSI}!>piDouble<!>: <!REDUNDANT_EXPLICIT_TYPE!>Double<!> = 3.14<!>
|
||||||
<!UNUSED_VARIABLE{LT}!>val <!UNUSED_VARIABLE{PSI}!>charZ<!>: <!REDUNDANT_EXPLICIT_TYPE!>Char<!> = 'z'<!>
|
<!UNUSED_VARIABLE{LT}!>val <!UNUSED_VARIABLE{PSI}!>charZ<!>: <!REDUNDANT_EXPLICIT_TYPE!>Char<!> = 'z'<!>
|
||||||
<!CAN_BE_VAL{LT}, UNUSED_VARIABLE{LT}!><!CAN_BE_VAL{PSI}!>var<!> <!UNUSED_VARIABLE{PSI}!>alpha<!>: <!REDUNDANT_EXPLICIT_TYPE!>Int<!> = 0<!>
|
<!UNUSED_VARIABLE{LT}!><!CAN_BE_VAL!>var<!> <!UNUSED_VARIABLE{PSI}!>alpha<!>: <!REDUNDANT_EXPLICIT_TYPE!>Int<!> = 0<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test(boolean: Boolean) {
|
fun test(boolean: Boolean) {
|
||||||
|
|||||||
Vendored
+29
-29
@@ -4,23 +4,23 @@ object O {
|
|||||||
|
|
||||||
// Interface
|
// Interface
|
||||||
interface Interface {
|
interface Interface {
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{LT}!>// Questionable cuz compiler reports warning here in FE 1.0
|
// Questionable cuz compiler reports warning here in FE 1.0
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{PSI}!>open<!> val gav: Int
|
<!REDUNDANT_MODALITY_MODIFIER!>open<!> val gav: Int
|
||||||
get() = 42<!>
|
get() = 42
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{LT}!>// Redundant
|
// Redundant
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{PSI}!>abstract<!> fun foo()<!>
|
<!REDUNDANT_MODALITY_MODIFIER!>abstract<!> fun foo()
|
||||||
<!PRIVATE_FUNCTION_WITH_NO_BODY{LT}!>// error
|
// error
|
||||||
<!PRIVATE_FUNCTION_WITH_NO_BODY{PSI}!>private<!> final fun bar()<!>
|
<!PRIVATE_FUNCTION_WITH_NO_BODY!>private<!> final fun bar()
|
||||||
|
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{LT}!><!REDUNDANT_MODALITY_MODIFIER{PSI}!>open<!> fun goo() {}<!>
|
<!REDUNDANT_MODALITY_MODIFIER!>open<!> fun goo() {}
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{LT}!><!REDUNDANT_MODALITY_MODIFIER{PSI}!>abstract<!> fun tar()<!>
|
<!REDUNDANT_MODALITY_MODIFIER!>abstract<!> fun tar()
|
||||||
|
|
||||||
<!ABSTRACT_FUNCTION_WITH_BODY{LT}!>// error
|
// error
|
||||||
<!ABSTRACT_FUNCTION_WITH_BODY{PSI}!>abstract<!> fun too() {}<!>
|
<!ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> fun too() {}
|
||||||
}
|
}
|
||||||
interface B {
|
interface B {
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{LT}!><!REDUNDANT_MODALITY_MODIFIER{PSI}!>abstract<!> var bar: Unit<!>
|
<!REDUNDANT_MODALITY_MODIFIER!>abstract<!> var bar: Unit
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{LT}!><!REDUNDANT_MODALITY_MODIFIER{PSI}!>abstract<!> fun foo()<!>
|
<!REDUNDANT_MODALITY_MODIFIER!>abstract<!> fun foo()
|
||||||
}
|
}
|
||||||
interface Foo
|
interface Foo
|
||||||
|
|
||||||
@@ -35,8 +35,8 @@ expect abstract class AbstractClass : Foo {
|
|||||||
|
|
||||||
// Abstract
|
// Abstract
|
||||||
abstract class Base {
|
abstract class Base {
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{LT}!>// Redundant final
|
// Redundant final
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{PSI}!>final<!> fun foo() {}<!>
|
<!REDUNDANT_MODALITY_MODIFIER!>final<!> fun foo() {}
|
||||||
// Abstract
|
// Abstract
|
||||||
abstract fun bar()
|
abstract fun bar()
|
||||||
// Open
|
// Open
|
||||||
@@ -44,8 +44,8 @@ abstract class Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FinalDerived : Base() {
|
class FinalDerived : Base() {
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{LT}!>// Redundant final
|
// Redundant final
|
||||||
override <!REDUNDANT_MODALITY_MODIFIER{PSI}!>final<!> fun bar() {}<!>
|
override <!REDUNDANT_MODALITY_MODIFIER!>final<!> fun bar() {}
|
||||||
// Non-final member in final class
|
// Non-final member in final class
|
||||||
override open val gav = 13
|
override open val gav = 13
|
||||||
}
|
}
|
||||||
@@ -53,33 +53,33 @@ class FinalDerived : Base() {
|
|||||||
open class OpenDerived : Base() {
|
open class OpenDerived : Base() {
|
||||||
// Final
|
// Final
|
||||||
override final fun bar() {}
|
override final fun bar() {}
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{LT}!>// Redundant open
|
// Redundant open
|
||||||
override <!REDUNDANT_MODALITY_MODIFIER{PSI}!>open<!> val gav = 13<!>
|
override <!REDUNDANT_MODALITY_MODIFIER!>open<!> val gav = 13
|
||||||
}
|
}
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{LT}!>// Redundant final
|
// Redundant final
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{PSI}!>final<!> class Final<!>
|
<!REDUNDANT_MODALITY_MODIFIER!>final<!> class Final
|
||||||
// Derived interface
|
// Derived interface
|
||||||
interface Derived : Interface {
|
interface Derived : Interface {
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{LT}!>// Redundant
|
// Redundant
|
||||||
override <!REDUNDANT_MODALITY_MODIFIER{PSI}!>open<!> fun foo() {}<!>
|
override <!REDUNDANT_MODALITY_MODIFIER!>open<!> fun foo() {}
|
||||||
// error
|
// error
|
||||||
final class Nested
|
final class Nested
|
||||||
}
|
}
|
||||||
// Derived abstract class
|
// Derived abstract class
|
||||||
abstract class AbstractDerived1(override final val gav: Int) : Interface {
|
abstract class AbstractDerived1(override final val gav: Int) : Interface {
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{LT}!>// Redundant
|
// Redundant
|
||||||
override <!REDUNDANT_MODALITY_MODIFIER{PSI}!>open<!> fun foo() {}<!>
|
override <!REDUNDANT_MODALITY_MODIFIER!>open<!> fun foo() {}
|
||||||
}
|
}
|
||||||
// Derived abstract class
|
// Derived abstract class
|
||||||
abstract class AbstractDerived2 : Interface {
|
abstract class AbstractDerived2 : Interface {
|
||||||
// Final
|
// Final
|
||||||
override final fun foo() {}
|
override final fun foo() {}
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{LT}!>// Redundant
|
// Redundant
|
||||||
override <!REDUNDANT_MODALITY_MODIFIER{PSI}!>open<!> val gav = 13<!>
|
override <!REDUNDANT_MODALITY_MODIFIER!>open<!> val gav = 13
|
||||||
}
|
}
|
||||||
// Redundant abstract interface
|
// Redundant abstract interface
|
||||||
abstract interface AbstractInterface
|
abstract interface AbstractInterface
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{LT}!>// Redundant final object
|
// Redundant final object
|
||||||
<!REDUNDANT_MODALITY_MODIFIER{PSI}!>final<!> object FinalObject<!>
|
<!REDUNDANT_MODALITY_MODIFIER!>final<!> object FinalObject
|
||||||
// Open interface
|
// Open interface
|
||||||
open interface OpenInterface
|
open interface OpenInterface
|
||||||
|
|||||||
Vendored
+14
-14
@@ -1,7 +1,7 @@
|
|||||||
fun f() {
|
fun f() {
|
||||||
<!CAN_BE_VAL{LT}, REDUNDANT_VISIBILITY_MODIFIER{LT}, UNUSED_VARIABLE{LT}!><!REDUNDANT_VISIBILITY_MODIFIER{PSI}!>public<!> <!CAN_BE_VAL{PSI}!>var<!> <!UNUSED_VARIABLE{PSI}!>baz<!> = 0<!>
|
<!UNUSED_VARIABLE{LT}!><!REDUNDANT_VISIBILITY_MODIFIER!>public<!> <!CAN_BE_VAL!>var<!> <!UNUSED_VARIABLE{PSI}!>baz<!> = 0<!>
|
||||||
class LocalClass {
|
class LocalClass {
|
||||||
<!REDUNDANT_VISIBILITY_MODIFIER{LT}!><!REDUNDANT_VISIBILITY_MODIFIER{PSI}!>internal<!> var foo = 0<!>
|
<!REDUNDANT_VISIBILITY_MODIFIER!>internal<!> var foo = 0
|
||||||
}
|
}
|
||||||
LocalClass().foo = 1
|
LocalClass().foo = 1
|
||||||
}
|
}
|
||||||
@@ -26,10 +26,10 @@ class Foo2<
|
|||||||
internal inner class B<T,T2,>
|
internal inner class B<T,T2,>
|
||||||
}
|
}
|
||||||
|
|
||||||
<!REDECLARATION, REDUNDANT_VISIBILITY_MODIFIER{LT}!><!REDUNDANT_VISIBILITY_MODIFIER{PSI}!>public<!> class C {
|
<!REDECLARATION!><!REDUNDANT_VISIBILITY_MODIFIER!>public<!> class C {
|
||||||
<!REDUNDANT_VISIBILITY_MODIFIER{LT}!><!REDUNDANT_VISIBILITY_MODIFIER{PSI}!>public<!> val foo: Int = 0<!>
|
<!REDUNDANT_VISIBILITY_MODIFIER!>public<!> val foo: Int = 0
|
||||||
|
|
||||||
<!REDUNDANT_VISIBILITY_MODIFIER{LT}!><!REDUNDANT_VISIBILITY_MODIFIER{PSI}!>public<!> fun bar() {}<!>
|
<!REDUNDANT_VISIBILITY_MODIFIER!>public<!> fun bar() {}
|
||||||
|
|
||||||
}<!>
|
}<!>
|
||||||
|
|
||||||
@@ -42,19 +42,19 @@ open class D {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class E : D() {
|
class E : D() {
|
||||||
<!REDUNDANT_VISIBILITY_MODIFIER{LT}!><!REDUNDANT_VISIBILITY_MODIFIER{PSI}!>protected<!> override fun willRemainProtected() {
|
<!REDUNDANT_VISIBILITY_MODIFIER!>protected<!> override fun willRemainProtected() {
|
||||||
}<!>
|
}
|
||||||
|
|
||||||
public override fun willBecomePublic() {
|
public override fun willBecomePublic() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class F <!REDUNDANT_VISIBILITY_MODIFIER{LT}!><!REDUNDANT_VISIBILITY_MODIFIER{PSI}!>private<!> constructor(val x: Int)<!> {
|
enum class F <!REDUNDANT_VISIBILITY_MODIFIER!>private<!> constructor(val x: Int) {
|
||||||
FIRST(42)
|
FIRST(42)
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class G constructor(val y: Int) {
|
sealed class G constructor(val y: Int) {
|
||||||
<!REDUNDANT_VISIBILITY_MODIFIER{LT}!><!REDUNDANT_VISIBILITY_MODIFIER{PSI}!>private<!> constructor(): this(42)<!>
|
<!REDUNDANT_VISIBILITY_MODIFIER!>private<!> constructor(): this(42)
|
||||||
|
|
||||||
object H : G()
|
object H : G()
|
||||||
}
|
}
|
||||||
@@ -63,16 +63,16 @@ interface I {
|
|||||||
fun bar()
|
fun bar()
|
||||||
}
|
}
|
||||||
|
|
||||||
<!REDUNDANT_VISIBILITY_MODIFIER{LT}!><!REDUNDANT_VISIBILITY_MODIFIER{PSI}!>public<!> var baz = 0<!>
|
<!REDUNDANT_VISIBILITY_MODIFIER!>public<!> var baz = 0
|
||||||
|
|
||||||
open class J {
|
open class J {
|
||||||
protected val baz = 0
|
protected val baz = 0
|
||||||
<!REDUNDANT_VISIBILITY_MODIFIER{LT}!><!REDUNDANT_VISIBILITY_MODIFIER{PSI}!>protected<!> get() = field * 2<!>
|
<!REDUNDANT_VISIBILITY_MODIFIER!>protected<!> get() = field * 2
|
||||||
var baf = 0
|
var baf = 0
|
||||||
<!REDUNDANT_VISIBILITY_MODIFIER{LT}!><!REDUNDANT_VISIBILITY_MODIFIER{PSI}!>public<!> get() = 1<!>
|
<!REDUNDANT_VISIBILITY_MODIFIER!>public<!> get() = 1
|
||||||
<!REDUNDANT_VISIBILITY_MODIFIER{LT}!><!REDUNDANT_VISIBILITY_MODIFIER{PSI}!>public<!> set(value) {
|
<!REDUNDANT_VISIBILITY_MODIFIER!>public<!> set(value) {
|
||||||
field = value
|
field = value
|
||||||
}<!>
|
}
|
||||||
|
|
||||||
var buf = 0
|
var buf = 0
|
||||||
private get() = 42
|
private get() = 42
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
fun goo() {
|
fun goo() {
|
||||||
var a = 2
|
var a = 2
|
||||||
val b = 4
|
val b = 4
|
||||||
<!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{LT}!>a <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{PSI}!>=<!> a + 1 + b<!>
|
a <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT!>=<!> a + 1 + b
|
||||||
<!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{LT}!>a <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{PSI}!>=<!> (a + 1)<!>
|
a <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT!>=<!> (a + 1)
|
||||||
<!ASSIGNED_VALUE_IS_NEVER_READ!>a<!> = a * b + 1
|
<!ASSIGNED_VALUE_IS_NEVER_READ!>a<!> = a * b + 1
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
fun foo() {
|
fun foo() {
|
||||||
var x = 0
|
var x = 0
|
||||||
<!CAN_BE_VAL{LT}!><!CAN_BE_VAL{PSI}!>var<!> y = 0<!>
|
<!CAN_BE_VAL!>var<!> y = 0
|
||||||
<!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{LT}!><!ASSIGNED_VALUE_IS_NEVER_READ!>x<!> <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{PSI}!>=<!> x + y + 5<!>
|
<!ASSIGNED_VALUE_IS_NEVER_READ!>x<!> <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT!>=<!> x + y + 5
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
fun foo() {
|
fun foo() {
|
||||||
var x = 0
|
var x = 0
|
||||||
<!CAN_BE_VAL{LT}!><!CAN_BE_VAL{PSI}!>var<!> y = 0<!>
|
<!CAN_BE_VAL!>var<!> y = 0
|
||||||
<!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{LT}!><!ASSIGNED_VALUE_IS_NEVER_READ!>x<!> <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{PSI}!>=<!> y + x + 5<!>
|
<!ASSIGNED_VALUE_IS_NEVER_READ!>x<!> <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT!>=<!> y + x + 5
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
fun foo() {
|
fun foo() {
|
||||||
var x = 0
|
var x = 0
|
||||||
<!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{LT}!>x <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{PSI}!>=<!> x - 1 - 1<!>
|
x <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT!>=<!> x - 1 - 1
|
||||||
|
|
||||||
<!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{LT}!>x <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{PSI}!>=<!> x / 1<!>
|
x <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT!>=<!> x / 1
|
||||||
x = 1 / x
|
x = 1 / x
|
||||||
<!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{LT}!><!ASSIGNED_VALUE_IS_NEVER_READ!>x<!> <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{PSI}!>=<!> -1 + x<!>
|
<!ASSIGNED_VALUE_IS_NEVER_READ!>x<!> <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT!>=<!> -1 + x
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
fun foo() {
|
fun foo() {
|
||||||
var x = 0
|
var x = 0
|
||||||
<!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{LT}!><!ASSIGNED_VALUE_IS_NEVER_READ!>x<!> <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{PSI}!>=<!> 1 + x<!>
|
<!ASSIGNED_VALUE_IS_NEVER_READ!>x<!> <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT!>=<!> 1 + x
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fun foo() {
|
fun foo() {
|
||||||
var y = 0
|
var y = 0
|
||||||
val x = 0
|
val x = 0
|
||||||
<!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{LT}!><!ASSIGNED_VALUE_IS_NEVER_READ!>y<!> <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{PSI}!>=<!> y + x<!>
|
<!ASSIGNED_VALUE_IS_NEVER_READ!>y<!> <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT!>=<!> y + x
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
fun foo() {
|
fun foo() {
|
||||||
var x = 0
|
var x = 0
|
||||||
<!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{LT}!><!ASSIGNED_VALUE_IS_NEVER_READ!>x<!> <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{PSI}!>=<!> x + 1<!>
|
<!ASSIGNED_VALUE_IS_NEVER_READ!>x<!> <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT!>=<!> x + 1
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
fun foo() {
|
fun foo() {
|
||||||
var x = 0
|
var x = 0
|
||||||
<!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{LT}!><!ASSIGNED_VALUE_IS_NEVER_READ!>x<!> <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT{PSI}!>=<!> x - 1<!>
|
<!ASSIGNED_VALUE_IS_NEVER_READ!>x<!> <!CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT!>=<!> x - 1
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fun foo() {
|
fun foo() {
|
||||||
<!CAN_BE_VAL{LT}!><!CAN_BE_VAL{PSI}!>var<!> a = 1<!>
|
<!CAN_BE_VAL!>var<!> a = 1
|
||||||
var b = <!VARIABLE_INITIALIZER_IS_REDUNDANT!>2<!>
|
var b = <!VARIABLE_INITIALIZER_IS_REDUNDANT!>2<!>
|
||||||
var c = 3
|
var c = 3
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
interface Some {
|
interface Some {
|
||||||
<!REDUNDANT_OPEN_IN_INTERFACE{LT}!><!REDUNDANT_OPEN_IN_INTERFACE{PSI}!>open<!> fun foo()<!>
|
<!REDUNDANT_OPEN_IN_INTERFACE!>open<!> fun foo()
|
||||||
open fun bar() {}
|
open fun bar() {}
|
||||||
|
|
||||||
<!REDUNDANT_OPEN_IN_INTERFACE{LT}!><!REDUNDANT_OPEN_IN_INTERFACE{PSI}!>open<!> val x: Int<!>
|
<!REDUNDANT_OPEN_IN_INTERFACE!>open<!> val x: Int
|
||||||
open val y = <!PROPERTY_INITIALIZER_IN_INTERFACE!>1<!>
|
open val y = <!PROPERTY_INITIALIZER_IN_INTERFACE!>1<!>
|
||||||
open val z get() = 1
|
open val z get() = 1
|
||||||
|
|
||||||
<!REDUNDANT_OPEN_IN_INTERFACE{LT}!><!REDUNDANT_OPEN_IN_INTERFACE{PSI}!>open<!> var xx: Int<!>
|
<!REDUNDANT_OPEN_IN_INTERFACE!>open<!> var xx: Int
|
||||||
open var yy = <!PROPERTY_INITIALIZER_IN_INTERFACE!>1<!>
|
open var yy = <!PROPERTY_INITIALIZER_IN_INTERFACE!>1<!>
|
||||||
open var zz: Int
|
open var zz: Int
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
<!CONFLICTING_OVERLOADS{LT}!><!CONFLICTING_OVERLOADS{PSI}!>fun takeString(s: String)<!> {}<!>
|
<!CONFLICTING_OVERLOADS!>fun takeString(s: String)<!> {}
|
||||||
|
|
||||||
class Wrapper(val s: String?) {
|
class Wrapper(val s: String?) {
|
||||||
fun withThis() {
|
fun withThis() {
|
||||||
@@ -11,4 +11,4 @@ class Wrapper(val s: String?) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<!CONFLICTING_OVERLOADS{LT}!><!CONFLICTING_OVERLOADS{PSI}!>fun takeString(s: String)<!> {}<!>
|
<!CONFLICTING_OVERLOADS!>fun takeString(s: String)<!> {}
|
||||||
|
|||||||
+4
-4
@@ -23,11 +23,11 @@ fun test_2(a: A?) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<!CONFLICTING_OVERLOADS{LT}!><!CONFLICTING_OVERLOADS{PSI}!>fun test_3(x: Any?)<!> {
|
<!CONFLICTING_OVERLOADS!>fun test_3(x: Any?)<!> {
|
||||||
val a = x as? A ?: return
|
val a = x as? A ?: return
|
||||||
a.foo() // Should be OK
|
a.foo() // Should be OK
|
||||||
x.foo() // Should be OK
|
x.foo() // Should be OK
|
||||||
}<!>
|
}
|
||||||
|
|
||||||
// ----------------- Unstable -----------------
|
// ----------------- Unstable -----------------
|
||||||
|
|
||||||
@@ -53,8 +53,8 @@ fun test_2(a: B?) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<!CONFLICTING_OVERLOADS{LT}!><!CONFLICTING_OVERLOADS{PSI}!>fun test_3(x: Any?)<!> {
|
<!CONFLICTING_OVERLOADS!>fun test_3(x: Any?)<!> {
|
||||||
val a = x as? B ?: return
|
val a = x as? B ?: return
|
||||||
a.foo() // Should be OK
|
a.foo() // Should be OK
|
||||||
x.foo() // Should be OK
|
x.foo() // Should be OK
|
||||||
}<!>
|
}
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ interface C {
|
|||||||
fun baz()
|
fun baz()
|
||||||
}
|
}
|
||||||
|
|
||||||
<!CONSTRUCTOR_IN_INTERFACE{LT}!>interface <!CONSTRUCTOR_IN_INTERFACE{PSI}!>Inv<K, T>()<!> {
|
interface <!CONSTRUCTOR_IN_INTERFACE!>Inv<K, T>()<!> {
|
||||||
fun k(): K
|
fun k(): K
|
||||||
fun t(): T
|
fun t(): T
|
||||||
}<!>
|
}
|
||||||
|
|
||||||
typealias Inv0 = Inv<A, B>
|
typealias Inv0 = Inv<A, B>
|
||||||
typealias Inv1<X> = Inv<A, X>
|
typealias Inv1<X> = Inv<A, X>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class B()
|
|||||||
class C(val b : B)
|
class C(val b : B)
|
||||||
fun get(f: Boolean) = if (f) {A.A1} else {""}
|
fun get(f: Boolean) = if (f) {A.A1} else {""}
|
||||||
|
|
||||||
<!CONFLICTING_OVERLOADS{LT}!><!CONFLICTING_OVERLOADS{PSI}!>fun case2()<!> {
|
<!CONFLICTING_OVERLOADS!>fun case2()<!> {
|
||||||
|
|
||||||
val flag: Any = get(false) //string
|
val flag: Any = get(false) //string
|
||||||
val l1 = when (flag!!) { // should be NO_ELSE_IN_WHEN
|
val l1 = when (flag!!) { // should be NO_ELSE_IN_WHEN
|
||||||
@@ -25,9 +25,9 @@ fun get(f: Boolean) = if (f) {A.A1} else {""}
|
|||||||
A.A1 -> B()
|
A.A1 -> B()
|
||||||
A.A2 -> B()
|
A.A2 -> B()
|
||||||
}
|
}
|
||||||
}<!>
|
}
|
||||||
|
|
||||||
<!CONFLICTING_OVERLOADS{LT}!><!CONFLICTING_OVERLOADS{PSI}!>fun case2()<!> {
|
<!CONFLICTING_OVERLOADS!>fun case2()<!> {
|
||||||
|
|
||||||
val flag: Any = get(true) //A
|
val flag: Any = get(true) //A
|
||||||
val l1 = when (flag!!) {// should be NO_ELSE_IN_WHEN
|
val l1 = when (flag!!) {// should be NO_ELSE_IN_WHEN
|
||||||
@@ -39,7 +39,7 @@ fun get(f: Boolean) = if (f) {A.A1} else {""}
|
|||||||
A.A1 -> B()
|
A.A1 -> B()
|
||||||
A.A2 -> B()
|
A.A2 -> B()
|
||||||
}
|
}
|
||||||
}<!>
|
}
|
||||||
|
|
||||||
fun case3() {
|
fun case3() {
|
||||||
|
|
||||||
|
|||||||
+100
-45
@@ -20,39 +20,56 @@ import org.jetbrains.kotlin.psi.KtParameter.VAL_VAR_TOKEN_SET
|
|||||||
|
|
||||||
object LightTreePositioningStrategies {
|
object LightTreePositioningStrategies {
|
||||||
val DEFAULT = object : LightTreePositioningStrategy() {
|
val DEFAULT = object : LightTreePositioningStrategy() {
|
||||||
override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): List<TextRange> {
|
override fun mark(
|
||||||
|
node: LighterASTNode,
|
||||||
|
startOffset: Int,
|
||||||
|
endOffset: Int,
|
||||||
|
tree: FlyweightCapableTreeStructure<LighterASTNode>
|
||||||
|
): List<TextRange> {
|
||||||
when (node.tokenType) {
|
when (node.tokenType) {
|
||||||
KtNodeTypes.OBJECT_DECLARATION -> {
|
KtNodeTypes.OBJECT_DECLARATION -> {
|
||||||
val objectKeyword = tree.objectKeyword(node)!!
|
val objectKeyword = tree.objectKeyword(node)!!
|
||||||
return markRange(
|
return markRange(
|
||||||
from = objectKeyword,
|
from = objectKeyword,
|
||||||
to = tree.nameIdentifier(node) ?: objectKeyword,
|
to = tree.nameIdentifier(node) ?: objectKeyword,
|
||||||
tree
|
startOffset, endOffset, tree, node
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
KtNodeTypes.CONSTRUCTOR_DELEGATION_CALL -> {
|
KtNodeTypes.CONSTRUCTOR_DELEGATION_CALL -> {
|
||||||
return SECONDARY_CONSTRUCTOR_DELEGATION_CALL.mark(node, tree)
|
return SECONDARY_CONSTRUCTOR_DELEGATION_CALL.mark(node, startOffset, endOffset, tree)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.mark(node, tree)
|
return super.mark(node, startOffset, endOffset, tree)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val VAL_OR_VAR_NODE: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
|
val VAL_OR_VAR_NODE: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
|
||||||
override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): List<TextRange> {
|
override fun mark(
|
||||||
|
node: LighterASTNode,
|
||||||
|
startOffset: Int,
|
||||||
|
endOffset: Int,
|
||||||
|
tree: FlyweightCapableTreeStructure<LighterASTNode>
|
||||||
|
): List<TextRange> {
|
||||||
val target = tree.valOrVarKeyword(node) ?: node
|
val target = tree.valOrVarKeyword(node) ?: node
|
||||||
return markElement(target, tree)
|
return markElement(target, startOffset, endOffset, tree, node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val SECONDARY_CONSTRUCTOR_DELEGATION_CALL: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
|
val SECONDARY_CONSTRUCTOR_DELEGATION_CALL: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
|
||||||
override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): List<TextRange> {
|
override fun mark(
|
||||||
|
node: LighterASTNode,
|
||||||
|
startOffset: Int,
|
||||||
|
endOffset: Int,
|
||||||
|
tree: FlyweightCapableTreeStructure<LighterASTNode>
|
||||||
|
): List<TextRange> {
|
||||||
when (node.tokenType) {
|
when (node.tokenType) {
|
||||||
KtNodeTypes.SECONDARY_CONSTRUCTOR -> {
|
KtNodeTypes.SECONDARY_CONSTRUCTOR -> {
|
||||||
val valueParameterList = tree.valueParameterList(node) ?: return markElement(node, tree)
|
val valueParameterList = tree.valueParameterList(node)
|
||||||
|
?: return markElement(node, startOffset, endOffset, tree)
|
||||||
return markRange(
|
return markRange(
|
||||||
tree.constructorKeyword(node)!!,
|
tree.constructorKeyword(node)!!,
|
||||||
tree.lastChild(valueParameterList)!!, tree
|
tree.lastChild(valueParameterList) ?: valueParameterList,
|
||||||
|
startOffset, endOffset, tree, node
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
KtNodeTypes.CONSTRUCTOR_DELEGATION_CALL -> {
|
KtNodeTypes.CONSTRUCTOR_DELEGATION_CALL -> {
|
||||||
@@ -60,13 +77,14 @@ object LightTreePositioningStrategies {
|
|||||||
if (delegationReference != null && tree.firstChild(delegationReference) == null) {
|
if (delegationReference != null && tree.firstChild(delegationReference) == null) {
|
||||||
val constructor = tree.findParentOfType(node, KtNodeTypes.SECONDARY_CONSTRUCTOR)!!
|
val constructor = tree.findParentOfType(node, KtNodeTypes.SECONDARY_CONSTRUCTOR)!!
|
||||||
val valueParameterList = tree.valueParameterList(constructor)
|
val valueParameterList = tree.valueParameterList(constructor)
|
||||||
?: return markElement(constructor, tree)
|
?: return markElement(constructor, startOffset, endOffset, tree, node)
|
||||||
return markRange(
|
return markRange(
|
||||||
tree.constructorKeyword(constructor)!!,
|
tree.constructorKeyword(constructor)!!,
|
||||||
tree.lastChild(valueParameterList)!!, tree
|
tree.lastChild(valueParameterList) ?: valueParameterList,
|
||||||
|
startOffset, endOffset, tree, node
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return markElement(delegationReference ?: node, tree)
|
return markElement(delegationReference ?: node, startOffset, endOffset, tree, node)
|
||||||
}
|
}
|
||||||
else -> error("unexpected element $node")
|
else -> error("unexpected element $node")
|
||||||
}
|
}
|
||||||
@@ -74,7 +92,12 @@ object LightTreePositioningStrategies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val DECLARATION_NAME: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
|
val DECLARATION_NAME: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
|
||||||
override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): List<TextRange> {
|
override fun mark(
|
||||||
|
node: LighterASTNode,
|
||||||
|
startOffset: Int,
|
||||||
|
endOffset: Int,
|
||||||
|
tree: FlyweightCapableTreeStructure<LighterASTNode>
|
||||||
|
): List<TextRange> {
|
||||||
val nameIdentifier = tree.nameIdentifier(node)
|
val nameIdentifier = tree.nameIdentifier(node)
|
||||||
if (nameIdentifier != null) {
|
if (nameIdentifier != null) {
|
||||||
if (node.tokenType == KtNodeTypes.CLASS || node.tokenType == KtNodeTypes.OBJECT_DECLARATION) {
|
if (node.tokenType == KtNodeTypes.CLASS || node.tokenType == KtNodeTypes.OBJECT_DECLARATION) {
|
||||||
@@ -83,24 +106,31 @@ object LightTreePositioningStrategies {
|
|||||||
?: tree.findChildByType(node, TokenSet.create(KtTokens.CLASS_KEYWORD, KtTokens.OBJECT_KEYWORD))
|
?: tree.findChildByType(node, TokenSet.create(KtTokens.CLASS_KEYWORD, KtTokens.OBJECT_KEYWORD))
|
||||||
?: node
|
?: node
|
||||||
|
|
||||||
return markRange(startElement, nameIdentifier, tree)
|
return markRange(startElement, nameIdentifier, startOffset, endOffset, tree, node)
|
||||||
}
|
}
|
||||||
return markElement(nameIdentifier, tree)
|
return markElement(node, startOffset, endOffset, tree)
|
||||||
}
|
}
|
||||||
if (node.tokenType == KtNodeTypes.FUN) {
|
if (node.tokenType == KtNodeTypes.FUN) {
|
||||||
return DECLARATION_SIGNATURE.mark(node, tree)
|
return DECLARATION_SIGNATURE.mark(node, startOffset, endOffset, tree)
|
||||||
}
|
}
|
||||||
return DEFAULT.mark(node, tree)
|
return DEFAULT.mark(node, startOffset, endOffset, tree)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val DECLARATION_SIGNATURE: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
|
val DECLARATION_SIGNATURE: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
|
||||||
override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): List<TextRange> {
|
override fun mark(
|
||||||
|
node: LighterASTNode,
|
||||||
|
startOffset: Int,
|
||||||
|
endOffset: Int,
|
||||||
|
tree: FlyweightCapableTreeStructure<LighterASTNode>
|
||||||
|
): List<TextRange> {
|
||||||
when (node.tokenType) {
|
when (node.tokenType) {
|
||||||
KtNodeTypes.PRIMARY_CONSTRUCTOR, KtNodeTypes.SECONDARY_CONSTRUCTOR -> {
|
KtNodeTypes.PRIMARY_CONSTRUCTOR, KtNodeTypes.SECONDARY_CONSTRUCTOR -> {
|
||||||
val begin = tree.constructorKeyword(node) ?: tree.valueParameterList(node) ?: return markElement(node, tree)
|
val begin = tree.constructorKeyword(node) ?: tree.valueParameterList(node)
|
||||||
val end = tree.valueParameterList(node) ?: tree.constructorKeyword(node) ?: return markElement(node, tree)
|
?: return markElement(node, startOffset, endOffset, tree)
|
||||||
return markRange(begin, end, tree)
|
val end = tree.valueParameterList(node) ?: tree.constructorKeyword(node)
|
||||||
|
?: return markElement(node, startOffset, endOffset, tree)
|
||||||
|
return markRange(begin, end, startOffset, endOffset, tree, node)
|
||||||
}
|
}
|
||||||
KtNodeTypes.FUN, KtNodeTypes.FUNCTION_LITERAL -> {
|
KtNodeTypes.FUN, KtNodeTypes.FUNCTION_LITERAL -> {
|
||||||
val endOfSignatureElement =
|
val endOfSignatureElement =
|
||||||
@@ -113,11 +143,11 @@ object LightTreePositioningStrategies {
|
|||||||
?: tree.valueParameterList(node)
|
?: tree.valueParameterList(node)
|
||||||
?: node
|
?: node
|
||||||
} else node
|
} else node
|
||||||
return markRange(startElement, endOfSignatureElement, tree)
|
return markRange(startElement, endOfSignatureElement, startOffset, endOffset, tree, node)
|
||||||
}
|
}
|
||||||
KtNodeTypes.PROPERTY -> {
|
KtNodeTypes.PROPERTY -> {
|
||||||
val endOfSignatureElement = tree.typeReference(node) ?: tree.nameIdentifier(node) ?: node
|
val endOfSignatureElement = tree.typeReference(node) ?: tree.nameIdentifier(node) ?: node
|
||||||
return markRange(node, endOfSignatureElement, tree)
|
return markRange(node, endOfSignatureElement, startOffset, endOffset, tree, node)
|
||||||
}
|
}
|
||||||
KtNodeTypes.PROPERTY_ACCESSOR -> {
|
KtNodeTypes.PROPERTY_ACCESSOR -> {
|
||||||
val endOfSignatureElement =
|
val endOfSignatureElement =
|
||||||
@@ -125,32 +155,38 @@ object LightTreePositioningStrategies {
|
|||||||
?: tree.rightParenthesis(node)
|
?: tree.rightParenthesis(node)
|
||||||
?: tree.accessorNamePlaceholder(node)
|
?: tree.accessorNamePlaceholder(node)
|
||||||
|
|
||||||
return markRange(node, endOfSignatureElement, tree)
|
return markRange(node, endOfSignatureElement, startOffset, endOffset, tree, node)
|
||||||
}
|
}
|
||||||
KtNodeTypes.CLASS -> {
|
KtNodeTypes.CLASS -> {
|
||||||
val nameAsDeclaration = tree.nameIdentifier(node) ?: return markElement(node, tree)
|
val nameAsDeclaration = tree.nameIdentifier(node)
|
||||||
|
?: return markElement(node, startOffset, endOffset, tree)
|
||||||
val primaryConstructorParameterList = tree.primaryConstructor(node)?.let { constructor ->
|
val primaryConstructorParameterList = tree.primaryConstructor(node)?.let { constructor ->
|
||||||
tree.valueParameterList(constructor)
|
tree.valueParameterList(constructor)
|
||||||
} ?: return markElement(nameAsDeclaration, tree)
|
} ?: return markElement(nameAsDeclaration, startOffset, endOffset, tree, node)
|
||||||
return markRange(nameAsDeclaration, primaryConstructorParameterList, tree)
|
return markRange(nameAsDeclaration, primaryConstructorParameterList, startOffset, endOffset, tree, node)
|
||||||
}
|
}
|
||||||
KtNodeTypes.OBJECT_DECLARATION -> {
|
KtNodeTypes.OBJECT_DECLARATION -> {
|
||||||
return DECLARATION_NAME.mark(node, tree)
|
return DECLARATION_NAME.mark(node, startOffset, endOffset, tree)
|
||||||
}
|
}
|
||||||
KtNodeTypes.CLASS_INITIALIZER -> {
|
KtNodeTypes.CLASS_INITIALIZER -> {
|
||||||
return markElement(tree.initKeyword(node)!!, tree)
|
return markElement(tree.initKeyword(node)!!, startOffset, endOffset, tree, node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.mark(node, tree)
|
return super.mark(node, startOffset, endOffset, tree)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val DECLARATION_SIGNATURE_OR_DEFAULT: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
|
val DECLARATION_SIGNATURE_OR_DEFAULT: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
|
||||||
override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): List<TextRange> =
|
override fun mark(
|
||||||
|
node: LighterASTNode,
|
||||||
|
startOffset: Int,
|
||||||
|
endOffset: Int,
|
||||||
|
tree: FlyweightCapableTreeStructure<LighterASTNode>
|
||||||
|
): List<TextRange> =
|
||||||
if (node.isDeclaration) {
|
if (node.isDeclaration) {
|
||||||
DECLARATION_SIGNATURE.mark(node, tree)
|
DECLARATION_SIGNATURE.mark(node, startOffset, endOffset, tree)
|
||||||
} else {
|
} else {
|
||||||
DEFAULT.mark(node, tree)
|
DEFAULT.mark(node, startOffset, endOffset, tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val LighterASTNode.isDeclaration: Boolean
|
private val LighterASTNode.isDeclaration: Boolean
|
||||||
@@ -170,17 +206,29 @@ object LightTreePositioningStrategies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class ModifierSetBasedLightTreePositioningStrategy(private val modifierSet: TokenSet) : LightTreePositioningStrategy() {
|
private class ModifierSetBasedLightTreePositioningStrategy(private val modifierSet: TokenSet) : LightTreePositioningStrategy() {
|
||||||
override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): List<TextRange> {
|
override fun mark(
|
||||||
tree.findChildByType(node, modifierSet)?.let { return markElement(it, tree) }
|
node: LighterASTNode,
|
||||||
tree.nameIdentifier(node)?.let { return markElement(it, tree) }
|
startOffset: Int,
|
||||||
|
endOffset: Int,
|
||||||
|
tree: FlyweightCapableTreeStructure<LighterASTNode>
|
||||||
|
): List<TextRange> {
|
||||||
|
val modifierList = tree.modifierList(node)
|
||||||
|
if (modifierList != null) {
|
||||||
|
tree.findChildByType(modifierList, modifierSet)?.let {
|
||||||
|
return markElement(it, startOffset, endOffset, tree, node)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tree.nameIdentifier(node)?.let {
|
||||||
|
return markElement(it, startOffset, endOffset, tree, node)
|
||||||
|
}
|
||||||
return when (node.tokenType) {
|
return when (node.tokenType) {
|
||||||
KtNodeTypes.OBJECT_DECLARATION -> {
|
KtNodeTypes.OBJECT_DECLARATION -> {
|
||||||
markElement(tree.objectKeyword(node)!!, tree)
|
markElement(tree.objectKeyword(node)!!, startOffset, endOffset, tree, node)
|
||||||
}
|
}
|
||||||
KtNodeTypes.PROPERTY_ACCESSOR -> {
|
KtNodeTypes.PROPERTY_ACCESSOR -> {
|
||||||
markElement(tree.accessorNamePlaceholder(node), tree)
|
markElement(tree.accessorNamePlaceholder(node), startOffset, endOffset, tree, node)
|
||||||
}
|
}
|
||||||
else -> markElement(node, tree)
|
else -> markElement(node, startOffset, endOffset, tree)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,8 +238,13 @@ object LightTreePositioningStrategies {
|
|||||||
val MODALITY_MODIFIER: LightTreePositioningStrategy = ModifierSetBasedLightTreePositioningStrategy(MODALITY_MODIFIERS)
|
val MODALITY_MODIFIER: LightTreePositioningStrategy = ModifierSetBasedLightTreePositioningStrategy(MODALITY_MODIFIERS)
|
||||||
|
|
||||||
val OPERATOR: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
|
val OPERATOR: LightTreePositioningStrategy = object : LightTreePositioningStrategy() {
|
||||||
override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): List<TextRange> {
|
override fun mark(
|
||||||
return markElement(tree.operationReference(node) ?: node, tree)
|
node: LighterASTNode,
|
||||||
|
startOffset: Int,
|
||||||
|
endOffset: Int,
|
||||||
|
tree: FlyweightCapableTreeStructure<LighterASTNode>
|
||||||
|
): List<TextRange> {
|
||||||
|
return markElement(tree.operationReference(node) ?: node, startOffset, endOffset, tree, node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,15 +301,17 @@ private fun FlyweightCapableTreeStructure<LighterASTNode>.valueParameterList(nod
|
|||||||
findChildByType(node, KtNodeTypes.VALUE_PARAMETER_LIST)
|
findChildByType(node, KtNodeTypes.VALUE_PARAMETER_LIST)
|
||||||
|
|
||||||
private fun FlyweightCapableTreeStructure<LighterASTNode>.typeReference(node: LighterASTNode): LighterASTNode? {
|
private fun FlyweightCapableTreeStructure<LighterASTNode>.typeReference(node: LighterASTNode): LighterASTNode? {
|
||||||
val childrenRef = Ref<Array<LighterASTNode>>()
|
val childrenRef = Ref<Array<LighterASTNode?>>()
|
||||||
getChildren(node, childrenRef)
|
getChildren(node, childrenRef)
|
||||||
return childrenRef.get()?.dropWhile { it.tokenType != KtTokens.COLON }?.firstOrNull { it.tokenType == KtNodeTypes.TYPE_REFERENCE }
|
return childrenRef.get()?.filterNotNull()?.dropWhile { it.tokenType != KtTokens.COLON }?.firstOrNull {
|
||||||
|
it.tokenType == KtNodeTypes.TYPE_REFERENCE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FlyweightCapableTreeStructure<LighterASTNode>.receiverTypeReference(node: LighterASTNode): LighterASTNode? {
|
private fun FlyweightCapableTreeStructure<LighterASTNode>.receiverTypeReference(node: LighterASTNode): LighterASTNode? {
|
||||||
val childrenRef = Ref<Array<LighterASTNode>>()
|
val childrenRef = Ref<Array<LighterASTNode?>>()
|
||||||
getChildren(node, childrenRef)
|
getChildren(node, childrenRef)
|
||||||
return childrenRef.get()?.firstOrNull {
|
return childrenRef.get()?.filterNotNull()?.firstOrNull {
|
||||||
if (it.tokenType == KtTokens.COLON || it.tokenType == KtTokens.LPAR) return null
|
if (it.tokenType == KtTokens.COLON || it.tokenType == KtTokens.LPAR) return null
|
||||||
it.tokenType == KtNodeTypes.TYPE_REFERENCE
|
it.tokenType == KtNodeTypes.TYPE_REFERENCE
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-11
@@ -15,13 +15,13 @@ import org.jetbrains.kotlin.lexer.KtTokens
|
|||||||
import org.jetbrains.kotlin.lexer.KtTokens.WHITE_SPACE
|
import org.jetbrains.kotlin.lexer.KtTokens.WHITE_SPACE
|
||||||
|
|
||||||
open class LightTreePositioningStrategy {
|
open class LightTreePositioningStrategy {
|
||||||
open fun markDiagnostic(diagnostic: FirDiagnostic<*>): List<TextRange> {
|
open fun mark(
|
||||||
val element = diagnostic.element
|
node: LighterASTNode,
|
||||||
return mark(element.lighterASTNode, element.treeStructure)
|
startOffset: Int,
|
||||||
}
|
endOffset: Int,
|
||||||
|
tree: FlyweightCapableTreeStructure<LighterASTNode>
|
||||||
open fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): List<TextRange> {
|
): List<TextRange> {
|
||||||
return markElement(node, tree)
|
return markElement(node, startOffset, endOffset, tree)
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun isValid(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): Boolean {
|
open fun isValid(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): Boolean {
|
||||||
@@ -29,12 +29,30 @@ open class LightTreePositioningStrategy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun markElement(node: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): List<TextRange> {
|
fun markElement(
|
||||||
return listOf(TextRange(tree.getStartOffset(node), tree.getEndOffset(node)))
|
node: LighterASTNode,
|
||||||
|
startOffset: Int,
|
||||||
|
endOffset: Int,
|
||||||
|
tree: FlyweightCapableTreeStructure<LighterASTNode>,
|
||||||
|
originalNode: LighterASTNode = node,
|
||||||
|
): List<TextRange> {
|
||||||
|
if (node === originalNode) return listOf(TextRange(startOffset, endOffset))
|
||||||
|
val startDelta = tree.getStartOffset(node) - tree.getStartOffset(originalNode)
|
||||||
|
val endDelta = tree.getEndOffset(node) - tree.getEndOffset(originalNode)
|
||||||
|
return listOf(TextRange(startDelta + startOffset, endDelta + endOffset))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun markRange(from: LighterASTNode, to: LighterASTNode, tree: FlyweightCapableTreeStructure<LighterASTNode>): List<TextRange> {
|
fun markRange(
|
||||||
return listOf(TextRange(tree.getStartOffset(from), tree.getEndOffset(to)))
|
from: LighterASTNode,
|
||||||
|
to: LighterASTNode,
|
||||||
|
startOffset: Int,
|
||||||
|
endOffset: Int,
|
||||||
|
tree: FlyweightCapableTreeStructure<LighterASTNode>,
|
||||||
|
originalNode: LighterASTNode
|
||||||
|
): List<TextRange> {
|
||||||
|
val startDelta = tree.getStartOffset(from) - tree.getStartOffset(originalNode)
|
||||||
|
val endDelta = tree.getEndOffset(to) - tree.getEndOffset(originalNode)
|
||||||
|
return listOf(TextRange(startDelta + startOffset, endDelta + endOffset))
|
||||||
}
|
}
|
||||||
|
|
||||||
private val DOC_AND_COMMENT_TOKENS = setOf(
|
private val DOC_AND_COMMENT_TOKENS = setOf(
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ open class SourceElementPositioningStrategy<in E : PsiElement>(
|
|||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
return psiStrategy.mark(element.psi as E)
|
return psiStrategy.mark(element.psi as E)
|
||||||
}
|
}
|
||||||
return lightTreeStrategy.mark(element.lighterASTNode, element.treeStructure)
|
return lightTreeStrategy.mark(element.lighterASTNode, element.startOffset, element.endOffset, element.treeStructure)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isValid(element: FirSourceElement): Boolean {
|
fun isValid(element: FirSourceElement): Boolean {
|
||||||
|
|||||||
+4
-12
@@ -6,14 +6,11 @@
|
|||||||
package org.jetbrains.kotlin.test.frontend.fir.handlers
|
package org.jetbrains.kotlin.test.frontend.fir.handlers
|
||||||
|
|
||||||
import com.intellij.openapi.util.TextRange
|
import com.intellij.openapi.util.TextRange
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import org.jetbrains.kotlin.codeMetaInfo.model.CodeMetaInfo
|
import org.jetbrains.kotlin.codeMetaInfo.model.CodeMetaInfo
|
||||||
import org.jetbrains.kotlin.codeMetaInfo.renderConfigurations.AbstractCodeMetaInfoRenderConfiguration
|
import org.jetbrains.kotlin.codeMetaInfo.renderConfigurations.AbstractCodeMetaInfoRenderConfiguration
|
||||||
import org.jetbrains.kotlin.diagnostics.PositioningStrategy
|
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDefaultErrorMessages
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDefaultErrorMessages
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnostic
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnostic
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderer
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderer
|
||||||
import org.jetbrains.kotlin.fir.psi
|
|
||||||
|
|
||||||
object FirMetaInfoUtils {
|
object FirMetaInfoUtils {
|
||||||
val renderDiagnosticNoArgs = FirDiagnosticCodeMetaRenderConfiguration().apply { renderParams = false }
|
val renderDiagnosticNoArgs = FirDiagnosticCodeMetaRenderConfiguration().apply { renderParams = false }
|
||||||
@@ -24,23 +21,18 @@ class FirDiagnosticCodeMetaInfo(
|
|||||||
val diagnostic: FirDiagnostic<*>,
|
val diagnostic: FirDiagnostic<*>,
|
||||||
renderConfiguration: FirDiagnosticCodeMetaRenderConfiguration
|
renderConfiguration: FirDiagnosticCodeMetaRenderConfiguration
|
||||||
) : CodeMetaInfo {
|
) : CodeMetaInfo {
|
||||||
// TODO: this implementation is hacky and doesn't support proper ranges for light tree diagnostics
|
private val textRangeFromClassicDiagnostic: TextRange = run {
|
||||||
private val textRangeFromClassicDiagnostic: TextRange? = run {
|
diagnostic.factory.positioningStrategy.markDiagnostic(diagnostic).first()
|
||||||
val psi = diagnostic.element.psi ?: return@run null
|
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
val positioningStrategy = diagnostic.factory.positioningStrategy.psiStrategy as PositioningStrategy<PsiElement>
|
|
||||||
positioningStrategy.mark(psi).first()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override var renderConfiguration: FirDiagnosticCodeMetaRenderConfiguration = renderConfiguration
|
override var renderConfiguration: FirDiagnosticCodeMetaRenderConfiguration = renderConfiguration
|
||||||
private set
|
private set
|
||||||
|
|
||||||
override val start: Int
|
override val start: Int
|
||||||
get() = textRangeFromClassicDiagnostic?.startOffset ?: diagnostic.element.startOffset
|
get() = textRangeFromClassicDiagnostic.startOffset
|
||||||
|
|
||||||
override val end: Int
|
override val end: Int
|
||||||
get() = textRangeFromClassicDiagnostic?.endOffset ?: diagnostic.element.endOffset
|
get() = textRangeFromClassicDiagnostic.endOffset
|
||||||
|
|
||||||
override val tag: String
|
override val tag: String
|
||||||
get() = renderConfiguration.getTag(this)
|
get() = renderConfiguration.getTag(this)
|
||||||
|
|||||||
Reference in New Issue
Block a user