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 import 'dart:async'; | 5 import 'dart:async'; |
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_closingLabels.dart'; | 8 import 'package:analysis_server/src/computer/computer_closingLabels.dart'; |
9 import 'package:analysis_server/src/computer/computer_highlights.dart'; | 9 import 'package:analysis_server/src/computer/computer_highlights.dart'; |
10 import 'package:analysis_server/src/computer/computer_highlights2.dart'; | 10 import 'package:analysis_server/src/computer/computer_highlights2.dart'; |
11 import 'package:analysis_server/src/computer/computer_outline.dart'; | 11 import 'package:analysis_server/src/computer/computer_outline.dart'; |
12 import 'package:analysis_server/src/computer/computer_overrides.dart'; | 12 import 'package:analysis_server/src/computer/computer_overrides.dart'; |
13 import 'package:analysis_server/src/domains/analysis/implemented_dart.dart'; | 13 import 'package:analysis_server/src/domains/analysis/implemented_dart.dart'; |
14 import 'package:analysis_server/src/protocol_server.dart' as protocol; | 14 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
15 import 'package:analysis_server/src/services/search/search_engine.dart'; | 15 import 'package:analysis_server/src/services/search/search_engine.dart'; |
16 import 'package:analyzer/dart/ast/ast.dart'; | 16 import 'package:analyzer/dart/ast/ast.dart'; |
17 import 'package:analyzer/dart/element/element.dart'; | 17 import 'package:analyzer/dart/element/element.dart'; |
18 import 'package:analyzer/src/generated/engine.dart'; | |
19 import 'package:analyzer/src/generated/source.dart'; | 18 import 'package:analyzer/src/generated/source.dart'; |
20 | 19 |
21 /** | |
22 * Run the given function [f] with the given [context] made active. | |
23 * Return the result of [f] invocation. | |
24 */ | |
25 runWithActiveContext(AnalysisContext context, f()) { | |
26 if (context is InternalAnalysisContext && !context.isActive) { | |
27 context.isActive = true; | |
28 try { | |
29 return f(); | |
30 } finally { | |
31 context.isActive = false; | |
32 } | |
33 } else { | |
34 return f(); | |
35 } | |
36 } | |
37 | |
38 Future<Null> scheduleImplementedNotification( | 20 Future<Null> scheduleImplementedNotification( |
39 AnalysisServer server, Iterable<String> files) async { | 21 AnalysisServer server, Iterable<String> files) async { |
40 SearchEngine searchEngine = server.searchEngine; | 22 SearchEngine searchEngine = server.searchEngine; |
41 if (searchEngine == null) { | 23 if (searchEngine == null) { |
42 return; | 24 return; |
43 } | 25 } |
44 for (String file in files) { | 26 for (String file in files) { |
45 CompilationUnit unit = server.getCachedAnalysisResult(file)?.unit; | 27 CompilationUnit unit = server.getCachedAnalysisResult(file)?.unit; |
46 CompilationUnitElement unitElement = unit?.element; | 28 CompilationUnitElement unitElement = unit?.element; |
47 if (unitElement != null) { | 29 if (unitElement != null) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 void _sendNotification(AnalysisServer server, f()) { | 155 void _sendNotification(AnalysisServer server, f()) { |
174 ServerPerformanceStatistics.notices.makeCurrentWhile(() { | 156 ServerPerformanceStatistics.notices.makeCurrentWhile(() { |
175 try { | 157 try { |
176 f(); | 158 f(); |
177 } catch (exception, stackTrace) { | 159 } catch (exception, stackTrace) { |
178 server.sendServerErrorNotification( | 160 server.sendServerErrorNotification( |
179 'Failed to send notification', exception, stackTrace); | 161 'Failed to send notification', exception, stackTrace); |
180 } | 162 } |
181 }); | 163 }); |
182 } | 164 } |
OLD | NEW |