Skip to content

Migrate the rest of package:dwds to null safety #1689

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

Merged
merged 18 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from 16 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
1 change: 1 addition & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
the scope.
- Remove showing uncaptured values from the stack during evaluation.
- Refactor code to break most circular dependencies between files.
- Migrate `package:dwds` to null safety.

**Breaking changes**
- Remove no longer used `ExpressionCompilerService.handler`.
Expand Down
63 changes: 24 additions & 39 deletions dwds/lib/dart_web_debug_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart = 2.9

import 'dart:async';

import 'package:logging/logging.dart';
import 'package:meta/meta.dart';
import 'package:shelf/shelf.dart';
import 'package:sse/server/sse_handler.dart';
import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';
Expand All @@ -33,7 +30,7 @@ class Dwds {
static final _logger = Logger('DWDS');
final Middleware middleware;
final Handler handler;
final DevTools _devTools;
final DevTools? _devTools;
final DevHandler _devHandler;
final AssetReader _assetReader;
final bool _enableDebugging;
Expand Down Expand Up @@ -67,53 +64,42 @@ class Dwds {
}

static Future<Dwds> start({
@required AssetReader assetReader,
@required Stream<BuildResult> buildResults,
@required ConnectionProvider chromeConnection,
@required LoadStrategy loadStrategy,
@required bool enableDebugging,
required AssetReader assetReader,
required Stream<BuildResult> buildResults,
required ConnectionProvider chromeConnection,
required LoadStrategy loadStrategy,
required bool enableDebugging,
// TODO(annagrin): make expressionCompiler argument required
// [issue 881](https://github.com/dart-lang/webdev/issues/881)
ExpressionCompiler expressionCompiler,
bool enableDebugExtension,
String hostname,
bool useSseForDebugProxy,
bool useSseForDebugBackend,
bool useSseForInjectedClient,
UrlEncoder urlEncoder,
bool spawnDds,
ExpressionCompiler? expressionCompiler,
bool enableDebugExtension = false,
String hostname = 'localhost',
bool useSseForDebugProxy = true,
bool useSseForDebugBackend = true,
bool useSseForInjectedClient = true,
UrlEncoder? urlEncoder,
bool spawnDds = true,
// TODO(elliette): DevTools is inconsistently capitalized throughout this
// file. Change all occurances of devtools/Devtools to devTools/DevTools.
bool enableDevtoolsLaunch,
DevtoolsLauncher devtoolsLauncher,
bool launchDevToolsInNewWindow,
SdkConfigurationProvider sdkConfigurationProvider,
bool emitDebugEvents,
// file. Change all occurences of devtools/Devtools to devTools/DevTools.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha we are both wrong 🤦‍♀️ Looked it up and it's spelled "occurrences" (two Rs)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol I run a spell checker and it is also wrong apparently:) So it is not just us:)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assume half the spelling mistakes in this package are mine lol. I can't spell and often forget to enable the spell checker.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We all contribute:)
I run a spell checker to please the g3 spell checker rules.

bool enableDevtoolsLaunch = true,
DevtoolsLauncher? devtoolsLauncher,
bool launchDevToolsInNewWindow = true,
SdkConfigurationProvider? sdkConfigurationProvider,
bool emitDebugEvents = true,
}) async {
hostname ??= 'localhost';
enableDebugging ??= true;
enableDebugExtension ??= false;
useSseForDebugProxy ??= true;
useSseForDebugBackend ??= true;
useSseForInjectedClient ??= true;
enableDevtoolsLaunch ??= true;
launchDevToolsInNewWindow ??= true;
spawnDds ??= true;
globalLoadStrategy = loadStrategy;
emitDebugEvents ??= true;

sdkConfigurationProvider ??= DefaultSdkConfigurationProvider();

DevTools devTools;
Future<String> extensionUri;
ExtensionBackend extensionBackend;
DevTools? devTools;
Future<String>? extensionUri;
ExtensionBackend? extensionBackend;
if (enableDebugExtension) {
final handler = useSseForDebugBackend
? SseSocketHandler(SseHandler(Uri.parse('/\$debug'),
// Proxy servers may actively kill long standing connections.
// Allow for clients to reconnect in a short window. Making the
// window too long may cause issues if the user closes a debug
// session and initites a new one during the keepAlive window.
// session and initiates a new one during the keepAlive window.
keepAlive: const Duration(seconds: 5)))
: WebSocketSocketHandler();

Expand Down Expand Up @@ -154,7 +140,6 @@ class Dwds {
urlEncoder,
useSseForDebugProxy,
useSseForInjectedClient,
serveDevTools,
expressionCompiler,
injected,
spawnDds,
Expand Down
2 changes: 0 additions & 2 deletions dwds/lib/dwds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart = 2.9

export 'dart_web_debug_service.dart' show Dwds, ConnectionProvider;
export 'src/connections/app_connection.dart' show AppConnection;
export 'src/connections/debug_connection.dart' show DebugConnection;
Expand Down
2 changes: 1 addition & 1 deletion dwds/lib/src/debugging/inspector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class AppInspector implements AppInspectorInterface {
}
final scriptRef = _scriptRefsById[objectId];
if (scriptRef != null) {
return await _getScript(scriptRef);
return _getScript(scriptRef);
}
final instance = await _instanceHelper
.instanceFor(remoteObjectFor(objectId), offset: offset, count: count);
Expand Down
Loading