Skip to content

Commit f300269

Browse files
DanTupCommit Queue
authored andcommitted
[analysis_server] Exclude NameWithTypeParameters from selection ranges
This makes things more consistent between class/mixin (that have different ASTs) but also avoids jumping to the name+type args which probably isn't what you'd expect. Change-Id: Ibd5e2a9b332c4c214ccc753080a61b1222445485 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490260 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
1 parent 25fe38a commit f300269

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

pkg/analysis_server/lib/src/computer/computer_selection_ranges.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ class DartSelectionRangeComputer {
4242
}
4343
}
4444

45+
// Ignore certain kinds of nodes.
46+
if (node is NameWithTypeParameters) {
47+
return;
48+
}
49+
4550
_selectionRanges.add(SelectionRange(node.offset, node.length));
4651
}
4752
}

pkg/analysis_server/test/lsp/selection_range_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void f() {
9292
class ^C;
9393
''';
9494

95-
await verifySelectionRanges(content, ['C', 'class C;']);
95+
await verifySelectionRanges(content, ['class C;']);
9696
}
9797

9898
Future<void> test_emptyBody_enum() async {
@@ -102,7 +102,7 @@ class ^C;
102102
enum ^E;
103103
''';
104104

105-
await verifySelectionRanges(content, ['E', 'enum E;']);
105+
await verifySelectionRanges(content, ['enum E;']);
106106
}
107107

108108
Future<void> test_emptyBody_extension() async {

0 commit comments

Comments
 (0)