@@ -37,7 +37,8 @@ class AnalysisServer {
37
37
this .enabledExperiments = const [],
38
38
this .disableStatusNotificationDebouncing = false ,
39
39
this .suppressAnalytics = false ,
40
- });
40
+ bool useAotSnapshot = false ,
41
+ }) : _useAotSnapshot = useAotSnapshot;
41
42
42
43
final String ? cacheDirectoryPath;
43
44
final File ? packagesFile;
@@ -48,6 +49,7 @@ class AnalysisServer {
48
49
final List <String > enabledExperiments;
49
50
final bool disableStatusNotificationDebouncing;
50
51
final bool suppressAnalytics;
52
+ final bool _useAotSnapshot;
51
53
52
54
Process ? _process;
53
55
@@ -107,24 +109,8 @@ class AnalysisServer {
107
109
/// Starts the process and returns the pid for it.
108
110
Future <int > start ({bool setAnalysisRoots = true }) async {
109
111
preAnalysisServerStart? .call (commandName, analysisRoots, argResults);
110
- final command = [
111
- sdk.analysisServerSnapshot,
112
- if (suppressAnalytics) '--${Driver .SUPPRESS_ANALYTICS_FLAG }' ,
113
- '--${Driver .CLIENT_ID }=dart-$commandName ' ,
114
- '--disable-server-feature-completion' ,
115
- '--disable-server-feature-search' ,
116
- if (disableStatusNotificationDebouncing)
117
- '--disable-status-notification-debouncing' ,
118
- '--disable-silent-analysis-exceptions' ,
119
- '--sdk' ,
120
- sdkPath.path,
121
- if (cacheDirectoryPath != null ) '--cache=$cacheDirectoryPath ' ,
122
- if (packagesFile != null ) '--packages=${packagesFile !.path }' ,
123
- if (enabledExperiments.isNotEmpty)
124
- '--$experimentFlagName =${enabledExperiments .join (',' )}'
125
- ];
126
112
127
- final process = await startDartProcess (sdk, command );
113
+ final process = await _startProcess ( );
128
114
_process = process;
129
115
_shutdownResponseReceived = false ;
130
116
// This callback hookup can't throw.
@@ -206,6 +192,32 @@ class AnalysisServer {
206
192
return process.pid;
207
193
}
208
194
195
+ Future <Process > _startProcess () {
196
+ final executable = _useAotSnapshot ? sdk.dartAotRuntime : sdk.dart;
197
+ final arguments = [
198
+ if (_useAotSnapshot)
199
+ sdk.analysisServerAotSnapshot
200
+ else
201
+ sdk.analysisServerSnapshot,
202
+ if (suppressAnalytics) '--${Driver .SUPPRESS_ANALYTICS_FLAG }' ,
203
+ '--${Driver .CLIENT_ID }=dart-$commandName ' ,
204
+ '--disable-server-feature-completion' ,
205
+ '--disable-server-feature-search' ,
206
+ if (disableStatusNotificationDebouncing)
207
+ '--disable-status-notification-debouncing' ,
208
+ '--disable-silent-analysis-exceptions' ,
209
+ '--sdk' ,
210
+ sdkPath.path,
211
+ if (cacheDirectoryPath != null ) '--cache=$cacheDirectoryPath ' ,
212
+ if (packagesFile != null ) '--packages=${packagesFile !.path }' ,
213
+ if (enabledExperiments.isNotEmpty)
214
+ '--$experimentFlagName =${enabledExperiments .join (',' )}' ,
215
+ ];
216
+
217
+ log.trace ('$executable ${arguments .join (' ' )}' );
218
+ return Process .start (executable, arguments);
219
+ }
220
+
209
221
Future <String > getVersion () {
210
222
return _sendCommand ('server.getVersion' )
211
223
.then ((response) => response['version' ]);
0 commit comments