| 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 operation.analysis; | 5 library operation.analysis; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/analysis_server.dart'; | 7 import 'package:analysis_server/src/analysis_server.dart'; |
| 8 import 'package:analysis_server/src/computer/computer_highlights.dart'; | 8 import 'package:analysis_server/src/computer/computer_highlights.dart'; |
| 9 import 'package:analysis_server/src/computer/computer_navigation.dart'; | 9 import 'package:analysis_server/src/computer/computer_navigation.dart'; |
| 10 import 'package:analysis_server/src/computer/computer_occurrences.dart'; | 10 import 'package:analysis_server/src/computer/computer_occurrences.dart'; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 server.addOperation(new _DartIndexOperation(context, file, dartUnit)); | 27 server.addOperation(new _DartIndexOperation(context, file, dartUnit)); |
| 28 } | 28 } |
| 29 | 29 |
| 30 /** | 30 /** |
| 31 * Schedules sending notifications for the given [file] using the resolved | 31 * Schedules sending notifications for the given [file] using the resolved |
| 32 * [resolvedDartUnit]. | 32 * [resolvedDartUnit]. |
| 33 */ | 33 */ |
| 34 void scheduleNotificationOperations(AnalysisServer server, String file, | 34 void scheduleNotificationOperations(AnalysisServer server, String file, |
| 35 LineInfo lineInfo, AnalysisContext context, CompilationUnit parsedDartUnit, | 35 LineInfo lineInfo, AnalysisContext context, CompilationUnit parsedDartUnit, |
| 36 CompilationUnit resolvedDartUnit, List<AnalysisError> errors) { | 36 CompilationUnit resolvedDartUnit, List<AnalysisError> errors) { |
| 37 // Only send notifications if the current context is the preferred | |
| 38 // context for the file. This avoids redundant notification messages | |
| 39 // being sent to the client (see dartbug.com/22210). | |
| 40 // TODO(paulberry): note that there is a small risk that this will cause | |
| 41 // notifications to be lost if the preferred context for a file changes | |
| 42 // while analysis is in progress (e.g. because the client sent an | |
| 43 // analysis.setAnalysisRoots message). | |
| 44 if (server.getAnalysisContext(file) != context) { | |
| 45 return; | |
| 46 } | |
| 47 // Dart | 37 // Dart |
| 48 CompilationUnit dartUnit = | 38 CompilationUnit dartUnit = |
| 49 resolvedDartUnit != null ? resolvedDartUnit : parsedDartUnit; | 39 resolvedDartUnit != null ? resolvedDartUnit : parsedDartUnit; |
| 50 if (resolvedDartUnit != null) { | 40 if (resolvedDartUnit != null) { |
| 51 if (server.hasAnalysisSubscription( | 41 if (server.hasAnalysisSubscription( |
| 52 protocol.AnalysisService.HIGHLIGHTS, file)) { | 42 protocol.AnalysisService.HIGHLIGHTS, file)) { |
| 53 server.scheduleOperation( | 43 server.scheduleOperation( |
| 54 new _DartHighlightsOperation(context, file, resolvedDartUnit)); | 44 new _DartHighlightsOperation(context, file, resolvedDartUnit)); |
| 55 } | 45 } |
| 56 if (server.hasAnalysisSubscription( | 46 if (server.hasAnalysisSubscription( |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 abstract class _SingleFileOperation extends SourceSensitiveOperation { | 393 abstract class _SingleFileOperation extends SourceSensitiveOperation { |
| 404 final String file; | 394 final String file; |
| 405 | 395 |
| 406 _SingleFileOperation(AnalysisContext context, this.file) : super(context); | 396 _SingleFileOperation(AnalysisContext context, this.file) : super(context); |
| 407 | 397 |
| 408 @override | 398 @override |
| 409 bool shouldBeDiscardedOnSourceChange(Source source) { | 399 bool shouldBeDiscardedOnSourceChange(Source source) { |
| 410 return source.fullName == file; | 400 return source.fullName == file; |
| 411 } | 401 } |
| 412 } | 402 } |
| OLD | NEW |