@@ -38,6 +38,7 @@ var timerLoad2 = Stopwatch();
3838class LibraryContext {
3939 static const _maxLinkedDataInBytes = 64 * 1024 * 1024 ;
4040
41+ final int id = fileObjectId++ ;
4142 final LibraryContextTestView testView;
4243 final PerformanceLog logger;
4344 final ByteStore byteStore;
@@ -109,12 +110,18 @@ class LibraryContext {
109110 var bytesGet = 0 ;
110111 var bytesPut = 0 ;
111112
112- void loadBundle (LibraryCycle cycle) {
113+ var thisLoadLogBuffer = StringBuffer ();
114+
115+ void loadBundle (LibraryCycle cycle, String debugPrefix) {
113116 if (! loadedBundles.add (cycle)) return ;
114117
118+ thisLoadLogBuffer.writeln ('$debugPrefix $cycle ' );
119+
115120 librariesTotal += cycle.libraries.length;
116121
117- cycle.directDependencies.forEach (loadBundle);
122+ cycle.directDependencies.forEach (
123+ (e) => loadBundle (e, '$debugPrefix ' ),
124+ );
118125
119126 var key = cycle.transitiveSignature + '.linked_bundle' ;
120127 var bytes = byteStore.get (key);
@@ -161,21 +168,34 @@ class LibraryContext {
161168 if (existingLibraryReference != null ) {
162169 var existingElement = existingLibraryReference.element;
163170 if (existingElement != null ) {
171+ var buffer = StringBuffer ();
172+
173+ buffer.writeln ('[The library is already loaded]' );
174+ buffer.writeln ();
175+
164176 var existingSource = existingElement? .source;
177+ buffer.writeln ('[oldUri: ${existingSource .uri }]' );
178+ buffer.writeln ('[oldPath: ${existingSource .fullName }]' );
179+ buffer.writeln ('[newUri: ${libraryFile .uriStr }]' );
180+ buffer.writeln ('[newPath: ${libraryFile .path }]' );
181+ buffer.writeln ('[cycle: $cycle ]' );
182+ buffer.writeln ();
183+
184+ buffer.writeln ('[loadedBundles: ${loadedBundles .toList ()}]' );
185+ buffer.writeln ();
186+
187+ buffer.writeln ('Bundles loaded in this load2() invocation:' );
188+ buffer.writeln (thisLoadLogBuffer);
189+ buffer.writeln ();
190+
165191 var libraryRefs = elementFactory.rootReference.children;
166192 var libraryUriList = libraryRefs.map ((e) => e.name).toList ();
167- var statusText = '[The library is already loaded]'
168- '[oldUri: ${existingSource .uri }]'
169- '[oldPath: ${existingSource .fullName }]'
170- '[newUri: ${libraryFile .uriStr }]'
171- '[newPath: ${libraryFile .path }]'
172- '[cycle: $cycle ]'
173- '[loadedBundles: ${loadedBundles .toList ()}]'
174- '[elementFactory.libraries: $libraryUriList ]' ;
193+ buffer.writeln ('[elementFactory.libraries: $libraryUriList ]' );
194+
175195 throw CaughtExceptionWithFiles (
176196 'Cycle loading state error' ,
177197 StackTrace .current,
178- {'status' : statusText },
198+ {'status' : buffer. toString () },
179199 );
180200 }
181201 }
@@ -247,7 +267,7 @@ class LibraryContext {
247267
248268 logger.run ('Prepare linked bundles' , () {
249269 var libraryCycle = targetLibrary.libraryCycle;
250- loadBundle (libraryCycle);
270+ loadBundle (libraryCycle, '' );
251271 logger.writeln (
252272 '[librariesTotal: $librariesTotal ]'
253273 '[librariesLoaded: $librariesLoaded ]'
0 commit comments