Skip to content

Commit 9f465e5

Browse files
bwilkersonCommit Queue
authored andcommitted
[Migrate] unused_local_elements_verifier.dart
Change-Id: I1d68dda93d6282118827826ea6ee8e5fe13b78fc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403907 Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
1 parent f72576a commit 9f465e5

File tree

4 files changed

+280
-229
lines changed

4 files changed

+280
-229
lines changed

pkg/analyzer/lib/src/dart/ast/extensions.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ extension IdentifierExtension on Identifier {
220220
return _readElement(this);
221221
}
222222

223+
Element2? get readElement2 {
224+
return _readElement(this).asElement2;
225+
}
226+
223227
SimpleIdentifier get simpleName {
224228
var self = this;
225229
if (self is SimpleIdentifier) {
@@ -233,6 +237,10 @@ extension IdentifierExtension on Identifier {
233237
return _writeElement(this);
234238
}
235239

240+
Element2? get writeElement2 {
241+
return _writeElement(this).asElement2;
242+
}
243+
236244
Element? get writeOrReadElement {
237245
return _writeElement(this) ?? staticElement;
238246
}

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,12 @@ class BindPatternVariableElementImpl2 extends PatternVariableElementImpl2
153153
];
154154
}
155155

156-
/// This flag is set to `true` if this variable clashes with another
157-
/// pattern variable with the same name within the same pattern.
156+
/// Whether this variable clashes with another pattern variable with the same
157+
/// name within the same pattern.
158+
bool get isDuplicate => _wrappedElement.isDuplicate;
159+
160+
/// Set whether this variable clashes with another pattern variable with the
161+
/// same name within the same pattern.
158162
set isDuplicate(bool value) => _wrappedElement.isDuplicate = value;
159163

160164
DeclaredVariablePatternImpl get node => _wrappedElement.node;
@@ -6793,6 +6797,23 @@ class JoinPatternVariableElementImpl2 extends PatternVariableElementImpl2
67936797
/// The identifiers that reference this element.
67946798
List<SimpleIdentifier> get references => _wrappedElement.references;
67956799

6800+
/// Returns this variable, and variables that join into it.
6801+
List<PatternVariableElementImpl2> get transitiveVariables {
6802+
var result = <PatternVariableElementImpl2>[];
6803+
6804+
void append(PatternVariableElementImpl2 variable) {
6805+
result.add(variable);
6806+
if (variable is JoinPatternVariableElementImpl2) {
6807+
for (var variable in variable.variables2) {
6808+
append(variable as PatternVariableElementImpl2);
6809+
}
6810+
}
6811+
}
6812+
6813+
append(this);
6814+
return result;
6815+
}
6816+
67966817
/// The variables that join into this variable.
67976818
List<PatternVariableElementImpl> get variables => _wrappedElement.variables;
67986819

0 commit comments

Comments
 (0)