DeprecatedSymbolUsageFix: fixed for java declaration + one more test
This commit is contained in:
+1
-1
@@ -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));
|
filterOutIrrelevantActions(actualActions), filterOutIrrelevantActions(validActions));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,8 @@ public abstract class DeprecatedSymbolUsageFixBase(
|
|||||||
companion object {
|
companion object {
|
||||||
public fun replaceWithPattern(descriptor: DeclarationDescriptor): ReplaceWith? {
|
public fun replaceWithPattern(descriptor: DeclarationDescriptor): ReplaceWith? {
|
||||||
val annotationClass = descriptor.builtIns.getDeprecatedAnnotation()
|
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()
|
val replaceWithValue = annotation.getAllValueArguments().entrySet()
|
||||||
.singleOrNull { it.key.getName().asString() == "replaceWith"/*TODO*/ }
|
.singleOrNull { it.key.getName().asString() == "replaceWith"/*TODO*/ }
|
||||||
?.value?.getValue() as? AnnotationDescriptor ?: return null
|
?.value?.getValue() as? AnnotationDescriptor ?: return null
|
||||||
|
|||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
// "class org.jetbrains.kotlin.idea.quickfix.DeprecatedSymbolUsageFix" "false"
|
||||||
|
|
||||||
|
@deprecated("")
|
||||||
|
class C(p: Int)
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
<caret>C(1)
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
class JavaClass {
|
||||||
|
@Deprecated
|
||||||
|
public void oldFun(){}
|
||||||
|
}
|
||||||
@@ -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.<caret>oldFun()
|
||||||
|
}
|
||||||
@@ -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);
|
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")
|
@TestMetadata("toMethodFromCompanionObject.before.Main.kt")
|
||||||
public void testToMethodFromCompanionObject() throws Exception {
|
public void testToMethodFromCompanionObject() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/toMethodFromCompanionObject.before.Main.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/deprecatedSymbolUsage/toMethodFromCompanionObject.before.Main.kt");
|
||||||
|
|||||||
@@ -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")
|
@TestMetadata("idea/testData/quickfix/deprecatedSymbolUsage/functionLiteralArguments")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user