Chromium Code Reviews| 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/domains/analysis/implemented_dart.dart'; | 13 import 'package:analysis_server/src/domains/analysis/implemented_dart.dart'; |
| 13 import 'package:analysis_server/src/domains/analysis/navigation.dart'; | 14 import 'package:analysis_server/src/domains/analysis/navigation.dart'; |
| 14 import 'package:analysis_server/src/domains/analysis/occurrences.dart'; | 15 import 'package:analysis_server/src/domains/analysis/occurrences.dart'; |
| 15 import 'package:analysis_server/src/operation/operation.dart'; | 16 import 'package:analysis_server/src/operation/operation.dart'; |
| 16 import 'package:analysis_server/src/protocol_server.dart' as protocol; | 17 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
| 17 import 'package:analysis_server/src/services/dependencies/library_dependencies.d art'; | 18 import 'package:analysis_server/src/services/dependencies/library_dependencies.d art'; |
| 18 import 'package:analysis_server/src/services/search/search_engine.dart'; | 19 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 19 import 'package:analyzer/dart/ast/ast.dart'; | 20 import 'package:analyzer/dart/ast/ast.dart'; |
| 20 import 'package:analyzer/dart/element/element.dart'; | 21 import 'package:analyzer/dart/element/element.dart'; |
| 21 import 'package:analyzer/src/generated/engine.dart'; | 22 import 'package:analyzer/src/generated/engine.dart'; |
| 22 import 'package:analyzer/src/generated/error.dart'; | 23 import 'package:analyzer/src/generated/error.dart'; |
| 23 import 'package:analyzer/src/generated/source.dart'; | 24 import 'package:analyzer/src/generated/source.dart'; |
| 25 import 'package:analyzer/src/task/dart.dart'; | |
| 24 | 26 |
| 25 /** | 27 /** |
| 26 * Runs the given function [f] with the working cache size in [context]. | 28 * Runs the given function [f] with the working cache size in [context]. |
| 27 * Returns the result of [f] invocation. | 29 * Returns the result of [f] invocation. |
| 28 */ | 30 */ |
| 29 runWithWorkingCacheSize(AnalysisContext context, f()) { | 31 runWithWorkingCacheSize(AnalysisContext context, f()) { |
| 30 int currentCacheSize = context.analysisOptions.cacheSize; | 32 int currentCacheSize = context.analysisOptions.cacheSize; |
| 31 if (currentCacheSize < PerformAnalysisOperation.WORKING_CACHE_SIZE) { | 33 if (currentCacheSize < PerformAnalysisOperation.WORKING_CACHE_SIZE) { |
| 32 setCacheSize(context, PerformAnalysisOperation.WORKING_CACHE_SIZE); | 34 setCacheSize(context, PerformAnalysisOperation.WORKING_CACHE_SIZE); |
| 33 try { | 35 try { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 } | 371 } |
| 370 // prepare results | 372 // prepare results |
| 371 AnalysisResult result = context.performAnalysisTask(); | 373 AnalysisResult result = context.performAnalysisTask(); |
| 372 List<ChangeNotice> notices = result.changeNotices; | 374 List<ChangeNotice> notices = result.changeNotices; |
| 373 // nothing to analyze | 375 // nothing to analyze |
| 374 if (notices == null) { | 376 if (notices == null) { |
| 375 server.scheduleCacheConsistencyValidation(context); | 377 server.scheduleCacheConsistencyValidation(context); |
| 376 setCacheSize(context, IDLE_CACHE_SIZE); | 378 setCacheSize(context, IDLE_CACHE_SIZE); |
| 377 server.sendContextAnalysisDoneNotifications( | 379 server.sendContextAnalysisDoneNotifications( |
| 378 context, AnalysisDoneReason.COMPLETE); | 380 context, AnalysisDoneReason.COMPLETE); |
| 381 _flushCache(server); | |
| 379 return; | 382 return; |
| 380 } | 383 } |
| 381 // process results | 384 // process results |
| 382 ServerPerformanceStatistics.notices.makeCurrentWhile(() { | 385 ServerPerformanceStatistics.notices.makeCurrentWhile(() { |
| 383 _sendNotices(server, notices); | 386 _sendNotices(server, notices); |
| 384 _updateIndex(server, notices); | 387 _updateIndex(server, notices); |
| 385 }); | 388 }); |
| 386 // continue analysis | 389 // continue analysis |
| 387 server.addOperation(new PerformAnalysisOperation(context, true)); | 390 server.addOperation(new PerformAnalysisOperation(context, true)); |
| 388 } | 391 } |
| 389 | 392 |
| 390 /** | 393 /** |
| 394 * Flush some of the [context] cache results, which we probably not | |
| 395 * going to use anymore. | |
| 396 */ | |
| 397 void _flushCache(AnalysisServer server) { | |
| 398 if (context is InternalAnalysisContext) { | |
| 399 InternalAnalysisContext context = this.context; | |
| 400 // Flush AST results for source outside of the analysis roots. | |
| 401 ContextManager contextManager = server.contextManager; | |
| 402 context.analysisCache.flush((target, result) { | |
|
Brian Wilkerson
2016/08/23 19:56:32
This won't work well when we start sharing more an
| |
| 403 Source targetSource = target.source; | |
| 404 if (RESOLVED_UNIT_RESULTS.contains(result) && | |
| 405 targetSource != null && | |
| 406 !context.prioritySources.contains(targetSource) && | |
| 407 !contextManager.isInAnalysisRoot(targetSource.fullName)) { | |
| 408 return true; | |
| 409 } | |
| 410 return false; | |
| 411 }); | |
| 412 } | |
| 413 } | |
| 414 | |
| 415 /** | |
| 391 * Send the information in the given list of notices back to the client. | 416 * Send the information in the given list of notices back to the client. |
| 392 */ | 417 */ |
| 393 void _sendNotices(AnalysisServer server, List<ChangeNotice> notices) { | 418 void _sendNotices(AnalysisServer server, List<ChangeNotice> notices) { |
| 394 for (int i = 0; i < notices.length; i++) { | 419 for (int i = 0; i < notices.length; i++) { |
| 395 ChangeNotice notice = notices[i]; | 420 ChangeNotice notice = notices[i]; |
| 396 Source source = notice.source; | 421 Source source = notice.source; |
| 397 String file = source.fullName; | 422 String file = source.fullName; |
| 398 // Dart | 423 // Dart |
| 399 CompilationUnit parsedDartUnit = notice.parsedDartUnit; | 424 CompilationUnit parsedDartUnit = notice.parsedDartUnit; |
| 400 CompilationUnit resolvedDartUnit = notice.resolvedDartUnit; | 425 CompilationUnit resolvedDartUnit = notice.resolvedDartUnit; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 535 abstract class _SingleFileOperation extends SourceSensitiveOperation { | 560 abstract class _SingleFileOperation extends SourceSensitiveOperation { |
| 536 final String file; | 561 final String file; |
| 537 | 562 |
| 538 _SingleFileOperation(AnalysisContext context, this.file) : super(context); | 563 _SingleFileOperation(AnalysisContext context, this.file) : super(context); |
| 539 | 564 |
| 540 @override | 565 @override |
| 541 bool shouldBeDiscardedOnSourceChange(Source source) { | 566 bool shouldBeDiscardedOnSourceChange(Source source) { |
| 542 return source.fullName == file; | 567 return source.fullName == file; |
| 543 } | 568 } |
| 544 } | 569 } |
| OLD | NEW |