DeprecatedCallableAddReplaceWithInspection: add argument name if needed
#KT-34297 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
23749bdde7
commit
f8f50b2131
+1
@@ -81,6 +81,7 @@ class DeprecatedCallableAddReplaceWithInspection : AbstractApplicabilityBasedIns
|
||||
}
|
||||
|
||||
val argumentText = StringBuilder().apply {
|
||||
if (annotationEntry.valueArguments.any { it.isNamed() }) append("replaceWith = ")
|
||||
append("kotlin.ReplaceWith(\"")
|
||||
append(escapedText)
|
||||
append("\"")
|
||||
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
<caret>@Deprecated(message = "")
|
||||
fun foo(someString: String) = someString
|
||||
}
|
||||
idea/testData/inspectionsLocal/deprecatedCallableAddReplaceWith/ReplaceWithHasNamedArgument.kt.after
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
class Foo {
|
||||
@Deprecated(message = "", replaceWith = ReplaceWith("someString"))
|
||||
fun foo(someString: String) = someString
|
||||
}
|
||||
Vendored
+9
@@ -125,4 +125,13 @@
|
||||
<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>ReplaceWithHasNamedArgument.kt</file>
|
||||
<line>2</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="ReplaceWithHasNamedArgument.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>
|
||||
+5
@@ -4108,6 +4108,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
runTest("idea/testData/inspectionsLocal/deprecatedCallableAddReplaceWith/QualifiedCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ReplaceWithHasNamedArgument.kt")
|
||||
public void testReplaceWithHasNamedArgument() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/deprecatedCallableAddReplaceWith/ReplaceWithHasNamedArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("Return.kt")
|
||||
public void testReturn() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/deprecatedCallableAddReplaceWith/Return.kt");
|
||||
|
||||
Reference in New Issue
Block a user