[DAS] Fixes pattern variable with multiple declarations highlight
Bug: https://github.com/dart-lang/sdk/issues/60398 Change-Id: Ifd7c29db38bb2ee048d2b7d0de1e050e1e3e9bc2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417964 Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Phil Quitslund <pquitslund@google.com> Auto-Submit: Felipe Morschel <git@fmorschel.dev> Reviewed-by: Phil Quitslund <pquitslund@google.com>
This commit is contained in:
@@ -100,7 +100,11 @@ class DartUnitOccurrencesComputerVisitor extends RecursiveAstVisitor<void> {
|
||||
|
||||
@override
|
||||
void visitDeclaredVariablePattern(DeclaredVariablePattern node) {
|
||||
_addOccurrence(node.declaredElement2!, node.name);
|
||||
if (node.declaredElement2 case BindPatternVariableElement2(:var join2?)) {
|
||||
_addOccurrence(join2.baseElement, node.name);
|
||||
} else {
|
||||
_addOccurrence(node.declaredElement2!, node.name);
|
||||
}
|
||||
|
||||
super.visitDeclaredVariablePattern(node);
|
||||
}
|
||||
|
||||
@@ -576,6 +576,18 @@ String f(int char) {
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_patternVariable_ifCase_logicalOr() async {
|
||||
await assertOccurrences(kind: ElementKind.LOCAL_VARIABLE, '''
|
||||
void f(Object? x) {
|
||||
if (x case int /*[0*/test/*0]*/ || [int /*[1*/test/*1]*/] when /*[2*/test/*2]*/ > 0) {
|
||||
/*[3*/test/*3]*/;
|
||||
/*[4*/test/*4]*/ = 1;
|
||||
/*[5*/test/*5]*/ += 2;
|
||||
}
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_prefix() async {
|
||||
await assertOccurrences(kind: ElementKind.PREFIX, '''
|
||||
import '' as /*[0*/p/*0]*/;
|
||||
|
||||
Reference in New Issue
Block a user