Skip to content

Commit 8a9fb7c

Browse files
munificentCommit Queue
authored andcommitted
Pass in a language version when calling the formatter.
There is an upcoming version of dart_style that makes this argument required, so every DartFormatter() constructor callsite needs to pass it in. These are the last two I could find in the Dart SDK. I'm not familiar with the surrounding code, but I believe passing in DartFormatter.latestLanguage version will do the right thing: * For the benchmark script, that's generated code that we will always want to be valid on the latest version of Dart. * For the text_outline_suite, my understanding is that CFE tests that require older language versions always use the "// @Dart=x.y" comment to opt in to that version. Those comments are also respected by the formatter and override the languageVersion argument passed to the constructor. So I think passing in latestSupportedVersion will do the right thing. Bug: #56687 Change-Id: If29188df479c7b41beb68ac889d56be13a395a16 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389622 Commit-Queue: Johnni Winther <[email protected]> Auto-Submit: Bob Nystrom <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent a99556b commit 8a9fb7c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pkg/front_end/benchmarks/patterns/util.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ class SeriesSet {
241241
sb.write(']),');
242242
}
243243
sb.write(']);');
244-
return new DartFormatter().format(sb.toString());
244+
return new DartFormatter(
245+
languageVersion: DartFormatter.latestLanguageVersion)
246+
.format(sb.toString());
245247
}
246248
}
247249

pkg/front_end/test/fasta/textual_outline_suite.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,13 @@ class TextualOutline extends Step<TestDescription, TestDescription, Context> {
158158
experimentFlags.add(entry.key.name);
159159
}
160160
}
161-
result = new DartFormatter(experimentFlags: experimentFlags)
161+
162+
// Default to the latest language version. If the test should be at
163+
// an older language version, it will contain a `// @dart=x.y`
164+
// comment, which takes precedence over this argument.
165+
result = new DartFormatter(
166+
languageVersion: DartFormatter.latestLanguageVersion,
167+
experimentFlags: experimentFlags)
162168
.format(result);
163169
} catch (e, st) {
164170
formatterException = e;

0 commit comments

Comments
 (0)