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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 // | 233 // |
234 // AnalysisResult result = context.performAnalysisTask((taskDescription) { | 234 // AnalysisResult result = context.performAnalysisTask((taskDescription) { |
235 // sendStatusNotification(context.toString(), taskDescription); | 235 // sendStatusNotification(context.toString(), taskDescription); |
236 // }); | 236 // }); |
237 if (!isContinue) { | 237 if (!isContinue) { |
238 setCacheSize(context, WORKING_CACHE_SIZE); | 238 setCacheSize(context, WORKING_CACHE_SIZE); |
239 } | 239 } |
240 // prepare results | 240 // prepare results |
241 AnalysisResult result = context.performAnalysisTask(); | 241 AnalysisResult result = context.performAnalysisTask(); |
242 List<ChangeNotice> notices = result.changeNotices; | 242 List<ChangeNotice> notices = result.changeNotices; |
243 // nothing to analyze | |
243 if (notices == null) { | 244 if (notices == null) { |
245 // TODO(scheglov) Move cache validation into a separate operation. | |
246 bool cacheIsInconsistent = _validateCacheConsistency(); | |
247 print('cacheIsInconsistent: $cacheIsInconsistent'); | |
Brian Wilkerson
2015/06/21 15:52:39
Remove debug line? If we want to capture this we s
| |
248 // there was a cache inconsistency, analyze again | |
249 if (cacheIsInconsistent) { | |
250 server.addOperation(new PerformAnalysisOperation(context, true)); | |
251 return; | |
252 } | |
253 // analysis is done | |
244 setCacheSize(context, IDLE_CACHE_SIZE); | 254 setCacheSize(context, IDLE_CACHE_SIZE); |
245 server.sendContextAnalysisDoneNotifications( | 255 server.sendContextAnalysisDoneNotifications( |
246 context, AnalysisDoneReason.COMPLETE); | 256 context, AnalysisDoneReason.COMPLETE); |
247 return; | 257 return; |
248 } | 258 } |
249 // process results | 259 // process results |
250 ServerPerformanceStatistics.notices.makeCurrentWhile(() { | 260 ServerPerformanceStatistics.notices.makeCurrentWhile(() { |
251 _sendNotices(server, notices); | 261 _sendNotices(server, notices); |
252 _updateIndex(server, notices); | 262 _updateIndex(server, notices); |
253 }); | 263 }); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 try { | 302 try { |
293 HtmlUnit htmlUnit = notice.resolvedHtmlUnit; | 303 HtmlUnit htmlUnit = notice.resolvedHtmlUnit; |
294 if (htmlUnit != null) { | 304 if (htmlUnit != null) { |
295 server.addOperation(new _HtmlIndexOperation(context, file, htmlUnit)); | 305 server.addOperation(new _HtmlIndexOperation(context, file, htmlUnit)); |
296 } | 306 } |
297 } catch (exception, stackTrace) { | 307 } catch (exception, stackTrace) { |
298 server.sendServerErrorNotification(exception, stackTrace); | 308 server.sendServerErrorNotification(exception, stackTrace); |
299 } | 309 } |
300 } | 310 } |
301 } | 311 } |
312 | |
313 /** | |
314 * Checks whether all of the cache entries of [context] are consistent. | |
315 * If there is an inconsistent entry, returns `true`. | |
316 */ | |
317 bool _validateCacheConsistency() { | |
Brian Wilkerson
2015/06/21 15:52:39
I'd move this method to AnalysisContext. I'd rathe
| |
318 bool hasInconsistentEntries = false; | |
319 InternalAnalysisContext context = this.context; | |
320 for (Source source in context.sources) { | |
321 if (context.validateSourceCacheConsistency(source)) { | |
322 hasInconsistentEntries = true; | |
323 } | |
324 } | |
325 return hasInconsistentEntries; | |
326 } | |
302 } | 327 } |
303 | 328 |
304 class _DartHighlightsOperation extends _DartNotificationOperation { | 329 class _DartHighlightsOperation extends _DartNotificationOperation { |
305 _DartHighlightsOperation( | 330 _DartHighlightsOperation( |
306 AnalysisContext context, String file, CompilationUnit unit) | 331 AnalysisContext context, String file, CompilationUnit unit) |
307 : super(context, file, unit); | 332 : super(context, file, unit); |
308 | 333 |
309 @override | 334 @override |
310 void perform(AnalysisServer server) { | 335 void perform(AnalysisServer server) { |
311 sendAnalysisNotificationHighlights(server, file, unit); | 336 sendAnalysisNotificationHighlights(server, file, unit); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 abstract class _SingleFileOperation extends SourceSensitiveOperation { | 459 abstract class _SingleFileOperation extends SourceSensitiveOperation { |
435 final String file; | 460 final String file; |
436 | 461 |
437 _SingleFileOperation(AnalysisContext context, this.file) : super(context); | 462 _SingleFileOperation(AnalysisContext context, this.file) : super(context); |
438 | 463 |
439 @override | 464 @override |
440 bool shouldBeDiscardedOnSourceChange(Source source) { | 465 bool shouldBeDiscardedOnSourceChange(Source source) { |
441 return source.fullName == file; | 466 return source.fullName == file; |
442 } | 467 } |
443 } | 468 } |
OLD | NEW |