| 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 'java_core.dart'; | 10 import 'java_core.dart'; |
| 11 import 'java_engine.dart'; | 11 import 'java_engine.dart'; |
| 12 import 'utilities_collection.dart'; | 12 import 'utilities_collection.dart'; |
| 13 import 'utilities_general.dart'; | 13 import 'utilities_general.dart'; |
| 14 import 'instrumentation.dart'; | 14 import 'instrumentation.dart'; |
| 15 import 'error.dart'; | 15 import 'error.dart'; |
| 16 import 'source.dart'; | 16 import 'source.dart'; |
| 17 import 'scanner.dart'; | 17 import 'scanner.dart'; |
| 18 import 'ast.dart'; | 18 import 'ast.dart'; |
| 19 import 'parser.dart' show Parser, IncrementalParser; | 19 import 'parser.dart' show Parser, IncrementalParser; |
| 20 import 'sdk.dart' show DartSdk; | 20 import 'sdk.dart' show DartSdk; |
| 21 import 'element.dart'; | 21 import 'element.dart'; |
| 22 import 'resolver.dart'; | 22 import 'resolver.dart'; |
| 23 import 'html.dart' as ht; | 23 import 'html.dart' as ht; |
| 24 import 'package:analyzer/src/generated/constant.dart'; |
| 24 | 25 |
| 25 /** | 26 /** |
| 26 * Instances of the class `AnalysisCache` implement an LRU cache of information
related to | 27 * Instances of the class `AnalysisCache` implement an LRU cache of information
related to |
| 27 * analysis. | 28 * analysis. |
| 28 */ | 29 */ |
| 29 class AnalysisCache { | 30 class AnalysisCache { |
| 30 /** | 31 /** |
| 31 * An array containing the partitions of which this cache is comprised. | 32 * An array containing the partitions of which this cache is comprised. |
| 32 */ | 33 */ |
| 33 final List<CachePartition> _partitions; | 34 final List<CachePartition> _partitions; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 /** | 233 /** |
| 233 * Apply the changes specified by the given change set to this context. Any an
alysis results that | 234 * Apply the changes specified by the given change set to this context. Any an
alysis results that |
| 234 * have been invalidated by these changes will be removed. | 235 * have been invalidated by these changes will be removed. |
| 235 * | 236 * |
| 236 * @param changeSet a description of the changes that are to be applied | 237 * @param changeSet a description of the changes that are to be applied |
| 237 */ | 238 */ |
| 238 void applyChanges(ChangeSet changeSet); | 239 void applyChanges(ChangeSet changeSet); |
| 239 | 240 |
| 240 /** | 241 /** |
| 241 * Return the documentation comment for the given element as it appears in the
original source | 242 * Return the documentation comment for the given element as it appears in the
original source |
| 242 * (complete with the beginning and ending delimiters), or `null` if the eleme
nt does not | 243 * (complete with the beginning and ending delimiters) for block documentation
comments, or lines |
| 243 * have a documentation comment associated with it. This can be a long-running
operation if the | 244 * starting with `"///"` and separated with `"\n"` characters for end-of-line |
| 244 * information needed to access the comment is not cached. | 245 * documentation comments, or `null` if the element does not have a documentat
ion comment |
| 246 * associated with it. This can be a long-running operation if the information
needed to access |
| 247 * the comment is not cached. |
| 245 * | 248 * |
| 246 * <b>Note:</b> This method cannot be used in an async environment. | 249 * <b>Note:</b> This method cannot be used in an async environment. |
| 247 * | 250 * |
| 248 * @param element the element whose documentation comment is to be returned | 251 * @param element the element whose documentation comment is to be returned |
| 249 * @return the element's documentation comment | 252 * @return the element's documentation comment |
| 250 * @throws AnalysisException if the documentation comment could not be determi
ned because the | 253 * @throws AnalysisException if the documentation comment could not be determi
ned because the |
| 251 * analysis could not be performed | 254 * analysis could not be performed |
| 252 */ | 255 */ |
| 253 String computeDocumentationComment(Element element); | 256 String computeDocumentationComment(Element element); |
| 254 | 257 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 * This method should be used rather than the method [Source#getContents] beca
use contexts | 395 * This method should be used rather than the method [Source#getContents] beca
use contexts |
| 393 * can have local overrides of the content of a source that the source is not
aware of. | 396 * can have local overrides of the content of a source that the source is not
aware of. |
| 394 * | 397 * |
| 395 * @param source the source whose content is to be returned | 398 * @param source the source whose content is to be returned |
| 396 * @return the contents and timestamp of the source | 399 * @return the contents and timestamp of the source |
| 397 * @throws Exception if the contents of the source could not be accessed | 400 * @throws Exception if the contents of the source could not be accessed |
| 398 */ | 401 */ |
| 399 TimestampedData<String> getContents(Source source); | 402 TimestampedData<String> getContents(Source source); |
| 400 | 403 |
| 401 /** | 404 /** |
| 405 * Return the set of declared variables used when computing constant values. |
| 406 * |
| 407 * @return the set of declared variables used when computing constant values |
| 408 */ |
| 409 DeclaredVariables get declaredVariables; |
| 410 |
| 411 /** |
| 402 * Return the element referenced by the given location, or `null` if the eleme
nt is not | 412 * Return the element referenced by the given location, or `null` if the eleme
nt is not |
| 403 * immediately available or if there is no element with the given location. Th
e latter condition | 413 * immediately available or if there is no element with the given location. Th
e latter condition |
| 404 * can occur, for example, if the location describes an element from a differe
nt context or if the | 414 * can occur, for example, if the location describes an element from a differe
nt context or if the |
| 405 * element has been removed from this context as a result of some change since
it was originally | 415 * element has been removed from this context as a result of some change since
it was originally |
| 406 * obtained. | 416 * obtained. |
| 407 * | 417 * |
| 408 * @param location the reference describing the element to be returned | 418 * @param location the reference describing the element to be returned |
| 409 * @return the element referenced by the given location | 419 * @return the element referenced by the given location |
| 410 */ | 420 */ |
| 411 Element getElement(ElementLocation location); | 421 Element getElement(ElementLocation location); |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 * A cache of content used to override the default content of a source. | 832 * A cache of content used to override the default content of a source. |
| 823 */ | 833 */ |
| 824 ContentCache _contentCache = new ContentCache(); | 834 ContentCache _contentCache = new ContentCache(); |
| 825 | 835 |
| 826 /** | 836 /** |
| 827 * The source factory used to create the sources that can be analyzed in this
context. | 837 * The source factory used to create the sources that can be analyzed in this
context. |
| 828 */ | 838 */ |
| 829 SourceFactory _sourceFactory; | 839 SourceFactory _sourceFactory; |
| 830 | 840 |
| 831 /** | 841 /** |
| 842 * The set of declared variables used when computing constant values. |
| 843 */ |
| 844 DeclaredVariables _declaredVariables = new DeclaredVariables(); |
| 845 |
| 846 /** |
| 832 * A source representing the core library. | 847 * A source representing the core library. |
| 833 */ | 848 */ |
| 834 Source _coreLibrarySource; | 849 Source _coreLibrarySource; |
| 835 | 850 |
| 836 /** | 851 /** |
| 837 * The partition that contains analysis results that are not shared with other
contexts. | 852 * The partition that contains analysis results that are not shared with other
contexts. |
| 838 */ | 853 */ |
| 839 CachePartition _privatePartition; | 854 CachePartition _privatePartition; |
| 840 | 855 |
| 841 /** | 856 /** |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 while (nameNode != null) { | 1041 while (nameNode != null) { |
| 1027 if (nameNode is AnnotatedNode) { | 1042 if (nameNode is AnnotatedNode) { |
| 1028 Comment comment = (nameNode as AnnotatedNode).documentationComment; | 1043 Comment comment = (nameNode as AnnotatedNode).documentationComment; |
| 1029 if (comment == null) { | 1044 if (comment == null) { |
| 1030 return null; | 1045 return null; |
| 1031 } | 1046 } |
| 1032 JavaStringBuilder builder = new JavaStringBuilder(); | 1047 JavaStringBuilder builder = new JavaStringBuilder(); |
| 1033 List<Token> tokens = comment.tokens; | 1048 List<Token> tokens = comment.tokens; |
| 1034 for (int i = 0; i < tokens.length; i++) { | 1049 for (int i = 0; i < tokens.length; i++) { |
| 1035 if (i > 0) { | 1050 if (i > 0) { |
| 1036 builder.append('\n'); | 1051 builder.append("\n"); |
| 1037 } | 1052 } |
| 1038 builder.append(tokens[i].lexeme); | 1053 builder.append(tokens[i].lexeme); |
| 1039 } | 1054 } |
| 1040 return builder.toString(); | 1055 return builder.toString(); |
| 1041 } | 1056 } |
| 1042 nameNode = nameNode.parent; | 1057 nameNode = nameNode.parent; |
| 1043 } | 1058 } |
| 1044 return null; | 1059 return null; |
| 1045 } | 1060 } |
| 1046 | 1061 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 @override | 1241 @override |
| 1227 TimestampedData<String> getContents(Source source) { | 1242 TimestampedData<String> getContents(Source source) { |
| 1228 String contents = _contentCache.getContents(source); | 1243 String contents = _contentCache.getContents(source); |
| 1229 if (contents != null) { | 1244 if (contents != null) { |
| 1230 return new TimestampedData<String>(_contentCache.getModificationStamp(sour
ce), contents); | 1245 return new TimestampedData<String>(_contentCache.getModificationStamp(sour
ce), contents); |
| 1231 } | 1246 } |
| 1232 return source.contents; | 1247 return source.contents; |
| 1233 } | 1248 } |
| 1234 | 1249 |
| 1235 @override | 1250 @override |
| 1251 DeclaredVariables get declaredVariables => _declaredVariables; |
| 1252 |
| 1253 @override |
| 1236 Element getElement(ElementLocation location) { | 1254 Element getElement(ElementLocation location) { |
| 1237 // TODO(brianwilkerson) This should not be a "get" method. | 1255 // TODO(brianwilkerson) This should not be a "get" method. |
| 1238 try { | 1256 try { |
| 1239 List<String> components = (location as ElementLocationImpl).components; | 1257 List<String> components = (location as ElementLocationImpl).components; |
| 1240 Source librarySource = _computeSourceFromEncoding(components[0]); | 1258 Source librarySource = _computeSourceFromEncoding(components[0]); |
| 1241 ElementImpl element = computeLibraryElement(librarySource) as ElementImpl; | 1259 ElementImpl element = computeLibraryElement(librarySource) as ElementImpl; |
| 1242 for (int i = 1; i < components.length; i++) { | 1260 for (int i = 1; i < components.length; i++) { |
| 1243 if (element == null) { | 1261 if (element == null) { |
| 1244 return null; | 1262 return null; |
| 1245 } | 1263 } |
| (...skipping 3732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4978 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 4996 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 4979 * | 4997 * |
| 4980 * @param source the source that has been added | 4998 * @param source the source that has been added |
| 4981 * @return `true` if the new source is a Dart file | 4999 * @return `true` if the new source is a Dart file |
| 4982 */ | 5000 */ |
| 4983 bool _sourceAvailable(Source source) { | 5001 bool _sourceAvailable(Source source) { |
| 4984 SourceEntry sourceEntry = _cache.get(source); | 5002 SourceEntry sourceEntry = _cache.get(source); |
| 4985 if (sourceEntry == null) { | 5003 if (sourceEntry == null) { |
| 4986 sourceEntry = _createSourceEntry(source, true); | 5004 sourceEntry = _createSourceEntry(source, true); |
| 4987 } else { | 5005 } else { |
| 4988 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; | 5006 _sourceChanged(source); |
| 4989 int newTime = getModificationStamp(source); | 5007 sourceEntry = _cache.get(source); |
| 4990 sourceCopy.modificationTime = newTime; | |
| 4991 sourceCopy.explicitlyAdded = true; | |
| 4992 // TODO(brianwilkerson) Understand why we're not invalidating the cached d
ata. | |
| 4993 _cache.put(source, sourceCopy); | |
| 4994 } | 5008 } |
| 4995 if (sourceEntry is HtmlEntry) { | 5009 if (sourceEntry is HtmlEntry) { |
| 4996 _workManager.add(source, SourcePriority.HTML); | 5010 _workManager.add(source, SourcePriority.HTML); |
| 4997 } else { | 5011 } else { |
| 4998 _workManager.add(source, SourcePriority.UNKNOWN); | 5012 _workManager.add(source, SourcePriority.UNKNOWN); |
| 4999 } | 5013 } |
| 5000 return sourceEntry is DartEntry; | 5014 return sourceEntry is DartEntry; |
| 5001 } | 5015 } |
| 5002 | 5016 |
| 5003 /** | 5017 /** |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5020 _cache.put(source, htmlCopy); | 5034 _cache.put(source, htmlCopy); |
| 5021 _cache.removedAst(source); | 5035 _cache.removedAst(source); |
| 5022 _workManager.add(source, SourcePriority.HTML); | 5036 _workManager.add(source, SourcePriority.HTML); |
| 5023 } else if (sourceEntry is DartEntry) { | 5037 } else if (sourceEntry is DartEntry) { |
| 5024 List<Source> containingLibraries = getLibrariesContaining(source); | 5038 List<Source> containingLibraries = getLibrariesContaining(source); |
| 5025 Set<Source> librariesToInvalidate = new Set<Source>(); | 5039 Set<Source> librariesToInvalidate = new Set<Source>(); |
| 5026 for (Source containingLibrary in containingLibraries) { | 5040 for (Source containingLibrary in containingLibraries) { |
| 5027 _computeAllLibrariesDependingOn(containingLibrary, librariesToInvalidate
); | 5041 _computeAllLibrariesDependingOn(containingLibrary, librariesToInvalidate
); |
| 5028 } | 5042 } |
| 5029 for (Source library in librariesToInvalidate) { | 5043 for (Source library in librariesToInvalidate) { |
| 5030 // for (Source library : containingLibraries) { | |
| 5031 _invalidateLibraryResolution(library); | 5044 _invalidateLibraryResolution(library); |
| 5032 } | 5045 } |
| 5033 _removeFromParts(source, _cache.get(source) as DartEntry); | 5046 _removeFromParts(source, _cache.get(source) as DartEntry); |
| 5034 DartEntryImpl dartCopy = (_cache.get(source) as DartEntry).writableCopy; | 5047 DartEntryImpl dartCopy = (_cache.get(source) as DartEntry).writableCopy; |
| 5035 dartCopy.modificationTime = getModificationStamp(source); | 5048 dartCopy.modificationTime = getModificationStamp(source); |
| 5036 dartCopy.invalidateAllInformation(); | 5049 dartCopy.invalidateAllInformation(); |
| 5037 _cache.put(source, dartCopy); | 5050 _cache.put(source, dartCopy); |
| 5038 _cache.removedAst(source); | 5051 _cache.removedAst(source); |
| 5039 _workManager.add(source, SourcePriority.UNKNOWN); | 5052 _workManager.add(source, SourcePriority.UNKNOWN); |
| 5040 } | 5053 } |
| (...skipping 6704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11745 return _basis.getCompilationUnitElement(unitSource, librarySource); | 11758 return _basis.getCompilationUnitElement(unitSource, librarySource); |
| 11746 } finally { | 11759 } finally { |
| 11747 instrumentation.log(); | 11760 instrumentation.log(); |
| 11748 } | 11761 } |
| 11749 } | 11762 } |
| 11750 | 11763 |
| 11751 @override | 11764 @override |
| 11752 TimestampedData<String> getContents(Source source) => _basis.getContents(sourc
e); | 11765 TimestampedData<String> getContents(Source source) => _basis.getContents(sourc
e); |
| 11753 | 11766 |
| 11754 @override | 11767 @override |
| 11768 DeclaredVariables get declaredVariables => _basis.declaredVariables; |
| 11769 |
| 11770 @override |
| 11755 Element getElement(ElementLocation location) { | 11771 Element getElement(ElementLocation location) { |
| 11756 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getElement"); | 11772 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getElement"); |
| 11757 _checkThread(instrumentation); | 11773 _checkThread(instrumentation); |
| 11758 try { | 11774 try { |
| 11759 instrumentation.metric3("contextId", _contextId); | 11775 instrumentation.metric3("contextId", _contextId); |
| 11760 return _basis.getElement(location); | 11776 return _basis.getElement(location); |
| 11761 } finally { | 11777 } finally { |
| 11762 instrumentation.log(); | 11778 instrumentation.log(); |
| 11763 } | 11779 } |
| 11764 } | 11780 } |
| (...skipping 3586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15351 _index++; | 15367 _index++; |
| 15352 if (_index >= WorkManager_this._workQueues[_queueIndex].length) { | 15368 if (_index >= WorkManager_this._workQueues[_queueIndex].length) { |
| 15353 _index = 0; | 15369 _index = 0; |
| 15354 _queueIndex++; | 15370 _queueIndex++; |
| 15355 while (_queueIndex < WorkManager_this._workQueues.length && WorkManager_th
is._workQueues[_queueIndex].isEmpty) { | 15371 while (_queueIndex < WorkManager_this._workQueues.length && WorkManager_th
is._workQueues[_queueIndex].isEmpty) { |
| 15356 _queueIndex++; | 15372 _queueIndex++; |
| 15357 } | 15373 } |
| 15358 } | 15374 } |
| 15359 } | 15375 } |
| 15360 } | 15376 } |
| OLD | NEW |