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 // 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 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1849 _disposed = true; | 1849 _disposed = true; |
| 1850 for (List<PendingFuture> pendingFutures in _pendingFutureSources.values) { | 1850 for (List<PendingFuture> pendingFutures in _pendingFutureSources.values) { |
| 1851 for (PendingFuture pendingFuture in pendingFutures) { | 1851 for (PendingFuture pendingFuture in pendingFutures) { |
| 1852 pendingFuture.forciblyComplete(); | 1852 pendingFuture.forciblyComplete(); |
| 1853 } | 1853 } |
| 1854 } | 1854 } |
| 1855 _pendingFutureSources.clear(); | 1855 _pendingFutureSources.clear(); |
| 1856 } | 1856 } |
| 1857 | 1857 |
| 1858 @override | 1858 @override |
| 1859 CompilationUnit ensureAnyResolvedDartUnit(Source source) { | |
| 1860 SourceEntry sourceEntry = _cache.get(source); | |
| 1861 if (sourceEntry is! DartEntry) { | |
| 1862 return null; | |
| 1863 } | |
| 1864 DartEntry dartEntry = sourceEntry; | |
| 1865 // Check if there is a resolved unit. | |
| 1866 CompilationUnit unit = dartEntry.anyResolvedCompilationUnit; | |
| 1867 if (unit != null) { | |
| 1868 return unit; | |
| 1869 } | |
| 1870 // Invalidate the flushed RESOLVED_UNIT to force it eventually. | |
| 1871 List<Source> librariesContaining = dartEntry.containingLibraries; | |
| 1872 for (Source librarySource in librariesContaining) { | |
| 1873 if (dartEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) == | |
| 1874 CacheState.FLUSHED) { | |
| 1875 dartEntry.setStateInLibrary( | |
| 1876 DartEntry.RESOLVED_UNIT, | |
| 1877 librarySource, | |
| 1878 CacheState.INVALID); | |
| 1879 } | |
| 1880 } | |
| 1881 // We cannot provide a resolved unit right now, | |
| 1882 // but the future analysis will. | |
| 1883 _workManager.add(source, SourcePriority.UNKNOWN); | |
|
Brian Wilkerson
2015/02/05 20:07:59
If the state was INVALID (or anything other than V
scheglov
2015/02/05 20:42:03
Done.
| |
| 1884 return null; | |
| 1885 } | |
| 1886 | |
| 1887 @override | |
| 1859 bool exists(Source source) { | 1888 bool exists(Source source) { |
| 1860 if (source == null) { | 1889 if (source == null) { |
| 1861 return false; | 1890 return false; |
| 1862 } | 1891 } |
| 1863 if (_contentCache.getContents(source) != null) { | 1892 if (_contentCache.getContents(source) != null) { |
| 1864 return true; | 1893 return true; |
| 1865 } | 1894 } |
| 1866 return source.exists(); | 1895 return source.exists(); |
| 1867 } | 1896 } |
| 1868 | 1897 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2177 } | 2206 } |
| 2178 bool changed = newContents != originalContents; | 2207 bool changed = newContents != originalContents; |
| 2179 if (newContents != null) { | 2208 if (newContents != null) { |
| 2180 if (newContents != originalContents) { | 2209 if (newContents != originalContents) { |
| 2181 _incrementalAnalysisCache = | 2210 _incrementalAnalysisCache = |
| 2182 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); | 2211 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); |
| 2183 if (!analysisOptions.incremental || | 2212 if (!analysisOptions.incremental || |
| 2184 !_tryPoorMansIncrementalResolution(source, newContents)) { | 2213 !_tryPoorMansIncrementalResolution(source, newContents)) { |
| 2185 _sourceChanged(source); | 2214 _sourceChanged(source); |
| 2186 } | 2215 } |
| 2187 if (sourceEntry != null) { | 2216 sourceEntry.modificationTime = |
| 2188 sourceEntry.modificationTime = | 2217 _contentCache.getModificationStamp(source); |
| 2189 _contentCache.getModificationStamp(source); | 2218 sourceEntry.setValue(SourceEntry.CONTENT, newContents); |
| 2190 sourceEntry.setValue(SourceEntry.CONTENT, newContents); | |
| 2191 } | |
| 2192 } else { | 2219 } else { |
| 2193 if (sourceEntry != null) { | 2220 sourceEntry.modificationTime = |
| 2194 sourceEntry.modificationTime = | 2221 _contentCache.getModificationStamp(source); |
| 2195 _contentCache.getModificationStamp(source); | |
| 2196 } | |
| 2197 } | 2222 } |
| 2198 } else if (originalContents != null) { | 2223 } else if (originalContents != null) { |
| 2199 _incrementalAnalysisCache = | 2224 _incrementalAnalysisCache = |
| 2200 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); | 2225 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); |
| 2201 changed = newContents != originalContents; | 2226 changed = newContents != originalContents; |
| 2202 // We are removing the overlay for the file, check if the file's | 2227 // We are removing the overlay for the file, check if the file's |
| 2203 // contents is the same as it was in the overlay. | 2228 // contents is the same as it was in the overlay. |
| 2204 if (sourceEntry != null) { | 2229 try { |
| 2205 try { | 2230 TimestampedData<String> fileContents = getContents(source); |
| 2206 TimestampedData<String> fileContents = getContents(source); | 2231 String fileContentsData = fileContents.data; |
| 2207 String fileContentsData = fileContents.data; | 2232 if (fileContentsData == originalContents) { |
| 2208 if (fileContentsData == originalContents) { | 2233 sourceEntry.modificationTime = fileContents.modificationTime; |
| 2209 sourceEntry.modificationTime = fileContents.modificationTime; | 2234 sourceEntry.setValue(SourceEntry.CONTENT, fileContentsData); |
| 2210 sourceEntry.setValue(SourceEntry.CONTENT, fileContentsData); | 2235 changed = false; |
| 2211 changed = false; | |
| 2212 } | |
| 2213 } catch (e) { | |
| 2214 } | 2236 } |
| 2237 } catch (e) { | |
| 2215 } | 2238 } |
| 2216 // If not the same content (e.g. the file is being closed without save), | 2239 // If not the same content (e.g. the file is being closed without save), |
| 2217 // then force analysis. | 2240 // then force analysis. |
| 2218 if (changed) { | 2241 if (changed) { |
| 2219 _sourceChanged(source); | 2242 _sourceChanged(source); |
| 2220 } | 2243 } |
| 2221 } | 2244 } |
| 2222 if (notify && changed) { | 2245 if (notify && changed) { |
| 2223 _onSourcesChangedController.add( | 2246 _onSourcesChangedController.add( |
| 2224 new SourcesChangedEvent.changedContent(source, newContents)); | 2247 new SourcesChangedEvent.changedContent(source, newContents)); |
| (...skipping 7471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9696 * | 9719 * |
| 9697 * <b>Note:</b> This method cannot be used in an async environment | 9720 * <b>Note:</b> This method cannot be used in an async environment |
| 9698 * | 9721 * |
| 9699 * @param source the compilation unit for which an AST structure should be ret urned | 9722 * @param source the compilation unit for which an AST structure should be ret urned |
| 9700 * @return the AST structure representing the content of the source | 9723 * @return the AST structure representing the content of the source |
| 9701 * @throws AnalysisException if the analysis could not be performed | 9724 * @throws AnalysisException if the analysis could not be performed |
| 9702 */ | 9725 */ |
| 9703 CompilationUnit computeResolvableCompilationUnit(Source source); | 9726 CompilationUnit computeResolvableCompilationUnit(Source source); |
| 9704 | 9727 |
| 9705 /** | 9728 /** |
| 9729 * Return any resolved [CompilationUnit] for the given [source] if not | |
| 9730 * flushed, otherwise return `null` and ensures that the [CompilationUnit] | |
| 9731 * will be eventually returned to the client from [performAnalysisTask]. | |
| 9732 */ | |
| 9733 CompilationUnit ensureAnyResolvedDartUnit(Source source); | |
| 9734 | |
| 9735 /** | |
| 9706 * Return context that owns the given source. | 9736 * Return context that owns the given source. |
| 9707 * | 9737 * |
| 9708 * @param source the source whose context is to be returned | 9738 * @param source the source whose context is to be returned |
| 9709 * @return the context that owns the partition that contains the source | 9739 * @return the context that owns the partition that contains the source |
| 9710 */ | 9740 */ |
| 9711 InternalAnalysisContext getContextFor(Source source); | 9741 InternalAnalysisContext getContextFor(Source source); |
| 9712 | 9742 |
| 9713 /** | 9743 /** |
| 9714 * Return a namespace containing mappings for all of the public names defined by the given | 9744 * Return a namespace containing mappings for all of the public names defined by the given |
| 9715 * library. | 9745 * library. |
| 9716 * | 9746 * |
| 9717 * @param library the library whose public namespace is to be returned | 9747 * @param library the library whose public namespace is to be returned |
| 9718 * @return the public namespace of the given library | 9748 * @return the public namespace of the given library |
| 9719 */ | 9749 */ |
| 9720 Namespace getPublicNamespace(LibraryElement library); | 9750 Namespace getPublicNamespace(LibraryElement library); |
| 9721 | 9751 |
| 9722 /** | 9752 /** |
| 9723 * Respond to a change which has been made to the given [source] file. | 9753 * Respond to a change which has been made to the given [source] file. |
| 9724 * [originalContents] is the former contents of the file, and [newContents] | 9754 * [originalContents] is the former contents of the file, and [newContents] |
| 9725 * is the updated contents. If [notify] is true, a source changed event is | 9755 * is the updated contents. If [notify] is true, a source changed event is |
| 9726 * triggered. | 9756 * triggered. |
| 9727 * | 9757 * |
| 9728 * Normally it should not be necessary for clinets to call this function, | 9758 * Normally it should not be necessary for clients to call this function, |
| 9729 * since it will be automatically invoked in response to a call to | 9759 * since it will be automatically invoked in response to a call to |
| 9730 * [applyChanges] or [setContents]. However, if this analysis context is | 9760 * [applyChanges] or [setContents]. However, if this analysis context is |
| 9731 * sharing its content cache with other contexts, then the client must | 9761 * sharing its content cache with other contexts, then the client must |
| 9732 * manually update the content cache and call this function for each context. | 9762 * manually update the content cache and call this function for each context. |
| 9733 * | 9763 * |
| 9734 * Return `true` if the change was significant to this context (i.e. [source] | 9764 * Return `true` if the change was significant to this context (i.e. [source] |
| 9735 * is either implicitly or explicitly analyzed by this context, and a change | 9765 * is either implicitly or explicitly analyzed by this context, and a change |
| 9736 * actually occurred). | 9766 * actually occurred). |
| 9737 */ | 9767 */ |
| 9738 bool handleContentsChanged(Source source, String originalContents, | 9768 bool handleContentsChanged(Source source, String originalContents, |
| (...skipping 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12321 if (element.id == _id) { | 12351 if (element.id == _id) { |
| 12322 result = element; | 12352 result = element; |
| 12323 throw new _ElementByIdFinderException(); | 12353 throw new _ElementByIdFinderException(); |
| 12324 } | 12354 } |
| 12325 super.visitElement(element); | 12355 super.visitElement(element); |
| 12326 } | 12356 } |
| 12327 } | 12357 } |
| 12328 | 12358 |
| 12329 class _ElementByIdFinderException { | 12359 class _ElementByIdFinderException { |
| 12330 } | 12360 } |
| OLD | NEW |