Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utilize new wait extension methods #8619

Merged
merged 6 commits into from
Feb 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -297,14 +297,14 @@ class ExtensionService extends DisposableController
...runtimeExtensions,
...staticExtensions,
].where((e) => e.name == extension.name);
await Future.wait([
await [
for (final ext in allMatchingExtensions)
server.extensionEnabledState(
devtoolsOptionsFileUri: ext.devtoolsOptionsUri,
extensionName: ext.name,
enable: enable,
),
]);
].wait;
await _refreshExtensionEnabledStates(
availableExtensions: _currentExtensions.value.availableExtensions,
);
Original file line number Diff line number Diff line change
@@ -180,7 +180,7 @@ class BreakpointManager with DisposerMixin {
}
}

await Future.wait([
await [
// Remove the breakpoints.
for (final bp in breakpointsToRemove) removeBreakpoint(bp.breakpoint),
// Add them back to the newer versions of those scripts.
@@ -189,7 +189,7 @@ class BreakpointManager with DisposerMixin {
if (scriptRef.uri == bp.scriptUri)
addBreakpoint(scriptRef.id!, bp.line!),
],
]);
].wait;
}

Future<List<Breakpoint>> _getBreakpointsForIsolate(String isolateId) async {
@@ -214,15 +214,17 @@ class BreakpointManager with DisposerMixin {
}) async {
_breakpoints.value = breakpoints;
// Build _breakpointsWithLocation from _breakpoints.
await Future.wait(
_breakpoints.value.map(breakpointManager.createBreakpointWithLocation),
).then((list) {
if (isolateId != _isolateRefId) {
// Current request is obsolete.
return;
}
_breakpointsWithLocation.value = list.toList()..sort();
});
final breakpointsWithLocation =
await _breakpoints.value
.map(breakpointManager.createBreakpointWithLocation)
.wait;

if (isolateId != _isolateRefId) {
// Current request is obsolete.
return;
}

_breakpointsWithLocation.value = breakpointsWithLocation.sorted();
}

Future<void> _setUpBreakpoints({
Original file line number Diff line number Diff line change
@@ -453,7 +453,7 @@ class DebuggerController extends DisposableController
);

return _StackInfo(
await Future.wait(frames.map(_createStackFrameWithLocation)),
await frames.map(_createStackFrameWithLocation).wait,
stack.truncated ?? false,
);
}
Original file line number Diff line number Diff line change
@@ -254,69 +254,68 @@ class ProgramExplorerController extends DisposableController
.id;

Future<List<Obj>> getObjects(Iterable<ObjRef> objs) {
return Future.wait(
objs.map((o) => service!.getObject(isolateId!, o.id!)),
);
return objs.map((o) => service!.getObject(isolateId!, o.id!)).wait;
}

Future<List<Func>> getFuncs(
Iterable<FuncRef> funcs,
Iterable<FieldRef>? fields,
) async {
return await Future.wait<Func>(
funcs
.where((f) => !_isSyntheticAccessor(f, fields as List<FieldRef>))
.map<Future<Func>>(
(f) => service!.getObject(isolateId!, f.id!).then((f) async {
final func = f as Func;
final codeRef = func.code;

// Populate the [Code] objects in each function if we want to
// show code nodes in the outline.
if (showCodeNodes && codeRef != null) {
final code =
await service.getObject(isolateId, codeRef.id!) as Code;
func.code = code;
Code unoptimizedCode = code;
// `func.code` could be unoptimized code, so don't bother
// fetching it again.
if (func.unoptimizedCode != null &&
func.unoptimizedCode?.id! != code.id!) {
unoptimizedCode =
await service.getObject(
isolateId,
func.unoptimizedCode!.id!,
)
as Code;
}
func.unoptimizedCode = unoptimizedCode;
return await funcs
.where((f) => !_isSyntheticAccessor(f, fields as List<FieldRef>))
.map<Future<Func>>(
(f) => service!.getObject(isolateId!, f.id!).then((f) async {
final func = f as Func;
final codeRef = func.code;

// Populate the [Code] objects in each function if we want to
// show code nodes in the outline.
if (showCodeNodes && codeRef != null) {
final code =
await service.getObject(isolateId, codeRef.id!) as Code;
func.code = code;
Code unoptimizedCode = code;
// `func.code` could be unoptimized code, so don't bother
// fetching it again.
if (func.unoptimizedCode != null &&
func.unoptimizedCode?.id! != code.id!) {
unoptimizedCode =
await service.getObject(
isolateId,
func.unoptimizedCode!.id!,
)
as Code;
}
return func;
}),
),
);
func.unoptimizedCode = unoptimizedCode;
}
return func;
}),
)
.wait;
}

try {
if (object == null || object is Obj) {
return;
} else if (object is LibraryRef) {
final lib = await service!.getObject(isolateId!, object.id!) as Library;
final results = await Future.wait([
getObjects(lib.variables!),
getFuncs(lib.functions!, lib.variables),
]);
lib.variables = results[0].cast<Field>();
lib.functions = results[1].cast<Func>();
final (variableObjects, functionObjects) =
await (
getObjects(lib.variables!),
getFuncs(lib.functions!, lib.variables),
).wait;
lib.variables = variableObjects.cast<Field>();
lib.functions = functionObjects;
node.updateObject(lib);
} else if (object is ClassRef) {
final clazz = await service!.getObject(isolateId!, object.id!) as Class;
final results = await Future.wait([
getObjects(clazz.fields!),
getFuncs(clazz.functions!, clazz.fields),
]);
clazz.fields = results[0].cast<Field>();
clazz.functions = results[1].cast<Func>();
final (fieldObjects, functionObjects) =
await (
getObjects(clazz.fields!),
getFuncs(clazz.functions!, clazz.fields),
).wait;
clazz.fields = fieldObjects.cast<Field>();
clazz.functions = functionObjects;
node.updateObject(clazz);
} else {
final obj = await service!.getObject(isolateId!, object.id!);
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ class Variables extends StatelessWidget {
Future<void> onItemPressed(DartObjectNode v) async {
// On expansion, lazily build the variables tree for performance reasons.
if (v.isExpanded) {
await Future.wait(v.children.map(buildVariablesTree));
await v.children.map(buildVariablesTree).wait;
}
}
}
Original file line number Diff line number Diff line change
@@ -331,10 +331,10 @@ class InspectorController extends DisposableController
final detailsLocal = details;
if (detailsLocal == null) return _waitForPendingUpdateDone();

return Future.wait([
return [
_waitForPendingUpdateDone(),
detailsLocal._waitForPendingUpdateDone(),
]);
].wait;
}

// Note that this may be called after the controller is disposed. We need to handle nulls in the fields.
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@ class DiffPaneController extends DisposableController with Serializable {
final item = SnapshotDataItem(defaultName: file.name);
await _addSnapshot(HeapGraphLoaderFile(file), item);
});
await Future.wait(importers);
await importers.wait;
derived._updateValues();
}

Original file line number Diff line number Diff line change
@@ -195,7 +195,7 @@ class TracingIsolateState with Serializable {

// All profile requests need to complete before we can consider the refresh
// completed.
await Future.wait(profileRequests);
await profileRequests.wait;
}

void updateClassFilter(String newFilter, {bool force = false}) {
Original file line number Diff line number Diff line change
@@ -310,10 +310,10 @@ class NetworkController extends DisposableController

// TODO(kenz): only call these if http logging and socket profiling are not
// already enabled. Listen to service manager streams for this info.
await Future.wait([
await [
http_service.toggleHttpRequestLogging(true),
networkService.toggleSocketProfiling(true),
]);
].wait;
await togglePolling(true);
}

@@ -469,11 +469,11 @@ class NetworkController extends DisposableController
);
}

Future<void> fetchFullDataBeforeExport() => Future.wait(
filteredData.value.whereType<DartIOHttpRequestData>().map(
(item) => item.getFullRequestData(),
),
);
Future<void> fetchFullDataBeforeExport() =>
filteredData.value
.whereType<DartIOHttpRequestData>()
.map((item) => item.getFullRequestData())
.wait;
}

/// Class for managing the set of all current sockets, and
Original file line number Diff line number Diff line change
@@ -307,15 +307,15 @@ class TraceWidgetBuildsCheckbox extends StatelessWidget {
value: extension.enabledValue,
);
} else {
await Future.wait([
await [
for (final extension in tracingExtensions)
serviceConnection.serviceManager.serviceExtensionManager
.setServiceExtensionState(
extension.extension,
enabled: false,
value: extension.disabledValue,
),
]);
].wait;
}
}
}
@@ -366,7 +366,7 @@ class TraceWidgetBuildsScopeSelector extends StatelessWidget {
assert(enabled);
final extension = type!.extensionForScope;
final opposite = type.opposite.extensionForScope;
await Future.wait([
await [
serviceConnection.serviceManager.serviceExtensionManager
.setServiceExtensionState(
opposite.extension,
@@ -379,6 +379,6 @@ class TraceWidgetBuildsScopeSelector extends StatelessWidget {
enabled: true,
value: extension.enabledValue,
),
]);
].wait;
}
}
Original file line number Diff line number Diff line change
@@ -210,11 +210,10 @@ class PerformanceController extends DisposableController
await futureOr(controller);
}

final futures = <Future<void>>[];
for (final controller in _featureControllers) {
futures.add(helper(callback, controller));
}
await Future.wait(futures);
await [
for (final controller in _featureControllers)
helper(callback, controller),
].wait;
}

Future<void> setActiveFeature(
Original file line number Diff line number Diff line change
@@ -26,10 +26,11 @@ class ClassHierarchyExplorerController {
final isolateId = isolate.id!;
final classList = await service.getClassList(isolateId);
// TODO(bkonyi): we should cache the class list like we do the script list
final classes = await Future.wait([
for (final cls in classList.classes!)
service.getObject(isolateId, cls.id!).then((e) => e as Class),
]);
final classes =
await [
for (final cls in classList.classes!)
service.getObject(isolateId, cls.id!).then((e) => e as Class),
].wait;

buildHierarchy(classes);
}
Original file line number Diff line number Diff line change
@@ -33,7 +33,8 @@ class _VmICDataDisplayState extends State<VmICDataDisplay> {
final argumentsDescriptor = <ObjRef?>[];
final entries = <ObjRef?>[];

late Future<void> _initialized;
Future<void> get _initialized => _initializingCompleter.future;
final Completer<void> _initializingCompleter = Completer<void>();

@override
void initState() {
@@ -64,7 +65,7 @@ class _VmICDataDisplayState extends State<VmICDataDisplay> {
final icDataEntries = icData.entries;
if (icDataArgsDescriptor is Instance && icDataEntries is Instance) {
populateLists(icDataArgsDescriptor, icDataEntries);
_initialized = Future.value();
_initializingCompleter.complete();
return;
}

@@ -82,10 +83,10 @@ class _VmICDataDisplayState extends State<VmICDataDisplay> {
final entriesFuture = service
.getObject(isolateId, icData.entries.id!)
.then((e) => e as Instance);
_initialized = Future.wait([
argumentsDescriptorFuture,
entriesFuture,
]).then((result) => populateLists(result[0], result[1]));
final (argDescriptor, entryList) =
await (argumentsDescriptorFuture, entriesFuture).wait;
populateLists(argDescriptor, entryList);
_initializingCompleter.complete();
}

@override
Original file line number Diff line number Diff line change
@@ -67,9 +67,9 @@ class _VmInstanceDisplayState extends State<VmInstanceDisplay> {
.then((_) => _root.expand())
.then(
(_) => unawaited(
Future.wait([
[
for (final child in _root.children) buildVariablesTree(child),
]),
].wait,
),
),
);
Original file line number Diff line number Diff line change
@@ -21,12 +21,9 @@ class VMStatisticsViewController extends DisposableController {
_refreshing.value = true;
final vm = await _service.getVM();
_vm = vm;
_isolates = await Future.wait<Isolate>(
vm.isolates!.map((i) => _service.getIsolate(i.id!)),
);
_systemIsolates = await Future.wait<Isolate>(
vm.systemIsolates!.map((i) => _service.getIsolate(i.id!)),
);
_isolates = await vm.isolates!.map((i) => _service.getIsolate(i.id!)).wait;
_systemIsolates =
await vm.systemIsolates!.map((i) => _service.getIsolate(i.id!)).wait;
_refreshing.value = false;
}

Loading