Add more data to debug no elements in libraryUnit.units

Change-Id: I66c1283924a9003069cfcd9625cb965cb131188c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201380
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2021-05-26 06:32:32 +00:00 committed by commit-bot@chromium.org
parent 4dea737439
commit 9aa7e922f2

View file

@ -447,8 +447,16 @@ class FileResolver {
completionPath: path,
performance: performance,
);
var result =
libraryUnit.units!.firstWhere((element) => element.path == path);
var result = libraryUnit.units!
.firstWhereOrNull((element) => element.path == path);
// TODO(scheglov) Fix and remove.
if (result == null) {
throw StateError('''
libraryFile.path: ${libraryFile.path}
path: $path
units: ${libraryUnit.units!.map((e) => '(${e.uri} = ${e.path})').toList()}
''');
}
return result;
});
}