From 6f7d9459fa25b788f527ee95192060f007a3d3d5 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 30 Sep 2015 15:52:23 +0300 Subject: [PATCH] Completion for sealed class inheritors and a pair of tests --- .../KotlinLightClassForExplicitDeclaration.kt | 4 +++- .../testData/smart/AbstractMembers.kt | 13 +++++++++++++ .../idea-completion/testData/smart/SealedMembers.kt | 13 +++++++++++++ .../test/JvmSmartCompletionTestGenerated.java | 12 ++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 idea/idea-completion/testData/smart/AbstractMembers.kt create mode 100644 idea/idea-completion/testData/smart/SealedMembers.kt diff --git a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightClassForExplicitDeclaration.kt b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightClassForExplicitDeclaration.kt index 82ec15ed192..a42e67df94d 100644 --- a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightClassForExplicitDeclaration.kt +++ b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightClassForExplicitDeclaration.kt @@ -292,7 +292,7 @@ public open class KotlinLightClassForExplicitDeclaration( // FINAL - if (isAbstract()) { + if (isAbstract() || isSealed()) { psiModifiers.add(PsiModifier.ABSTRACT) } else if (!(classOrObject.hasModifier(OPEN_KEYWORD) || (classOrObject is JetClass && classOrObject.isEnum()))) { @@ -308,6 +308,8 @@ public open class KotlinLightClassForExplicitDeclaration( private fun isAbstract(): Boolean = classOrObject.hasModifier(ABSTRACT_KEYWORD) || isInterface + private fun isSealed(): Boolean = classOrObject.hasModifier(SEALED_KEYWORD) + override fun hasModifierProperty(@NonNls name: String): Boolean = getModifierList().hasModifierProperty(name) override fun isDeprecated(): Boolean { diff --git a/idea/idea-completion/testData/smart/AbstractMembers.kt b/idea/idea-completion/testData/smart/AbstractMembers.kt new file mode 100644 index 00000000000..0a891399100 --- /dev/null +++ b/idea/idea-completion/testData/smart/AbstractMembers.kt @@ -0,0 +1,13 @@ +package sample + +abstract class Foo { + object X: Foo() + class Y: Foo() +} + +fun foo(){ + val f : Foo = +} + +// EXIST: { lookupString:"X", itemText:"X", tailText:" (sample.Foo)" } +// EXIST: { lookupString:"Y", itemText:"Y", tailText:"() (sample.Foo)" } diff --git a/idea/idea-completion/testData/smart/SealedMembers.kt b/idea/idea-completion/testData/smart/SealedMembers.kt new file mode 100644 index 00000000000..b7124e341d1 --- /dev/null +++ b/idea/idea-completion/testData/smart/SealedMembers.kt @@ -0,0 +1,13 @@ +package sample + +sealed class Foo { + object X: Foo() + class Y: Foo() +} + +fun foo(){ + val f : Foo = +} + +// EXIST: { lookupString:"X", itemText:"X", tailText:" (sample.Foo)" } +// EXIST: { lookupString:"Y", itemText:"Y", tailText:"() (sample.Foo)" } diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java index 240386b1c5a..b8bd4ee2529 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java @@ -31,6 +31,12 @@ import java.util.regex.Pattern; @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionTest { + @TestMetadata("AbstractMembers.kt") + public void testAbstractMembers() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/smart/AbstractMembers.kt"); + doTest(fileName); + } + @TestMetadata("AfterEmptyArgument.kt") public void testAfterEmptyArgument() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/smart/AfterEmptyArgument.kt"); @@ -449,6 +455,12 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT doTest(fileName); } + @TestMetadata("SealedMembers.kt") + public void testSealedMembers() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/smart/SealedMembers.kt"); + doTest(fileName); + } + @TestMetadata("SkipDeclarationsOfType.kt") public void testSkipDeclarationsOfType() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/smart/SkipDeclarationsOfType.kt");