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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
Expand Up @@ -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,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 {
Expand All @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ class DebuggerController extends DisposableController
);

return _StackInfo(
await Future.wait(frames.map(_createStackFrameWithLocation)),
await frames.map(_createStackFrameWithLocation).wait,
stack.truncated ?? false,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,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
Expand Up @@ -328,10 +328,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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,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}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,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);
}

Expand Down Expand Up @@ -400,11 +400,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down Expand Up @@ -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,
Expand All @@ -379,6 +379,6 @@ class TraceWidgetBuildsScopeSelector extends StatelessWidget {
enabled: true,
value: extension.enabledValue,
),
]);
].wait;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ class _VmICDataDisplayState extends State<VmICDataDisplay> {
final entriesFuture = service
.getObject(isolateId, icData.entries.id!)
.then((e) => e as Instance);
_initialized = Future.wait([
_initialized = [
argumentsDescriptorFuture,
entriesFuture,
]).then((result) => populateLists(result[0], result[1]));
].wait.then((result) => populateLists(result[0], result[1]));
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ class EditorClient extends DisposableController
}
}),
);
await Future.wait([
await [
_dtd.streamListen('Service'),
_dtd.streamListen(editorStreamName).catchError((_) {
// Because we currently call streamListen in two places (here and
// ThemeManager) this can fail. It doesn't matter if this happens,
// however we should refactor this code to better support using the DTD
// connection in multiple places without them having to coordinate.
}),
]);
].wait;
}

/// Close the connection to DTD.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Future<Set<String>> _libraryMemberAndImportsAutocompletes(
}
}
}
(await Future.wait(futures)).forEach(result.addAll);
(await futures.wait).forEach(result.addAll);
} catch (_) {
// Silently skip library completions if there is a failure.
}
Expand Down Expand Up @@ -227,7 +227,7 @@ Future<Set<String>> _libraryMemberAutocompletes(
}
}
if (futures.isNotEmpty) {
(await Future.wait(futures)).forEach(result.addAll);
(await futures.wait).forEach(result.addAll);
}
}
return result;
Expand Down
Loading
Loading