Unverified Commit 0d3b44e8 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter] replace 'checked mode' with 'debug mode' (#87408)

parent 6f9de0a9
...@@ -48,6 +48,9 @@ Future<void> run(List<String> arguments) async { ...@@ -48,6 +48,9 @@ Future<void> run(List<String> arguments) async {
print('$clock runtimeType in toString...'); print('$clock runtimeType in toString...');
await verifyNoRuntimeTypeInToString(flutterRoot); await verifyNoRuntimeTypeInToString(flutterRoot);
print('$clock debug mode instead of checked mode...');
await verifyNoCheckedMode(flutterRoot);
print('$clock Unexpected binaries...'); print('$clock Unexpected binaries...');
await verifyNoBinaries(flutterRoot); await verifyNoBinaries(flutterRoot);
...@@ -471,6 +474,29 @@ Future<void> verifyInternationalizations(String workingDirectory, String dartExe ...@@ -471,6 +474,29 @@ Future<void> verifyInternationalizations(String workingDirectory, String dartExe
} }
} }
/// Verifies that all instances of "checked mode" have been migrated to "debug mode".
Future<void> verifyNoCheckedMode(String workingDirectory) async {
final String flutterPackages = path.join(workingDirectory, 'packages');
final List<File> files = await _allFiles(flutterPackages, 'dart', minimumMatches: 400)
.where((File file) => path.extension(file.path) == '.dart')
.toList();
final List<String> problems = <String>[];
for (final File file in files) {
int lineCount = 0;
for (final String line in file.readAsLinesSync()) {
if (line.toLowerCase().contains('checked mode')) {
problems.add('${file.path}:$lineCount uses deprecated "checked mode" instead of "debug mode".');
}
lineCount += 1;
}
}
if (problems.isNotEmpty) {
exitWithError(problems);
}
}
Future<void> verifyNoRuntimeTypeInToString(String workingDirectory) async { Future<void> verifyNoRuntimeTypeInToString(String workingDirectory) async {
final String flutterLib = path.join(workingDirectory, 'packages', 'flutter', 'lib'); final String flutterLib = path.join(workingDirectory, 'packages', 'flutter', 'lib');
final Set<String> excludedFiles = <String>{ final Set<String> excludedFiles = <String>{
......
...@@ -533,7 +533,7 @@ class FlutterErrorDetails with Diagnosticable { ...@@ -533,7 +533,7 @@ class FlutterErrorDetails with Diagnosticable {
/// dump this error to the console. /// dump this error to the console.
/// ///
/// If this is true, then the default error handler would only dump this error /// If this is true, then the default error handler would only dump this error
/// to the console in checked mode. In release mode, the error is ignored. /// to the console in debug mode. In release mode, the error is ignored.
/// ///
/// This is used by certain exception handlers that catch errors that could be /// This is used by certain exception handlers that catch errors that could be
/// triggered by environmental conditions (as opposed to logic errors). For /// triggered by environmental conditions (as opposed to logic errors). For
...@@ -950,7 +950,7 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti ...@@ -950,7 +950,7 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
assert(details.exception != null); assert(details.exception != null);
bool isInDebugMode = false; bool isInDebugMode = false;
assert(() { assert(() {
// In checked mode, we ignore the "silent" flag. // In debug mode, we ignore the "silent" flag.
isInDebugMode = true; isInDebugMode = true;
return true; return true;
}()); }());
......
...@@ -33,7 +33,7 @@ typedef ServiceExtensionCallback = Future<Map<String, dynamic>> Function(Map<Str ...@@ -33,7 +33,7 @@ typedef ServiceExtensionCallback = Future<Map<String, dynamic>> Function(Map<Str
/// To use this class in an `on` clause of a mixin, inherit from it and implement /// To use this class in an `on` clause of a mixin, inherit from it and implement
/// [initInstances()]. The mixin is guaranteed to only be constructed once in /// [initInstances()]. The mixin is guaranteed to only be constructed once in
/// the lifetime of the app (more precisely, it will assert if constructed twice /// the lifetime of the app (more precisely, it will assert if constructed twice
/// in checked mode). /// in debug mode).
/// ///
/// The top-most layer used to write the application will have a concrete class /// The top-most layer used to write the application will have a concrete class
/// that inherits from [BindingBase] and uses all the various [BindingBase] /// that inherits from [BindingBase] and uses all the various [BindingBase]
......
...@@ -660,7 +660,7 @@ class MaterialApp extends StatefulWidget { ...@@ -660,7 +660,7 @@ class MaterialApp extends StatefulWidget {
/// Turns on a [GridPaper] overlay that paints a baseline grid /// Turns on a [GridPaper] overlay that paints a baseline grid
/// Material apps. /// Material apps.
/// ///
/// Only available in checked mode. /// Only available in debug mode.
/// ///
/// See also: /// See also:
/// ///
......
...@@ -29,7 +29,7 @@ abstract class Decoration with Diagnosticable { ...@@ -29,7 +29,7 @@ abstract class Decoration with Diagnosticable {
@override @override
String toStringShort() => objectRuntimeType(this, 'Decoration'); String toStringShort() => objectRuntimeType(this, 'Decoration');
/// In checked mode, throws an exception if the object is not in a /// In debug mode, throws an exception if the object is not in a
/// valid configuration. Otherwise, returns true. /// valid configuration. Otherwise, returns true.
/// ///
/// This is intended to be used as follows: /// This is intended to be used as follows:
......
...@@ -331,7 +331,7 @@ abstract class InlineSpan extends DiagnosticableTree { ...@@ -331,7 +331,7 @@ abstract class InlineSpan extends DiagnosticableTree {
@protected @protected
int? codeUnitAtVisitor(int index, Accumulator offset); int? codeUnitAtVisitor(int index, Accumulator offset);
/// In checked mode, throws an exception if the object is not in a /// In debug mode, throws an exception if the object is not in a
/// valid configuration. Otherwise, returns true. /// valid configuration. Otherwise, returns true.
/// ///
/// This is intended to be used as follows: /// This is intended to be used as follows:
......
...@@ -432,7 +432,7 @@ class TextSpan extends InlineSpan implements HitTestTarget, MouseTrackerAnnotati ...@@ -432,7 +432,7 @@ class TextSpan extends InlineSpan implements HitTestTarget, MouseTrackerAnnotati
offset.increment(text != null ? text!.length : 0); offset.increment(text != null ? text!.length : 0);
} }
/// In checked mode, throws an exception if the object is not in a valid /// In debug mode, throws an exception if the object is not in a valid
/// configuration. Otherwise, returns true. /// configuration. Otherwise, returns true.
/// ///
/// This is intended to be used as follows: /// This is intended to be used as follows:
......
...@@ -497,7 +497,7 @@ class BoxConstraints extends Constraints { ...@@ -497,7 +497,7 @@ class BoxConstraints extends Constraints {
/// ///
/// Most of the APIs on BoxConstraints expect the constraints to be /// Most of the APIs on BoxConstraints expect the constraints to be
/// normalized and have undefined behavior when they are not. In /// normalized and have undefined behavior when they are not. In
/// checked mode, many of these APIs will assert if the constraints /// debug mode, many of these APIs will assert if the constraints
/// are not normalized. /// are not normalized.
@override @override
bool get isNormalized { bool get isNormalized {
...@@ -1951,7 +1951,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1951,7 +1951,7 @@ abstract class RenderBox extends RenderObject {
return _size!; return _size!;
} }
Size? _size; Size? _size;
/// Setting the size, in checked mode, triggers some analysis of the render box, /// Setting the size, in debug mode, triggers some analysis of the render box,
/// as implemented by [debugAssertDoesMeetConstraints], including calling the intrinsic /// as implemented by [debugAssertDoesMeetConstraints], including calling the intrinsic
/// sizing methods and checking that they meet certain invariants. /// sizing methods and checking that they meet certain invariants.
@protected @protected
......
...@@ -36,7 +36,7 @@ bool debugPaintLayerBordersEnabled = false; ...@@ -36,7 +36,7 @@ bool debugPaintLayerBordersEnabled = false;
/// [RenderBox.debugHandleEvent]. /// [RenderBox.debugHandleEvent].
bool debugPaintPointersEnabled = false; bool debugPaintPointersEnabled = false;
/// Overlay a rotating set of colors when repainting layers in checked mode. /// Overlay a rotating set of colors when repainting layers in debug mode.
/// ///
/// See also: /// See also:
/// ///
...@@ -44,7 +44,7 @@ bool debugPaintPointersEnabled = false; ...@@ -44,7 +44,7 @@ bool debugPaintPointersEnabled = false;
/// areas are being excessively repainted. /// areas are being excessively repainted.
bool debugRepaintRainbowEnabled = false; bool debugRepaintRainbowEnabled = false;
/// Overlay a rotating set of colors when repainting text in checked mode. /// Overlay a rotating set of colors when repainting text in debug mode.
bool debugRepaintTextRainbowEnabled = false; bool debugRepaintTextRainbowEnabled = false;
/// The current color to overlay when repainting a layer. /// The current color to overlay when repainting a layer.
......
...@@ -1879,7 +1879,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im ...@@ -1879,7 +1879,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
/// If a subclass has a "size" (the state controlled by `parentUsesSize`, /// If a subclass has a "size" (the state controlled by `parentUsesSize`,
/// whatever it is in the subclass, e.g. the actual `size` property of /// whatever it is in the subclass, e.g. the actual `size` property of
/// [RenderBox]), and the subclass verifies that in checked mode this "size" /// [RenderBox]), and the subclass verifies that in debug mode this "size"
/// property isn't used when [debugCanParentUseSize] isn't set, then that /// property isn't used when [debugCanParentUseSize] isn't set, then that
/// subclass should override [debugResetSize] to reapply the current values of /// subclass should override [debugResetSize] to reapply the current values of
/// [debugCanParentUseSize] to that state. /// [debugCanParentUseSize] to that state.
...@@ -2023,7 +2023,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im ...@@ -2023,7 +2023,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
/// See [RepaintBoundary] for more information about how repaint boundaries function. /// See [RepaintBoundary] for more information about how repaint boundaries function.
bool get isRepaintBoundary => false; bool get isRepaintBoundary => false;
/// Called, in checked mode, if [isRepaintBoundary] is true, when either the /// Called, in debug mode, if [isRepaintBoundary] is true, when either the
/// this render object or its parent attempt to paint. /// this render object or its parent attempt to paint.
/// ///
/// This can be used to record metrics about whether the node should actually /// This can be used to record metrics about whether the node should actually
......
...@@ -3075,7 +3075,7 @@ class RenderMouseRegion extends RenderProxyBox implements MouseTrackerAnnotation ...@@ -3075,7 +3075,7 @@ class RenderMouseRegion extends RenderProxyBox implements MouseTrackerAnnotation
/// application and the rest of the application would not repaint. /// application and the rest of the application would not repaint.
/// ///
/// To tell if a particular RenderRepaintBoundary is useful, run your /// To tell if a particular RenderRepaintBoundary is useful, run your
/// application in checked mode, interacting with it in typical ways, and then /// application in debug mode, interacting with it in typical ways, and then
/// call [debugDumpRenderTree]. Each RenderRepaintBoundary will include the /// call [debugDumpRenderTree]. Each RenderRepaintBoundary will include the
/// ratio of cases where the repaint boundary was useful vs the cases where it /// ratio of cases where the repaint boundary was useful vs the cases where it
/// was not. These counts can also be inspected programmatically using /// was not. These counts can also be inspected programmatically using
...@@ -3237,7 +3237,7 @@ class RenderRepaintBoundary extends RenderProxyBox { ...@@ -3237,7 +3237,7 @@ class RenderRepaintBoundary extends RenderProxyBox {
return true; return true;
}()); }());
if (inReleaseMode) if (inReleaseMode)
properties.add(DiagnosticsNode.message('(run in checked mode to collect repaint boundary statistics)')); properties.add(DiagnosticsNode.message('(run in debug mode to collect repaint boundary statistics)'));
} }
} }
......
...@@ -385,7 +385,7 @@ abstract class RenderViewportBase<ParentDataClass extends ContainerParentDataMix ...@@ -385,7 +385,7 @@ abstract class RenderViewportBase<ParentDataClass extends ContainerParentDataMix
} }
/// Throws an exception saying that the object does not support returning /// Throws an exception saying that the object does not support returning
/// intrinsic dimensions if, in checked mode, we are not in the /// intrinsic dimensions if, in debug mode, we are not in the
/// [RenderObject.debugCheckingIntrinsics] mode. /// [RenderObject.debugCheckingIntrinsics] mode.
/// ///
/// This is used by [computeMinIntrinsicWidth] et al because viewports do not /// This is used by [computeMinIntrinsicWidth] et al because viewports do not
......
...@@ -245,7 +245,7 @@ typedef InitialRouteListFactory = List<Route<dynamic>> Function(String initialRo ...@@ -245,7 +245,7 @@ typedef InitialRouteListFactory = List<Route<dynamic>> Function(String initialRo
/// See also: /// See also:
/// ///
/// * [CheckedModeBanner], which displays a [Banner] saying "DEBUG" when /// * [CheckedModeBanner], which displays a [Banner] saying "DEBUG" when
/// running in checked mode. /// running in debug mode.
/// * [DefaultTextStyle], the text style to apply to descendant [Text] widgets /// * [DefaultTextStyle], the text style to apply to descendant [Text] widgets
/// without an explicit style. /// without an explicit style.
/// * [MediaQuery], which establishes a subtree in which media queries resolve /// * [MediaQuery], which establishes a subtree in which media queries resolve
...@@ -967,9 +967,9 @@ class WidgetsApp extends StatefulWidget { ...@@ -967,9 +967,9 @@ class WidgetsApp extends StatefulWidget {
/// Turns on an overlay that enables inspecting the widget tree. /// Turns on an overlay that enables inspecting the widget tree.
/// ///
/// The inspector is only available in checked mode as it depends on /// The inspector is only available in debug mode as it depends on
/// [RenderObject.debugDescribeChildren] which should not be called outside of /// [RenderObject.debugDescribeChildren] which should not be called outside of
/// checked mode. /// debug mode.
final bool debugShowWidgetInspector; final bool debugShowWidgetInspector;
/// Builds the widget the [WidgetInspector] uses to switch between view and /// Builds the widget the [WidgetInspector] uses to switch between view and
...@@ -981,18 +981,18 @@ class WidgetsApp extends StatefulWidget { ...@@ -981,18 +981,18 @@ class WidgetsApp extends StatefulWidget {
final InspectorSelectButtonBuilder? inspectorSelectButtonBuilder; final InspectorSelectButtonBuilder? inspectorSelectButtonBuilder;
/// {@template flutter.widgets.widgetsApp.debugShowCheckedModeBanner} /// {@template flutter.widgets.widgetsApp.debugShowCheckedModeBanner}
/// Turns on a little "DEBUG" banner in checked mode to indicate /// Turns on a little "DEBUG" banner in debug mode to indicate
/// that the app is in checked mode. This is on by default (in /// that the app is in debug mode. This is on by default (in
/// checked mode), to turn it off, set the constructor argument to /// debug mode), to turn it off, set the constructor argument to
/// false. In release mode this has no effect. /// false. In release mode this has no effect.
/// ///
/// To get this banner in your application if you're not using /// To get this banner in your application if you're not using
/// WidgetsApp, include a [CheckedModeBanner] widget in your app. /// WidgetsApp, include a [CheckedModeBanner] widget in your app.
/// ///
/// This banner is intended to deter people from complaining that your /// This banner is intended to deter people from complaining that your
/// app is slow when it's in checked mode. In checked mode, Flutter /// app is slow when it's in debug mode. In debug mode, Flutter
/// enables a large number of expensive diagnostics to aid in /// enables a large number of expensive diagnostics to aid in
/// development, and so performance in checked mode is not /// development, and so performance in debug mode is not
/// representative of what will happen in release mode. /// representative of what will happen in release mode.
/// {@endtemplate} /// {@endtemplate}
final bool debugShowCheckedModeBanner; final bool debugShowCheckedModeBanner;
......
...@@ -325,11 +325,11 @@ class Banner extends StatelessWidget { ...@@ -325,11 +325,11 @@ class Banner extends StatelessWidget {
} }
} }
/// Displays a [Banner] saying "DEBUG" when running in checked mode. /// Displays a [Banner] saying "DEBUG" when running in debug mode.
/// [MaterialApp] builds one of these by default. /// [MaterialApp] builds one of these by default.
/// Does nothing in release mode. /// Does nothing in release mode.
class CheckedModeBanner extends StatelessWidget { class CheckedModeBanner extends StatelessWidget {
/// Creates a const checked mode banner. /// Creates a const debug mode banner.
const CheckedModeBanner({ const CheckedModeBanner({
Key? key, Key? key,
required this.child, required this.child,
......
...@@ -2087,7 +2087,7 @@ abstract class BuildContext { ...@@ -2087,7 +2087,7 @@ abstract class BuildContext {
/// This getter will only return a valid result if [findRenderObject] actually /// This getter will only return a valid result if [findRenderObject] actually
/// returns a [RenderBox]. If [findRenderObject] returns a render object that /// returns a [RenderBox]. If [findRenderObject] returns a render object that
/// is not a subtype of [RenderBox] (e.g., [RenderView]), this getter will /// is not a subtype of [RenderBox] (e.g., [RenderView]), this getter will
/// throw an exception in checked mode and will return null in release mode. /// throw an exception in debug mode and will return null in release mode.
/// ///
/// Calling this getter is theoretically relatively expensive (O(N) in the /// Calling this getter is theoretically relatively expensive (O(N) in the
/// depth of the tree), but in practice is usually cheap because the tree /// depth of the tree), but in practice is usually cheap because the tree
......
...@@ -951,8 +951,8 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ...@@ -951,8 +951,8 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
/// This binding controls time, allowing tests to verify long /// This binding controls time, allowing tests to verify long
/// animation sequences without having to execute them in real time. /// animation sequences without having to execute them in real time.
/// ///
/// This class assumes it is always run in checked mode (since tests are always /// This class assumes it is always run in debug mode (since tests are always
/// run in checked mode). /// run in debug mode).
class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
@override @override
void initInstances() { void initInstances() {
......
...@@ -393,15 +393,15 @@ const String kDebugWarning = ''' ...@@ -393,15 +393,15 @@ const String kDebugWarning = '''
/// passed to the `callback`, and that handle will automatically be disposed /// passed to the `callback`, and that handle will automatically be disposed
/// after the callback is finished. /// after the callback is finished.
/// ///
/// Benchmarks must not be run in checked mode, because the performance is not /// Benchmarks must not be run in debug mode, because the performance is not
/// representative. To avoid this, this function will print a big message if it /// representative. To avoid this, this function will print a big message if it
/// is run in checked mode. Unit tests of this method pass `mayRunWithAsserts`, /// is run in debug mode. Unit tests of this method pass `mayRunWithAsserts`,
/// but it should not be used for actual benchmarking. /// but it should not be used for actual benchmarking.
/// ///
/// Example: /// Example:
/// ///
/// main() async { /// main() async {
/// assert(false); // fail in checked mode /// assert(false); // fail in debug mode
/// await benchmarkWidgets((WidgetTester tester) async { /// await benchmarkWidgets((WidgetTester tester) async {
/// await tester.pumpWidget(MyWidget()); /// await tester.pumpWidget(MyWidget());
/// final Stopwatch timer = Stopwatch()..start(); /// final Stopwatch timer = Stopwatch()..start();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment