Skip to content

Commit ba4e18b

Browse files
nshahanCommit Bot
authored and
Commit Bot
committed
[ddc] Remove more diffs with pkg/js_ast
- Remove lint ignores and cleanup violations when they are either in code that doesn't exist in or are already fixed in the pkg/js_ast version. - Migrate the builder_test.dart (the small test file). Issue: #46617 Change-Id: I1083235de93f028e5f338180b97308f52a45f17f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239363 Reviewed-by: Stephen Adams <[email protected]> Commit-Queue: Nicholas Shahan <[email protected]>
1 parent 31dbdd4 commit ba4e18b

File tree

6 files changed

+23
-44
lines changed

6 files changed

+23
-44
lines changed

pkg/dev_compiler/lib/src/js_ast/builder.dart

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: always_declare_return_types
65
// ignore_for_file: library_prefixes
76
// ignore_for_file: non_constant_identifier_names
87
// ignore_for_file: omit_local_variable_types
9-
// ignore_for_file: prefer_collection_literals
108
// ignore_for_file: prefer_single_quotes
119
// ignore_for_file: unnecessary_brace_in_string_interps
12-
// ignore_for_file: unnecessary_new
1310

1411
/// Utilities for building JS ASTs at runtime. Contains a builder class and a
1512
/// parser that parses part of the language.
@@ -325,7 +322,7 @@ class JsBuilder {
325322
return string(value, quote);
326323
}
327324

328-
var sb = new StringBuffer();
325+
var sb = StringBuffer();
329326

330327
for (int rune in value.runes) {
331328
final escape = _irregularEscape(rune, quote);
@@ -398,7 +395,7 @@ class JsBuilder {
398395
LiteralNumber number(num value) => LiteralNumber('$value');
399396

400397
LiteralNumber uint64(int value) {
401-
BigInt uint64Value = new BigInt.from(value).toUnsigned(64);
398+
BigInt uint64Value = BigInt.from(value).toUnsigned(64);
402399
return LiteralNumber('$uint64Value');
403400
}
404401

@@ -640,7 +637,7 @@ class MiniJsParser {
640637
'/': 5,
641638
'%': 5
642639
};
643-
static final UNARY_OPERATORS = [
640+
static final UNARY_OPERATORS = {
644641
'++',
645642
'--',
646643
'+',
@@ -651,20 +648,20 @@ class MiniJsParser {
651648
'void',
652649
'delete',
653650
'await'
654-
].toSet();
651+
};
655652

656653
static final ARROW_TOKEN = '=>';
657654
static final ELLIPSIS_TOKEN = '...';
658655

659-
static final OPERATORS_THAT_LOOK_LIKE_IDENTIFIERS = [
656+
static final OPERATORS_THAT_LOOK_LIKE_IDENTIFIERS = {
660657
'typeof',
661658
'void',
662659
'delete',
663660
'in',
664661
'instanceof',
665662
'await',
666663
'extends'
667-
].toSet();
664+
};
668665

669666
static int category(int code) {
670667
if (code >= CATEGORIES.length) return OTHER;

pkg/dev_compiler/lib/src/js_ast/js_ast.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// @dart = 2.9
6-
7-
// ignore_for_file: directives_ordering
8-
95
library js_ast;
106

11-
export 'nodes.dart';
127
export 'builder.dart';
8+
export 'nodes.dart';
139
export 'printer.dart';
1410
export 'template.dart';

pkg/dev_compiler/lib/src/js_ast/nodes.dart

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
// ignore_for_file: always_declare_return_types
6-
// ignore_for_file: always_require_non_null_named_parameters
76
// ignore_for_file: omit_local_variable_types
8-
// ignore_for_file: prefer_final_fields
9-
// ignore_for_file: prefer_initializing_formals
107
// ignore_for_file: prefer_single_quotes
118
// ignore_for_file: unnecessary_this
129

@@ -1124,9 +1121,7 @@ abstract class BindingPattern extends Expression implements VariableBinding {
11241121

11251122
class SimpleBindingPattern extends BindingPattern {
11261123
final Identifier name;
1127-
SimpleBindingPattern(Identifier name)
1128-
: name = name,
1129-
super([DestructuredVariable(name: name)]);
1124+
SimpleBindingPattern(this.name) : super([DestructuredVariable(name: name)]);
11301125

11311126
@override
11321127
T accept<T>(NodeVisitor<T> visitor) =>
@@ -1406,7 +1401,7 @@ class Identifier extends Expression implements Parameter {
14061401
throw ArgumentError.value(name, "name", "not a valid identifier");
14071402
}
14081403
}
1409-
static RegExp _identifierRE = RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$');
1404+
static final RegExp _identifierRE = RegExp(r'^[A-Za-z_$][A-Za-z_$0-9]*$');
14101405

14111406
@override
14121407
bool shadows(Set<String> names) => names.contains(name);

pkg/dev_compiler/lib/src/js_ast/printer.dart

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55
// ignore_for_file: always_declare_return_types
66
// ignore_for_file: library_prefixes
77
// ignore_for_file: omit_local_variable_types
8-
// ignore_for_file: prefer_collection_literals
9-
// ignore_for_file: prefer_final_fields
108
// ignore_for_file: prefer_initializing_formals
119
// ignore_for_file: prefer_interpolation_to_compose_strings
1210
// ignore_for_file: prefer_is_not_empty
1311
// ignore_for_file: prefer_single_quotes
14-
// ignore_for_file: unnecessary_const
1512
// ignore_for_file: use_function_type_syntax_for_parameters
1613

1714
library js_ast.printer;
@@ -89,7 +86,7 @@ class Printer implements NodeVisitor {
8986
// The current indentation level.
9087
int _indentLevel = 0;
9188
// A cache of all indentation strings used so far.
92-
List<String> _indentList = <String>[""];
89+
final List<String> _indentList = [""];
9390

9491
/// Whether the next call to [indent] should just be a no-op.
9592
bool _skipNextIndent = false;
@@ -610,15 +607,15 @@ class Printer implements NodeVisitor {
610607

611608
out(")");
612609
switch (fun.asyncModifier) {
613-
case const AsyncModifier.sync():
610+
case AsyncModifier.sync():
614611
break;
615-
case const AsyncModifier.async():
612+
case AsyncModifier.async():
616613
out(' async');
617614
break;
618-
case const AsyncModifier.syncStar():
615+
case AsyncModifier.syncStar():
619616
out(' sync*');
620617
break;
621-
case const AsyncModifier.asyncStar():
618+
case AsyncModifier.asyncStar():
622619
out(' async*');
623620
break;
624621
}
@@ -1452,8 +1449,8 @@ class VarCollector extends BaseVisitorVoid {
14521449

14531450
VarCollector()
14541451
: nested = false,
1455-
vars = Set<String>(),
1456-
params = Set<String>();
1452+
vars = {},
1453+
params = {};
14571454

14581455
void forEachVar(void fn(String v)) => vars.forEach(fn);
14591456
void forEachParam(void fn(String p)) => params.forEach(fn);
@@ -1632,7 +1629,7 @@ class MinifyRenamer implements LocalNamer {
16321629
void enterScope(Node node) {
16331630
var vars = VarCollector();
16341631
node.accept(vars);
1635-
maps.add(Map<String, String>());
1632+
maps.add({});
16361633
variableNumberStack.add(variableNumber);
16371634
parameterNumberStack.add(parameterNumber);
16381635
vars.forEachVar(declareVariable);

pkg/dev_compiler/lib/src/js_ast/template.dart

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,17 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
// ignore_for_file: always_declare_return_types
6-
// ignore_for_file: avoid_returning_null_for_void
76
// ignore_for_file: omit_local_variable_types
8-
// ignore_for_file: prefer_collection_literals
97
// ignore_for_file: prefer_generic_function_type_aliases
108
// ignore_for_file: prefer_single_quotes
11-
// ignore_for_file: unnecessary_this
129

1310
library js_ast.template;
1411

1512
import 'nodes.dart';
1613

1714
class TemplateManager {
18-
Map<String, Template> expressionTemplates = Map<String, Template>();
19-
Map<String, Template> statementTemplates = Map<String, Template>();
15+
Map<String, Template> expressionTemplates = {};
16+
Map<String, Template> statementTemplates = {};
2017

2118
TemplateManager();
2219

@@ -817,13 +814,13 @@ class InstantiatorGeneratorVisitor implements NodeVisitor<Instantiator> {
817814
@override
818815
Instantiator<ArrayBindingPattern> visitArrayBindingPattern(
819816
ArrayBindingPattern node) {
820-
List<Instantiator> makeVars = node.variables.map(this.visit).toList();
817+
List<Instantiator> makeVars = node.variables.map(visit).toList();
821818
return (a) => ArrayBindingPattern(splayNodes(makeVars, a));
822819
}
823820

824821
@override
825822
Instantiator visitObjectBindingPattern(ObjectBindingPattern node) {
826-
List<Instantiator> makeVars = node.variables.map(this.visit).toList();
823+
List<Instantiator> makeVars = node.variables.map(visit).toList();
827824
return (a) => ObjectBindingPattern(splayNodes(makeVars, a));
828825
}
829826

@@ -835,8 +832,8 @@ class InstantiatorGeneratorVisitor implements NodeVisitor<Instantiator> {
835832
/// InterpolatedNodeAnalysis determines which AST trees contain
836833
/// [InterpolatedNode]s, and the names of the named interpolated nodes.
837834
class InterpolatedNodeAnalysis extends BaseVisitorVoid {
838-
final Set<Node> containsInterpolatedNode = Set<Node>();
839-
final Set<String> holeNames = Set<String>();
835+
final Set<Node> containsInterpolatedNode = {};
836+
final Set<String> holeNames = {};
840837
int count = 0;
841838

842839
InterpolatedNodeAnalysis();
@@ -853,7 +850,6 @@ class InterpolatedNodeAnalysis extends BaseVisitorVoid {
853850
int before = count;
854851
node.visitChildren(this);
855852
if (count != before) containsInterpolatedNode.add(node);
856-
return null;
857853
}
858854

859855
@override

pkg/dev_compiler/test/js/builder_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @dart = 2.9
2-
31
import 'package:dev_compiler/src/js_ast/js_ast.dart';
42
import 'package:test/test.dart';
53

0 commit comments

Comments
 (0)