Inspection & fix for redundant supertype qualification

This commit is contained in:
Valentin Kipyatkov
2015-08-26 15:05:10 +03:00
parent d62eeb1c25
commit 4717b17418
30 changed files with 531 additions and 2 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.intentions.RemoveExplicitSuperQualifierIntention
@@ -0,0 +1,15 @@
// IS_APPLICABLE: false
open class B {
open fun foo(p: String){}
}
interface I {
fun foo(p: String) {}
}
class A : B(), I {
override fun foo(p: String) {
super<B><caret>.foo("")
}
}
@@ -0,0 +1,15 @@
// IS_APPLICABLE: false
open class B {
open val v: Int = 0
}
interface I {
val v: Int
get() = 0
}
class A : B(), I {
override val v: Int
get() = super<B><caret>.v
}
@@ -0,0 +1,17 @@
open class B {
open fun foo(p: String){}
fun foo(p: Int){}
}
interface I {
fun foo(p: String)
}
class A : B(), I {
fun foo(p: Any) {
if (p is Int) {
super<B><caret>.foo(p)
}
}
}
@@ -0,0 +1,17 @@
open class B {
open fun foo(p: String){}
fun foo(p: Int){}
}
interface I {
fun foo(p: String)
}
class A : B(), I {
fun foo(p: Any) {
if (p is Int) {
super<caret>.foo(p)
}
}
}
@@ -0,0 +1,15 @@
// ERROR: No value passed for parameter p
open class B {
open fun foo(p: String){}
}
interface I {
fun foo(p: String)
}
class A : B(), I {
override fun foo(p: String) {
super<B><caret>.foo()
}
}
@@ -0,0 +1,15 @@
// ERROR: No value passed for parameter p
open class B {
open fun foo(p: String){}
}
interface I {
fun foo(p: String)
}
class A : B(), I {
override fun foo(p: String) {
super<caret>.foo()
}
}
@@ -0,0 +1,17 @@
// IS_APPLICABLE: false
// ERROR: <html>None of the following functions can be called with the arguments supplied. <ul><li>foo(<font color=red><b>Int</b></font>) <i>defined in</i> B</li><li>foo(<font color=red><b>String</b></font>) <i>defined in</i> B</li></ul></html>
open class B {
open fun foo(p: String){}
fun foo(p: Int){}
}
interface I {
fun foo(p: String)
}
class A : B(), I {
override fun foo(p: String) {
super<B><caret>.foo()
}
}
@@ -0,0 +1,8 @@
open class B {
open fun foo(){}
}
class A : B() {
override fun foo() {
super<B><caret>.foo()
}
}
@@ -0,0 +1,8 @@
open class B {
open fun foo(){}
}
class A : B() {
override fun foo() {
super<caret>.foo()
}
}
@@ -0,0 +1,16 @@
open class Base {
open fun foo() {
}
}
class A : Base() {
override fun foo() {
super.foo()
}
inner class C {
fun test() {
super<Base><caret>@A.foo()
}
}
}
@@ -0,0 +1,16 @@
open class Base {
open fun foo() {
}
}
class A : Base() {
override fun foo() {
super.foo()
}
inner class C {
fun test() {
super@A.foo()
}
}
}
@@ -0,0 +1,15 @@
open class B {
open fun foo(p: String){}
fun foo(p: Int){}
}
interface I {
fun foo(p: String)
}
class A : B(), I {
override fun foo(p: String) {
super<B><caret>.foo("")
}
}
@@ -0,0 +1,15 @@
open class B {
open fun foo(p: String){}
fun foo(p: Int){}
}
interface I {
fun foo(p: String)
}
class A : B(), I {
override fun foo(p: String) {
super<caret>.foo("")
}
}
@@ -0,0 +1,12 @@
open class B {
open val v: Int = 0
}
interface I {
val v: Int
}
class A : B(), I {
override val v: Int
get() = super<caret><B>.v
}
@@ -0,0 +1,12 @@
open class B {
open val v: Int = 0
}
interface I {
val v: Int
}
class A : B(), I {
override val v: Int
get() = super<caret>.v
}
@@ -0,0 +1,18 @@
// IS_APPLICABLE: false
open class Base {
open fun foo() {
}
}
class A : Base() {
override fun foo() {
super.foo()
}
inner class C {
fun test() {
super<Base>@<caret>A.foo()
}
}
}
@@ -0,0 +1,18 @@
// IS_APPLICABLE: false
open class Base {
open fun foo() {
}
}
class A : Base() {
override fun foo() {
super.foo()
}
inner class C {
fun test() {
supe<caret>r<Base>@A.foo()
}
}
}
@@ -0,0 +1,73 @@
<problems>
<problem>
<file>UnambiguousSuperProperty.kt</file>
<line>11</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="UnambiguousSuperProperty.kt" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Supertype qualification is unnecessary</problem_class>
<description>Remove explicit supertype qualification</description>
</problem>
<problem>
<file>UnambiguousSuperMethod.kt</file>
<line>13</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="UnambiguousSuperMethod.kt" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Supertype qualification is unnecessary</problem_class>
<description>Remove explicit supertype qualification</description>
</problem>
<problem>
<file>SingleSuper.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="SingleSuper.kt" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Supertype qualification is unnecessary</problem_class>
<description>Remove explicit supertype qualification</description>
</problem>
<problem>
<file>IncompleteCall.kt</file>
<line>13</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="IncompleteCall.kt" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Supertype qualification is unnecessary</problem_class>
<description>Remove explicit supertype qualification</description>
</problem>
<problem>
<file>DataFlowInfoUsed.kt</file>
<line>14</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="DataFlowInfoUsed.kt" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Supertype qualification is unnecessary</problem_class>
<description>Remove explicit supertype qualification</description>
</problem>
<problem>
<file>SuperWithLabel.kt</file>
<line>13</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="SuperWithLabel.kt" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Supertype qualification is unnecessary</problem_class>
<description>Remove explicit supertype qualification</description>
</problem>
<problem>
<file>WrongOffset1.kt</file>
<line>15</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="WrongOffset1.kt" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Supertype qualification is unnecessary</problem_class>
<description>Remove explicit supertype qualification</description>
</problem>
<problem>
<file>WrongOffset2.kt</file>
<line>15</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="WrongOffset2.kt" />
<problem_class severity="WARNING" attribute_key="NOT_USED_ELEMENT_ATTRIBUTES">Supertype qualification is unnecessary</problem_class>
<description>Remove explicit supertype qualification</description>
</problem>
</problems>
@@ -0,0 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.RemoveExplicitSuperQualifierInspection