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_highlights2.dart'; | 9 import 'package:analysis_server/src/computer/computer_highlights2.dart'; |
10 import 'package:analysis_server/src/computer/computer_outline.dart'; | 10 import 'package:analysis_server/src/computer/computer_outline.dart'; |
11 import 'package:analysis_server/src/computer/computer_overrides.dart'; | 11 import 'package:analysis_server/src/computer/computer_overrides.dart'; |
12 import 'package:analysis_server/src/context_manager.dart'; | 12 import 'package:analysis_server/src/context_manager.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/domains/analysis/navigation.dart'; | 14 import 'package:analysis_server/src/domains/analysis/navigation.dart'; |
15 import 'package:analysis_server/src/domains/analysis/occurrences.dart'; | 15 import 'package:analysis_server/src/domains/analysis/occurrences.dart'; |
16 import 'package:analysis_server/src/operation/operation.dart'; | 16 import 'package:analysis_server/src/operation/operation.dart'; |
17 import 'package:analysis_server/src/protocol_server.dart' as protocol; | 17 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
18 import 'package:analysis_server/src/services/dependencies/library_dependencies.d
art'; | 18 import 'package:analysis_server/src/services/dependencies/library_dependencies.d
art'; |
19 import 'package:analysis_server/src/services/search/search_engine.dart'; | 19 import 'package:analysis_server/src/services/search/search_engine.dart'; |
20 import 'package:analyzer/dart/ast/ast.dart'; | 20 import 'package:analyzer/dart/ast/ast.dart'; |
21 import 'package:analyzer/dart/element/element.dart'; | 21 import 'package:analyzer/dart/element/element.dart'; |
22 import 'package:analyzer/src/generated/engine.dart'; | 22 import 'package:analyzer/src/generated/engine.dart'; |
23 import 'package:analyzer/src/generated/error.dart'; | 23 import 'package:analyzer/src/generated/error.dart'; |
24 import 'package:analyzer/src/generated/source.dart'; | 24 import 'package:analyzer/src/generated/source.dart'; |
| 25 import 'package:analyzer/task/dart.dart'; |
25 import 'package:analyzer/task/model.dart'; | 26 import 'package:analyzer/task/model.dart'; |
26 | 27 |
27 /** | 28 /** |
28 * Runs the given function [f] with the working cache size in [context]. | 29 * Runs the given function [f] with the working cache size in [context]. |
29 * Returns the result of [f] invocation. | 30 * Returns the result of [f] invocation. |
30 */ | 31 */ |
31 runWithWorkingCacheSize(AnalysisContext context, f()) { | 32 runWithWorkingCacheSize(AnalysisContext context, f()) { |
32 int currentCacheSize = context.analysisOptions.cacheSize; | 33 int currentCacheSize = context.analysisOptions.cacheSize; |
33 if (currentCacheSize < PerformAnalysisOperation.WORKING_CACHE_SIZE) { | 34 if (currentCacheSize < PerformAnalysisOperation.WORKING_CACHE_SIZE) { |
34 setCacheSize(context, PerformAnalysisOperation.WORKING_CACHE_SIZE); | 35 setCacheSize(context, PerformAnalysisOperation.WORKING_CACHE_SIZE); |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 | 393 |
393 /** | 394 /** |
394 * Flush some of the [context] cache results, which we probably not | 395 * Flush some of the [context] cache results, which we probably not |
395 * going to use anymore. | 396 * going to use anymore. |
396 */ | 397 */ |
397 void _flushCache(AnalysisServer server) { | 398 void _flushCache(AnalysisServer server) { |
398 if (context is InternalAnalysisContext) { | 399 if (context is InternalAnalysisContext) { |
399 InternalAnalysisContext context = this.context; | 400 InternalAnalysisContext context = this.context; |
400 // Flush AST results for source outside of the analysis roots. | 401 // Flush AST results for source outside of the analysis roots. |
401 ContextManager contextManager = server.contextManager; | 402 ContextManager contextManager = server.contextManager; |
402 context.analysisCache.flush((target, result) { | 403 context.analysisCache.flush((target) { |
403 Source targetSource = target.source; | 404 if (target is Source || target is LibrarySpecificUnit) { |
404 if (result is ResultDescriptor<CompilationUnit> && | 405 Source targetSource = target.source; |
405 targetSource != null && | 406 return !context.prioritySources.contains(targetSource) && |
406 !context.prioritySources.contains(targetSource) && | 407 !contextManager.isInAnalysisRoot(targetSource.fullName); |
407 !contextManager.isInAnalysisRoot(targetSource.fullName)) { | |
408 return true; | |
409 } | 408 } |
410 return false; | 409 return false; |
| 410 }, (target, result) { |
| 411 return result is ResultDescriptor<CompilationUnit>; |
411 }); | 412 }); |
412 } | 413 } |
413 } | 414 } |
414 | 415 |
415 /** | 416 /** |
416 * Send the information in the given list of notices back to the client. | 417 * Send the information in the given list of notices back to the client. |
417 */ | 418 */ |
418 void _sendNotices(AnalysisServer server, List<ChangeNotice> notices) { | 419 void _sendNotices(AnalysisServer server, List<ChangeNotice> notices) { |
419 for (int i = 0; i < notices.length; i++) { | 420 for (int i = 0; i < notices.length; i++) { |
420 ChangeNotice notice = notices[i]; | 421 ChangeNotice notice = notices[i]; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 abstract class _SingleFileOperation extends SourceSensitiveOperation { | 561 abstract class _SingleFileOperation extends SourceSensitiveOperation { |
561 final String file; | 562 final String file; |
562 | 563 |
563 _SingleFileOperation(AnalysisContext context, this.file) : super(context); | 564 _SingleFileOperation(AnalysisContext context, this.file) : super(context); |
564 | 565 |
565 @override | 566 @override |
566 bool shouldBeDiscardedOnSourceChange(Source source) { | 567 bool shouldBeDiscardedOnSourceChange(Source source) { |
567 return source.fullName == file; | 568 return source.fullName == file; |
568 } | 569 } |
569 } | 570 } |
OLD | NEW |