Skip to content

Commit 1bf8ea0

Browse files
committed
More migration
1 parent 1705f09 commit 1bf8ea0

File tree

63 files changed

+483
-433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+483
-433
lines changed

_analysis_config/lib/analysis_options.yaml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
include: package:dart_flutter_team_lints/analysis_options.yaml
66

77
analyzer:
8-
# language:
9-
# strict-casts: true
8+
language:
9+
strict-casts: true
1010
errors:
1111
dead_code: error
1212
unused_element: error
@@ -15,27 +15,18 @@ analyzer:
1515

1616
linter:
1717
rules:
18-
- always_declare_return_types
1918
- avoid_classes_with_only_static_members
2019
- avoid_returning_this
2120
- avoid_unused_constructor_parameters
2221
- avoid_void_async
2322
- cancel_subscriptions
24-
- directives_ordering
2523
- join_return_with_assignment
2624
- library_names
2725
- literal_only_boolean_expressions
28-
- omit_local_variable_types
29-
- only_throw_errors
3026
- package_prefixed_library_names
3127
- prefer_final_in_for_each
3228
- prefer_final_locals
33-
- prefer_single_quotes
34-
# - prefer_relative_imports
3529
- prefer_void_to_null
36-
- test_types_in_equals
37-
- throw_in_finally
38-
- unawaited_futures
3930
- unnecessary_lambdas
4031
- unnecessary_parenthesis
4132
- unnecessary_statements
@@ -55,7 +46,7 @@ dart_code_metrics:
5546
- avoid-collection-methods-with-unrelated-types
5647
# - avoid-double-slash-imports
5748
- avoid-duplicate-exports
58-
# - avoid-Object?
49+
# - avoid-dynamic
5950
# - avoid-global-state # Enable.
6051
# - avoid-ignoring-return-values
6152
# - avoid-late-keyword

dwds/debug_extension/web/background.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Future<void> _handleRuntimeMessages(
6666
Function sendResponse,
6767
) async {
6868
if (jsRequest is! String) return;
69-
69+
if (sendResponse is! void Function(Object?)) return;
7070
interceptMessage<String>(
7171
message: jsRequest,
7272
expectedType: MessageType.isAuthenticated,

dwds/debug_extension/web/debug_session.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,9 @@ Future<void> _onDebuggerEvent(
278278
}
279279

280280
Future<void> _maybeConnectToDwds(int tabId, Object? params) async {
281-
final context = json.decode(JSON.stringify(params))['context'];
281+
final context =
282+
(json.decode(JSON.stringify(params)) as Map<String, Object?>)['context']!
283+
as Map<String, Object?>;
282284
final contextOrigin = context['origin'] as String?;
283285
if (contextOrigin == null) return;
284286
if (contextOrigin.contains('chrome-extension:')) return;

dwds/debug_extension/web/messaging.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import 'utils.dart';
2424
//
2525
// Prevents the message port from closing. See:
2626
// https://developer.chrome.com/docs/extensions/mv3/messaging/#simple
27-
final defaultResponse = jsify({'response': 'received'});
27+
final defaultResponse = jsify({'response': 'received'}) as Map<String, Object?>;
2828

2929
enum Script {
3030
background,

dwds/lib/dart_web_debug_service.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,9 @@ class Dwds {
146146
debugSettings.expressionCompiler,
147147
injected,
148148
DartDevelopmentServiceConfiguration(
149-
// This technically isn't correct, but DartDevelopmentServiceConfiguration.enable
150-
// is true by default, so this won't break unmigrated tools.
149+
// This technically isn't correct, but
150+
// DartDevelopmentServiceConfiguration.enable is true by default, so
151+
// this won't break unmigrated tools.
151152
// ignore: deprecated_member_use_from_same_package
152153
enable: debugSettings.spawnDds && debugSettings.ddsConfiguration.enable,
153154
// ignore: deprecated_member_use_from_same_package

dwds/lib/src/debugging/chrome_inspector.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ class ChromeAppInspector extends AppInspector {
165165
if (namedArgs.isNotEmpty) {
166166
throw UnsupportedError('Named arguments are not yet supported');
167167
}
168-
// We use the JS pseudo-variable 'arguments' to get the list of all arguments.
168+
// We use the JS pseudo-variable 'arguments' to get the list of all
169+
// arguments.
169170
final send = globalToolConfiguration.loadStrategy.dartRuntimeDebugger
170171
.callInstanceMethodJsExpression(methodName);
171172
final remote = await jsCallFunctionOn(receiver, send, positionalArgs);

dwds/lib/src/debugging/dart_runtime_debugger.dart

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ class DartRuntimeDebugger {
107107
/// Generates a JS expression for retrieving Dart Developer Extension Names.
108108
String getDartDeveloperExtensionNamesJsExpression() {
109109
return _generateJsExpression(
110-
"${_loadStrategy.loadModuleSnippet}('dart_sdk').developer._extensions.keys.toList();",
110+
"${_loadStrategy.loadModuleSnippet}('dart_sdk')'"
111+
'.developer._extensions.keys.toList();"',
111112
'dartDevEmbedder.debugger.extensionNames',
112113
);
113114
}
@@ -180,19 +181,24 @@ class DartRuntimeDebugger {
180181

181182
return _generateJsExpression(
182183
generateInstanceMethodJsExpression(
183-
'${_loadStrategy.loadModuleSnippet}("dart_sdk").dart.dsendRepl(this, "$methodName", arguments)',
184+
'${_loadStrategy.loadModuleSnippet}("dart_sdk").dart.dsendRepl(this, '
185+
'"$methodName", arguments)',
184186
),
185187
generateInstanceMethodJsExpression(
186-
'dartDevEmbedder.debugger.callInstanceMethod(this, "$methodName", arguments)',
188+
'dartDevEmbedder.debugger.callInstanceMethod(this, "$methodName", '
189+
'arguments)',
187190
),
188191
);
189192
}
190193

191194
/// Generates a JS expression to invoke a Dart extension method.
192195
String invokeExtensionJsExpression(String methodName, String encodedJson) {
193196
return _generateJsExpression(
194-
"${_loadStrategy.loadModuleSnippet}('dart_sdk').developer.invokeExtension('$methodName', JSON.stringify($encodedJson));",
195-
"dartDevEmbedder.debugger.invokeExtension('$methodName', JSON.stringify($encodedJson));",
197+
"${_loadStrategy.loadModuleSnippet}('dart_sdk')"
198+
".developer.invokeExtension('$methodName',"
199+
'JSON.stringify($encodedJson));',
200+
"dartDevEmbedder.debugger.invokeExtension('$methodName',"
201+
'JSON.stringify($encodedJson));',
196202
);
197203
}
198204

@@ -209,14 +215,15 @@ class DartRuntimeDebugger {
209215
})();
210216
''';
211217

212-
// `callLibraryMethod` expects an array of arguments. Chrome DevTools spreads
213-
// arguments individually when calling functions. This code reconstructs the
214-
// expected argument array.
218+
// `callLibraryMethod` expects an array of arguments. Chrome DevTools
219+
// spreads arguments individually when calling functions. This code
220+
// reconstructs the expected argument array.
215221
return _generateJsExpression(
216222
findLibraryExpression,
217223
_wrapWithBundleLoader(
218224
'',
219-
'callLibraryMethod("$libraryUri", "$methodName", Array.from(arguments))',
225+
'callLibraryMethod("$libraryUri", "$methodName", '
226+
'Array.from(arguments))',
220227
),
221228
);
222229
}

dwds/lib/src/debugging/debugger.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ class Debugger {
424424
// void _showPausedOverlay() async {
425425
// if (_pausedOverlayVisible) return;
426426
// handleErrorIfPresent(await _remoteDebugger?.sendCommand('DOM.enable'));
427+
// ignore: lines_longer_than_80_chars
427428
// handleErrorIfPresent(await _remoteDebugger?.sendCommand('Overlay.enable'));
428429
// handleErrorIfPresent(await _remoteDebugger
429430
// ?.sendCommand('Overlay.setPausedInDebuggerMessage', params: {
@@ -435,6 +436,7 @@ class Debugger {
435436
// Removes the paused at breakpoint overlay from the application.
436437
// void _hidePausedOverlay() async {
437438
// if (!_pausedOverlayVisible) return;
439+
// ignore: lines_longer_than_80_chars
438440
// handleErrorIfPresent(await _remoteDebugger?.sendCommand('Overlay.disable'));
439441
// _pausedOverlayVisible = false;
440442
// }
@@ -500,7 +502,8 @@ class Debugger {
500502
void logAnyFrameErrors({required String frameType}) {
501503
if (_frameErrorCount > 0) {
502504
logger.warning(
503-
'Error calculating Dart variables for $_frameErrorCount $frameType frames.',
505+
'Error calculating Dart variables for $_frameErrorCount $frameType '
506+
'frames.',
504507
);
505508
}
506509
_frameErrorCount = 0;

dwds/lib/src/debugging/execution_context.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ class RemoteDebuggerExecutionContext extends ExecutionContext {
8989
_remoteDebugger
9090
.eventStream('Runtime.executionContextCreated', (e) {
9191
// Parse and add the context ID to the stream.
92-
// If we cannot detect or parse the context ID, add `null` to the stream
93-
// to indicate an error context - those will be skipped when trying to find
94-
// the dart context, with a warning.
92+
// If we cannot detect or parse the context ID, add `null` to the
93+
// stream to indicate an error context - those will be skipped when
94+
// trying to find the dart context, with a warning.
9595
final id = (e.params?['context'] as Map<String, Object?>?)?['id']
9696
?.toString();
9797
final parsedId = id == null ? null : int.parse(id);

dwds/lib/src/debugging/frame_computer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class FrameComputer {
113113
'url': callFrame.url,
114114
'functionName': callFrame.functionName,
115115
'location': location.json,
116-
'scopeChain': [],
116+
'scopeChain': <Map<String, Object?>>[],
117117
});
118118

119119
final frame = await debugger.calculateDartFrameFor(

0 commit comments

Comments
 (0)