[java] IDEA-293932 Extend selection selects unnecessary trailing whitespaces

GitOrigin-RevId: 40ce5ff3c6839ec4f1b2393964050e409fa1f658
This commit is contained in:
Tagir Valeev
2022-10-12 17:24:15 +00:00
committed by intellij-monorepo-bot
parent 89d0b76240
commit cbe007679b
14 changed files with 91 additions and 6 deletions
@@ -39,8 +39,8 @@ public class MethodCallSelectioner implements ExtendWordSelectionHandler {
return null;
}
else {
return Collections.singletonList(new TextRange(referenceNameElement.getTextRange().getStartOffset(),
methodCall.getTextRange().getEndOffset()));
return List.of(new TextRange(referenceNameElement.getTextRange().getStartOffset(), methodCall.getTextRange().getEndOffset()),
methodCall.getTextRange());
}
}
}
@@ -66,10 +66,10 @@ public class ReferenceSelectioner extends BasicSelectioner {
element = firstChild;
}
// if (element instanceof PsiMethodCallExpression) {
result.addAll(expandToWholeLine(editorText, new TextRange(element.getTextRange().getStartOffset(),
endElement.getTextRange().getEndOffset())));
// }
TextRange range = new TextRange(element.getTextRange().getStartOffset(),
endElement.getTextRange().getEndOffset());
result.add(range);
result.addAll(expandToWholeLine(editorText, range));
if (!(e.getParent() instanceof PsiJavaCodeReferenceElement)) {
if (e.getNextSibling() instanceof PsiJavaToken ||
@@ -0,0 +1,7 @@
class X {
void test(List<String> list) {
list.stream()
.<selection>m<caret>ap</selection>(x -> x)
.collect(toList());
}
}
@@ -0,0 +1,7 @@
class X {
void test(List<String> list) {
list.stream()
.<selection>m<caret>ap(x -> x)</selection>
.collect(toList());
}
}
@@ -0,0 +1,7 @@
class X {
void test(List<String> list) {
<selection>list.stream()
.m<caret>ap(x -> x)</selection>
.collect(toList());
}
}
@@ -0,0 +1,7 @@
class X {
void test(List<String> list) {
<selection> list.stream()
.m<caret>ap(x -> x)
</selection> .collect(toList());
}
}
@@ -0,0 +1,7 @@
class X {
void test(List<String> list) {
list.stream()
.m<caret>ap(x -> x)
.collect(toList());
}
}
@@ -0,0 +1,7 @@
class X {
void test(List<String> list) {
list.stream()
.map(x <selection><caret>-></selection> x)
.collect(toList());
}
}
@@ -0,0 +1,7 @@
class X {
void test(List<String> list) {
list.stream()
.map(<selection>x <caret>-> x</selection>)
.collect(toList());
}
}
@@ -0,0 +1,7 @@
class X {
void test(List<String> list) {
list.stream()
.<selection>map(x <caret>-> x)</selection>
.collect(toList());
}
}
@@ -0,0 +1,7 @@
class X {
void test(List<String> list) {
<selection>list.stream()
.map(x <caret>-> x)</selection>
.collect(toList());
}
}
@@ -0,0 +1,7 @@
class X {
void test(List<String> list) {
<selection> list.stream()
.map(x <caret>-> x)
</selection> .collect(toList());
}
}
@@ -0,0 +1,7 @@
class X {
void test(List<String> list) {
list.stream()
.map(x <caret>-> x)
.collect(toList());
}
}
@@ -66,6 +66,14 @@ public class JavaSelectWordTest extends SelectWordTestBase {
doTest("java");
}
public void testCallMultiline() {
doTest("java");
}
public void testCallMultiline2() {
doTest("java");
}
public void testBlock1() {
doTest("java");
}