Skip to content

Commit 1d65847

Browse files
Markzipancommit-bot@chromium.org
authored andcommitted
Migrating DDC dart:developer patch files.
Change-Id: I99fb8004433ac0b518c6da23dfb7d73d2a30e769 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124421 Reviewed-by: Erik Ernst <eernst@google.com> Commit-Queue: Mark Zhou <markzipan@google.com>
1 parent 830b3d5 commit 1d65847

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

sdk_nnbd/lib/_internal/js_dev_runtime/patch/developer_patch.dart

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import 'dart:isolate';
1313

1414
@patch
1515
@ForceInline()
16-
bool debugger({bool when = true, String message}) {
16+
bool debugger({bool when = true, String? message}) {
1717
if (when) {
1818
JS('', 'debugger');
1919
}
2020
return when;
2121
}
2222

2323
@patch
24-
Object inspect(Object object) {
24+
Object? inspect(Object? object) {
2525
// Note: this log level does not show up by default in Chrome.
2626
// This is used for communication with the debugger service.
2727
JS('', 'console.debug("dart.developer.inspect", #)', object);
@@ -30,13 +30,13 @@ Object inspect(Object object) {
3030

3131
@patch
3232
void log(String message,
33-
{DateTime time,
34-
int sequenceNumber,
33+
{DateTime? time,
34+
int? sequenceNumber,
3535
int level = 0,
3636
String name = '',
37-
Zone zone,
38-
Object error,
39-
StackTrace stackTrace}) {
37+
Zone? zone,
38+
Object? error,
39+
StackTrace? stackTrace}) {
4040
Object items =
4141
JS('!', '{ message: #, name: #, level: # }', message, name, level);
4242
if (time != null) JS('', '#.time = #', items, time);
@@ -50,10 +50,10 @@ void log(String message,
5050
JS('', 'console.debug("dart.developer.log", #)', items);
5151
}
5252

53-
final _extensions = Map<String, ServiceExtensionHandler>();
53+
final _extensions = <String, ServiceExtensionHandler>{};
5454

5555
@patch
56-
ServiceExtensionHandler _lookupExtension(String method) {
56+
ServiceExtensionHandler? _lookupExtension(String method) {
5757
return _extensions[method];
5858
}
5959

@@ -79,7 +79,7 @@ _invokeExtension(String methodName, String encodedJson) {
7979
return JS('', 'new #.Promise(#)', dart.global_,
8080
(Function(Object) resolve, Function(Object) reject) async {
8181
try {
82-
var method = _lookupExtension(methodName);
82+
var method = _lookupExtension(methodName)!;
8383
var parameters = (json.decode(encodedJson) as Map).cast<String, String>();
8484
var result = await method(methodName, parameters);
8585
resolve(result._toString());
@@ -164,7 +164,7 @@ void _webServerControl(SendPort sendPort, bool enable) {
164164
}
165165

166166
@patch
167-
String _getIsolateIDFromSendPort(SendPort sendPort) {
167+
String? _getIsolateIDFromSendPort(SendPort sendPort) {
168168
return null;
169169
}
170170

@@ -178,7 +178,7 @@ class UserTag {
178178
}
179179

180180
class _FakeUserTag implements UserTag {
181-
static Map _instances = {};
181+
static final _instances = <String, _FakeUserTag>{};
182182

183183
_FakeUserTag.real(this.label);
184184

@@ -193,10 +193,7 @@ class _FakeUserTag implements UserTag {
193193
throw UnsupportedError(
194194
'UserTag instance limit (${UserTag.MAX_USER_TAGS}) reached.');
195195
}
196-
// Create a new instance and add it to the instance map.
197-
var instance = _FakeUserTag.real(label);
198-
_instances[label] = instance;
199-
return instance;
196+
return _instances[label] = _FakeUserTag.real(label);
200197
}
201198

202199
final String label;

sdk_nnbd/lib/developer/developer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ external bool debugger({bool when = true, String? message});
3939
/// Send a reference to [object] to any attached debuggers.
4040
///
4141
/// Debuggers may open an inspector on the object. Returns the argument.
42-
external Object inspect(Object? object);
42+
external Object? inspect(Object? object);
4343

4444
/// Emit a log event.
4545
///

sdk_nnbd/lib/developer/extension.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,5 @@ external void _postEvent(String eventKind, String eventData);
158158
// these into Dart code unless you can ensure that the operations will can be
159159
// done atomically. Native code lives in vm/isolate.cc-
160160
// LookupServiceExtensionHandler and RegisterServiceExtensionHandler.
161-
external ServiceExtensionHandler _lookupExtension(String method);
161+
external ServiceExtensionHandler? _lookupExtension(String method);
162162
external _registerExtension(String method, ServiceExtensionHandler handler);

sdk_nnbd/lib/developer/service.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ServiceProtocolInfo {
1919

2020
/// The Uri to access the service. If the web server is not running, this
2121
/// will be null.
22-
final Uri serverUri;
22+
final Uri? serverUri;
2323

2424
ServiceProtocolInfo(this.serverUri);
2525

@@ -77,7 +77,7 @@ class Service {
7777
///
7878
/// Returns null if the running Dart environment does not support the service
7979
/// protocol.
80-
static String getIsolateID(Isolate isolate) {
80+
static String? getIsolateID(Isolate isolate) {
8181
// TODO: When NNBD is complete, delete the following line.
8282
ArgumentError.checkNotNull(isolate, 'isolate');
8383
return _getIsolateIDFromSendPort(isolate.controlPort);
@@ -97,4 +97,4 @@ external int _getServiceMajorVersion();
9797
external int _getServiceMinorVersion();
9898

9999
/// Returns the service id for the isolate that owns [sendPort].
100-
external String _getIsolateIDFromSendPort(SendPort sendPort);
100+
external String? _getIsolateIDFromSendPort(SendPort sendPort);

0 commit comments

Comments
 (0)