Add more debug data to LinkedElementFactory.
Change-Id: I9bf172856cd8a3c06388038574890f6ad872572a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250441
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_context.dart b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
index fdf5ba2..0ef2a0e 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_context.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
@@ -46,7 +46,7 @@
final SummaryDataStore store = SummaryDataStore();
late final AnalysisContextImpl analysisContext;
- late LinkedElementFactory elementFactory;
+ late final LinkedElementFactory elementFactory;
Set<LibraryCycle> loadedBundles = Set.identity();
@@ -120,6 +120,7 @@
required LibraryFileStateKind targetLibrary,
required OperationPerformanceImpl performance,
}) async {
+ addToLogRing('[load][targetLibrary: ${targetLibrary.file}]');
var librariesTotal = 0;
var librariesLoaded = 0;
var librariesLinked = 0;
diff --git a/pkg/analyzer/lib/src/summary2/linked_element_factory.dart b/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
index 27c1357..45859a4 100644
--- a/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
+++ b/pkg/analyzer/lib/src/summary2/linked_element_factory.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'dart:collection';
+
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/context/context.dart';
import 'package:analyzer/src/dart/analysis/session.dart';
@@ -13,6 +15,15 @@
import 'package:analyzer/src/summary2/reference.dart';
import 'package:meta/meta.dart';
+final _logRing = Queue<String>();
+
+void addToLogRing(String entry) {
+ _logRing.add(entry);
+ if (_logRing.length > 10) {
+ _logRing.removeFirst();
+ }
+}
+
class LinkedElementFactory {
static final _dartCoreUri = Uri.parse('dart:core');
static final _dartAsyncUri = Uri.parse('dart:async');
@@ -104,9 +115,10 @@
final rootChildren = rootReference.children.map((e) => e.name).toList();
throw ArgumentError(
'Missing library: $uri\n'
- 'Libraries: $uriListWithLibraryElements'
- 'Root children: $rootChildren'
- 'Readers: ${_libraryReaders.keys.toList()}',
+ 'Libraries: $uriListWithLibraryElements\n'
+ 'Root children: $rootChildren\n'
+ 'Readers: ${_libraryReaders.keys.toList()}\n'
+ 'Log: ${_logRing.join('\n')}\n',
);
}
@@ -217,6 +229,7 @@
/// Remove libraries with the specified URIs from the reference tree, and
/// any session level caches.
void removeLibraries(Set<Uri> uriSet) {
+ addToLogRing('[removeLibraries][uriSet: $uriSet][${StackTrace.current}]');
for (final uri in uriSet) {
_libraryReaders.remove(uri);
final libraryReference = rootReference.removeChild('$uri');