@@ -49,7 +49,8 @@ abstract class AppInspector {
4949
5050 final AppConnection appConnection;
5151
52- late LibraryHelper _libraryHelper;
52+ @protected
53+ LibraryHelper get libraryHelper;
5354
5455 /// The root URI from which the application is served.
5556 final String root;
@@ -61,7 +62,7 @@ abstract class AppInspector {
6162 static final exceptionMessageRegex = RegExp (r'^.*$' , multiLine: true );
6263
6364 /// Flutter widget inspector library.
64- Future <LibraryRef ?> get flutterWidgetInspectorLibrary => _libraryHelper
65+ Future <LibraryRef ?> get flutterWidgetInspectorLibrary => libraryHelper
6566 .libraryRefFor ('package:flutter/src/widgets/widget_inspector.dart' );
6667
6768 /// Regex used to extract a stack trace line from the exception description.
@@ -73,23 +74,22 @@ abstract class AppInspector {
7374 /// Reset all caches and recompute any mappings.
7475 ///
7576 /// Should be called across hot reloads with a valid [ModifiedModuleReport] .
77+ @protected
7678 @mustCallSuper
7779 Future <void > initialize ({ModifiedModuleReport ? modifiedModuleReport}) async {
7880 _scriptCacheMemoizer = AsyncMemoizer <List <ScriptRef >>();
7981
80- if (modifiedModuleReport != null ) {
81- // Invalidate `_libraryHelper` as we use it populate any script caches.
82- _libraryHelper.initialize (modifiedModuleReport: modifiedModuleReport);
83- } else {
84- _libraryHelper = LibraryHelper (this )..initialize ();
82+ // Invalidate `_libraryHelper` as we use it populate any script caches.
83+ libraryHelper.initialize (modifiedModuleReport: modifiedModuleReport);
84+ if (modifiedModuleReport == null ) {
8585 _scriptRefsById.clear ();
8686 _serverPathToScriptRef.clear ();
8787 _scriptIdToLibraryId.clear ();
8888 _libraryIdToScriptRefs.clear ();
8989 }
9090
91- final libraries = await _libraryHelper .libraryRefs;
92- isolate.rootLib = await _libraryHelper .rootLib;
91+ final libraries = await libraryHelper .libraryRefs;
92+ isolate.rootLib = await libraryHelper .rootLib;
9393 isolate.libraries? .clear ();
9494 isolate.libraries? .addAll (libraries);
9595
@@ -111,7 +111,7 @@ abstract class AppInspector {
111111 );
112112
113113 Future <LibraryRef ?> libraryRefFor (String objectId) =>
114- _libraryHelper .libraryRefFor (objectId);
114+ libraryHelper .libraryRefFor (objectId);
115115
116116 /// Returns the [ScriptRef] for the provided Dart server path [uri] .
117117 Future <ScriptRef ?> scriptRefFor (String uri) async {
@@ -152,7 +152,7 @@ abstract class AppInspector {
152152 // Invalidate any script caches that were computed for the now invalid
153153 // libraries. They will get repopulated below.
154154 for (final libraryUri in modifiedModuleReport.modifiedLibraries) {
155- final libraryRef = await _libraryHelper .libraryRefFor (libraryUri);
155+ final libraryRef = await libraryHelper .libraryRefFor (libraryUri);
156156 final libraryId = libraryRef? .id;
157157 // If this was not a pre-existing library, nothing to invalidate.
158158 if (libraryId == null ) continue ;
@@ -185,7 +185,7 @@ abstract class AppInspector {
185185 ScriptRef (uri: uri, id: createId ()),
186186 for (final part in parts ?? []) ScriptRef (uri: part, id: createId ()),
187187 ];
188- final libraryRef = await _libraryHelper .libraryRefFor (uri);
188+ final libraryRef = await libraryHelper .libraryRefFor (uri);
189189 final libraryId = libraryRef? .id;
190190 if (libraryId != null ) {
191191 final libraryIdToScriptRefs = _libraryIdToScriptRefs.putIfAbsent (
0 commit comments