@@ -9,7 +9,6 @@ import 'dart:typed_data';
99import 'package:analyzer/dart/analysis/declared_variables.dart' ;
1010import 'package:analyzer/dart/analysis/features.dart' ;
1111import 'package:analyzer/dart/analysis/results.dart' ;
12- import 'package:analyzer/dart/element/element.dart' ;
1312import 'package:analyzer/dart/element/element2.dart' ;
1413import 'package:analyzer/error/error.dart' ;
1514import 'package:analyzer/file_system/file_system.dart' ;
@@ -259,24 +258,14 @@ class FileResolver {
259258 /// cached by the resolver are searched, generated files are ignored.
260259 Future <List <CiderSearchMatch >> findReferences (Element2 element,
261260 {OperationPerformanceImpl ? performance}) {
262- return findReferences2 (
263- element.asElement! ,
264- performance: performance,
265- );
266- }
267-
268- /// Looks for references to the given Element. All the files currently
269- /// cached by the resolver are searched, generated files are ignored.
270- Future <List <CiderSearchMatch >> findReferences2 (Element element,
271- {OperationPerformanceImpl ? performance}) {
272- return logger.runAsync ('findReferences for ${element .name }' , () async {
261+ return logger.runAsync ('findReferences for ${element .name3 }' , () async {
273262 var references = < CiderSearchMatch > [];
274263
275264 Future <void > collectReferences2 (
276265 String path, OperationPerformanceImpl performance) async {
277266 await performance.runAsync ('collectReferences' , (_) async {
278267 var resolved = await resolve (path: path);
279- var collector = ReferencesCollector (element);
268+ var collector = ReferencesCollector (element.asElement ! );
280269 resolved.unit.accept (collector);
281270 var matches = collector.references;
282271 if (matches.isNotEmpty) {
@@ -295,10 +284,13 @@ class FileResolver {
295284
296285 performance ?? = OperationPerformanceImpl ('<default>' );
297286 // TODO(keertip): check if element is named constructor.
298- if (element is LocalVariableElement ||
299- (element is ParameterElement && ! element.isNamed)) {
300- await collectReferences2 (element.source! .fullName, performance! );
301- } else if (element is LibraryImportElementImpl ) {
287+ if (element is LocalVariableElement2 ||
288+ (element is FormalParameterElement && ! element.isNamed)) {
289+ await collectReferences2 (
290+ element.firstFragment.libraryFragment! .source.fullName,
291+ performance! ,
292+ );
293+ } else if (element is MockLibraryImportElement ) {
302294 return await _searchReferences_Import (element);
303295 } else {
304296 var result = performance! .run ('getFilesContaining' , (performance) {
@@ -892,13 +884,14 @@ class FileResolver {
892884 }
893885
894886 Future <List <CiderSearchMatch >> _searchReferences_Import (
895- LibraryImportElementImpl element) async {
887+ MockLibraryImportElement element) async {
896888 var results = < CiderSearchMatch > [];
897- var libraryElement = element.library ;
898- for (var unitElement in libraryElement.units ) {
899- String unitPath = unitElement .source.fullName;
889+ var libraryElement = element.library2 ;
890+ for (var libraryFragment in libraryElement.fragments ) {
891+ String unitPath = libraryFragment .source.fullName;
900892 var unitResult = await resolve (path: unitPath);
901- var visitor = ImportElementReferencesVisitor (element, unitElement);
893+ var visitor =
894+ ImportElementReferencesVisitor (element.import, libraryFragment);
902895 unitResult.unit.accept (visitor);
903896 var lineInfo = unitResult.lineInfo;
904897 var infos = visitor.results
0 commit comments