| 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 5005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5016 */ | 5016 */ |
| 5017 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) { | 5017 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) { |
| 5018 incrementalResolutionValidation_lastUnitSource = null; | 5018 incrementalResolutionValidation_lastUnitSource = null; |
| 5019 incrementalResolutionValidation_lastLibrarySource = null; | 5019 incrementalResolutionValidation_lastLibrarySource = null; |
| 5020 incrementalResolutionValidation_lastUnit = null; | 5020 incrementalResolutionValidation_lastUnit = null; |
| 5021 // prepare the entry | 5021 // prepare the entry |
| 5022 DartEntry dartEntry = _cache.get(unitSource); | 5022 DartEntry dartEntry = _cache.get(unitSource); |
| 5023 if (dartEntry == null) { | 5023 if (dartEntry == null) { |
| 5024 return false; | 5024 return false; |
| 5025 } | 5025 } |
| 5026 // prepare the (only) library | 5026 // prepare the (only) library source |
| 5027 List<Source> librarySources = getLibrariesContaining(unitSource); | 5027 List<Source> librarySources = getLibrariesContaining(unitSource); |
| 5028 if (librarySources.length != 1) { | 5028 if (librarySources.length != 1) { |
| 5029 return false; | 5029 return false; |
| 5030 } | 5030 } |
| 5031 Source librarySource = librarySources[0]; |
| 5032 // prepare the library element |
| 5033 LibraryElement libraryElement = getLibraryElement(librarySource); |
| 5034 if (libraryElement == null) { |
| 5035 return false; |
| 5036 } |
| 5037 // prepare the existing library units |
| 5038 Map<Source, CompilationUnit> units = <Source, CompilationUnit>{}; |
| 5039 for (CompilationUnitElement unitElement in libraryElement.units) { |
| 5040 Source unitSource = unitElement.source; |
| 5041 CompilationUnit unit = |
| 5042 getResolvedCompilationUnit2(unitSource, librarySource); |
| 5043 if (unit == null) { |
| 5044 return false; |
| 5045 } |
| 5046 units[unitSource] = unit; |
| 5047 } |
| 5031 // prepare the existing unit | 5048 // prepare the existing unit |
| 5032 Source librarySource = librarySources[0]; | 5049 CompilationUnit oldUnit = units[unitSource]; |
| 5033 CompilationUnit oldUnit = | |
| 5034 getResolvedCompilationUnit2(unitSource, librarySource); | |
| 5035 if (oldUnit == null) { | 5050 if (oldUnit == null) { |
| 5036 return false; | 5051 return false; |
| 5037 } | 5052 } |
| 5038 // do resolution | 5053 // do resolution |
| 5039 Stopwatch perfCounter = new Stopwatch()..start(); | 5054 Stopwatch perfCounter = new Stopwatch()..start(); |
| 5040 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver( | 5055 PoorMansIncrementalResolver resolver = new PoorMansIncrementalResolver( |
| 5041 typeProvider, | 5056 typeProvider, |
| 5057 units, |
| 5042 unitSource, | 5058 unitSource, |
| 5043 dartEntry, | 5059 dartEntry, |
| 5044 analysisOptions.incrementalApi); | 5060 analysisOptions.incrementalApi); |
| 5045 bool success = resolver.resolve(oldUnit, newCode); | 5061 bool success = resolver.resolve(newCode); |
| 5046 AnalysisEngine.instance.instrumentationService.logPerformance( | 5062 AnalysisEngine.instance.instrumentationService.logPerformance( |
| 5047 AnalysisPerformanceKind.INCREMENTAL, | 5063 AnalysisPerformanceKind.INCREMENTAL, |
| 5048 perfCounter, | 5064 perfCounter, |
| 5049 'success=$success,context_id=$_id,code_length=${newCode.length}'); | 5065 'success=$success,context_id=$_id,code_length=${newCode.length}'); |
| 5050 if (!success) { | 5066 if (!success) { |
| 5051 return false; | 5067 return false; |
| 5052 } | 5068 } |
| 5053 // if validation, remember the result, but throw it away | 5069 // if validation, remember the result, but throw it away |
| 5054 if (analysisOptions.incrementalValidation) { | 5070 if (analysisOptions.incrementalValidation) { |
| 5055 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source; | 5071 incrementalResolutionValidation_lastUnitSource = oldUnit.element.source; |
| 5056 incrementalResolutionValidation_lastLibrarySource = | 5072 incrementalResolutionValidation_lastLibrarySource = |
| 5057 oldUnit.element.library.source; | 5073 oldUnit.element.library.source; |
| 5058 incrementalResolutionValidation_lastUnit = oldUnit; | 5074 incrementalResolutionValidation_lastUnit = oldUnit; |
| 5059 return false; | 5075 return false; |
| 5060 } | 5076 } |
| 5061 // prepare notice | 5077 // prepare notices |
| 5062 ChangeNoticeImpl notice = _getNotice(unitSource); | 5078 units.forEach((Source source, CompilationUnit unit) { |
| 5063 notice.compilationUnit = oldUnit; | 5079 DartEntry dartEntry = _cache.get(source); |
| 5064 // apply updated errors | 5080 LineInfo lineInfo = getLineInfo(source); |
| 5065 { | 5081 ChangeNoticeImpl notice = _getNotice(source); |
| 5066 LineInfo lineInfo = getLineInfo(unitSource); | 5082 notice.compilationUnit = unit; |
| 5067 notice.setErrors(dartEntry.allErrors, lineInfo); | 5083 notice.setErrors(dartEntry.allErrors, lineInfo); |
| 5068 } | 5084 }); |
| 5069 // OK | 5085 // OK |
| 5070 return true; | 5086 return true; |
| 5071 } | 5087 } |
| 5072 | 5088 |
| 5073 /** | 5089 /** |
| 5074 * Check the cache for any invalid entries (entries whose modification time do
es not match the | 5090 * Check the cache for any invalid entries (entries whose modification time do
es not match the |
| 5075 * modification time of the source associated with the entry). Invalid entries
will be marked as | 5091 * modification time of the source associated with the entry). Invalid entries
will be marked as |
| 5076 * invalid so that the source will be re-analyzed. | 5092 * invalid so that the source will be re-analyzed. |
| 5077 * | 5093 * |
| 5078 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 5094 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| (...skipping 4454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9533 cache.offset, | 9549 cache.offset, |
| 9534 cache.offset + cache.oldLength); | 9550 cache.offset + cache.oldLength); |
| 9535 // Update the resolution | 9551 // Update the resolution |
| 9536 TypeProvider typeProvider = this.typeProvider; | 9552 TypeProvider typeProvider = this.typeProvider; |
| 9537 if (_updatedUnit != null && typeProvider != null) { | 9553 if (_updatedUnit != null && typeProvider != null) { |
| 9538 CompilationUnitElement element = _updatedUnit.element; | 9554 CompilationUnitElement element = _updatedUnit.element; |
| 9539 if (element != null) { | 9555 if (element != null) { |
| 9540 LibraryElement library = element.library; | 9556 LibraryElement library = element.library; |
| 9541 if (library != null) { | 9557 if (library != null) { |
| 9542 IncrementalResolver resolver = new IncrementalResolver( | 9558 IncrementalResolver resolver = new IncrementalResolver( |
| 9559 <Source, CompilationUnit>{}, |
| 9543 element, | 9560 element, |
| 9544 cache.offset, | 9561 cache.offset, |
| 9545 cache.oldLength, | 9562 cache.oldLength, |
| 9546 cache.newLength); | 9563 cache.newLength); |
| 9547 resolver.resolve(parser.updatedNode); | 9564 resolver.resolve(parser.updatedNode); |
| 9548 } | 9565 } |
| 9549 } | 9566 } |
| 9550 } | 9567 } |
| 9551 } | 9568 } |
| 9552 } | 9569 } |
| (...skipping 2668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12221 if (element.id == _id) { | 12238 if (element.id == _id) { |
| 12222 result = element; | 12239 result = element; |
| 12223 throw new _ElementByIdFinderException(); | 12240 throw new _ElementByIdFinderException(); |
| 12224 } | 12241 } |
| 12225 super.visitElement(element); | 12242 super.visitElement(element); |
| 12226 } | 12243 } |
| 12227 } | 12244 } |
| 12228 | 12245 |
| 12229 class _ElementByIdFinderException { | 12246 class _ElementByIdFinderException { |
| 12230 } | 12247 } |
| OLD | NEW |