From 73176fae1758e421bb9907fc3df694cded26c50b Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 19 Oct 2015 19:40:17 +0300 Subject: [PATCH] Property with all accessors deprecated considered as deprecated --- .../kotlin/builtins/KotlinBuiltIns.java | 11 +++++++- ...ntheticExtensionDeprecated.dependency.java | 27 +++++++++++++++++++ .../SyntheticExtensionDeprecated.kt | 9 +++++++ ...tiFileJvmBasicCompletionTestGenerated.java | 6 +++++ 4 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 idea/idea-completion/testData/basic/multifile/SyntheticExtensionDeprecated/SyntheticExtensionDeprecated.dependency.java create mode 100644 idea/idea-completion/testData/basic/multifile/SyntheticExtensionDeprecated/SyntheticExtensionDeprecated.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java index b18f4e924df..11a66cd038a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java @@ -1019,7 +1019,16 @@ public abstract class KotlinBuiltIns { } public static boolean isDeprecated(@NotNull DeclarationDescriptor declarationDescriptor) { - return containsAnnotation(declarationDescriptor, FQ_NAMES.deprecated); + if (containsAnnotation(declarationDescriptor, FQ_NAMES.deprecated)) return true; + + if (declarationDescriptor instanceof PropertyDescriptor) { + boolean isVar = ((PropertyDescriptor) declarationDescriptor).isVar(); + PropertyGetterDescriptor getter = ((PropertyDescriptor) declarationDescriptor).getGetter(); + PropertySetterDescriptor setter = ((PropertyDescriptor) declarationDescriptor).getSetter(); + return getter != null && isDeprecated(getter) && (!isVar || setter != null && isDeprecated(setter)); + } + + return false; } public static boolean isSuppressAnnotation(@NotNull AnnotationDescriptor annotationDescriptor) { diff --git a/idea/idea-completion/testData/basic/multifile/SyntheticExtensionDeprecated/SyntheticExtensionDeprecated.dependency.java b/idea/idea-completion/testData/basic/multifile/SyntheticExtensionDeprecated/SyntheticExtensionDeprecated.dependency.java new file mode 100644 index 00000000000..797a53944f0 --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/SyntheticExtensionDeprecated/SyntheticExtensionDeprecated.dependency.java @@ -0,0 +1,27 @@ +interface JavaClass{ + /** + * @deprecated + */ + public int getSomething1(); + + /** + * @deprecated + */ + public int getSomething2(); + public void setSomething2(int value); + + public int getSomething3(); + /** + * @deprecated + */ + public void setSomething3(int value); + + /** + * @deprecated + */ + public int getSomething4(); + /** + * @deprecated + */ + public void setSomething4(int value); +} \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/SyntheticExtensionDeprecated/SyntheticExtensionDeprecated.kt b/idea/idea-completion/testData/basic/multifile/SyntheticExtensionDeprecated/SyntheticExtensionDeprecated.kt new file mode 100644 index 00000000000..d086b327a79 --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/SyntheticExtensionDeprecated/SyntheticExtensionDeprecated.kt @@ -0,0 +1,9 @@ +fun foo(javaClass: JavaClass) { + javaClass. +} + +// WITH_ORDER +// EXIST: { lookupString: "something2", attributes: "bold" } +// EXIST: { lookupString: "something3", attributes: "bold" } +// EXIST: { lookupString: "something1", attributes: "bold strikeout" } +// EXIST: { lookupString: "something4", attributes: "bold strikeout" } diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java index 1344881c10e..b8a49c660ed 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java @@ -329,6 +329,12 @@ public class MultiFileJvmBasicCompletionTestGenerated extends AbstractMultiFileJ doTest(fileName); } + @TestMetadata("SyntheticExtensionDeprecated") + public void testSyntheticExtensionDeprecated() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/SyntheticExtensionDeprecated/"); + doTest(fileName); + } + @TestMetadata("SyntheticExtensionForGenericClass") public void testSyntheticExtensionForGenericClass() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/SyntheticExtensionForGenericClass/");