[analyzer] Trim 'Missing library' error text

It looks like the error is currently truncated after approximately 300
library URIs are listed in the 'root children' piece. Trimming to 100
libraries seems quite safe. I can't claim that I foresee situations that
could only be solved by seeing the 100th URI, but I don't see any reason
to pick a smaller number.

Bug: b/267353400
Change-Id: Ibc16637cd9fa3ac59ea273393ccfc5a4e1d9c5d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280243
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
Sam Rawlins 2023-02-01 22:38:32 +00:00 committed by Commit Queue
parent 8cce064bf1
commit 6829a9de37

View file

@ -113,7 +113,13 @@ class LinkedElementFactory {
var reader = _libraryReaders[uri];
if (reader == null) {
final rootChildren = rootReference.children.map((e) => e.name).toList();
var rootChildren = rootReference.children.map((e) => e.name).toList();
if (rootChildren.length > 100) {
rootChildren = [
...rootChildren.take(100),
'... (${rootChildren.length} total)'
];
}
throw ArgumentError(
'Missing library: $uri\n'
'Libraries: $uriListWithLibraryElements\n'