Make DeprecatedCallableAddReplaceWithInspection applicability based
Removes intention version of the same thing Includes some optimization of 'Deprecated' annotation detection
This commit is contained in:
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.DeprecatedCallableAddReplaceWithInspection
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
<caret>@Deprecated("", ReplaceWith("bar()"))
|
||||
fun foo() {
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar(){}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<caret>@Deprecated("")
|
||||
fun foo() {
|
||||
// invoke bar()
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar(){}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
@Deprecated("", <caret>ReplaceWith("bar()"))
|
||||
fun foo() {
|
||||
// invoke bar()
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar(){}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: none
|
||||
<caret>@Deprecated("")
|
||||
fun foo(p: Int) {
|
||||
if (p > 0) {
|
||||
val v = p + 1
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(p: Int){}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// PROBLEM: none
|
||||
|
||||
<caret>@Deprecated("Use the other version", level=DeprecationLevel.HIDDEN)
|
||||
fun foo(a: Int) { foo(a) }
|
||||
|
||||
fun foo(a: Int, b: Int = 0) { ... }
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// PROBLEM: none
|
||||
|
||||
// See KT-7929, EA-76715
|
||||
class C {
|
||||
val (<caret>x, y) = Pair(1, 2)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
<caret>@Deprecated("")
|
||||
fun foo(): String = bar()
|
||||
|
||||
fun bar(): String = ""
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
@Deprecated("", <caret>ReplaceWith("bar()"))
|
||||
fun foo(): String = bar()
|
||||
|
||||
fun bar(): String = ""
|
||||
@@ -0,0 +1,10 @@
|
||||
<caret>@Deprecated("")
|
||||
fun foo(p: Int) {
|
||||
if (p > 0)
|
||||
bar1(p)
|
||||
else
|
||||
bar2(p)
|
||||
}
|
||||
|
||||
fun bar1(p: Int){}
|
||||
fun bar2(p: Int){}
|
||||
@@ -0,0 +1,10 @@
|
||||
@Deprecated("", ReplaceWith("if (p > 0) bar1(p) else bar2(p)"))
|
||||
fun foo(p: Int) {
|
||||
if (p > 0)
|
||||
bar1(p)
|
||||
else
|
||||
bar2(p)
|
||||
}
|
||||
|
||||
fun bar1(p: Int){}
|
||||
fun bar2(p: Int){}
|
||||
@@ -0,0 +1,3 @@
|
||||
package dependency
|
||||
|
||||
val valueFromOtherPackage = 1
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package dependency
|
||||
|
||||
val valueFromOtherPackage = 1
|
||||
@@ -0,0 +1,10 @@
|
||||
package pack
|
||||
|
||||
import dependency.valueFromOtherPackage
|
||||
|
||||
<caret>@Deprecated("")
|
||||
fun foo() {
|
||||
bar(valueFromOtherPackage)
|
||||
}
|
||||
|
||||
fun bar(p: Int){}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package pack
|
||||
|
||||
import dependency.valueFromOtherPackage
|
||||
|
||||
@Deprecated("", ReplaceWith("bar(valueFromOtherPackage)", "dependency.valueFromOtherPackage"))
|
||||
fun foo() {
|
||||
bar(valueFromOtherPackage)
|
||||
}
|
||||
|
||||
fun bar(p: Int){}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package dependency
|
||||
|
||||
class D {
|
||||
companion object {
|
||||
val value = 1
|
||||
}
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package dependency
|
||||
|
||||
class D {
|
||||
companion object {
|
||||
val value = 1
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package pack
|
||||
|
||||
import dependency.D
|
||||
|
||||
<caret>@Deprecated("")
|
||||
fun foo() {
|
||||
bar(D.value)
|
||||
}
|
||||
|
||||
fun bar(p: Int){}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
package pack
|
||||
|
||||
import dependency.D
|
||||
|
||||
@Deprecated("", ReplaceWith("bar(D.value)", "dependency.D"))
|
||||
fun foo() {
|
||||
bar(D.value)
|
||||
}
|
||||
|
||||
fun bar(p: Int){}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
<caret>@Deprecated("")
|
||||
fun foo(s: String): String {
|
||||
return s.substring(1) + Int.MAX_VALUE
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
@Deprecated("", ReplaceWith("s.substring(1) + Int.MAX_VALUE"))
|
||||
fun foo(s: String): String {
|
||||
return s.substring(1) + Int.MAX_VALUE
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// PROBLEM: none
|
||||
// ERROR: A 'return' expression required in a function with a block body ('{...}')
|
||||
|
||||
<caret>@Deprecated("")
|
||||
fun foo(): String {
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar(): String = ""
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: none
|
||||
/**
|
||||
* <caret>This is a doc-comment
|
||||
*/
|
||||
@Deprecated("")
|
||||
fun foo() {
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar(){}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// PROBLEM: none
|
||||
class C {
|
||||
private val v = 1
|
||||
|
||||
<caret>@Deprecated("")
|
||||
fun foo() {
|
||||
bar(v)
|
||||
}
|
||||
|
||||
fun bar(p: Int){}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<caret>@Deprecated("")
|
||||
fun foo(s: String) {
|
||||
s.bar()
|
||||
}
|
||||
|
||||
fun String.bar(){}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
@Deprecated("", <caret>ReplaceWith("s.bar()"))
|
||||
fun foo(s: String) {
|
||||
s.bar()
|
||||
}
|
||||
|
||||
fun String.bar(){}
|
||||
@@ -0,0 +1,6 @@
|
||||
<caret>@Deprecated("")
|
||||
fun foo(): String {
|
||||
return bar()
|
||||
}
|
||||
|
||||
fun bar(): String = ""
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
@Deprecated("", <caret>ReplaceWith("bar()"))
|
||||
fun foo(): String {
|
||||
return bar()
|
||||
}
|
||||
|
||||
fun bar(): String = ""
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
<caret>@Deprecated("")
|
||||
fun foo() {
|
||||
bar() ?: return
|
||||
}
|
||||
|
||||
fun bar(): String? = null
|
||||
@@ -0,0 +1,6 @@
|
||||
<caret>@Deprecated("")
|
||||
fun foo() {
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar(){}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
@Deprecated("", <caret>ReplaceWith("bar()"))
|
||||
fun foo() {
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar(){}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<caret>@Deprecated("")
|
||||
fun foo(p: Int) {
|
||||
bar("\"\"\n1\r2\t3")
|
||||
}
|
||||
|
||||
fun bar(s: String){}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
@Deprecated("", ReplaceWith("bar(\"\\\"\\\"\\n1\\r2\\t3\")"))
|
||||
fun foo(p: Int) {
|
||||
bar("\"\"\n1\r2\t3")
|
||||
}
|
||||
|
||||
fun bar(s: String){}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<caret>@Deprecated("")
|
||||
fun foo(p: Int) {
|
||||
bar("$p ${p + 1} $0")
|
||||
}
|
||||
|
||||
fun bar(s: String){}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
@Deprecated("", ReplaceWith("bar(\"\$p \${p + 1} $0\")"))
|
||||
fun foo(p: Int) {
|
||||
bar("$p ${p + 1} $0")
|
||||
}
|
||||
|
||||
fun bar(s: String){}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// PROBLEM: none
|
||||
<caret>@Deprecated("")
|
||||
fun foo() {
|
||||
bar()
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar(){}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
<caret>@Deprecated("")
|
||||
val foo: String
|
||||
get() = bar()
|
||||
|
||||
fun bar(): String = ""
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
@Deprecated("", ReplaceWith("bar()"))
|
||||
val foo: String
|
||||
get() = bar()
|
||||
|
||||
fun bar(): String = ""
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class C {
|
||||
<caret>@Deprecated("")
|
||||
val foo: String
|
||||
get() {
|
||||
return bar()
|
||||
}
|
||||
|
||||
fun bar(): String = ""
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
class C {
|
||||
@Deprecated("", ReplaceWith("bar()"))
|
||||
val foo: String
|
||||
get() {
|
||||
return bar()
|
||||
}
|
||||
|
||||
fun bar(): String = ""
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
// SKIP_ERRORS_BEFORE
|
||||
// SKIP_ERRORS_AFTER
|
||||
|
||||
val (x, y) = run <caret>{
|
||||
|
||||
}
|
||||
|
||||
fun run(f: () -> Unit) = f()
|
||||
Vendored
+128
@@ -0,0 +1,128 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>ValPropertyWithReturn.kt</file>
|
||||
<line>2</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="ValPropertyWithReturn.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
|
||||
<description>@Deprecated annotation without 'replaceWith' argument</description>
|
||||
</problem>
|
||||
|
||||
|
||||
<problem>
|
||||
<file>ValProperty.kt</file>
|
||||
<line>2</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="ValProperty.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
|
||||
<description>@Deprecated annotation without 'replaceWith' argument</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>StringTemplate.kt</file>
|
||||
<line>1</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="StringTemplate.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
|
||||
<description>@Deprecated annotation without 'replaceWith' argument</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>StringLiteral.kt</file>
|
||||
<line>1</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="StringLiteral.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
|
||||
<description>@Deprecated annotation without 'replaceWith' argument</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>Simple.kt</file>
|
||||
<line>1</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="Simple.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
|
||||
<description>@Deprecated annotation without 'replaceWith' argument</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>Return.kt</file>
|
||||
<line>1</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="Return.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
|
||||
<description>@Deprecated annotation without 'replaceWith' argument</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>QualifiedCall.kt</file>
|
||||
<line>1</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="QualifiedCall.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
|
||||
<description>@Deprecated annotation without 'replaceWith' argument</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>NotAvailableOnDocComment.kt</file>
|
||||
<line>5</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="NotAvailableOnDocComment.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
|
||||
<description>@Deprecated annotation without 'replaceWith' argument</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>NoDefaultImport.kt</file>
|
||||
<line>2</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="NoDefaultImport.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
|
||||
<description>@Deprecated annotation without 'replaceWith' argument</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>NoCompanionObjectImport.kt</file>
|
||||
<line>5</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="NoCompanionObjectImport.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
|
||||
<description>@Deprecated annotation without 'replaceWith' argument</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>Imports.kt</file>
|
||||
<line>5</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="Imports.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
|
||||
<description>@Deprecated annotation without 'replaceWith' argument</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>If.kt</file>
|
||||
<line>1</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="If.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
|
||||
<description>@Deprecated annotation without 'replaceWith' argument</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>ExpressionBody.kt</file>
|
||||
<line>1</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="ExpressionBody.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
|
||||
<description>@Deprecated annotation without 'replaceWith' argument</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>CommentInBody.kt</file>
|
||||
<line>1</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="CommentInBody.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
|
||||
<description>@Deprecated annotation without 'replaceWith' argument</description>
|
||||
</problem>
|
||||
</problems>
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.DeprecatedCallableAddReplaceWithInspection
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
// SKIP_ERRORS_BEFORE
|
||||
// SKIP_ERRORS_AFTER
|
||||
|
||||
run <caret>{
|
||||
|
||||
}
|
||||
|
||||
fun run(f: () -> Unit) = f()
|
||||
Reference in New Issue
Block a user