From e41cddd870d942720a39a132021f8993c7301a5c Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Mon, 24 Oct 2016 19:52:36 +0300 Subject: [PATCH] Allow to select single word on double click in one line doc comment (KT-14327) (cherry picked from commit 184d39a) #KT-14327 Fixed --- .../editor/wordSelection/KotlinWordSelectionFilter.kt | 1 - idea/testData/wordSelection/DocCommentOneLine/0.kt | 3 +++ idea/testData/wordSelection/DocCommentOneLine/1.kt | 3 +++ idea/testData/wordSelection/DocCommentOneLine/2.kt | 3 +++ idea/testData/wordSelection/DocCommentTagLink/0.kt | 6 ++++++ idea/testData/wordSelection/DocCommentTagLink/1.kt | 6 ++++++ idea/testData/wordSelection/DocCommentTagLink/2.kt | 6 ++++++ idea/testData/wordSelection/DocCommentTagName/0.kt | 6 ++++++ idea/testData/wordSelection/DocCommentTagName/1.kt | 6 ++++++ idea/testData/wordSelection/DocCommentTagName/2.kt | 6 ++++++ idea/testData/wordSelection/DocCommentTagName/3.kt | 6 ++++++ idea/testData/wordSelection/DocCommentTagText/0.kt | 6 ++++++ idea/testData/wordSelection/DocCommentTagText/1.kt | 6 ++++++ idea/testData/wordSelection/DocCommentTagText/2.kt | 6 ++++++ idea/testData/wordSelection/DocCommentTagText/3.kt | 6 ++++++ .../org/jetbrains/kotlin/idea/WordSelectionTest.java | 8 ++++++++ 16 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 idea/testData/wordSelection/DocCommentOneLine/0.kt create mode 100644 idea/testData/wordSelection/DocCommentOneLine/1.kt create mode 100644 idea/testData/wordSelection/DocCommentOneLine/2.kt create mode 100644 idea/testData/wordSelection/DocCommentTagLink/0.kt create mode 100644 idea/testData/wordSelection/DocCommentTagLink/1.kt create mode 100644 idea/testData/wordSelection/DocCommentTagLink/2.kt create mode 100644 idea/testData/wordSelection/DocCommentTagName/0.kt create mode 100644 idea/testData/wordSelection/DocCommentTagName/1.kt create mode 100644 idea/testData/wordSelection/DocCommentTagName/2.kt create mode 100644 idea/testData/wordSelection/DocCommentTagName/3.kt create mode 100644 idea/testData/wordSelection/DocCommentTagText/0.kt create mode 100644 idea/testData/wordSelection/DocCommentTagText/1.kt create mode 100644 idea/testData/wordSelection/DocCommentTagText/2.kt create mode 100644 idea/testData/wordSelection/DocCommentTagText/3.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinWordSelectionFilter.kt b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinWordSelectionFilter.kt index dad54a90bb3..cd00ec258b1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinWordSelectionFilter.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/wordSelection/KotlinWordSelectionFilter.kt @@ -34,7 +34,6 @@ class KotlinWordSelectionFilter : Condition{ if (elementType == KtTokens.REGULAR_STRING_PART || elementType == KtTokens.ESCAPE_SEQUENCE) return true if (e is KtContainerNode) return false - if (e.parent.firstChild.nextSibling == null && e.parent !is KtContainerNode) return false // skip nodes with the same range as their parent return when (e.node.elementType) { BLOCK, KDocElementTypes.KDOC_SECTION -> false diff --git a/idea/testData/wordSelection/DocCommentOneLine/0.kt b/idea/testData/wordSelection/DocCommentOneLine/0.kt new file mode 100644 index 00000000000..fbdb9d0007d --- /dev/null +++ b/idea/testData/wordSelection/DocCommentOneLine/0.kt @@ -0,0 +1,3 @@ +/** Doc comment here */ +fun foo() { +} \ No newline at end of file diff --git a/idea/testData/wordSelection/DocCommentOneLine/1.kt b/idea/testData/wordSelection/DocCommentOneLine/1.kt new file mode 100644 index 00000000000..ef0513ceb77 --- /dev/null +++ b/idea/testData/wordSelection/DocCommentOneLine/1.kt @@ -0,0 +1,3 @@ +/** Doc comment here */ +fun foo() { +} \ No newline at end of file diff --git a/idea/testData/wordSelection/DocCommentOneLine/2.kt b/idea/testData/wordSelection/DocCommentOneLine/2.kt new file mode 100644 index 00000000000..2da4a098fa2 --- /dev/null +++ b/idea/testData/wordSelection/DocCommentOneLine/2.kt @@ -0,0 +1,3 @@ +/** Doc comment here */ +fun foo() { +} \ No newline at end of file diff --git a/idea/testData/wordSelection/DocCommentTagLink/0.kt b/idea/testData/wordSelection/DocCommentTagLink/0.kt new file mode 100644 index 00000000000..843c3255a22 --- /dev/null +++ b/idea/testData/wordSelection/DocCommentTagLink/0.kt @@ -0,0 +1,6 @@ +/** + * Doc comment + * @param a The description of a. + */ +fun foo(a: Int) { +} \ No newline at end of file diff --git a/idea/testData/wordSelection/DocCommentTagLink/1.kt b/idea/testData/wordSelection/DocCommentTagLink/1.kt new file mode 100644 index 00000000000..b70902a3d04 --- /dev/null +++ b/idea/testData/wordSelection/DocCommentTagLink/1.kt @@ -0,0 +1,6 @@ +/** + * Doc comment + * @param a The description of a. + */ +fun foo(a: Int) { +} \ No newline at end of file diff --git a/idea/testData/wordSelection/DocCommentTagLink/2.kt b/idea/testData/wordSelection/DocCommentTagLink/2.kt new file mode 100644 index 00000000000..85ea0a16d16 --- /dev/null +++ b/idea/testData/wordSelection/DocCommentTagLink/2.kt @@ -0,0 +1,6 @@ +/** + * Doc comment + * @param a The description of a. + */ +fun foo(a: Int) { +} \ No newline at end of file diff --git a/idea/testData/wordSelection/DocCommentTagName/0.kt b/idea/testData/wordSelection/DocCommentTagName/0.kt new file mode 100644 index 00000000000..8ea9be2ea67 --- /dev/null +++ b/idea/testData/wordSelection/DocCommentTagName/0.kt @@ -0,0 +1,6 @@ +/** + * Doc comment + * @param a The description of a. + */ +fun foo(a: Int) { +} \ No newline at end of file diff --git a/idea/testData/wordSelection/DocCommentTagName/1.kt b/idea/testData/wordSelection/DocCommentTagName/1.kt new file mode 100644 index 00000000000..c039bd15a73 --- /dev/null +++ b/idea/testData/wordSelection/DocCommentTagName/1.kt @@ -0,0 +1,6 @@ +/** + * Doc comment + * @param a The description of a. + */ +fun foo(a: Int) { +} \ No newline at end of file diff --git a/idea/testData/wordSelection/DocCommentTagName/2.kt b/idea/testData/wordSelection/DocCommentTagName/2.kt new file mode 100644 index 00000000000..57faf4dd545 --- /dev/null +++ b/idea/testData/wordSelection/DocCommentTagName/2.kt @@ -0,0 +1,6 @@ +/** + * Doc comment + * @param a The description of a. + */ +fun foo(a: Int) { +} \ No newline at end of file diff --git a/idea/testData/wordSelection/DocCommentTagName/3.kt b/idea/testData/wordSelection/DocCommentTagName/3.kt new file mode 100644 index 00000000000..42925605ba7 --- /dev/null +++ b/idea/testData/wordSelection/DocCommentTagName/3.kt @@ -0,0 +1,6 @@ +/** + * Doc comment + * @param a The description of a. + */ +fun foo(a: Int) { +} \ No newline at end of file diff --git a/idea/testData/wordSelection/DocCommentTagText/0.kt b/idea/testData/wordSelection/DocCommentTagText/0.kt new file mode 100644 index 00000000000..a7ccaeeff51 --- /dev/null +++ b/idea/testData/wordSelection/DocCommentTagText/0.kt @@ -0,0 +1,6 @@ +/** + * Doc comment + * @param a The description of a. + */ +fun foo(a: Int) { +} \ No newline at end of file diff --git a/idea/testData/wordSelection/DocCommentTagText/1.kt b/idea/testData/wordSelection/DocCommentTagText/1.kt new file mode 100644 index 00000000000..39cc51a5d42 --- /dev/null +++ b/idea/testData/wordSelection/DocCommentTagText/1.kt @@ -0,0 +1,6 @@ +/** + * Doc comment + * @param a The description of a. + */ +fun foo(a: Int) { +} \ No newline at end of file diff --git a/idea/testData/wordSelection/DocCommentTagText/2.kt b/idea/testData/wordSelection/DocCommentTagText/2.kt new file mode 100644 index 00000000000..aa02600a034 --- /dev/null +++ b/idea/testData/wordSelection/DocCommentTagText/2.kt @@ -0,0 +1,6 @@ +/** + * Doc comment + * @param a The description of a. + */ +fun foo(a: Int) { +} \ No newline at end of file diff --git a/idea/testData/wordSelection/DocCommentTagText/3.kt b/idea/testData/wordSelection/DocCommentTagText/3.kt new file mode 100644 index 00000000000..49d94737b36 --- /dev/null +++ b/idea/testData/wordSelection/DocCommentTagText/3.kt @@ -0,0 +1,6 @@ +/** + * Doc comment + * @param a The description of a. + */ +fun foo(a: Int) { +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/WordSelectionTest.java b/idea/tests/org/jetbrains/kotlin/idea/WordSelectionTest.java index 800328ad751..c15e95098b0 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/WordSelectionTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/WordSelectionTest.java @@ -51,6 +51,14 @@ public class WordSelectionTest extends KotlinLightCodeInsightFixtureTestCase { public void testDocComment() { doTest(); } + public void testDocCommentOneLine() { doTest(); } + + public void testDocCommentTagName() { doTest(); } + + public void testDocCommentTagText() { doTest(); } + + public void testDocCommentTagLink() { doTest(); } + public void testFunctionWithLineCommentBefore() { doTest(); } public void testFunctionWithLineCommentAfter() { doTest(); }