Skip to content

Commit 470429d

Browse files
committed
Fix up
1 parent 58af580 commit 470429d

File tree

9 files changed

+33
-26
lines changed

9 files changed

+33
-26
lines changed

dwds/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 24.4.0-wip
22

33
- Added support for breakpoint registering on a hot reload with the DDC library bundle format using PausePostRequests.
4+
- `FrontendServerDdcLibraryBundleStrategy.hotReloadSourceUri` is now expected to also provide the reloaded modules.
45

56
## 24.3.11
67

dwds/lib/src/debugging/inspector.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ class AppInspector implements AppInspectorInterface {
740740
.scripts;
741741
if (modifiedModuleReport != null) {
742742
// Invalidate any script caches that were computed for the now invalid
743-
// libraries. They will get repopulated later.
743+
// libraries. They will get repopulated below.
744744
for (final libraryUri in modifiedModuleReport.modifiedLibraries) {
745745
final libraryRef = await _libraryHelper.libraryRefFor(libraryUri);
746746
final libraryId = libraryRef?.id;

dwds/lib/src/debugging/libraries.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class LibraryHelper extends Domain {
5252
return _rootLib!;
5353
}
5454

55+
/// Removes any modified libraries from the cache and either eagerly or lazily
56+
/// computes values for the reloaded libraries in the [modifiedModuleReport].
5557
void invalidate(ModifiedModuleReport modifiedModuleReport) {
5658
for (final library in modifiedModuleReport.modifiedLibraries) {
5759
// These will later be initialized by `libraryFor` if needed.

dwds/lib/src/debugging/metadata/provider.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,19 @@ class MetadataProvider {
7676
return true;
7777
}
7878

79-
/// A set of all libraries in the Dart application.
79+
/// A list of all libraries in the Dart application.
8080
///
8181
/// Example:
8282
///
83-
/// {
83+
/// [
8484
/// dart:web_gl,
8585
/// dart:math,
8686
/// org-dartlang-app:///web/main.dart
87-
/// }
87+
/// ]
8888
///
89-
Future<Set<String>> get libraries async {
89+
Future<List<String>> get libraries async {
9090
await _initialize();
91-
return _libraries;
91+
return _libraries.toList();
9292
}
9393

9494
/// A map of library uri to dart scripts.
@@ -226,9 +226,9 @@ class MetadataProvider {
226226
/// determines deleted and invalidated libraries and modules, invalidates them
227227
/// in any caches, and recomputes the necessary information.
228228
///
229-
/// Returns an [ModifiedModuleReport] that can be used to invalidate other
229+
/// Returns a [ModifiedModuleReport] that can be used to invalidate other
230230
/// caches after a hot reload.
231-
Future<ModifiedModuleReport> reinitializeAfterReload(
231+
Future<ModifiedModuleReport> reinitializeAfterHotReload(
232232
Map<String, List> reloadedModulesToLibraries,
233233
) async {
234234
final modules = (await _processMetadata(true))!;
@@ -265,7 +265,7 @@ class MetadataProvider {
265265
);
266266
_addMetadata(modules[module]!);
267267
}
268-
// The libraries that were removed from the program or those that we
268+
// The libraries that are removed from the program are those that we
269269
// invalidated but were never added again.
270270
final deletedLibraries =
271271
invalidatedLibraries
@@ -332,7 +332,7 @@ class AbsoluteImportUriException implements Exception {
332332
}
333333

334334
/// Computed after a hot reload using
335-
/// [MetadataProvider.reinitializeAfterReload], represents the modules and
335+
/// [MetadataProvider.reinitializeAfterHotReload], represents the modules and
336336
/// libraries in the program that were deleted, reloaded, and therefore,
337337
/// modified.
338338
///

dwds/lib/src/debugging/modules.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ class Modules {
9999
final serverPath = await globalToolConfiguration.loadStrategy
100100
.serverPathForModule(entrypoint, module);
101101
// TODO(srujzs): We should wait until all scripts are parsed before
102-
// accessing.
102+
// accessing after a hot reload. See
103+
// https://github.com/dart-lang/webdev/issues/2640.
103104
return chromePathToRuntimeScriptId[serverPath];
104105
}
105106

dwds/lib/src/debugging/skip_list.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ class SkipLists {
2525
if (modifiedModuleReport != null) {
2626
assert(entrypoint != null);
2727
for (final url in _urlToId.keys) {
28-
if (url.isEmpty) continue;
29-
3028
final dartUri = DartUri(url, _root);
3129
final serverPath = dartUri.serverPath;
3230
final module = await globalToolConfiguration.loadStrategy
3331
.moduleForServerPath(entrypoint!, serverPath);
3432
if (modifiedModuleReport.modifiedModules.contains(module)) {
3533
_idToList.remove(_urlToId[url]!);
34+
_urlToId.remove(url);
3635
}
3736
}
3837
} else {
@@ -51,7 +50,6 @@ class SkipLists {
5150
String url,
5251
Set<Location> locations,
5352
) {
54-
_urlToId[url] = scriptId;
5553
if (_idToList.containsKey(scriptId)) return _idToList[scriptId]!;
5654

5755
final sortedLocations =
@@ -82,7 +80,10 @@ class SkipLists {
8280
}
8381
ranges.add(_rangeFor(scriptId, startLine, startColumn, maxValue, maxValue));
8482

85-
_idToList[scriptId] = ranges;
83+
if (url.isNotEmpty) {
84+
_idToList[scriptId] = ranges;
85+
_urlToId[url] = scriptId;
86+
}
8687
return ranges;
8788
}
8889

dwds/lib/src/loaders/strategy.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,12 @@ abstract class LoadStrategy {
183183
return Future.value();
184184
}
185185

186-
Future<ModifiedModuleReport> reinitializeEntrypointAfterReload(
186+
Future<ModifiedModuleReport> reinitializeProviderAfterHotReload(
187187
String entrypoint,
188188
Map<String, List> reloadedModulesToLibraries,
189189
) {
190190
final provider = _providers[entrypoint]!;
191-
return provider.reinitializeAfterReload(reloadedModulesToLibraries);
191+
return provider.reinitializeAfterHotReload(reloadedModulesToLibraries);
192192
}
193193
}
194194

dwds/lib/src/services/chrome_proxy_service.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ class ChromeProxyService implements VmServiceInterface {
242242
) async {
243243
final entrypoint = inspector.appConnection.request.entrypointPath;
244244
final modifiedModuleReport = await globalToolConfiguration.loadStrategy
245-
.reinitializeEntrypointAfterReload(entrypoint, reloadedModules);
245+
.reinitializeProviderAfterHotReload(entrypoint, reloadedModules);
246246
await _initializeEntrypoint(entrypoint, modifiedModuleReport);
247247
await inspector.initialize(modifiedModuleReport);
248248
}
@@ -1211,13 +1211,13 @@ class ChromeProxyService implements VmServiceInterface {
12111211

12121212
// Initiate a hot reload.
12131213
_logger.info('Issuing \$dartHotReloadStartDwds request');
1214-
final reloadedModulesMap = await inspector.jsEvaluate(
1214+
final remoteObject = await inspector.jsEvaluate(
12151215
'\$dartHotReloadStartDwds();',
12161216
awaitPromise: true,
12171217
returnByValue: true,
12181218
);
1219-
final reloadedModules =
1220-
(reloadedModulesMap.value as Map).cast<String, List>();
1219+
final reloadedModulesToLibraries =
1220+
(remoteObject.value as Map).cast<String, List>();
12211221

12221222
if (!pauseIsolatesOnStart) {
12231223
// Finish hot reload immediately.
@@ -1252,7 +1252,7 @@ class ChromeProxyService implements VmServiceInterface {
12521252
await pause(isolateId);
12531253
await pausedEvent;
12541254

1255-
await _reinitializeForHotReload(reloadedModules);
1255+
await _reinitializeForHotReload(reloadedModulesToLibraries);
12561256

12571257
// This lets the client know that we're ready for breakpoint management
12581258
// and a resume.

dwds/test/metadata_test.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ void main() {
207207
],
208208
};
209209
final libraryToParts = <String, List<String>>{
210-
'l1': ['org-dartlang-app:///web/l1_p1.dart'],
210+
'org-dartlang-app:///web/l1.dart': ['org-dartlang-app:///web/l1_p1.dart'],
211+
'org-dartlang-app:///web/l3.dart': ['org-dartlang-app:///web/l3_p1.dart'],
211212
};
212213
final assetReader = FakeAssetReader(
213214
metadata: createMetadataContents(moduleToLibraries, libraryToParts),
@@ -227,8 +228,9 @@ void main() {
227228
],
228229
};
229230
final newLibraryToParts = <String, List<String>>{
230-
'l1': ['org-dartlang-app:///web/l1_p1.dart'],
231-
'l7': ['org-dartlang-app:///web/l7_p1.dart'],
231+
'org-dartlang-app:///web/l2.dart': ['org-dartlang-app:///web/l1_p1.dart'],
232+
'org-dartlang-app:///web/l3.dart': ['org-dartlang-app:///web/l3_p2.dart'],
233+
'org-dartlang-app:///web/l7.dart': ['org-dartlang-app:///web/l7_p1.dart'],
232234
};
233235
final reloadedModulesToLibraries = <String, List<String>>{
234236
'm3': ['org-dartlang-app:///web/l3.dart'],
@@ -241,7 +243,7 @@ void main() {
241243
newModuleToLibraries,
242244
newLibraryToParts,
243245
);
244-
final modifiedModuleReport = await provider.reinitializeAfterReload(
246+
final modifiedModuleReport = await provider.reinitializeAfterHotReload(
245247
reloadedModulesToLibraries,
246248
);
247249
expect(modifiedModuleReport.deletedModules, ['m2']);

0 commit comments

Comments
 (0)