From 50e1ec9c4f542eaf1d926b90535e9cf56079b138 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 9 Oct 2014 19:18:59 +0200 Subject: [PATCH] Fixed KT-5809 Code completion after "?." should not include keywords #KT-5809 Fixed --- .../jet/plugin/completion/KeywordCompletion.kt | 3 ++- idea/testData/completion/keywords/AfterSafeDot.kt | 6 ++++++ .../completion/KeywordCompletionTestGenerated.java | 12 +++++++----- 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 idea/testData/completion/keywords/AfterSafeDot.kt diff --git a/idea/src/org/jetbrains/jet/plugin/completion/KeywordCompletion.kt b/idea/src/org/jetbrains/jet/plugin/completion/KeywordCompletion.kt index dd9af3db93b..9a40a9609a9 100644 --- a/idea/src/org/jetbrains/jet/plugin/completion/KeywordCompletion.kt +++ b/idea/src/org/jetbrains/jet/plugin/completion/KeywordCompletion.kt @@ -67,7 +67,8 @@ object KeywordCompletion { CommentFilter(), ParentFilter(ClassFilter(javaClass())), ParentFilter(ClassFilter(javaClass())), - LeftNeighbour(TextFilter(".")) + LeftNeighbour(TextFilter(".")), + LeftNeighbour(TextFilter("?.")) )) private class CommentFilter() : ElementFilter { diff --git a/idea/testData/completion/keywords/AfterSafeDot.kt b/idea/testData/completion/keywords/AfterSafeDot.kt new file mode 100644 index 00000000000..ce9eb1994c0 --- /dev/null +++ b/idea/testData/completion/keywords/AfterSafeDot.kt @@ -0,0 +1,6 @@ +fun foo() { + val str : String? + str?. +} + +// NUMBER: 0 diff --git a/idea/tests/org/jetbrains/jet/completion/KeywordCompletionTestGenerated.java b/idea/tests/org/jetbrains/jet/completion/KeywordCompletionTestGenerated.java index bcd7aa0ec56..503d27e9a7d 100644 --- a/idea/tests/org/jetbrains/jet/completion/KeywordCompletionTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/completion/KeywordCompletionTestGenerated.java @@ -17,13 +17,9 @@ package org.jetbrains.jet.completion; import com.intellij.testFramework.TestDataPath; -import junit.framework.Test; -import junit.framework.TestSuite; -import org.junit.runner.RunWith; import org.jetbrains.jet.JetTestUtils; -import org.jetbrains.jet.test.InnerTestClasses; import org.jetbrains.jet.test.TestMetadata; -import org.jetbrains.jet.JUnit3RunnerWithInners; +import org.junit.runner.RunWith; import java.io.File; import java.util.regex.Pattern; @@ -52,6 +48,12 @@ public class KeywordCompletionTestGenerated extends AbstractKeywordCompletionTes doTest(fileName); } + @TestMetadata("AfterSafeDot.kt") + public void testAfterSafeDot() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/AfterSafeDot.kt"); + doTest(fileName); + } + @TestMetadata("AfterSpaceAndDot.kt") public void testAfterSpaceAndDot() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/keywords/AfterSpaceAndDot.kt");