| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer_cli.src.build_mode; | 5 library analyzer_cli.src.build_mode; |
| 6 | 6 |
| 7 import 'dart:core' hide Resource; | 7 import 'dart:core' hide Resource; |
| 8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
| 9 | 9 |
| 10 import 'package:protobuf/protobuf.dart'; | 10 import 'package:protobuf/protobuf.dart'; |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 */ | 307 */ |
| 308 class WorkerLoop { | 308 class WorkerLoop { |
| 309 static const int EXIT_CODE_OK = 0; | 309 static const int EXIT_CODE_OK = 0; |
| 310 static const int EXIT_CODE_ERROR = 15; | 310 static const int EXIT_CODE_ERROR = 15; |
| 311 | 311 |
| 312 final WorkerConnection connection; | 312 final WorkerConnection connection; |
| 313 | 313 |
| 314 final StringBuffer errorBuffer = new StringBuffer(); | 314 final StringBuffer errorBuffer = new StringBuffer(); |
| 315 final StringBuffer outBuffer = new StringBuffer(); | 315 final StringBuffer outBuffer = new StringBuffer(); |
| 316 | 316 |
| 317 WorkerLoop(this.connection); | 317 final String dartSdkPath; |
| 318 | 318 |
| 319 factory WorkerLoop.std({io.Stdin stdinStream, io.Stdout stdoutStream}) { | 319 WorkerLoop(this.connection, {this.dartSdkPath}); |
| 320 |
| 321 factory WorkerLoop.std( |
| 322 {io.Stdin stdinStream, io.Stdout stdoutStream, String dartSdkPath}) { |
| 320 stdinStream ??= io.stdin; | 323 stdinStream ??= io.stdin; |
| 321 stdoutStream ??= io.stdout; | 324 stdoutStream ??= io.stdout; |
| 322 WorkerConnection connection = | 325 WorkerConnection connection = |
| 323 new StdWorkerConnection(stdinStream, stdoutStream); | 326 new StdWorkerConnection(stdinStream, stdoutStream); |
| 324 return new WorkerLoop(connection); | 327 return new WorkerLoop(connection, dartSdkPath: dartSdkPath); |
| 325 } | 328 } |
| 326 | 329 |
| 327 /** | 330 /** |
| 328 * Performs analysis with given [options]. | 331 * Performs analysis with given [options]. |
| 329 */ | 332 */ |
| 330 void analyze(CommandLineOptions options) { | 333 void analyze(CommandLineOptions options) { |
| 334 options.dartSdkPath ??= dartSdkPath; |
| 331 new BuildMode(options, new AnalysisStats()).analyze(); | 335 new BuildMode(options, new AnalysisStats()).analyze(); |
| 332 } | 336 } |
| 333 | 337 |
| 334 /** | 338 /** |
| 335 * Perform a single loop step. Return `true` if should exit the loop. | 339 * Perform a single loop step. Return `true` if should exit the loop. |
| 336 */ | 340 */ |
| 337 bool performSingle() { | 341 bool performSingle() { |
| 338 try { | 342 try { |
| 339 WorkRequest request = connection.readRequest(); | 343 WorkRequest request = connection.readRequest(); |
| 340 if (request == null) { | 344 if (request == null) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 void writeResponse(WorkResponse response) { | 418 void writeResponse(WorkResponse response) { |
| 415 var responseBuffer = response.writeToBuffer(); | 419 var responseBuffer = response.writeToBuffer(); |
| 416 | 420 |
| 417 var writer = new CodedBufferWriter(); | 421 var writer = new CodedBufferWriter(); |
| 418 writer.writeInt32NoTag(responseBuffer.length); | 422 writer.writeInt32NoTag(responseBuffer.length); |
| 419 writer.writeRawBytes(responseBuffer); | 423 writer.writeRawBytes(responseBuffer); |
| 420 | 424 |
| 421 _stdoutStream.add(writer.toBuffer()); | 425 _stdoutStream.add(writer.toBuffer()); |
| 422 } | 426 } |
| 423 } | 427 } |
| OLD | NEW |