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 analysis.server; | 5 library analysis.server; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 * [CommunicationChannel] for analysis requests and process them. | 98 * [CommunicationChannel] for analysis requests and process them. |
99 */ | 99 */ |
100 class AnalysisServer { | 100 class AnalysisServer { |
101 /** | 101 /** |
102 * The channel from which requests are received and to which responses should | 102 * The channel from which requests are received and to which responses should |
103 * be sent. | 103 * be sent. |
104 */ | 104 */ |
105 final ServerCommunicationChannel channel; | 105 final ServerCommunicationChannel channel; |
106 | 106 |
107 /** | 107 /** |
108 * The [ResourceProvider] using which paths are converted into [Resource]s. | |
109 */ | |
110 final ResourceProvider resourceProvider; | |
111 | |
112 /** | |
108 * The [Index] for this server. | 113 * The [Index] for this server. |
109 */ | 114 */ |
110 final Index index; | 115 final Index index; |
111 | 116 |
112 /** | 117 /** |
113 * The [SearchEngine] for this server. | 118 * The [SearchEngine] for this server. |
114 */ | 119 */ |
115 SearchEngine searchEngine; | 120 SearchEngine searchEngine; |
116 | 121 |
117 /** | 122 /** |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 | 191 |
187 /** | 192 /** |
188 * Initialize a newly created server to receive requests from and send | 193 * Initialize a newly created server to receive requests from and send |
189 * responses to the given [channel]. | 194 * responses to the given [channel]. |
190 * | 195 * |
191 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are | 196 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are |
192 * propagated up the call stack. The default is true to allow analysis | 197 * propagated up the call stack. The default is true to allow analysis |
193 * exceptions to show up in unit tests, but it should be set to false when | 198 * exceptions to show up in unit tests, but it should be set to false when |
194 * running a full analysis server. | 199 * running a full analysis server. |
195 */ | 200 */ |
196 AnalysisServer(this.channel, ResourceProvider resourceProvider, | 201 AnalysisServer(this.channel, this.resourceProvider, |
197 PackageMapProvider packageMapProvider, this.index, this.defaultSdk, | 202 PackageMapProvider packageMapProvider, this.index, this.defaultSdk, |
198 {this.rethrowExceptions: true}) { | 203 {this.rethrowExceptions: true}) { |
199 searchEngine = createSearchEngine(index); | 204 searchEngine = createSearchEngine(index); |
200 operationQueue = new ServerOperationQueue(this); | 205 operationQueue = new ServerOperationQueue(this); |
201 contextDirectoryManager = new AnalysisServerContextDirectoryManager( | 206 contextDirectoryManager = new AnalysisServerContextDirectoryManager( |
202 this, resourceProvider, packageMapProvider); | 207 this, resourceProvider, packageMapProvider); |
Brian Wilkerson
2014/08/07 14:40:29
We no longer need to pass the resource provider in
| |
203 AnalysisEngine.instance.logger = new AnalysisLogger(); | 208 AnalysisEngine.instance.logger = new AnalysisLogger(); |
204 running = true; | 209 running = true; |
205 Notification notification = new Notification(SERVER_CONNECTED); | 210 Notification notification = new Notification(SERVER_CONNECTED); |
206 channel.sendNotification(notification); | 211 channel.sendNotification(notification); |
207 channel.listen(handleRequest, onDone: done, onError: error); | 212 channel.listen(handleRequest, onDone: done, onError: error); |
208 } | 213 } |
209 | 214 |
210 /** | 215 /** |
211 * Schedules execution of the given [ServerOperation]. | 216 * Schedules execution of the given [ServerOperation]. |
212 */ | 217 */ |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
555 } | 560 } |
556 return null; | 561 return null; |
557 } | 562 } |
558 | 563 |
559 /** | 564 /** |
560 * Return the [Source] of the Dart file with the given [path]. | 565 * Return the [Source] of the Dart file with the given [path]. |
561 */ | 566 */ |
562 Source getSource(String path) { | 567 Source getSource(String path) { |
563 // try SDK | 568 // try SDK |
564 { | 569 { |
565 Uri uri = toUri(path); | 570 Uri uri = resourceProvider.pathContext.toUri(path); |
566 Source sdkSource = defaultSdk.fromFileUri(uri); | 571 Source sdkSource = defaultSdk.fromFileUri(uri); |
567 if (sdkSource != null) { | 572 if (sdkSource != null) { |
568 return sdkSource; | 573 return sdkSource; |
569 } | 574 } |
570 } | 575 } |
571 // file-based source | 576 // file-based source |
572 File file = contextDirectoryManager.resourceProvider.getResource(path); | 577 File file = resourceProvider.getResource(path); |
573 return file.createSource(); | 578 return file.createSource(); |
574 } | 579 } |
575 | 580 |
576 /** | 581 /** |
577 * Returns the [CompilationUnit] of the Dart file with the given [path] that | 582 * Returns the [CompilationUnit] of the Dart file with the given [path] that |
578 * should be used to resend notifications for already resolved unit. | 583 * should be used to resend notifications for already resolved unit. |
579 * Returns `null` if the file is not a part of any context, library has not | 584 * Returns `null` if the file is not a part of any context, library has not |
580 * been yet resolved, or any problem happened. | 585 * been yet resolved, or any problem happened. |
581 */ | 586 */ |
582 CompilationUnit getResolvedCompilationUnitToResendNotification(String path) { | 587 CompilationUnit getResolvedCompilationUnitToResendNotification(String path) { |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
811 /** | 816 /** |
812 * An enumeration of the services provided by the server domain. | 817 * An enumeration of the services provided by the server domain. |
813 */ | 818 */ |
814 class ServerService extends Enum2<ServerService> { | 819 class ServerService extends Enum2<ServerService> { |
815 static const ServerService STATUS = const ServerService('STATUS', 0); | 820 static const ServerService STATUS = const ServerService('STATUS', 0); |
816 | 821 |
817 static const List<ServerService> VALUES = const [STATUS]; | 822 static const List<ServerService> VALUES = const [STATUS]; |
818 | 823 |
819 const ServerService(String name, int ordinal) : super(name, ordinal); | 824 const ServerService(String name, int ordinal) : super(name, ordinal); |
820 } | 825 } |
OLD | NEW |