| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine; | 8 library engine; |
| 9 | 9 |
| 10 import "dart:math" as math; | 10 import "dart:math" as math; |
| (...skipping 5034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5045 } | 5045 } |
| 5046 _cache.remove(source); | 5046 _cache.remove(source); |
| 5047 _workManager.remove(source); | 5047 _workManager.remove(source); |
| 5048 _removeFromPriorityOrder(source); | 5048 _removeFromPriorityOrder(source); |
| 5049 } | 5049 } |
| 5050 | 5050 |
| 5051 /** | 5051 /** |
| 5052 * TODO(scheglov) A hackish, limited incremental resolution implementation. | 5052 * TODO(scheglov) A hackish, limited incremental resolution implementation. |
| 5053 */ | 5053 */ |
| 5054 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) { | 5054 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) { |
| 5055 incrementalResolutionValidation_lastUnitSource = null; | 5055 return PerformanceStatistics.incrementalAnalysis.makeCurrentWhile(() { |
| 5056 incrementalResolutionValidation_lastLibrarySource = null; | 5056 incrementalResolutionValidation_lastUnitSource = null; |
| 5057 incrementalResolutionValidation_lastUnit = null; | 5057 incrementalResolutionValidation_lastLibrarySource = null; |
| 5058 // prepare the entry | 5058 incrementalResolutionValidation_lastUnit = null; |
| 5059 DartEntry dartEntry = _cache.get(unitSource); | 5059 // prepare the entry |
| 5060 if (dartEntry == null) { | 5060 DartEntry dartEntry = _cache.get(unitSource); |
| 5061 return false; | 5061 if (dartEntry == null) { |
| 5062 } | 5062 return false; |
| 5063 // prepare the (only) library source | 5063 } |
| 5064 List<Source> librarySources = getLibrariesContaining(unitSource); | 5064 // prepare the (only) library source |
| 5065 if (librarySources.length != 1) { | 5065 List<Source> librarySources = getLibrariesContaining(unitSource); |
| 5066 return false; | 5066 if (librarySources.length != 1) { |
| 5067 } | 5067 return false; |
| 5068 Source librarySource = librarySources[0]; | 5068 } |
| 5069 // prepare the library element | 5069 Source librarySource = librarySources[0]; |
| 5070 LibraryElement libraryElement = getLibraryElement(librarySource); | 5070 // prepare the library element |
| 5071 if (libraryElement == null) { | 5071 LibraryElement libraryElement = getLibraryElement(librarySource); |
| 5072 return false; | 5072 if (libraryElement == null) { |
| 5073 } | 5073 return false; |
| 5074 // prepare the existing unit | 5074 } |
| 5075 CompilationUnit oldUnit = | 5075 // prepare the existing unit |
| 5076 getResolvedCompilationUnit2(unitSource, librarySource); | 5076 CompilationUnit oldUnit = |
| 5077 if (oldUnit == null) { | 5077 getResolvedCompilationUnit2(unitSource, librarySource); |
| 5078 return false; | 5078 if (oldUnit == null) { |
| 5079 } | 5079 return false; |
| 5080 // do resolution | 5080 } |
| 5081 Stopwatch perfCounter = new Stopwatch()..start(); | 5081 // do resolution |
| 5082 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver( | 5082 Stopwatch perfCounter = new Stopwatch()..start(); |
| 5083 typeProvider, | 5083 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver( |
| 5084 unitSource, | 5084 typeProvider, |
| 5085 dartEntry, | 5085 unitSource, |
| 5086 oldUnit, | 5086 dartEntry, |
| 5087 analysisOptions.incrementalApi); | 5087 oldUnit, |
| 5088 bool success = resolver.resolve(newCode); | 5088 analysisOptions.incrementalApi); |
| 5089 AnalysisEngine.instance.instrumentationService.logPerformance( | 5089 bool success = resolver.resolve(newCode); |
| 5090 AnalysisPerformanceKind.INCREMENTAL, | 5090 AnalysisEngine.instance.instrumentationService.logPerformance( |
| 5091 perfCounter, | 5091 AnalysisPerformanceKind.INCREMENTAL, |
| 5092 'success=$success,context_id=$_id,code_length=${newCode.length}'); | 5092 perfCounter, |
| 5093 if (!success) { | 5093 'success=$success,context_id=$_id,code_length=${newCode.length}'); |
| 5094 return false; | 5094 if (!success) { |
| 5095 } | 5095 return false; |
| 5096 // if validation, remember the result, but throw it away | 5096 } |
| 5097 if (analysisOptions.incrementalValidation) { | 5097 // if validation, remember the result, but throw it away |
| 5098 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source; | 5098 if (analysisOptions.incrementalValidation) { |
| 5099 incrementalResolutionValidation_lastLibrarySource = | 5099 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source; |
| 5100 oldUnit.element.library.source; | 5100 incrementalResolutionValidation_lastLibrarySource = |
| 5101 incrementalResolutionValidation_lastUnit = oldUnit; | 5101 oldUnit.element.library.source; |
| 5102 return false; | 5102 incrementalResolutionValidation_lastUnit = oldUnit; |
| 5103 } | 5103 return false; |
| 5104 // prepare notice | 5104 } |
| 5105 { | 5105 // prepare notice |
| 5106 LineInfo lineInfo = getLineInfo(unitSource); | 5106 { |
| 5107 ChangeNoticeImpl notice = _getNotice(unitSource); | 5107 LineInfo lineInfo = getLineInfo(unitSource); |
| 5108 notice.resolvedDartUnit = oldUnit; | 5108 ChangeNoticeImpl notice = _getNotice(unitSource); |
| 5109 notice.setErrors(dartEntry.allErrors, lineInfo); | 5109 notice.resolvedDartUnit = oldUnit; |
| 5110 } | 5110 notice.setErrors(dartEntry.allErrors, lineInfo); |
| 5111 // OK | 5111 } |
| 5112 return true; | 5112 // OK |
| 5113 return true; |
| 5114 }); |
| 5113 } | 5115 } |
| 5114 | 5116 |
| 5115 /** | 5117 /** |
| 5116 * Check the cache for any invalid entries (entries whose modification time do
es not match the | 5118 * Check the cache for any invalid entries (entries whose modification time do
es not match the |
| 5117 * modification time of the source associated with the entry). Invalid entries
will be marked as | 5119 * modification time of the source associated with the entry). Invalid entries
will be marked as |
| 5118 * invalid so that the source will be re-analyzed. | 5120 * invalid so that the source will be re-analyzed. |
| 5119 * | 5121 * |
| 5120 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 5122 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 5121 * | 5123 * |
| 5122 * @return `true` if at least one entry was invalid | 5124 * @return `true` if at least one entry was invalid |
| (...skipping 5404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10527 * tasks are complete. | 10529 * tasks are complete. |
| 10528 */ | 10530 */ |
| 10529 static PerformanceTag analysisTaskVisitor = | 10531 static PerformanceTag analysisTaskVisitor = |
| 10530 new PerformanceTag('analysisTaskVisitor'); | 10532 new PerformanceTag('analysisTaskVisitor'); |
| 10531 | 10533 |
| 10532 /** | 10534 /** |
| 10533 * The [PerformanceTag] for time spent in the getter | 10535 * The [PerformanceTag] for time spent in the getter |
| 10534 * AnalysisContextImpl.nextAnalysisTask. | 10536 * AnalysisContextImpl.nextAnalysisTask. |
| 10535 */ | 10537 */ |
| 10536 static var nextTask = new PerformanceTag('nextAnalysisTask'); | 10538 static var nextTask = new PerformanceTag('nextAnalysisTask'); |
| 10539 |
| 10540 /** |
| 10541 * The [PerformanceTag] for time spent during otherwise not accounted parts |
| 10542 * incremental of analysis. |
| 10543 */ |
| 10544 static PerformanceTag incrementalAnalysis = |
| 10545 new PerformanceTag('incrementalAnalysis'); |
| 10537 } | 10546 } |
| 10538 | 10547 |
| 10539 /** | 10548 /** |
| 10540 * Instances of the class `RecordingErrorListener` implement an error listener t
hat will | 10549 * Instances of the class `RecordingErrorListener` implement an error listener t
hat will |
| 10541 * record the errors that are reported to it in a way that is appropriate for ca
ching those errors | 10550 * record the errors that are reported to it in a way that is appropriate for ca
ching those errors |
| 10542 * within an analysis context. | 10551 * within an analysis context. |
| 10543 */ | 10552 */ |
| 10544 class RecordingErrorListener implements AnalysisErrorListener { | 10553 class RecordingErrorListener implements AnalysisErrorListener { |
| 10545 /** | 10554 /** |
| 10546 * A HashMap of lists containing the errors that were collected, keyed by each
[Source]. | 10555 * A HashMap of lists containing the errors that were collected, keyed by each
[Source]. |
| (...skipping 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12437 if (element.id == _id) { | 12446 if (element.id == _id) { |
| 12438 result = element; | 12447 result = element; |
| 12439 throw new _ElementByIdFinderException(); | 12448 throw new _ElementByIdFinderException(); |
| 12440 } | 12449 } |
| 12441 super.visitElement(element); | 12450 super.visitElement(element); |
| 12442 } | 12451 } |
| 12443 } | 12452 } |
| 12444 | 12453 |
| 12445 class _ElementByIdFinderException { | 12454 class _ElementByIdFinderException { |
| 12446 } | 12455 } |
| OLD | NEW |