Skip to content

Commit 66ef66b

Browse files
stereotype441Commit Queue
authored andcommitted
[analyzer] Remove CompilationUnitMemberTest._updateBeginToken.
The sole purpose of this method was in parser recovery tests, to adjust `CompilationUnit.beginToken` after parser recovery, to work around the fact that a mismatch in begin tokens caused `ResultComparator` to report a failure in parser recovery. Now that `ResultComparator` doesn't examine `CompilationUnit.beginToken` (see https://dart-review.googlesource.com/c/sdk/+/419521), this is unnecessary. Removing this logic allows `CompilationUnit.beginToken` to be changed to a final field. Change-Id: Ic2528b5ff9dd9f1aec0fade4499b78ff165eff02 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419680 Commit-Queue: Paul Berry <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
1 parent f05baf5 commit 66ef66b

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

pkg/analyzer/lib/src/dart/ast/ast.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3476,7 +3476,7 @@ final class CompilationUnitImpl extends AstNodeImpl
34763476
with AstNodeWithNameScopeMixin
34773477
implements CompilationUnit {
34783478
@override
3479-
Token beginToken;
3479+
final Token beginToken;
34803480

34813481
ScriptTagImpl? _scriptTag;
34823482

pkg/analyzer/test/src/fasta/recovery/code_order_test.dart

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export 'bar.dart';
115115
''', [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION], '''
116116
export 'bar.dart';
117117
class C { }
118-
''', adjustValidUnitBeforeComparison: _updateBeginToken);
118+
''');
119119
}
120120

121121
void test_declarationBeforeDirective_import() {
@@ -125,7 +125,7 @@ import 'bar.dart';
125125
''', [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION], '''
126126
import 'bar.dart';
127127
class C { }
128-
''', adjustValidUnitBeforeComparison: _updateBeginToken);
128+
''');
129129
}
130130

131131
void test_declarationBeforeDirective_part() {
@@ -135,7 +135,7 @@ part 'bar.dart';
135135
''', [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION], '''
136136
part 'bar.dart';
137137
class C { }
138-
''', adjustValidUnitBeforeComparison: _updateBeginToken);
138+
''');
139139
}
140140

141141
void test_declarationBeforeDirective_part_of() {
@@ -145,7 +145,7 @@ part of foo;
145145
''', [ParserErrorCode.DIRECTIVE_AFTER_DECLARATION], '''
146146
part of foo;
147147
class C { }
148-
''', adjustValidUnitBeforeComparison: _updateBeginToken);
148+
''');
149149
}
150150

151151
void test_exportBeforeLibrary() {
@@ -194,11 +194,6 @@ part 'foo.dart';
194194
invalidNodes: [],
195195
);
196196
}
197-
198-
CompilationUnitImpl _updateBeginToken(CompilationUnitImpl unit) {
199-
unit.beginToken = unit.declarations[0].beginToken;
200-
return unit;
201-
}
202197
}
203198

204199
/// Test how well the parser recovers when the members of an import directive

0 commit comments

Comments
 (0)