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