| 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 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 running = false; | 899 running = false; |
| 900 if (index != null) { | 900 if (index != null) { |
| 901 index.clear(); | 901 index.clear(); |
| 902 index.stop(); | 902 index.stop(); |
| 903 } | 903 } |
| 904 // Defer closing the channel so that the shutdown response can be sent. | 904 // Defer closing the channel so that the shutdown response can be sent. |
| 905 new Future(channel.close); | 905 new Future(channel.close); |
| 906 } | 906 } |
| 907 | 907 |
| 908 /** | 908 /** |
| 909 * Return the [CompilationUnit] of the Dart file with the given [path]. | |
| 910 * Return `null` if the file is not a part of any context. | |
| 911 */ | |
| 912 CompilationUnit test_getResolvedCompilationUnit(String path) { | |
| 913 // prepare AnalysisContext | |
| 914 AnalysisContext context = getAnalysisContext(path); | |
| 915 if (context == null) { | |
| 916 return null; | |
| 917 } | |
| 918 // prepare sources | |
| 919 Source unitSource = getSource(path); | |
| 920 List<Source> librarySources = context.getLibrariesContaining(unitSource); | |
| 921 if (librarySources.isEmpty) { | |
| 922 return null; | |
| 923 } | |
| 924 // get a resolved unit | |
| 925 return context.getResolvedCompilationUnit2(unitSource, librarySources[0]); | |
| 926 } | |
| 927 | |
| 928 /** | |
| 929 * Return `true` if all operations have been performed in this [AnalysisServer
]. | |
| 930 */ | |
| 931 bool test_areOperationsFinished() { | |
| 932 return operationQueue.isEmpty; | |
| 933 } | |
| 934 | |
| 935 /** | |
| 936 * Schedules [performOperation] exection. | 909 * Schedules [performOperation] exection. |
| 937 */ | 910 */ |
| 938 void _schedulePerformOperation() { | 911 void _schedulePerformOperation() { |
| 939 new Future(performOperation); | 912 new Future(performOperation); |
| 940 } | 913 } |
| 941 | 914 |
| 942 /** | 915 /** |
| 943 * Sends a fatal `server.error` notification. | 916 * Sends a fatal `server.error` notification. |
| 944 */ | 917 */ |
| 945 void _sendServerErrorNotification(exception, stackTrace) { | 918 void _sendServerErrorNotification(exception, stackTrace) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 960 // send the notification | 933 // send the notification |
| 961 channel.sendNotification( | 934 channel.sendNotification( |
| 962 new ServerErrorParams( | 935 new ServerErrorParams( |
| 963 true, | 936 true, |
| 964 exceptionString, | 937 exceptionString, |
| 965 stackTraceString).toNotification()); | 938 stackTraceString).toNotification()); |
| 966 } | 939 } |
| 967 } | 940 } |
| 968 | 941 |
| 969 typedef void OptionUpdater(AnalysisOptionsImpl options); | 942 typedef void OptionUpdater(AnalysisOptionsImpl options); |
| OLD | NEW |