Skip to content

Commit 56fc836

Browse files
DanTupCommit Queue
authored andcommitted
[analysis_server] Fix occurrences highlighting for prefixed identifiers
Fixes #56981 Change-Id: I817625962b5a4975ec5f597ab147fe7312cdf06f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392580 Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 8d845f6 commit 56fc836

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

pkg/analysis_server/lib/src/domains/analysis/occurrences_dart.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class _DartUnitOccurrencesComputerVisitor extends RecursiveAstVisitor<void> {
121121
void visitNamedType(NamedType node) {
122122
var element = node.element;
123123
if (element != null) {
124-
_addOccurrence(element, node.offset);
124+
_addOccurrence(element, node.name2.offset);
125125
}
126126

127127
super.visitNamedType(node);

pkg/analysis_server/test/analysis/notification_occurrences_test.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,19 @@ import 'dart:io' as /*[0*/_/*0]*/;
682682
);
683683
}
684684

685+
Future<void> test_prefixed() async {
686+
await assertOccurrences(
687+
kind: ElementKind.CLASS,
688+
'''
689+
import '' as p;
690+
691+
class /*[0*/A/*0]*/ {}
692+
693+
p./*[1*/A/*1]*/? a;
694+
''',
695+
);
696+
}
697+
685698
Future<void> test_recordType_typeName() async {
686699
await assertOccurrences(
687700
kind: ElementKind.CLASS,

pkg/analysis_server/test/lsp/document_highlights_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ void f() {
148148
/*[2*/key/*2]*/;
149149
}
150150
}
151+
''');
152+
153+
Future<void> test_prefixed() => _testMarkedContent('''
154+
import '' as p;
155+
156+
class /*[0*/A^/*0]*/ {}
157+
158+
p./*[1*/A/*1]*/? a;
151159
''');
152160

153161
Future<void> test_shadow_inner() => _testMarkedContent('''

0 commit comments

Comments
 (0)