| 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; |
| 11 import 'dart:async'; | 11 import 'dart:async'; |
| 12 import 'dart:collection'; | 12 import 'dart:collection'; |
| 13 | 13 |
| 14 import 'package:analyzer/src/cancelable_future.dart'; | 14 import 'package:analyzer/src/cancelable_future.dart'; |
| 15 import 'package:analyzer/src/generated/incremental_resolution_validator.dart'; | 15 import 'package:analyzer/src/generated/incremental_resolution_validator.dart'; |
| 16 import 'package:analyzer/src/services/lint.dart'; | 16 import 'package:analyzer/src/services/lint.dart'; |
| 17 import 'package:analyzer/src/task/task_dart.dart'; | 17 import 'package:analyzer/src/task/task_dart.dart'; |
| 18 import 'package:analyzer/src/util/lru_map.dart'; |
| 18 | 19 |
| 19 import '../../instrumentation/instrumentation.dart'; | 20 import '../../instrumentation/instrumentation.dart'; |
| 20 import 'ast.dart'; | 21 import 'ast.dart'; |
| 21 import 'constant.dart'; | 22 import 'constant.dart'; |
| 22 import 'element.dart'; | 23 import 'element.dart'; |
| 23 import 'error.dart'; | 24 import 'error.dart'; |
| 24 import 'error_verifier.dart'; | 25 import 'error_verifier.dart'; |
| 25 import 'html.dart' as ht; | 26 import 'html.dart' as ht; |
| 26 import 'incremental_resolver.dart' show IncrementalResolver, | 27 import 'incremental_resolver.dart' show IncrementalResolver, |
| 27 PoorMansIncrementalResolver; | 28 PoorMansIncrementalResolver; |
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 * A flag indicating whether this context is disposed. | 946 * A flag indicating whether this context is disposed. |
| 946 */ | 947 */ |
| 947 bool _disposed = false; | 948 bool _disposed = false; |
| 948 | 949 |
| 949 /** | 950 /** |
| 950 * A cache of content used to override the default content of a source. | 951 * A cache of content used to override the default content of a source. |
| 951 */ | 952 */ |
| 952 ContentCache _contentCache = new ContentCache(); | 953 ContentCache _contentCache = new ContentCache(); |
| 953 | 954 |
| 954 /** | 955 /** |
| 956 * A cache of content used to override the default content of a source |
| 957 * before the corresponding override was removed from [_contentCache]. |
| 958 */ |
| 959 LRUMap<Source, String> _prevOverlayCache = new LRUMap<Source, String>(5); |
| 960 |
| 961 /** |
| 955 * The source factory used to create the sources that can be analyzed in this
context. | 962 * The source factory used to create the sources that can be analyzed in this
context. |
| 956 */ | 963 */ |
| 957 SourceFactory _sourceFactory; | 964 SourceFactory _sourceFactory; |
| 958 | 965 |
| 959 /** | 966 /** |
| 960 * The set of declared variables used when computing constant values. | 967 * The set of declared variables used when computing constant values. |
| 961 */ | 968 */ |
| 962 DeclaredVariables _declaredVariables = new DeclaredVariables(); | 969 DeclaredVariables _declaredVariables = new DeclaredVariables(); |
| 963 | 970 |
| 964 /** | 971 /** |
| (...skipping 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2202 } else if (originalContents != null) { | 2209 } else if (originalContents != null) { |
| 2203 _incrementalAnalysisCache = | 2210 _incrementalAnalysisCache = |
| 2204 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); | 2211 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); |
| 2205 changed = newContents != originalContents; | 2212 changed = newContents != originalContents; |
| 2206 // We are removing the overlay for the file, check if the file's | 2213 // We are removing the overlay for the file, check if the file's |
| 2207 // contents is the same as it was in the overlay. | 2214 // contents is the same as it was in the overlay. |
| 2208 try { | 2215 try { |
| 2209 TimestampedData<String> fileContents = getContents(source); | 2216 TimestampedData<String> fileContents = getContents(source); |
| 2210 String fileContentsData = fileContents.data; | 2217 String fileContentsData = fileContents.data; |
| 2211 if (fileContentsData == originalContents) { | 2218 if (fileContentsData == originalContents) { |
| 2219 _prevOverlayCache.put(source, fileContentsData); |
| 2212 sourceEntry.modificationTime = fileContents.modificationTime; | 2220 sourceEntry.modificationTime = fileContents.modificationTime; |
| 2213 sourceEntry.setValue(SourceEntry.CONTENT, fileContentsData); | |
| 2214 changed = false; | 2221 changed = false; |
| 2215 } | 2222 } |
| 2216 } catch (e) { | 2223 } catch (e) { |
| 2217 } | 2224 } |
| 2218 // If not the same content (e.g. the file is being closed without save), | 2225 // If not the same content (e.g. the file is being closed without save), |
| 2219 // then force analysis. | 2226 // then force analysis. |
| 2220 if (changed) { | 2227 if (changed) { |
| 2221 _sourceChanged(source); | 2228 _sourceChanged(source); |
| 2222 } | 2229 } |
| 2223 } | 2230 } |
| (...skipping 2746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4970 | 4977 |
| 4971 /** | 4978 /** |
| 4972 * Invalidate the [source] that was changed and any sources that referenced | 4979 * Invalidate the [source] that was changed and any sources that referenced |
| 4973 * the source before it existed. | 4980 * the source before it existed. |
| 4974 * | 4981 * |
| 4975 * <b>Note:</b> This method must only be invoked while we are synchronized on | 4982 * <b>Note:</b> This method must only be invoked while we are synchronized on |
| 4976 * [cacheLock]. | 4983 * [cacheLock]. |
| 4977 */ | 4984 */ |
| 4978 void _sourceChanged(Source source) { | 4985 void _sourceChanged(Source source) { |
| 4979 SourceEntry sourceEntry = _cache.get(source); | 4986 SourceEntry sourceEntry = _cache.get(source); |
| 4980 if (sourceEntry == null || | 4987 // If the source is removed, we don't care about it. |
| 4981 sourceEntry.modificationTime == getModificationStamp(source)) { | 4988 if (sourceEntry == null) { |
| 4982 // Either we have removed this source, in which case we don't care that | |
| 4983 // it is changed, or we have already invalidated the cache and don't need | |
| 4984 // to invalidate it again. | |
| 4985 return; | 4989 return; |
| 4986 } | 4990 } |
| 4991 // Check if the content of the source is the same as it was the last time. |
| 4992 String sourceContent = _prevOverlayCache.get(source); |
| 4993 if (sourceContent != null) { |
| 4994 try { |
| 4995 TimestampedData<String> fileContents = getContents(source); |
| 4996 if (fileContents.data == sourceContent) { |
| 4997 return; |
| 4998 } |
| 4999 } catch (e) { |
| 5000 } |
| 5001 } |
| 5002 // We have to invalidate the cache. |
| 4987 _propagateInvalidation(source, sourceEntry); | 5003 _propagateInvalidation(source, sourceEntry); |
| 4988 } | 5004 } |
| 4989 | 5005 |
| 4990 /** | 5006 /** |
| 4991 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 5007 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 4992 * | 5008 * |
| 4993 * @param source the source that has been deleted | 5009 * @param source the source that has been deleted |
| 4994 */ | 5010 */ |
| 4995 void _sourceDeleted(Source source) { | 5011 void _sourceDeleted(Source source) { |
| 4996 SourceEntry sourceEntry = _cache.get(source); | 5012 SourceEntry sourceEntry = _cache.get(source); |
| (...skipping 4699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9696 set contentCache(ContentCache value); | 9712 set contentCache(ContentCache value); |
| 9697 | 9713 |
| 9698 /** | 9714 /** |
| 9699 * Return an array containing all of the sources that have been marked as prio
rity sources. | 9715 * Return an array containing all of the sources that have been marked as prio
rity sources. |
| 9700 * Clients must not modify the returned array. | 9716 * Clients must not modify the returned array. |
| 9701 * | 9717 * |
| 9702 * @return the sources that have been marked as priority sources | 9718 * @return the sources that have been marked as priority sources |
| 9703 */ | 9719 */ |
| 9704 List<Source> get prioritySources; | 9720 List<Source> get prioritySources; |
| 9705 | 9721 |
| 9722 /** A factory to override how [ResolverVisitor] is created. */ |
| 9723 ResolverVisitorFactory get resolverVisitorFactory; |
| 9724 |
| 9706 /** | 9725 /** |
| 9707 * Returns a statistics about this context. | 9726 * Returns a statistics about this context. |
| 9708 */ | 9727 */ |
| 9709 AnalysisContextStatistics get statistics; | 9728 AnalysisContextStatistics get statistics; |
| 9710 | 9729 |
| 9711 /** | 9730 /** |
| 9712 * Returns a type provider for this context or throws an exception if dart:cor
e cannot be | 9731 * Returns a type provider for this context or throws an exception if dart:cor
e cannot be |
| 9713 * resolved. | 9732 * resolved. |
| 9714 * | 9733 * |
| 9715 * @return the type provider (not `null`) | 9734 * @return the type provider (not `null`) |
| 9716 * @throws AnalysisException if dart:core cannot be resolved | 9735 * @throws AnalysisException if dart:core cannot be resolved |
| 9717 */ | 9736 */ |
| 9718 TypeProvider get typeProvider; | 9737 TypeProvider get typeProvider; |
| 9719 | 9738 |
| 9720 /** A factory to override how [ResolverVisitor] is created. */ | |
| 9721 ResolverVisitorFactory get resolverVisitorFactory; | |
| 9722 | |
| 9723 /** A factory to override how [TypeResolverVisitor] is created. */ | 9739 /** A factory to override how [TypeResolverVisitor] is created. */ |
| 9724 TypeResolverVisitorFactory get typeResolverVisitorFactory; | 9740 TypeResolverVisitorFactory get typeResolverVisitorFactory; |
| 9725 | 9741 |
| 9726 /** | 9742 /** |
| 9727 * Add the given source with the given information to this context. | 9743 * Add the given source with the given information to this context. |
| 9728 * | 9744 * |
| 9729 * @param source the source to be added | 9745 * @param source the source to be added |
| 9730 * @param info the information about the source | 9746 * @param info the information about the source |
| 9731 */ | 9747 */ |
| 9732 void addSourceInfo(Source source, SourceEntry info); | 9748 void addSourceInfo(Source source, SourceEntry info); |
| (...skipping 2713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12446 if (element.id == _id) { | 12462 if (element.id == _id) { |
| 12447 result = element; | 12463 result = element; |
| 12448 throw new _ElementByIdFinderException(); | 12464 throw new _ElementByIdFinderException(); |
| 12449 } | 12465 } |
| 12450 super.visitElement(element); | 12466 super.visitElement(element); |
| 12451 } | 12467 } |
| 12452 } | 12468 } |
| 12453 | 12469 |
| 12454 class _ElementByIdFinderException { | 12470 class _ElementByIdFinderException { |
| 12455 } | 12471 } |
| OLD | NEW |