diff --git a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.java b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.java index a35bd8d27b0..0c4b032d603 100644 --- a/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.java +++ b/idea/idea-test-framework/src/org/jetbrains/kotlin/idea/test/DirectiveBasedActionUtils.java @@ -83,7 +83,7 @@ public class DirectiveBasedActionUtils { } }))); - UsefulTestCase.assertOrderedEquals("Some unexpected actions available at current position: %s. Use // ACTION: directive", + UsefulTestCase.assertOrderedEquals("Some unexpected actions available at current position. Use // ACTION: directive", filterOutIrrelevantActions(actualActions), filterOutIrrelevantActions(validActions)); } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt index 4cf42cc5f71..c625f8b306e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt @@ -107,7 +107,8 @@ public abstract class DeprecatedSymbolUsageFixBase( companion object { public fun replaceWithPattern(descriptor: DeclarationDescriptor): ReplaceWith? { val annotationClass = descriptor.builtIns.getDeprecatedAnnotation() - val annotation = descriptor.getAnnotations().findAnnotation(DescriptorUtils.getFqNameSafe(annotationClass))!! + val annotation = descriptor.getAnnotations().findAnnotation(DescriptorUtils.getFqNameSafe(annotationClass)) ?: return null + //TODO: code duplication val replaceWithValue = annotation.getAllValueArguments().entrySet() .singleOrNull { it.key.getName().asString() == "replaceWith"/*TODO*/ } ?.value?.getValue() as? AnnotationDescriptor ?: return null diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/noAnnotationConstructorUsage.kt b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/noAnnotationConstructorUsage.kt new file mode 100644 index 00000000000..f4567c0c6f2 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/classUsages/noAnnotationConstructorUsage.kt @@ -0,0 +1,8 @@ +// "class org.jetbrains.kotlin.idea.quickfix.DeprecatedSymbolUsageFix" "false" + +@deprecated("") +class C(p: Int) + +fun foo() { + C(1) +} diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/javaDeprecated.before.Declaration.java b/idea/testData/quickfix/deprecatedSymbolUsage/javaDeprecated.before.Declaration.java new file mode 100644 index 00000000000..07a5f80f8f4 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/javaDeprecated.before.Declaration.java @@ -0,0 +1,4 @@ +class JavaClass { + @Deprecated + public void oldFun(){} +} \ No newline at end of file diff --git a/idea/testData/quickfix/deprecatedSymbolUsage/javaDeprecated.before.Main.kt b/idea/testData/quickfix/deprecatedSymbolUsage/javaDeprecated.before.Main.kt new file mode 100644 index 00000000000..887988f0aa8 --- /dev/null +++ b/idea/testData/quickfix/deprecatedSymbolUsage/javaDeprecated.before.Main.kt @@ -0,0 +1,7 @@ +// "class org.jetbrains.kotlin.idea.quickfix.DeprecatedSymbolUsageFix" "false" +// ACTION: Inspection 'DEPRECATED_SYMBOL_WITH_MESSAGE' options + +fun foo() { + val c = JavaClass() + c.oldFun() +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java index ae068dcda83..835d74729fa 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java @@ -852,6 +852,12 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/deprecatedSymbolUsage"), Pattern.compile("^(\\w+)\\.before\\.Main\\.kt$"), true); } + @TestMetadata("javaDeprecated.before.Main.kt") + public void testJavaDeprecated() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/javaDeprecated.before.Main.kt"); + doTestWithExtraFile(fileName); + } + @TestMetadata("toMethodFromCompanionObject.before.Main.kt") public void testToMethodFromCompanionObject() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/toMethodFromCompanionObject.before.Main.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index 8604a11dfb7..8f89972deb6 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -3175,6 +3175,21 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest { } } + @TestMetadata("idea/testData/quickfix/deprecatedSymbolUsage/classUsages") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ClassUsages extends AbstractQuickFixTest { + public void testAllFilesPresentInClassUsages() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/deprecatedSymbolUsage/classUsages"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true); + } + + @TestMetadata("noAnnotationConstructorUsage.kt") + public void testNoAnnotationConstructorUsage() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/classUsages/noAnnotationConstructorUsage.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/testData/quickfix/deprecatedSymbolUsage/functionLiteralArguments") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)