@@ -7,7 +7,6 @@ import 'package:collection/collection.dart';
7
7
8
8
import '../../utils/flutter_types_utils.dart' ;
9
9
import 'models/file_elements_usage.dart' ;
10
- import 'models/prefix_element_usage.dart' ;
11
10
12
11
// Copied from https://github.com/dart-lang/sdk/blob/main/pkg/analyzer/lib/src/error/imports_verifier.dart#L15
13
12
@@ -124,40 +123,6 @@ class UsedCodeVisitor extends RecursiveAstVisitor<void> {
124
123
}
125
124
}
126
125
127
- /// If the given [identifier] is prefixed with a [PrefixElement] , fill the
128
- /// corresponding `UsedImportedElements.prefixMap` entry and return `true` .
129
- bool _recordPrefixMap (SimpleIdentifier identifier, Element element) {
130
- bool recordIfTargetIsPrefixElement (Expression ? target) {
131
- if (target is SimpleIdentifier ) {
132
- final targetElement = target.staticElement;
133
- if (targetElement is PrefixElement ) {
134
- fileElementsUsage.prefixMap
135
- .putIfAbsent (
136
- targetElement,
137
- () => PrefixElementUsage (_getPrefixUsagePaths (target), {}),
138
- )
139
- .add (element);
140
-
141
- return true ;
142
- }
143
- }
144
-
145
- return false ;
146
- }
147
-
148
- final parent = identifier.parent;
149
-
150
- if (parent is MethodInvocation && parent.methodName == identifier) {
151
- return recordIfTargetIsPrefixElement (parent.target);
152
- }
153
-
154
- if (parent is PrefixedIdentifier && parent.identifier == identifier) {
155
- return recordIfTargetIsPrefixElement (parent.prefix);
156
- }
157
-
158
- return false ;
159
- }
160
-
161
126
bool _recordConditionalElement (Element element) {
162
127
// ignore: deprecated_member_use
163
128
final elementPath = element.enclosingElement3? .source? .fullName;
@@ -194,7 +159,7 @@ class UsedCodeVisitor extends RecursiveAstVisitor<void> {
194
159
}
195
160
196
161
void _visitIdentifier (SimpleIdentifier identifier, Element ? element) {
197
- if (element == null ) {
162
+ if (element == null || element is PrefixElement ) {
198
163
return ;
199
164
}
200
165
@@ -214,11 +179,6 @@ class UsedCodeVisitor extends RecursiveAstVisitor<void> {
214
179
return ;
215
180
}
216
181
217
- // Record `importPrefix.identifier` into 'prefixMap'.
218
- if (_recordPrefixMap (identifier, element)) {
219
- return ;
220
- }
221
-
222
182
// ignore: deprecated_member_use
223
183
final enclosingElement = element.enclosingElement3;
224
184
if (enclosingElement is CompilationUnitElement ) {
@@ -227,11 +187,6 @@ class UsedCodeVisitor extends RecursiveAstVisitor<void> {
227
187
_recordUsedExtension (enclosingElement);
228
188
229
189
return ;
230
- } else if (element is PrefixElement ) {
231
- fileElementsUsage.prefixMap.putIfAbsent (
232
- element,
233
- () => PrefixElementUsage (_getPrefixUsagePaths (identifier), {}),
234
- );
235
190
} else if (element is MultiplyDefinedElement ) {
236
191
// If the element is multiply defined then call this method recursively
237
192
// for each of the conflicting elements.
@@ -244,34 +199,6 @@ class UsedCodeVisitor extends RecursiveAstVisitor<void> {
244
199
}
245
200
}
246
201
247
- Iterable <String > _getPrefixUsagePaths (SimpleIdentifier target) {
248
- final root = target.root;
249
-
250
- if (root is ! CompilationUnit ) {
251
- return [];
252
- }
253
-
254
- return root.directives.fold <List <String >>([], (previousValue, directive) {
255
- if (directive is ImportDirective &&
256
- directive.prefix? .name == target.name) {
257
- // ignore: deprecated_member_use
258
- final path = directive.element2? .importedLibrary? .source.fullName;
259
- if (path != null ) {
260
- previousValue.add (path);
261
- }
262
-
263
- for (final config in directive.configurations) {
264
- final uri = config.resolvedUri;
265
- if (uri is DirectiveUriWithSource ) {
266
- previousValue.add (uri.source.fullName);
267
- }
268
- }
269
- }
270
-
271
- return previousValue;
272
- });
273
- }
274
-
275
202
bool _isVariableDeclarationInitializer (
276
203
AstNode ? target,
277
204
SimpleIdentifier identifier,
0 commit comments