KT-9628 Intention&inspection to replace use of "set" operator function with []

#KT-9628 Fixed
This commit is contained in:
Valentin Kipyatkov
2015-10-20 16:01:04 +03:00
parent 852579e7f3
commit 66310806ca
51 changed files with 248 additions and 126 deletions
@@ -1,64 +0,0 @@
<problems>
<problem>
<file>singleArgument.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/singleArgument.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
<problem>
<file>multiArgument.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/multiArgument.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
<problem>
<file>functionalArgument.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/functionalArgument.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
<problem>
<file>extensionFunction.kt</file>
<line>7</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/extensionFunction.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
<problem>
<file>argumentAndFunction.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/argumentAndFunction.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
<problem>
<file>acceptableVararg.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/acceptableVararg.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
<problem>
<file>qualifier.kt</file>
<line>8</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/qualifier.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
</problems>
@@ -1 +1 @@
org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetIntention
org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetOrSetIntention
@@ -0,0 +1,82 @@
<problems>
<problem>
<file>singleArgument.kt</file>
<line>8</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="singleArgument.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'get' call with indexing operator</description>
</problem>
<problem>
<file>multiArgument.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="multiArgument.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'get' call with indexing operator</description>
</problem>
<problem>
<file>functionalArgument.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="functionalArgument.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'get' call with indexing operator</description>
</problem>
<problem>
<file>extensionFunction.kt</file>
<line>7</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="extensionFunction.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'get' call with indexing operator</description>
</problem>
<problem>
<file>argumentAndFunction.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="argumentAndFunction.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'get' call with indexing operator</description>
</problem>
<problem>
<file>acceptableVararg.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="acceptableVararg.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'get' call with indexing operator</description>
</problem>
<problem>
<file>qualifier.kt</file>
<line>8</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="qualifier.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'get' call with indexing operator</description>
</problem>
<problem>
<file>set.kt</file>
<line>8</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="set.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'set' call with indexing operator</description>
</problem>
<problem>
<file>set2.kt</file>
<line>9</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="set2.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'set' call with indexing operator</description>
</problem>
</problems>
@@ -1 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetInspection
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetOrSetInspection
@@ -0,0 +1,9 @@
// INTENTION_TEXT: Replace 'set' call with indexing operator
class C {
operator fun set(s: String, value: Int) {}
}
fun foo() {
C().<caret>set("x", 1)
}
@@ -0,0 +1,9 @@
// INTENTION_TEXT: Replace 'set' call with indexing operator
class C {
operator fun set(s: String, value: Int) {}
}
fun foo() {
C()["x"] = 1
}
@@ -0,0 +1,11 @@
// INTENTION_TEXT: Replace 'set' call with indexing operator
class C {
operator fun set(s: String, value: Int) {}
}
class D(val c: C) {
fun foo() {
this.c.<caret>set("x", 1)
}
}
@@ -0,0 +1,11 @@
// INTENTION_TEXT: Replace 'set' call with indexing operator
class C {
operator fun set(s: String, value: Int) {}
}
class D(val c: C) {
fun foo() {
this.c["x"] = 1
}
}
@@ -0,0 +1,11 @@
// IS_APPLICABLE: false
class C {
operator fun set(s: String, value: Int): Boolean = true
}
class D(val c: C) {
fun foo(): Boolean {
return this.c.<caret>set("x", 1)
}
}
@@ -1,3 +1,5 @@
// INTENTION_TEXT: Replace 'get' call with indexing operator
fun test() {
class Test{
operator fun get(i: Int) : Int = 0
@@ -1,3 +1,5 @@
// INTENTION_TEXT: Replace 'get' call with indexing operator
fun test() {
class Test{
operator fun get(i: Int) : Int = 0