@@ -49,34 +49,33 @@ import 'package:convert/convert.dart';
4949 */
5050class AnalyzerWorkerLoop extends AsyncWorkerLoop {
5151 final ResourceProvider resourceProvider;
52- final PerformanceLog logger = new PerformanceLog (null );
52+ final PerformanceLog logger = PerformanceLog (null );
5353 final String dartSdkPath;
5454 WorkerPackageBundleCache packageBundleCache;
5555
56- final StringBuffer errorBuffer = new StringBuffer ();
57- final StringBuffer outBuffer = new StringBuffer ();
56+ final StringBuffer errorBuffer = StringBuffer ();
57+ final StringBuffer outBuffer = StringBuffer ();
5858
5959 AnalyzerWorkerLoop (this .resourceProvider, AsyncWorkerConnection connection,
6060 {this .dartSdkPath})
6161 : super (connection: connection) {
62- packageBundleCache = new WorkerPackageBundleCache (
63- resourceProvider, logger, 256 * 1024 * 1024 );
62+ packageBundleCache =
63+ WorkerPackageBundleCache ( resourceProvider, logger, 256 * 1024 * 1024 );
6464 }
6565
6666 factory AnalyzerWorkerLoop .sendPort (
6767 ResourceProvider resourceProvider, SendPort sendPort,
6868 {String dartSdkPath}) {
69- AsyncWorkerConnection connection =
70- new SendPortAsyncWorkerConnection (sendPort);
71- return new AnalyzerWorkerLoop (resourceProvider, connection,
69+ AsyncWorkerConnection connection = SendPortAsyncWorkerConnection (sendPort);
70+ return AnalyzerWorkerLoop (resourceProvider, connection,
7271 dartSdkPath: dartSdkPath);
7372 }
7473
7574 factory AnalyzerWorkerLoop .std (ResourceProvider resourceProvider,
7675 {io.Stdin stdinStream, io.Stdout stdoutStream, String dartSdkPath}) {
77- AsyncWorkerConnection connection = new StdAsyncWorkerConnection (
76+ AsyncWorkerConnection connection = StdAsyncWorkerConnection (
7877 inputStream: stdinStream, outputStream: stdoutStream);
79- return new AnalyzerWorkerLoop (resourceProvider, connection,
78+ return AnalyzerWorkerLoop (resourceProvider, connection,
8079 dartSdkPath: dartSdkPath);
8180 }
8281
@@ -86,14 +85,10 @@ class AnalyzerWorkerLoop extends AsyncWorkerLoop {
8685 Future <void > analyze (
8786 CommandLineOptions options, Map <String , WorkerInput > inputs) async {
8887 var packageBundleProvider =
89- new WorkerPackageBundleProvider (packageBundleCache, inputs);
90- var buildMode = new BuildMode (
91- resourceProvider,
92- options,
93- new AnalysisStats (),
94- new ContextCache (resourceProvider, options, Driver .verbosePrint),
95- logger: logger,
96- packageBundleProvider: packageBundleProvider);
88+ WorkerPackageBundleProvider (packageBundleCache, inputs);
89+ var buildMode = BuildMode (resourceProvider, options, AnalysisStats (),
90+ ContextCache (resourceProvider, options, Driver .verbosePrint),
91+ logger: logger, packageBundleProvider: packageBundleProvider);
9792 await buildMode.analyze ();
9893 AnalysisEngine .instance.clearCaches ();
9994 }
@@ -110,7 +105,7 @@ class AnalyzerWorkerLoop extends AsyncWorkerLoop {
110105 // Prepare inputs with their digests.
111106 Map <String , WorkerInput > inputs = {};
112107 for (var input in request.inputs) {
113- inputs[input.path] = new WorkerInput (input.path, input.digest);
108+ inputs[input.path] = WorkerInput (input.path, input.digest);
114109 }
115110
116111 // Add in the dart-sdk argument if `dartSdkPath` is not null,
@@ -124,19 +119,19 @@ class AnalyzerWorkerLoop extends AsyncWorkerLoop {
124119 // Prepare options.
125120 CommandLineOptions options =
126121 CommandLineOptions .parse (arguments, printAndFail: (String msg) {
127- throw new ArgumentError (msg);
122+ throw ArgumentError (msg);
128123 });
129124
130125 // Analyze and respond.
131126 await analyze (options, inputs);
132127 String msg = _getErrorOutputBuffersText ();
133- return new WorkResponse ()
128+ return WorkResponse ()
134129 ..exitCode = EXIT_CODE_OK
135130 ..output = msg;
136131 } catch (e, st) {
137132 String msg = _getErrorOutputBuffersText ();
138133 msg += '$e \n $st ' ;
139- return new WorkResponse ()
134+ return WorkResponse ()
140135 ..exitCode = EXIT_CODE_ERROR
141136 ..output = msg;
142137 }
@@ -151,7 +146,7 @@ class AnalyzerWorkerLoop extends AsyncWorkerLoop {
151146 errorSink = errorBuffer;
152147 outSink = outBuffer;
153148 exitHandler = (int exitCode) {
154- throw new StateError ('Exit called: $exitCode ' );
149+ throw StateError ('Exit called: $exitCode ' );
155150 };
156151 await super .run ();
157152 }
@@ -200,9 +195,9 @@ class BuildMode with HasContextMixin {
200195
201196 BuildMode (this .resourceProvider, this .options, this .stats, this .contextCache,
202197 {PerformanceLog logger, PackageBundleProvider packageBundleProvider})
203- : logger = logger ?? new PerformanceLog (null ),
198+ : logger = logger ?? PerformanceLog (null ),
204199 packageBundleProvider = packageBundleProvider ??
205- new DirectPackageBundleProvider (resourceProvider),
200+ DirectPackageBundleProvider (resourceProvider),
206201 dependencyTracker = options.summaryDepsOutput != null
207202 ? DependencyTracker (options.summaryDepsOutput)
208203 : null ;
@@ -256,12 +251,12 @@ class BuildMode with HasContextMixin {
256251 io.exitCode = ErrorSeverity .ERROR .ordinal;
257252 return ErrorSeverity .ERROR ;
258253 }
259- Source source = new FileSource (file, uri);
254+ Source source = FileSource (file, uri);
260255 explicitSources.add (source);
261256 }
262257
263258 // Write summary.
264- assembler = new PackageBundleAssembler ();
259+ assembler = PackageBundleAssembler ();
265260 if (_shouldOutputSummary) {
266261 await logger.runAsync ('Build and write output summary' , () async {
267262 // Prepare all unlinked units.
@@ -277,13 +272,13 @@ class BuildMode with HasContextMixin {
277272 // Write the whole package bundle.
278273 PackageBundleBuilder bundle = assembler.assemble ();
279274 if (options.buildSummaryOutput != null ) {
280- io.File file = new io.File (options.buildSummaryOutput);
275+ io.File file = io.File (options.buildSummaryOutput);
281276 file.writeAsBytesSync (bundle.toBuffer (),
282277 mode: io.FileMode .writeOnly);
283278 }
284279 if (options.buildSummaryOutputSemantic != null ) {
285280 bundle.flushInformative ();
286- io.File file = new io.File (options.buildSummaryOutputSemantic);
281+ io.File file = io.File (options.buildSummaryOutputSemantic);
287282 file.writeAsBytesSync (bundle.toBuffer (),
288283 mode: io.FileMode .writeOnly);
289284 }
@@ -305,7 +300,7 @@ class BuildMode with HasContextMixin {
305300 }
306301
307302 if (dependencyTracker != null ) {
308- io.File file = new io.File (dependencyTracker.outputPath);
303+ io.File file = io.File (dependencyTracker.outputPath);
309304 file.writeAsStringSync (dependencyTracker.dependencies.join ('\n ' ));
310305 }
311306
@@ -399,7 +394,7 @@ class BuildMode with HasContextMixin {
399394
400395 void _createAnalysisDriver () {
401396 // Read the summaries.
402- summaryDataStore = new SummaryDataStore (< String > []);
397+ summaryDataStore = SummaryDataStore (< String > []);
403398
404399 // Adds a bundle at `path` to `summaryDataStore`.
405400 PackageBundle addBundle (String path) {
@@ -422,11 +417,11 @@ class BuildMode with HasContextMixin {
422417 PackageBundle sdkBundle;
423418 if (options.dartSdkSummaryPath != null ) {
424419 SummaryBasedDartSdk summarySdk =
425- new SummaryBasedDartSdk (options.dartSdkSummaryPath, true );
420+ SummaryBasedDartSdk (options.dartSdkSummaryPath, true );
426421 sdk = summarySdk;
427422 sdkBundle = summarySdk.bundle;
428423 } else {
429- FolderBasedDartSdk dartSdk = new FolderBasedDartSdk (
424+ FolderBasedDartSdk dartSdk = FolderBasedDartSdk (
430425 resourceProvider, resourceProvider.getFolder (options.dartSdkPath));
431426 dartSdk.analysisOptions =
432427 createAnalysisOptionsForCommandLineOptions (options, rootPath);
@@ -439,30 +434,30 @@ class BuildMode with HasContextMixin {
439434 summaryDataStore.addBundle (null , sdkBundle);
440435 });
441436
442- sourceFactory = new SourceFactory (< UriResolver > [
443- new DartUriResolver (sdk),
444- new TrackingInSummaryUriResolver (
445- new InSummaryUriResolver (resourceProvider, summaryDataStore),
437+ sourceFactory = SourceFactory (< UriResolver > [
438+ DartUriResolver (sdk),
439+ TrackingInSummaryUriResolver (
440+ InSummaryUriResolver (resourceProvider, summaryDataStore),
446441 dependencyTracker),
447- new ExplicitSourceResolver (uriToFileMap)
442+ ExplicitSourceResolver (uriToFileMap)
448443 ]);
449444
450445 analysisOptions =
451446 createAnalysisOptionsForCommandLineOptions (options, rootPath);
452447
453- AnalysisDriverScheduler scheduler = new AnalysisDriverScheduler (logger);
454- analysisDriver = new AnalysisDriver (
448+ AnalysisDriverScheduler scheduler = AnalysisDriverScheduler (logger);
449+ analysisDriver = AnalysisDriver (
455450 scheduler,
456451 logger,
457452 resourceProvider,
458- new MemoryByteStore (),
459- new FileContentOverlay (),
453+ MemoryByteStore (),
454+ FileContentOverlay (),
460455 null ,
461456 sourceFactory,
462457 analysisOptions,
463458 externalSummaries: summaryDataStore);
464459
465- declaredVariables = new DeclaredVariables .fromMap (options.definedVariables);
460+ declaredVariables = DeclaredVariables .fromMap (options.definedVariables);
466461 analysisDriver.declaredVariables = declaredVariables;
467462
468463 _createLinkedElementFactory ();
@@ -537,13 +532,13 @@ class BuildMode with HasContextMixin {
537532 */
538533 Future <void > _printErrors ({String outputPath}) async {
539534 await logger.runAsync ('Compute and print analysis errors' , () async {
540- StringBuffer buffer = new StringBuffer ();
535+ StringBuffer buffer = StringBuffer ();
541536 var severityProcessor = (AnalysisError error) =>
542537 determineProcessedSeverity (error, options, analysisOptions);
543538 ErrorFormatter formatter = options.machineFormat
544- ? new MachineErrorFormatter (buffer, options, stats,
539+ ? MachineErrorFormatter (buffer, options, stats,
545540 severityProcessor: severityProcessor)
546- : new HumanErrorFormatter (buffer, options, stats,
541+ : HumanErrorFormatter (buffer, options, stats,
547542 severityProcessor: severityProcessor);
548543 for (Source source in explicitSources) {
549544 var result = await analysisDriver.getErrors (source.fullName);
@@ -557,7 +552,7 @@ class BuildMode with HasContextMixin {
557552 StringSink sink = options.machineFormat ? errorSink : outSink;
558553 sink.write (buffer);
559554 } else {
560- new io.File (outputPath).writeAsStringSync (buffer.toString ());
555+ io.File (outputPath).writeAsStringSync (buffer.toString ());
561556 }
562557 });
563558 }
@@ -589,8 +584,8 @@ class DirectPackageBundleProvider implements PackageBundleProvider {
589584
590585 @override
591586 PackageBundle get (String path) {
592- var bytes = new io.File (path).readAsBytesSync ();
593- return new PackageBundle .fromBuffer (bytes);
587+ var bytes = io.File (path).readAsBytesSync ();
588+ return PackageBundle .fromBuffer (bytes);
594589 }
595590}
596591
@@ -616,7 +611,7 @@ class ExplicitSourceResolver extends UriResolver {
616611 if (file == null ) {
617612 return null ;
618613 } else {
619- return new FileSource (file, actualUri);
614+ return FileSource (file, actualUri);
620615 }
621616 }
622617
@@ -723,7 +718,7 @@ class WorkerPackageBundleCache {
723718 final Cache <WorkerInput , WorkerPackageBundle > _cache;
724719
725720 WorkerPackageBundleCache (this .resourceProvider, this .logger, int maxSizeBytes)
726- : _cache = new Cache <WorkerInput , WorkerPackageBundle >(
721+ : _cache = Cache <WorkerInput , WorkerPackageBundle >(
727722 maxSizeBytes, (value) => value.size);
728723
729724 /**
@@ -738,14 +733,14 @@ class WorkerPackageBundleCache {
738733 if (input == null ) {
739734 logger.writeln ('Read $path outside of the inputs.' );
740735 var bytes = resourceProvider.getFile (path).readAsBytesSync ();
741- return new PackageBundle .fromBuffer (bytes);
736+ return PackageBundle .fromBuffer (bytes);
742737 }
743738
744739 return _cache.get (input, () {
745740 logger.writeln ('Read $input .' );
746741 var bytes = resourceProvider.getFile (path).readAsBytesSync ();
747- var bundle = new PackageBundle .fromBuffer (bytes);
748- return new WorkerPackageBundle (bytes, bundle);
742+ var bundle = PackageBundle .fromBuffer (bytes);
743+ return WorkerPackageBundle (bytes, bundle);
749744 }).bundle;
750745 }
751746}
0 commit comments