Convert intention "a..b-1 -> a until b" into weak warning inspection

So #KT-17895 Fixed
This commit is contained in:
Ilya Zorin
2017-05-25 18:25:11 +03:00
committed by Mikhail Glukhikh
parent 0fd42bc747
commit 5e265b3d17
26 changed files with 242 additions and 157 deletions
@@ -0,0 +1,18 @@
<problems>
<problem>
<file>test.kt</file>
<line>3</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'rangeTo' or the '..' call can be replaced with 'until'</problem_class>
<description>'rangeTo' or the '..' call can be replaced with 'until'</description>
</problem>
<problem>
<file>test.kt</file>
<line>8</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'rangeTo' or the '..' call can be replaced with 'until'</problem_class>
<description>'rangeTo' or the '..' call can be replaced with 'until'</description>
</problem>
</problems>
@@ -0,0 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.ReplaceRangeToWithUntilInspection
@@ -0,0 +1,9 @@
fun foo() {
val n = 10
for (i in 0 .. n - 1) {}
}
fun bar() {
val n = 10
for (i in 0.rangeTo(n - 1)) {}
}
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.ReplaceRangeToWithUntilInspection
@@ -1,5 +1,5 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
// PROBLEM: none
fun foo(a: Float) {
1f<caret>..a - 1
@@ -1,5 +1,5 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
// PROBLEM: none
fun foo(a: Int) {
for (i in 0..a - 2<caret>) {
@@ -1,5 +1,5 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
// PROBLEM: none
fun foo(a: Int) {
for (i in 0..a<caret>) {
@@ -1,7 +1,7 @@
// WITH_RUNTIME
fun foo(a: Int) {
for (i in 0..a - 1<caret>) {
for (i in 0..<caret>a - 1) {
}
}
@@ -1,7 +1,7 @@
// WITH_RUNTIME
fun foo(a: Int) {
for (i in 0 until a<caret>) {
for (i in 0 until a) {
}
}
@@ -1,7 +1,7 @@
// WITH_RUNTIME
fun foo(a: Long) {
for (i in 1L..a - 1L<caret>) {
for (i in 1L<caret>..a - 1L) {
}
}
@@ -1,7 +1,7 @@
// WITH_RUNTIME
fun foo(a: Long) {
for (i in 1L until a<caret>) {
for (i in 1L until a) {
}
}
@@ -1,5 +1,5 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
// PROBLEM: none
fun foo(a: Int) {
for (i in 0..a + 1<caret>) {
@@ -1,7 +1,7 @@
// WITH_RUNTIME
fun foo(a: Int) {
for (i in 0.rangeTo(a - 1)<caret>) {
for (i in <caret>0.rangeTo(a - 1)) {
}
}
@@ -1,7 +1,7 @@
// WITH_RUNTIME
fun foo(a: Int) {
for (i in 0 until a<caret>) {
for (i in 0 until a) {
}
}
@@ -1 +0,0 @@
org.jetbrains.kotlin.idea.intentions.ReplaceRangeToWithUntilIntention