diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/SmartSelectionTestGenerated.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/SmartSelectionTestGenerated.java index 6237a1883172..1d21cb434dcb 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/SmartSelectionTestGenerated.java +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/SmartSelectionTestGenerated.java @@ -50,6 +50,11 @@ public class SmartSelectionTestGenerated extends AbstractSmartSelectionTest { runTest("testData/smartSelection/beforeComment.kt"); } + @TestMetadata("beforeDot.kt") + public void testBeforeDot() throws Exception { + runTest("testData/smartSelection/beforeDot.kt"); + } + @TestMetadata("beforeKDocComment.kt") public void testBeforeKDocComment() throws Exception { runTest("testData/smartSelection/beforeKDocComment.kt"); diff --git a/plugins/kotlin/idea/tests/testData/smartSelection/beforeDot.kt b/plugins/kotlin/idea/tests/testData/smartSelection/beforeDot.kt new file mode 100644 index 000000000000..8ddf7ea2ec98 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/smartSelection/beforeDot.kt @@ -0,0 +1,13 @@ +class Foo { + val foo: Foo = this + val bar: Foo = this + + fun f(f: Foo) { + val foo1 = f.foo.bar + } +} + +/* +f.foo +f.foo.bar +*/ \ No newline at end of file diff --git a/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/elementSelectionUtils.kt b/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/elementSelectionUtils.kt index 41fcba7ac3be..060751942ffe 100644 --- a/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/elementSelectionUtils.kt +++ b/plugins/kotlin/refactorings/kotlin.refactorings.common/src/org/jetbrains/kotlin/idea/refactoring/elementSelectionUtils.kt @@ -12,6 +12,7 @@ import com.intellij.openapi.ui.popup.JBPopupListener import com.intellij.openapi.ui.popup.LightweightWindowEvent import com.intellij.platform.backend.presentation.TargetPresentation import com.intellij.psi.* +import com.intellij.psi.impl.source.tree.LeafPsiElement import com.intellij.psi.util.PsiTreeUtil import com.intellij.util.concurrency.AppExecutorUtil import org.jetbrains.kotlin.idea.base.resources.KotlinBundle @@ -118,6 +119,7 @@ fun getSmartSelectSuggestions( || isOriginalOffset && element?.node?.elementType == KtTokens.RPAR || element is PsiComment || element?.getStrictParentOfType() != null + || element is LeafPsiElement && element.elementType == KtTokens.DOT ) return getSmartSelectSuggestions(file, offset - 1, elementKind, isOriginalOffset = false) val elements = ArrayList()