| 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 | 8 |
| 9 import 'package:analysis_server/src/analysis_logger.dart'; | 9 import 'package:analysis_server/src/analysis_logger.dart'; |
| 10 import 'package:analysis_server/src/channel.dart'; | 10 import 'package:analysis_server/src/channel.dart'; |
| 11 import 'package:analysis_server/src/context_directory_manager.dart'; | 11 import 'package:analysis_server/src/context_directory_manager.dart'; |
| 12 import 'package:analysis_server/src/domain_analysis.dart'; | 12 import 'package:analysis_server/src/domain_analysis.dart'; |
| 13 import 'package:analysis_server/src/protocol.dart'; | 13 import 'package:analysis_server/src/protocol.dart'; |
| 14 import 'package:analysis_server/src/resource.dart'; | 14 import 'package:analysis_server/src/resource.dart'; |
| 15 import 'package:analyzer/src/generated/ast.dart'; | 15 import 'package:analyzer/src/generated/ast.dart'; |
| 16 import 'package:analyzer/src/generated/engine.dart'; | 16 import 'package:analyzer/src/generated/engine.dart'; |
| 17 import 'package:analyzer/src/generated/error.dart'; | 17 import 'package:analyzer/src/generated/error.dart'; |
| 18 import 'package:analyzer/src/generated/java_core.dart'; | 18 import 'package:analyzer/src/generated/java_core.dart'; |
| 19 import 'package:analyzer/src/generated/source.dart'; | 19 import 'package:analyzer/src/generated/source.dart'; |
| 20 import 'package:analyzer/src/generated/sdk.dart'; | 20 import 'package:analyzer/src/generated/sdk.dart'; |
| 21 import 'package:analyzer/src/generated/sdk_io.dart'; | 21 import 'package:analyzer/src/generated/sdk_io.dart'; |
| 22 import 'package:analyzer/src/generated/source_io.dart'; | 22 import 'package:analyzer/src/generated/source_io.dart'; |
| 23 import 'package:analysis_server/src/computers.dart'; |
| 23 | 24 |
| 24 | 25 |
| 25 /** | 26 /** |
| 26 * An instance of [DirectoryBasedDartSdk] that is shared between | 27 * An instance of [DirectoryBasedDartSdk] that is shared between |
| 27 * [AnalysisServer] instances to improve performance. | 28 * [AnalysisServer] instances to improve performance. |
| 28 */ | 29 */ |
| 29 final DirectoryBasedDartSdk SHARED_SDK = DirectoryBasedDartSdk.defaultSdk; | 30 final DirectoryBasedDartSdk SHARED_SDK = DirectoryBasedDartSdk.defaultSdk; |
| 30 | 31 |
| 31 class AnalysisServerContextDirectoryManager extends ContextDirectoryManager { | 32 class AnalysisServerContextDirectoryManager extends ContextDirectoryManager { |
| 32 final AnalysisServer analysisServer; | 33 final AnalysisServer analysisServer; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 } | 255 } |
| 255 } | 256 } |
| 256 | 257 |
| 257 /** | 258 /** |
| 258 * Send the information in the given list of notices back to the client. | 259 * Send the information in the given list of notices back to the client. |
| 259 */ | 260 */ |
| 260 void sendNotices(List<ChangeNotice> notices) { | 261 void sendNotices(List<ChangeNotice> notices) { |
| 261 for (int i = 0; i < notices.length; i++) { | 262 for (int i = 0; i < notices.length; i++) { |
| 262 ChangeNotice notice = notices[i]; | 263 ChangeNotice notice = notices[i]; |
| 263 Source source = notice.source; | 264 Source source = notice.source; |
| 264 // send "analysis.errors" notification | 265 CompilationUnit dartUnit = notice.compilationUnit; |
| 265 // TODO(scheglov) use subscriptions to determine if we should do this | 266 // TODO(scheglov) use subscriptions to determine notifications to send |
| 266 if (!source.isInSystemLibrary) { | 267 if (!source.isInSystemLibrary) { |
| 267 Notification notification = new Notification(AnalysisDomainHandler.ERROR
S_NOTIFICATION); | 268 // errors |
| 268 notification.setParameter(FILE_PARAM, source.fullName); | 269 { |
| 269 notification.setParameter(ERRORS_PARAM, notice.errors.map(errorToJson).t
oList()); | 270 Notification notification = new Notification(AnalysisDomainHandler.ERR
ORS_NOTIFICATION); |
| 270 sendNotification(notification); | 271 notification.setParameter(FILE_PARAM, source.fullName); |
| 272 notification.setParameter(ERRORS_PARAM, notice.errors.map(errorToJson)
.toList()); |
| 273 sendNotification(notification); |
| 274 } |
| 275 // highlights |
| 276 if (dartUnit != null) { |
| 277 Notification notification = new Notification(AnalysisDomainHandler.HIG
HLIGHTS_NOTIFICATION); |
| 278 notification.setParameter(FILE_PARAM, source.fullName); |
| 279 notification.setParameter( |
| 280 AnalysisDomainHandler.REGIONS_PARAM, |
| 281 new DartUnitHighlightsComputer(dartUnit).compute()); |
| 282 sendNotification(notification); |
| 283 } |
| 271 } | 284 } |
| 272 } | 285 } |
| 273 } | 286 } |
| 274 | 287 |
| 275 /** | 288 /** |
| 276 * Send status notification to the client. The `contextId` indicates | 289 * Send status notification to the client. The `contextId` indicates |
| 277 * the current context being analyzed or `null` if analysis is complete. | 290 * the current context being analyzed or `null` if analysis is complete. |
| 278 */ | 291 */ |
| 279 void sendStatusNotification(String contextId) { | 292 void sendStatusNotification(String contextId) { |
| 280 if (contextId == lastStatusNotificationContextId) { | 293 if (contextId == lastStatusNotificationContextId) { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 /** | 493 /** |
| 481 * An enumeration of the services provided by the server domain. | 494 * An enumeration of the services provided by the server domain. |
| 482 */ | 495 */ |
| 483 class ServerService extends Enum2<ServerService> { | 496 class ServerService extends Enum2<ServerService> { |
| 484 static const ServerService STATUS = const ServerService('STATUS', 0); | 497 static const ServerService STATUS = const ServerService('STATUS', 0); |
| 485 | 498 |
| 486 static const List<ServerService> VALUES = const [STATUS]; | 499 static const List<ServerService> VALUES = const [STATUS]; |
| 487 | 500 |
| 488 const ServerService(String name, int ordinal) : super(name, ordinal); | 501 const ServerService(String name, int ordinal) : super(name, ordinal); |
| 489 } | 502 } |
| OLD | NEW |