[frontend_server] Migrate to new constructor decl syntax.

(Part of https://github.com/dart-lang/sdk/issues/63288)

This change migrates the frontend_server package to use the new
constructor declaration syntax, described in
https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md#abbreviations-of-in-body-constructor-declarations.

This change was performed in an automated fashion, by (a) bumping the
package's SDK constraint to `3.13.0-0`, (b) enabling the lints
`unnecessary_type_name_in_constructor` and
`unnecessary_const_in_enum_constructor`, (c) fixing the resulting lint
failures using `dart fix`, and then (d) reformatting the affected
files.

To ease code review, I've reverted unrelated formatting changes.

Change-Id: Icbc924a1faae2f1c8fe0d5fa07bb9bd66a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/508369
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Paul Berry
2026-06-01 17:48:27 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent e82bd2c8ed
commit 7a5c71ba05
12 changed files with 33 additions and 43 deletions
@@ -4,6 +4,8 @@ analyzer:
linter: linter:
rules: rules:
- unnecessary_type_name_in_constructor
- unnecessary_const_in_enum_constructor
- collection_methods_unrelated_type - collection_methods_unrelated_type
- curly_braces_in_flow_control_structures - curly_braces_in_flow_control_structures
- prefer_adjacent_string_concatenation - prefer_adjacent_string_concatenation
+4 -7
View File
@@ -160,7 +160,7 @@ class ComputeKernelResult {
final bool succeeded; final bool succeeded;
final fe.InitializedCompilerState? previousState; final fe.InitializedCompilerState? previousState;
ComputeKernelResult(this.succeeded, this.previousState); new(this.succeeded, this.previousState);
} }
/// Computes a kernel file based on [args]. /// Computes a kernel file based on [args].
@@ -600,7 +600,7 @@ class _FakeFileSystem extends FileSystem {
final Map<Uri, Uri> redirectsFromTo = {}; final Map<Uri, Uri> redirectsFromTo = {};
final Set<Uri> redirectsTo = {}; final Set<Uri> redirectsTo = {};
final FileSystem fs; final FileSystem fs;
_FakeFileSystem(this.fs); new(this.fs);
void addRedirect(Uri from, Uri to) { void addRedirect(Uri from, Uri to) {
redirectsTo.add(to); redirectsTo.add(to);
@@ -621,11 +621,8 @@ class DevCompilerSummaryTarget extends DevCompilerTarget with SummaryMixin {
@override @override
final bool excludeNonSources; final bool excludeNonSources;
DevCompilerSummaryTarget( new(this.sources, this.excludeNonSources, TargetFlags targetFlags)
this.sources, : super(targetFlags);
this.excludeNonSources,
TargetFlags targetFlags,
) : super(targetFlags);
@override @override
bool isModularlyCompatibleWith(Target other) { bool isModularlyCompatibleWith(Target other) {
+1 -1
View File
@@ -573,7 +573,7 @@ class BinaryPrinterFactory {
} }
class FrontendCompiler implements CompilerInterface { class FrontendCompiler implements CompilerInterface {
FrontendCompiler( new(
StringSink? outputStream, { StringSink? outputStream, {
BinaryPrinterFactory? printerFactory, BinaryPrinterFactory? printerFactory,
this.transformer, this.transformer,
@@ -43,11 +43,7 @@ final class ResidentCompilerInfo {
); );
} }
ResidentCompilerInfo._({ new _({required this.sdkHash, required this.port, required this.address});
required this.sdkHash,
required this.port,
required this.address,
});
} }
typedef CachedDillAndCompilerOptionsPaths = ({ typedef CachedDillAndCompilerOptionsPaths = ({
@@ -152,7 +148,7 @@ final class CompileResult {
/// The output lines produced by the compiler, if any. /// The output lines produced by the compiler, if any.
final List<String> compilerOutputLines; final List<String> compilerOutputLines;
CompileResult({ new({
required this.outputDill, required this.outputDill,
required this.errorCount, required this.errorCount,
this.compilerOutputLines = const [], this.compilerOutputLines = const [],
@@ -171,7 +167,7 @@ final class CompileExpressionResult {
/// The output lines produced by the compiler, if any. /// The output lines produced by the compiler, if any.
final List<String> compilerOutputLines; final List<String> compilerOutputLines;
CompileExpressionResult({ new({
required this.kernelBytes, required this.kernelBytes,
required this.errorCount, required this.errorCount,
this.compilerOutputLines = const [], this.compilerOutputLines = const [],
@@ -184,7 +180,7 @@ final class CompileException implements Exception {
/// The error message from the compiler. /// The error message from the compiler.
final String message; final String message;
CompileException(this.message); new(this.message);
@override @override
String toString() => 'CompileException: $message'; String toString() => 'CompileException: $message';
@@ -34,7 +34,7 @@ import 'strong_components.dart';
/// an incremental build, a different file is written for each which contains /// an incremental build, a different file is written for each which contains
/// only the updated libraries. /// only the updated libraries.
class IncrementalJavaScriptBundler { class IncrementalJavaScriptBundler {
IncrementalJavaScriptBundler( new(
this._fileSystem, this._fileSystem,
this._loadedLibraries, this._loadedLibraries,
this._fileSystemScheme, { this._fileSystemScheme, {
@@ -97,7 +97,7 @@ class ResidentCompiler {
File get _outputDill => File get _outputDill =>
new File(_compileOptions.option(ResidentFrontendServer._outputString)!); new File(_compileOptions.option(ResidentFrontendServer._outputString)!);
ResidentCompiler(this._entryPoint, this._compileOptions) { new(this._entryPoint, this._compileOptions) {
_compiler = new FrontendCompiler(_compilerOutput); _compiler = new FrontendCompiler(_compilerOutput);
updateState(_compileOptions); updateState(_compileOptions);
} }
@@ -26,12 +26,7 @@ import 'package:kernel/util/graph.dart';
/// On incremental updates, we completely recompute the strongly connected /// On incremental updates, we completely recompute the strongly connected
/// components, but only for the partial component produced. /// components, but only for the partial component produced.
class StrongComponents { class StrongComponents {
StrongComponents( new(this.component, this.loadedLibraries, this.mainUri, [this.fileSystem]);
this.component,
this.loadedLibraries,
this.mainUri, [
this.fileSystem,
]);
/// The Component that is being compiled. /// The Component that is being compiled.
/// ///
@@ -110,7 +105,7 @@ class StrongComponents {
} }
class _LibraryGraph implements Graph<Library> { class _LibraryGraph implements Graph<Library> {
_LibraryGraph(this.library, this.loadedLibraries, [this._partialComponent]); new(this.library, this.loadedLibraries, [this._partialComponent]);
final Library library; final Library library;
final Set<Library> loadedLibraries; final Set<Library> loadedLibraries;
+1 -1
View File
@@ -4,7 +4,7 @@ description: A resident kernel compiler
publish_to: none publish_to: none
environment: environment:
sdk: '^3.12.0-0' sdk: '^3.13.0-0'
resolution: workspace resolution: workspace
@@ -451,7 +451,7 @@ enum Compiler {
} }
class _Test { class _Test {
_Test({ new({
required this.name, required this.name,
required this.dartSource, required this.dartSource,
required this.sdkRoot, required this.sdkRoot,
@@ -531,7 +531,7 @@ class _Test {
/// Equality that casts all [num]'s to [double] before comparing. /// Equality that casts all [num]'s to [double] before comparing.
class Dart2JSDeepCollectionEquality extends DeepCollectionEquality { class Dart2JSDeepCollectionEquality extends DeepCollectionEquality {
const Dart2JSDeepCollectionEquality(); const new();
@override @override
bool equals(Object? e1, Object? e2) { bool equals(Object? e1, Object? e2) {
@@ -188,7 +188,7 @@ class _QueueEntry {
final File packageConfig; final File packageConfig;
final Directory testDir; final Directory testDir;
_QueueEntry(this.files, this.packageConfig, this.testDir); new(this.files, this.packageConfig, this.testDir);
} }
Future<void> _processFiles( Future<void> _processFiles(
@@ -446,7 +446,7 @@ Future<List<String>> attemptStuff(
// (expect can only be used in tests via the test framework). // (expect can only be used in tests via the test framework).
class OutputParser { class OutputParser {
OutputParser(this._receivedResults); new(this._receivedResults);
bool expectSources = true; bool expectSources = true;
final StreamController<Result> _receivedResults; final StreamController<Result> _receivedResults;
@@ -500,7 +500,7 @@ class Result {
String? status; String? status;
List<String>? sources; List<String>? sources;
Result(this.status, this.sources); new(this.status, this.sources);
void expectNoErrors({String? filename}) { void expectNoErrors({String? filename}) {
CompilationResult result = new CompilationResult.parse(status!); CompilationResult result = new CompilationResult.parse(status!);
@@ -519,7 +519,7 @@ class CompilationResult {
late String filename; late String filename;
late int errorsCount; late int errorsCount;
CompilationResult.parse(String? filenameAndErrorCount) { new parse(String? filenameAndErrorCount) {
if (filenameAndErrorCount == null) { if (filenameAndErrorCount == null) {
return; return;
} }
@@ -579,7 +579,7 @@ class _MockFile implements File {
final File _f; final File _f;
_MockIOSink? writeSink; _MockIOSink? writeSink;
_MockFile(this._f); new(this._f);
@override @override
bool existsSync() { bool existsSync() {
@@ -23,7 +23,7 @@ class Options {
final String flutterDir; final String flutterDir;
final String flutterPlatformDir; final String flutterPlatformDir;
Options( new(
this.configurationName, this.configurationName,
this.verbose, this.verbose,
this.printFailureLog, this.printFailureLog,
@@ -86,7 +86,7 @@ class ResultLogger extends Logger {
final Map<String, Stopwatch> stopwatches = {}; final Map<String, Stopwatch> stopwatches = {};
final List<String> _log = <String>[]; final List<String> _log = <String>[];
ResultLogger(this.suiteConfiguration); new(this.suiteConfiguration);
void handleTestResult(String testName, bool matchedExpectations) { void handleTestResult(String testName, bool matchedExpectations) {
String fullTestName = "$suiteNamePrefix/$testName"; String fullTestName = "$suiteNamePrefix/$testName";
@@ -172,7 +172,7 @@ class SuiteConfiguration {
final String flutterDir; final String flutterDir;
final String flutterPlatformDir; final String flutterPlatformDir;
const SuiteConfiguration( const new(
this.resultsPort, this.resultsPort,
this.logsPort, this.logsPort,
this.verbose, this.verbose,
@@ -54,7 +54,7 @@ void nopVerifyRecompileDelta(String? entryPoint) {}
void nopVerify() {} void nopVerify() {}
class _MockedCompiler implements CompilerInterface { class _MockedCompiler implements CompilerInterface {
_MockedCompiler({ new({
this.verifyCompile = nopVerifyCompile, this.verifyCompile = nopVerifyCompile,
this.verifyRecompileDelta = nopVerifyRecompileDelta, this.verifyRecompileDelta = nopVerifyRecompileDelta,
this.verifyInvalidate = nopVerifyInvalidate, this.verifyInvalidate = nopVerifyInvalidate,
@@ -3845,7 +3845,7 @@ class CompilationResult {
late String filename; late String filename;
int errorsCount = 0; int errorsCount = 0;
CompilationResult.parse(String? filenameAndErrorCount) { new parse(String? filenameAndErrorCount) {
if (filenameAndErrorCount == null) { if (filenameAndErrorCount == null) {
return; return;
} }
@@ -3864,7 +3864,7 @@ class OutputParser {
String? _boundaryKey; String? _boundaryKey;
bool _readingSources = false; bool _readingSources = false;
OutputParser(this._receivedResults); new(this._receivedResults);
void listener(String s) { void listener(String s) {
if (_boundaryKey == null) { if (_boundaryKey == null) {
@@ -3910,7 +3910,7 @@ class Result {
String? status; String? status;
List<String> sources; List<String> sources;
Result(this.status, this.sources); new(this.status, this.sources);
void expectNoErrors({String? filename}) { void expectNoErrors({String? filename}) {
CompilationResult result = new CompilationResult.parse(status); CompilationResult result = new CompilationResult.parse(status);
@@ -3927,7 +3927,7 @@ Matcher not(Matcher matcher) => new NotMatcher(matcher);
class NotMatcher extends Matcher { class NotMatcher extends Matcher {
final Matcher matcher; final Matcher matcher;
const NotMatcher(this.matcher); const new(this.matcher);
@override @override
Description describe(Description description) => Description describe(Description description) =>
@@ -3947,7 +3947,7 @@ class FrontendServer {
final StreamController<Result> receivedResults; final StreamController<Result> receivedResults;
final OutputParser outputParser; final OutputParser outputParser;
factory FrontendServer() { factory() {
final StreamController<List<int>> inputStreamController = final StreamController<List<int>> inputStreamController =
new StreamController<List<int>>(); new StreamController<List<int>>();
final StreamController<List<int>> stdoutStreamController = final StreamController<List<int>> stdoutStreamController =
@@ -3968,7 +3968,7 @@ class FrontendServer {
); );
} }
FrontendServer._internal( new _internal(
this.inputStreamController, this.inputStreamController,
this.stdoutStreamController, this.stdoutStreamController,
this.ioSink, this.ioSink,