Make DeprecatedCallableAddReplaceWithInspection applicability based

Removes intention version of the same thing
Includes some optimization of 'Deprecated' annotation detection
This commit is contained in:
Mikhail Glukhikh
2018-03-27 16:53:20 +03:00
parent ab973b2ff0
commit 2125c42328
54 changed files with 245 additions and 262 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.DeprecatedCallableAddReplaceWithInspection
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
<caret>@Deprecated("", ReplaceWith("bar()"))
fun foo() {
bar()
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
<caret>@Deprecated("")
fun foo(p: Int) {
if (p > 0) {
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
<caret>@Deprecated("Use the other version", level=DeprecationLevel.HIDDEN)
fun foo(a: Int) { foo(a) }
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
// ERROR: A 'return' expression required in a function with a block body ('{...}')
<caret>@Deprecated("")
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
/**
* <caret>This is a doc-comment
*/
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
class C {
private val v = 1
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
<caret>@Deprecated("")
fun foo() {
bar() ?: return
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
<caret>@Deprecated("")
fun foo() {
bar()
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
// WITH_RUNTIME
// SKIP_ERRORS_BEFORE
// SKIP_ERRORS_AFTER
@@ -4,8 +4,8 @@
<line>2</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="ValPropertyWithReturn.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Add 'replaceWith' argument to 'deprecated' annotation</problem_class>
<description>Add 'replaceWith' argument to specify replacement pattern</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
<description>@Deprecated annotation without 'replaceWith' argument</description>
</problem>
@@ -14,8 +14,8 @@
<line>2</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="ValProperty.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Add 'replaceWith' argument to 'deprecated' annotation</problem_class>
<description>Add 'replaceWith' argument to specify replacement pattern</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
<description>@Deprecated annotation without 'replaceWith' argument</description>
</problem>
<problem>
@@ -23,8 +23,8 @@
<line>1</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="StringTemplate.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Add 'replaceWith' argument to 'deprecated' annotation</problem_class>
<description>Add 'replaceWith' argument to specify replacement pattern</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
<description>@Deprecated annotation without 'replaceWith' argument</description>
</problem>
<problem>
@@ -32,8 +32,8 @@
<line>1</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="StringLiteral.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Add 'replaceWith' argument to 'deprecated' annotation</problem_class>
<description>Add 'replaceWith' argument to specify replacement pattern</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
<description>@Deprecated annotation without 'replaceWith' argument</description>
</problem>
<problem>
@@ -41,8 +41,8 @@
<line>1</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="Simple.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Add 'replaceWith' argument to 'deprecated' annotation</problem_class>
<description>Add 'replaceWith' argument to specify replacement pattern</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
<description>@Deprecated annotation without 'replaceWith' argument</description>
</problem>
<problem>
@@ -50,8 +50,8 @@
<line>1</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="Return.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Add 'replaceWith' argument to 'deprecated' annotation</problem_class>
<description>Add 'replaceWith' argument to specify replacement pattern</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
<description>@Deprecated annotation without 'replaceWith' argument</description>
</problem>
<problem>
@@ -59,8 +59,8 @@
<line>1</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="QualifiedCall.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Add 'replaceWith' argument to 'deprecated' annotation</problem_class>
<description>Add 'replaceWith' argument to specify replacement pattern</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
<description>@Deprecated annotation without 'replaceWith' argument</description>
</problem>
<problem>
@@ -68,8 +68,8 @@
<line>5</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="NotAvailableOnDocComment.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Add 'replaceWith' argument to 'deprecated' annotation</problem_class>
<description>Add 'replaceWith' argument to specify replacement pattern</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
<description>@Deprecated annotation without 'replaceWith' argument</description>
</problem>
<problem>
@@ -77,8 +77,8 @@
<line>2</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="NoDefaultImport.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Add 'replaceWith' argument to 'deprecated' annotation</problem_class>
<description>Add 'replaceWith' argument to specify replacement pattern</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
<description>@Deprecated annotation without 'replaceWith' argument</description>
</problem>
<problem>
@@ -86,8 +86,8 @@
<line>5</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="NoCompanionObjectImport.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Add 'replaceWith' argument to 'deprecated' annotation</problem_class>
<description>Add 'replaceWith' argument to specify replacement pattern</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
<description>@Deprecated annotation without 'replaceWith' argument</description>
</problem>
<problem>
@@ -95,8 +95,8 @@
<line>5</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="Imports.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Add 'replaceWith' argument to 'deprecated' annotation</problem_class>
<description>Add 'replaceWith' argument to specify replacement pattern</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
<description>@Deprecated annotation without 'replaceWith' argument</description>
</problem>
<problem>
@@ -104,8 +104,8 @@
<line>1</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="If.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Add 'replaceWith' argument to 'deprecated' annotation</problem_class>
<description>Add 'replaceWith' argument to specify replacement pattern</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
<description>@Deprecated annotation without 'replaceWith' argument</description>
</problem>
<problem>
@@ -113,8 +113,8 @@
<line>1</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="ExpressionBody.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Add 'replaceWith' argument to 'deprecated' annotation</problem_class>
<description>Add 'replaceWith' argument to specify replacement pattern</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
<description>@Deprecated annotation without 'replaceWith' argument</description>
</problem>
<problem>
@@ -122,7 +122,7 @@
<line>1</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="CommentInBody.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Add 'replaceWith' argument to 'deprecated' annotation</problem_class>
<description>Add 'replaceWith' argument to specify replacement pattern</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">@Deprecated annotation without 'replaceWith' argument</problem_class>
<description>@Deprecated annotation without 'replaceWith' argument</description>
</problem>
</problems>
@@ -0,0 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.DeprecatedCallableAddReplaceWithInspection
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
// WITH_RUNTIME
// SKIP_ERRORS_BEFORE
// SKIP_ERRORS_AFTER
@@ -1 +0,0 @@
org.jetbrains.kotlin.idea.intentions.DeprecatedCallableAddReplaceWithIntention
@@ -1 +0,0 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.DeprecatedCallableAddReplaceWithInspection