| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.source.pub_package_map_provider; | 5 library analyzer.source.pub_package_map_provider; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:core'; | 9 import 'dart:core'; |
| 10 import 'dart:io' as io; | 10 import 'dart:io' as io; |
| 11 | 11 |
| 12 import 'package:analysis_server/src/analysis_server.dart'; | |
| 13 import 'package:analyzer/file_system/file_system.dart'; | 12 import 'package:analyzer/file_system/file_system.dart'; |
| 14 import 'package:analyzer/source/package_map_provider.dart'; | 13 import 'package:analyzer/source/package_map_provider.dart'; |
| 15 import 'package:analyzer/src/dart/sdk/sdk.dart'; | 14 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
| 16 import 'package:analyzer/src/generated/engine.dart'; | 15 import 'package:analyzer/src/generated/engine.dart'; |
| 17 | 16 |
| 18 /** | 17 /** |
| 19 * The function used to run pub list. | 18 * The function used to run pub list. |
| 20 */ | 19 */ |
| 21 typedef io.ProcessResult RunPubList(Folder folder); | 20 typedef io.ProcessResult RunPubList(Folder folder); |
| 22 | 21 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 String lockPath = getPubspecLockPath(folder); | 64 String lockPath = getPubspecLockPath(folder); |
| 66 if (!resourceProvider.getFile(lockPath).exists) { | 65 if (!resourceProvider.getFile(lockPath).exists) { |
| 67 return computePackageMapError(folder); | 66 return computePackageMapError(folder); |
| 68 } | 67 } |
| 69 } | 68 } |
| 70 // TODO(paulberry) make this asynchronous so that we can (a) do other | 69 // TODO(paulberry) make this asynchronous so that we can (a) do other |
| 71 // analysis while it's in progress, and (b) time out if it takes too long | 70 // analysis while it's in progress, and (b) time out if it takes too long |
| 72 // to respond. | 71 // to respond. |
| 73 io.ProcessResult result; | 72 io.ProcessResult result; |
| 74 try { | 73 try { |
| 75 result = ServerPerformanceStatistics.pub.makeCurrentWhile(() { | 74 result = _runPubList(folder); |
| 76 return _runPubList(folder); | |
| 77 }); | |
| 78 } on io.ProcessException catch (exception, stackTrace) { | 75 } on io.ProcessException catch (exception, stackTrace) { |
| 79 AnalysisEngine.instance.logger.logInformation( | 76 AnalysisEngine.instance.logger.logInformation( |
| 80 "Error running pub $PUB_LIST_COMMAND\n$exception\n$stackTrace"); | 77 "Error running pub $PUB_LIST_COMMAND\n$exception\n$stackTrace"); |
| 81 } | 78 } |
| 82 if (result == null || result.exitCode != 0) { | 79 if (result == null || result.exitCode != 0) { |
| 83 String exitCode = | 80 String exitCode = |
| 84 result != null ? 'exit code ${result.exitCode}' : 'null'; | 81 result != null ? 'exit code ${result.exitCode}' : 'null'; |
| 85 AnalysisEngine.instance.logger | 82 AnalysisEngine.instance.logger |
| 86 .logInformation("pub $PUB_LIST_COMMAND failed: $exitCode"); | 83 .logInformation("pub $PUB_LIST_COMMAND failed: $exitCode"); |
| 87 return computePackageMapError(folder); | 84 return computePackageMapError(folder); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 String workingDirectory = folder.path; | 175 String workingDirectory = folder.path; |
| 179 int subprocessId = AnalysisEngine.instance.instrumentationService | 176 int subprocessId = AnalysisEngine.instance.instrumentationService |
| 180 .logSubprocessStart(executablePath, arguments, workingDirectory); | 177 .logSubprocessStart(executablePath, arguments, workingDirectory); |
| 181 io.ProcessResult result = io.Process | 178 io.ProcessResult result = io.Process |
| 182 .runSync(executablePath, arguments, workingDirectory: workingDirectory); | 179 .runSync(executablePath, arguments, workingDirectory: workingDirectory); |
| 183 AnalysisEngine.instance.instrumentationService.logSubprocessResult( | 180 AnalysisEngine.instance.instrumentationService.logSubprocessResult( |
| 184 subprocessId, result.exitCode, result.stdout, result.stderr); | 181 subprocessId, result.exitCode, result.stdout, result.stderr); |
| 185 return result; | 182 return result; |
| 186 } | 183 } |
| 187 } | 184 } |
| OLD | NEW |