[tool] Fix deprecated API calls within tool (#168200)

Done by temporarily enabling the associated lints
This commit is contained in:
Kevin Moore 2025-05-13 12:27:22 -05:00 committed by GitHub
parent 40e990fd17
commit a1c4d99e4e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 25 additions and 35 deletions

View File

@ -64,7 +64,7 @@ Future<int> run(
flutterVersion ?? globals.flutterVersion.getVersionString(redactUnknownBranches: true);
Object? firstError;
StackTrace? firstStackTrace;
return runZoned<Future<int>>(
return runZonedGuarded<Future<int>>(
() async {
try {
if (args.contains('--disable-analytics') && args.contains('--enable-analytics')) {
@ -122,7 +122,7 @@ Future<int> run(
);
}
},
onError: (Object error, StackTrace stackTrace) async {
(Object error, StackTrace stackTrace) async {
// If sending a crash report throws an error into the zone, we don't want
// to re-try sending the crash report with *that* error. Rather, we want
// to send the original error that triggered the crash report.
@ -138,7 +138,7 @@ Future<int> run(
shutdownHooks,
);
},
);
)!;
}, overrides: overrides);
}

View File

@ -103,24 +103,19 @@ Future<T> asyncGuard<T>(Future<T> Function() fn, {Function? onError}) {
}
}
runZoned<void>(
() async {
try {
final T result = await fn();
if (!completer.isCompleted) {
completer.complete(result);
}
// This catches all exceptions so that they can be propagated to the
// caller-supplied error handling or the completer.
// ignore: avoid_catches_without_on_clauses, forwards to Future
} catch (e, s) {
handleError(e, s);
runZonedGuarded<void>(() async {
try {
final T result = await fn();
if (!completer.isCompleted) {
completer.complete(result);
}
},
onError: (Object e, StackTrace s) {
// This catches all exceptions so that they can be propagated to the
// caller-supplied error handling or the completer.
// ignore: avoid_catches_without_on_clauses, forwards to Future
} catch (e, s) {
handleError(e, s);
},
);
}
}, handleError);
return completer.future;
}

View File

@ -28,10 +28,7 @@ abstract class FlutterBaseDebugAdapter
super.enableAuthCodes,
super.logger,
super.onError,
}) : flutterSdkRoot = Cache.flutterRoot!,
// Always disable in the DAP layer as it's handled in the spawned
// 'flutter' process.
super(enableDds: false) {
}) : flutterSdkRoot = Cache.flutterRoot! {
configureOrgDartlangSdkMappings();
}

View File

@ -1154,7 +1154,7 @@ void main() {
// device.startApp() asynchronously calls throwToolExit, so we
// catch it in a zone.
unawaited(
runZoned<Future<void>?>(
runZonedGuarded<Future<void>?>(
() {
unawaited(
device.startApp(
@ -1166,7 +1166,7 @@ void main() {
);
return null;
},
onError: (Object error, StackTrace stack) {
(Object error, StackTrace stack) {
expect(error.toString(), contains(jITCrashFailureInstructions('iOS 18.4')));
completer.complete();
},

View File

@ -72,7 +72,7 @@ void main() {
// runner.run() asynchronously calls the exit function set above, so we
// catch it in a zone.
unawaited(
runZoned<Future<void>?>(
runZonedGuarded<Future<void>?>(
() {
unawaited(
runner.run(
@ -86,7 +86,7 @@ void main() {
);
return null;
},
onError: (Object error, StackTrace stack) {
(Object error, StackTrace stack) {
expect(firstExitCode, isNotNull);
expect(firstExitCode, isNot(0));
expect(error.toString(), 'Exception: test exit');
@ -133,7 +133,7 @@ void main() {
// runner.run() asynchronously calls the exit function set above, so we
// catch it in a zone.
unawaited(
runZoned<Future<void>?>(
runZonedGuarded<Future<void>?>(
() {
unawaited(
runner.run(
@ -149,7 +149,7 @@ void main() {
);
return null;
},
onError: (Object error, StackTrace stack) {
(Object error, StackTrace stack) {
expect(firstExitCode, isNotNull);
expect(firstExitCode, isNot(0));
expect(error.toString(), 'Exception: test exit');
@ -190,7 +190,7 @@ void main() {
// runner.run() asynchronously calls the exit function set above, so we
// catch it in a zone.
unawaited(
runZoned<Future<void>?>(
runZonedGuarded<Future<void>?>(
() {
unawaited(
runner.run(
@ -204,7 +204,7 @@ void main() {
);
return null;
},
onError: (Object error, StackTrace stack) {
(Object error, StackTrace stack) {
expect(firstExitCode, isNotNull);
expect(firstExitCode, isNot(0));
expect(error.toString(), 'Exception: test exit');
@ -297,7 +297,7 @@ void main() {
// runner.run() asynchronously calls the exit function set above, so we
// catch it in a zone.
unawaited(
runZoned<Future<void>?>(
runZonedGuarded<Future<void>?>(
() {
unawaited(
runner.run(
@ -311,7 +311,7 @@ void main() {
);
return null;
},
onError: (Object error, StackTrace stack) {
(Object error, StackTrace stack) {
expect(firstExitCode, isNotNull);
expect(firstExitCode, isNot(0));
expect(error.toString(), 'Exception: test exit');

View File

@ -26,7 +26,6 @@ class SwiftPackageManagerUtils {
'Failed to enable Swift Package Manager: \n'
'stdout: \n${result.stdout}\n'
'stderr: \n${result.stderr}\n',
verbose: true,
);
}
@ -45,7 +44,6 @@ class SwiftPackageManagerUtils {
'Failed to disable Swift Package Manager: \n'
'stdout: \n${result.stdout}\n'
'stderr: \n${result.stderr}\n',
verbose: true,
);
}