Skip to content

Commit c6a1a27

Browse files
committed
[ddc] Format sdk/lib/_internal/js_dev_runtime
Change-Id: I67314dd300cd6dd1781362f511e71c2bdd53fe38 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424689 Reviewed-by: Bob Nystrom <[email protected]>
1 parent 2178648 commit c6a1a27

File tree

13 files changed

+182
-204
lines changed

13 files changed

+182
-204
lines changed

sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -589,8 +589,8 @@ void _asyncRethrow(Object? object, _AsyncAwaitCompleter completer) {
589589
/// The [bodyFunction] argument is the continuation that should be invoked
590590
/// when the future completes.
591591
void _awaitOnObject(Object? object, _WrappedAsyncBody bodyFunction) {
592-
FutureOr<dynamic> Function(dynamic) thenCallback =
593-
(result) => bodyFunction(async_status_codes.SUCCESS, result);
592+
FutureOr<dynamic> Function(dynamic) thenCallback = (result) =>
593+
bodyFunction(async_status_codes.SUCCESS, result);
594594

595595
Function errorCallback = (dynamic error, StackTrace stackTrace) {
596596
final wrappedException = dart.createErrorWithStack(error, stackTrace);
@@ -747,10 +747,9 @@ void _asyncStarHelper(
747747
// No need to check for pause because to get here the stream either
748748
// completed normally or was cancelled. The stream cannot be paused
749749
// after either of these states.
750-
int errorCode =
751-
controller.isCanceled
752-
? async_status_codes.STREAM_WAS_CANCELED
753-
: async_status_codes.SUCCESS;
750+
int errorCode = controller.isCanceled
751+
? async_status_codes.STREAM_WAS_CANCELED
752+
: async_status_codes.SUCCESS;
754753
bodyFunction(errorCode, null);
755754
});
756755
return;

sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ import 'dart:typed_data' show Endian, Uint8List, Uint16List;
2828
// These are the additional parts of this patch library:
2929
part 'bigint_patch.dart';
3030

31-
String _symbolToString(Symbol symbol) =>
32-
symbol is PrivateSymbol
33-
? PrivateSymbol.getName(symbol)
34-
: _symbol_dev.Symbol.getName(symbol as _symbol_dev.Symbol);
31+
String _symbolToString(Symbol symbol) => symbol is PrivateSymbol
32+
? PrivateSymbol.getName(symbol)
33+
: _symbol_dev.Symbol.getName(symbol as _symbol_dev.Symbol);
3534

3635
@patch
3736
int identityHashCode(Object? object) {
@@ -667,10 +666,9 @@ class NoSuchMethodError {
667666
String receiverText = Error.safeToString(_receiver);
668667
String actualParameters = '$sb';
669668
var invocation = _invocation;
670-
var failureMessage =
671-
(invocation is dart.InvocationImpl)
672-
? invocation.failureMessage
673-
: 'method not found';
669+
var failureMessage = (invocation is dart.InvocationImpl)
670+
? invocation.failureMessage
671+
: 'method not found';
674672
return "NoSuchMethodError: '$memberName'\n"
675673
"$failureMessage\n"
676674
"Receiver: ${receiverText}\n"

sdk/lib/_internal/js_dev_runtime/patch/js_patch.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,9 @@ class JsArray<E> /*extends JsObject with ListMixin<E>*/ {
261261

262262
@patch
263263
void addAll(Iterable<E> iterable) {
264-
var list =
265-
(JS<bool>('!', '# instanceof Array', iterable))
266-
? JS<List>('', '#', iterable)
267-
: List.from(iterable);
264+
var list = (JS<bool>('!', '# instanceof Array', iterable))
265+
? JS<List>('', '#', iterable)
266+
: List.from(iterable);
268267
callMethod('push', list);
269268
}
270269

sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/classes.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,9 @@ String getClassName(Object? cls) {
229229
/// Returns the class of the instance [obj].
230230
///
231231
/// The passed [obj] is expected to have a Dart class representation.
232-
Object getClass(obj) =>
233-
_jsInstanceOf(obj, Object)
234-
? JS('', '#.constructor', obj)
235-
: JS('', '#[#]', obj, _extensionType);
232+
Object getClass(obj) => _jsInstanceOf(obj, Object)
233+
? JS('', '#.constructor', obj)
234+
: JS('', '#[#]', obj, _extensionType);
236235

237236
bool isJsInterop(obj) {
238237
if (obj == null) return false;

sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/debugger.dart

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ List<String> getLibraryMetadata(
5353
@notNull String libraryUri, [
5454
Object? libraries,
5555
]) {
56-
var library =
57-
libraries != null
58-
? _get<Object?>(libraries, libraryUri)
59-
: getLibrary('$libraryUri');
56+
var library = libraries != null
57+
? _get<Object?>(libraries, libraryUri)
58+
: getLibrary('$libraryUri');
6059
if (library == null) throw 'cannot find library for $libraryUri';
6160

6261
final classes = <String>[];
@@ -120,10 +119,9 @@ Object? getClassMetadata(
120119
Object? objectInstance,
121120
Object? libraries,
122121
]) {
123-
var library =
124-
libraries != null
125-
? _get<Object?>(libraries, libraryUri)
126-
: getLibrary('$libraryUri');
122+
var library = libraries != null
123+
? _get<Object?>(libraries, libraryUri)
124+
: getLibrary('$libraryUri');
127125
if (library == null) throw 'cannot find library for $libraryUri';
128126

129127
final rawName = name.split('<').first;
@@ -307,14 +305,13 @@ Object getObjectMetadata(@notNull Object object) {
307305
var reifiedType = getReifiedType(object);
308306
var className = typeName(reifiedType);
309307
var libraryId = null;
310-
var cls =
311-
JS<bool>('!', '#.Array.isArray(#)', global_, object)
312-
// When the object is actually represented by a JavaScript Array use
313-
// the interceptor class that matches the reified type.
314-
? JS_CLASS_REF(JSArray)
315-
: (_hasConstructor(object)
316-
? _get<Object>(object, 'constructor')
317-
: object);
308+
var cls = JS<bool>('!', '#.Array.isArray(#)', global_, object)
309+
// When the object is actually represented by a JavaScript Array use
310+
// the interceptor class that matches the reified type.
311+
? JS_CLASS_REF(JSArray)
312+
: (_hasConstructor(object)
313+
? _get<Object>(object, 'constructor')
314+
: object);
318315
if (cls != null) {
319316
libraryId = getLibraryUri(cls);
320317
}
@@ -399,8 +396,9 @@ Object getObjectMetadata(@notNull Object object) {
399396
@notNull
400397
List<String> getObjectFieldNames(@notNull Object object) {
401398
var fieldNames = <String>[];
402-
var cls =
403-
_hasConstructor(object) ? _get<Object>(object, 'constructor') : object;
399+
var cls = _hasConstructor(object)
400+
? _get<Object>(object, 'constructor')
401+
: object;
404402

405403
_collectObjectFieldNames(fieldNames, getFields(cls));
406404
return fieldNames..sort();
@@ -578,10 +576,9 @@ Shape _recordTypeShape(@notNull Type type) {
578576
String _symbolDescription(@notNull Object symbol) =>
579577
_get(symbol, 'description');
580578

581-
String? _getDartSymbolName(@notNull dynamic symbol) =>
582-
symbol is String
583-
? _getDartName(symbol)
584-
: _getDartName(_symbolDescription(symbol));
579+
String? _getDartSymbolName(@notNull dynamic symbol) => symbol is String
580+
? _getDartName(symbol)
581+
: _getDartName(_symbolDescription(symbol));
585582

586583
String? _getDartName(String? name) {
587584
if (name == null) return null;

sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart

Lines changed: 56 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ class InvocationImpl extends Invocation {
2626
this.isGetter = false,
2727
this.isSetter = false,
2828
this.failureMessage = 'method not found',
29-
}) : memberName =
30-
isSetter ? _setterSymbol(memberName) : _dartSymbol(memberName),
29+
}) : memberName = isSetter
30+
? _setterSymbol(memberName)
31+
: _dartSymbol(memberName),
3132
positionalArguments = List.unmodifiable(positionalArguments),
3233
namedArguments = _namedArgsToSymbols(namedArguments),
3334
typeArguments = List.unmodifiable(
@@ -348,10 +349,9 @@ String? _argumentErrors(Object type, @notNull List actuals, namedActuals) {
348349
var optionalPositionalCount = JS<int>('!', '#.length', optionalPositional);
349350
if (extras > optionalPositionalCount) {
350351
var maxPositionalCount = requiredCount + optionalPositionalCount;
351-
var expected =
352-
requiredCount == maxPositionalCount
353-
? '$maxPositionalCount'
354-
: '$requiredCount - $maxPositionalCount';
352+
var expected = requiredCount == maxPositionalCount
353+
? '$maxPositionalCount'
354+
: '$requiredCount - $maxPositionalCount';
355355
return 'Dynamic call with too many positional arguments. '
356356
'Expected: $expected '
357357
'Actual: $actualsCount';
@@ -378,13 +378,11 @@ String? _argumentErrors(Object type, @notNull List actuals, namedActuals) {
378378
// Verify that all required named parameters are provided an argument.
379379
Iterable requiredNames = getOwnPropertyNames(requiredNamed);
380380
if (JS<int>('!', '#.length', requiredNames) > 0) {
381-
var missingRequired =
382-
namedActuals == null
383-
? requiredNames
384-
: requiredNames.where(
385-
(name) =>
386-
!JS<bool>('!', '#.hasOwnProperty(#)', namedActuals, name),
387-
);
381+
var missingRequired = namedActuals == null
382+
? requiredNames
383+
: requiredNames.where(
384+
(name) => !JS<bool>('!', '#.hasOwnProperty(#)', namedActuals, name),
385+
);
388386
if (missingRequired.isNotEmpty) {
389387
var argNames = JS<String>('!', '#.join(", ")', missingRequired);
390388
var error =
@@ -468,39 +466,39 @@ _toDisplayName(name) => JS('', '''(() => {
468466
Symbol _dartSymbol(name) {
469467
return (JS<bool>('!', 'typeof # === "symbol"', name))
470468
? JS(
471-
'Symbol',
472-
'#(new #.new(#, #))',
473-
const_,
474-
JS_CLASS_REF(PrivateSymbol),
475-
_toSymbolName(name),
476-
name,
477-
)
469+
'Symbol',
470+
'#(new #.new(#, #))',
471+
const_,
472+
JS_CLASS_REF(PrivateSymbol),
473+
_toSymbolName(name),
474+
name,
475+
)
478476
: JS(
479-
'Symbol',
480-
'#(new #.new(#))',
481-
const_,
482-
JS_CLASS_REF(internal.Symbol),
483-
_toDisplayName(name),
484-
);
477+
'Symbol',
478+
'#(new #.new(#))',
479+
const_,
480+
JS_CLASS_REF(internal.Symbol),
481+
_toDisplayName(name),
482+
);
485483
}
486484

487485
Symbol _setterSymbol(name) {
488486
return (JS<bool>('!', 'typeof # === "symbol"', name))
489487
? JS(
490-
'Symbol',
491-
'#(new #.new(# + "=", #))',
492-
const_,
493-
JS_CLASS_REF(PrivateSymbol),
494-
_toSymbolName(name),
495-
name,
496-
)
488+
'Symbol',
489+
'#(new #.new(# + "=", #))',
490+
const_,
491+
JS_CLASS_REF(PrivateSymbol),
492+
_toSymbolName(name),
493+
name,
494+
)
497495
: JS(
498-
'Symbol',
499-
'#(new #.new(# + "="))',
500-
const_,
501-
JS_CLASS_REF(internal.Symbol),
502-
_toDisplayName(name),
503-
);
496+
'Symbol',
497+
'#(new #.new(# + "="))',
498+
const_,
499+
JS_CLASS_REF(internal.Symbol),
500+
_toDisplayName(name),
501+
);
504502
}
505503

506504
/// Checks for a valid function, receiver and arguments before calling [f].
@@ -1434,21 +1432,19 @@ declareClass(library, classIdentifier, classDeclaration) {
14341432
} else {
14351433
var newClassProto = JS<Object>('!', '#.prototype', classDeclaration);
14361434
var originalClassProto = JS<Object>('!', '#.prototype', originalClass);
1437-
var copyWhenProto =
1438-
(property) => JS<bool>(
1439-
'!',
1440-
'# || # === void 0',
1441-
!isStateBearingSymbol(property),
1442-
originalClassProto,
1443-
);
1435+
var copyWhenProto = (property) => JS<bool>(
1436+
'!',
1437+
'# || # === void 0',
1438+
!isStateBearingSymbol(property),
1439+
originalClassProto,
1440+
);
14441441
copyProperties(originalClassProto, newClassProto, copyWhen: copyWhenProto);
1445-
var copyWhen =
1446-
(property) => JS<bool>(
1447-
'!',
1448-
'# || # === void 0',
1449-
!isStateBearingSymbol(property),
1450-
originalClass,
1451-
);
1442+
var copyWhen = (property) => JS<bool>(
1443+
'!',
1444+
'# || # === void 0',
1445+
!isStateBearingSymbol(property),
1446+
originalClass,
1447+
);
14521448
copyProperties(originalClass, classDeclaration, copyWhen: copyWhen);
14531449
}
14541450
return JS<Object>('!', '#.#', library, classIdentifier);
@@ -1463,14 +1459,13 @@ declareTopLevelProperties(topLevelContainer, propertiesObject) {
14631459
if (JS<bool>('!', '# === void 0', topLevelContainer)) {
14641460
throw Exception('$topLevelContainer does not exist.');
14651461
}
1466-
var copyWhen =
1467-
(property) => JS<bool>(
1468-
'!',
1469-
'# || #.# === void 0',
1470-
!isStateBearingSymbol(property),
1471-
topLevelContainer,
1472-
property,
1473-
);
1462+
var copyWhen = (property) => JS<bool>(
1463+
'!',
1464+
'# || #.# === void 0',
1465+
!isStateBearingSymbol(property),
1466+
topLevelContainer,
1467+
property,
1468+
);
14741469
copyProperties(topLevelContainer, propertiesObject, copyWhen: copyWhen);
14751470
return topLevelContainer;
14761471
}

sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/records.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class Shape {
1414
/// This is a JS Array of JS String literals. We avoid typing this explicitly
1515
/// so it can remain unboxed, as it's only used for our internal
1616
/// representation.
17-
final List<dynamic /* String */ >? named;
17+
final List<dynamic /* String */>? named;
1818

1919
Shape(this.positionals, this.named);
2020

@@ -153,7 +153,7 @@ final _records = JS('!', 'new Map()');
153153
Shape registerShape(
154154
@notNull String shapeKey,
155155
@notNull int positionals,
156-
List<dynamic /* String */ >? named,
156+
List<dynamic /* String */>? named,
157157
) {
158158
var cached = JS<Shape?>('', '#.get(#)', shapes, shapeKey);
159159
if (cached != null) {
@@ -173,7 +173,7 @@ Shape registerShape(
173173
Object registerRecord(
174174
@notNull String shapeKey,
175175
@notNull int positionals,
176-
List<dynamic /* String */ >? named,
176+
List<dynamic /* String */>? named,
177177
) {
178178
var cached = JS('', '#.get(#)', _records, shapeKey);
179179
if (cached != null) {
@@ -249,7 +249,7 @@ Object registerRecord(
249249
Object recordLiteral(
250250
@notNull String shapeKey,
251251
@notNull int positionals,
252-
List<dynamic /* String */ >? named,
252+
List<dynamic /* String */>? named,
253253
@notNull List values,
254254
) {
255255
var shape = registerShape(shapeKey, positionals, named);

0 commit comments

Comments
 (0)