Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1473)

Side by Side Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 899753004: Send notificatinos after no-op changes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Schedule source analysis only if a change was made Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 bool shouldBeScheduled = false;
1872 List<Source> librariesContaining = dartEntry.containingLibraries;
1873 for (Source librarySource in librariesContaining) {
1874 if (dartEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) ==
1875 CacheState.FLUSHED) {
1876 dartEntry.setStateInLibrary(
1877 DartEntry.RESOLVED_UNIT,
1878 librarySource,
1879 CacheState.INVALID);
1880 shouldBeScheduled = true;
1881 }
1882 }
1883 if (shouldBeScheduled) {
1884 _workManager.add(source, SourcePriority.UNKNOWN);
1885 }
1886 // We cannot provide a resolved unit right now,
1887 // but the future analysis will.
1888 return null;
1889 }
1890
1891 @override
1859 bool exists(Source source) { 1892 bool exists(Source source) {
1860 if (source == null) { 1893 if (source == null) {
1861 return false; 1894 return false;
1862 } 1895 }
1863 if (_contentCache.getContents(source) != null) { 1896 if (_contentCache.getContents(source) != null) {
1864 return true; 1897 return true;
1865 } 1898 }
1866 return source.exists(); 1899 return source.exists();
1867 } 1900 }
1868 1901
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 } 2210 }
2178 bool changed = newContents != originalContents; 2211 bool changed = newContents != originalContents;
2179 if (newContents != null) { 2212 if (newContents != null) {
2180 if (newContents != originalContents) { 2213 if (newContents != originalContents) {
2181 _incrementalAnalysisCache = 2214 _incrementalAnalysisCache =
2182 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); 2215 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source);
2183 if (!analysisOptions.incremental || 2216 if (!analysisOptions.incremental ||
2184 !_tryPoorMansIncrementalResolution(source, newContents)) { 2217 !_tryPoorMansIncrementalResolution(source, newContents)) {
2185 _sourceChanged(source); 2218 _sourceChanged(source);
2186 } 2219 }
2187 if (sourceEntry != null) { 2220 sourceEntry.modificationTime =
2188 sourceEntry.modificationTime = 2221 _contentCache.getModificationStamp(source);
2189 _contentCache.getModificationStamp(source); 2222 sourceEntry.setValue(SourceEntry.CONTENT, newContents);
2190 sourceEntry.setValue(SourceEntry.CONTENT, newContents);
2191 }
2192 } else { 2223 } else {
2193 if (sourceEntry != null) { 2224 sourceEntry.modificationTime =
2194 sourceEntry.modificationTime = 2225 _contentCache.getModificationStamp(source);
2195 _contentCache.getModificationStamp(source);
2196 }
2197 } 2226 }
2198 } else if (originalContents != null) { 2227 } else if (originalContents != null) {
2199 _incrementalAnalysisCache = 2228 _incrementalAnalysisCache =
2200 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); 2229 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source);
2201 changed = newContents != originalContents; 2230 changed = newContents != originalContents;
2202 // We are removing the overlay for the file, check if the file's 2231 // We are removing the overlay for the file, check if the file's
2203 // contents is the same as it was in the overlay. 2232 // contents is the same as it was in the overlay.
2204 if (sourceEntry != null) { 2233 try {
2205 try { 2234 TimestampedData<String> fileContents = getContents(source);
2206 TimestampedData<String> fileContents = getContents(source); 2235 String fileContentsData = fileContents.data;
2207 String fileContentsData = fileContents.data; 2236 if (fileContentsData == originalContents) {
2208 if (fileContentsData == originalContents) { 2237 sourceEntry.modificationTime = fileContents.modificationTime;
2209 sourceEntry.modificationTime = fileContents.modificationTime; 2238 sourceEntry.setValue(SourceEntry.CONTENT, fileContentsData);
2210 sourceEntry.setValue(SourceEntry.CONTENT, fileContentsData); 2239 changed = false;
2211 changed = false;
2212 }
2213 } catch (e) {
2214 } 2240 }
2241 } catch (e) {
2215 } 2242 }
2216 // If not the same content (e.g. the file is being closed without save), 2243 // If not the same content (e.g. the file is being closed without save),
2217 // then force analysis. 2244 // then force analysis.
2218 if (changed) { 2245 if (changed) {
2219 _sourceChanged(source); 2246 _sourceChanged(source);
2220 } 2247 }
2221 } 2248 }
2222 if (notify && changed) { 2249 if (notify && changed) {
2223 _onSourcesChangedController.add( 2250 _onSourcesChangedController.add(
2224 new SourcesChangedEvent.changedContent(source, newContents)); 2251 new SourcesChangedEvent.changedContent(source, newContents));
(...skipping 7471 matching lines...) Expand 10 before | Expand all | Expand 10 after
9696 * 9723 *
9697 * <b>Note:</b> This method cannot be used in an async environment 9724 * <b>Note:</b> This method cannot be used in an async environment
9698 * 9725 *
9699 * @param source the compilation unit for which an AST structure should be ret urned 9726 * @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 9727 * @return the AST structure representing the content of the source
9701 * @throws AnalysisException if the analysis could not be performed 9728 * @throws AnalysisException if the analysis could not be performed
9702 */ 9729 */
9703 CompilationUnit computeResolvableCompilationUnit(Source source); 9730 CompilationUnit computeResolvableCompilationUnit(Source source);
9704 9731
9705 /** 9732 /**
9733 * Return any resolved [CompilationUnit] for the given [source] if not
9734 * flushed, otherwise return `null` and ensures that the [CompilationUnit]
9735 * will be eventually returned to the client from [performAnalysisTask].
9736 */
9737 CompilationUnit ensureAnyResolvedDartUnit(Source source);
9738
9739 /**
9706 * Return context that owns the given source. 9740 * Return context that owns the given source.
9707 * 9741 *
9708 * @param source the source whose context is to be returned 9742 * @param source the source whose context is to be returned
9709 * @return the context that owns the partition that contains the source 9743 * @return the context that owns the partition that contains the source
9710 */ 9744 */
9711 InternalAnalysisContext getContextFor(Source source); 9745 InternalAnalysisContext getContextFor(Source source);
9712 9746
9713 /** 9747 /**
9714 * Return a namespace containing mappings for all of the public names defined by the given 9748 * Return a namespace containing mappings for all of the public names defined by the given
9715 * library. 9749 * library.
9716 * 9750 *
9717 * @param library the library whose public namespace is to be returned 9751 * @param library the library whose public namespace is to be returned
9718 * @return the public namespace of the given library 9752 * @return the public namespace of the given library
9719 */ 9753 */
9720 Namespace getPublicNamespace(LibraryElement library); 9754 Namespace getPublicNamespace(LibraryElement library);
9721 9755
9722 /** 9756 /**
9723 * Respond to a change which has been made to the given [source] file. 9757 * Respond to a change which has been made to the given [source] file.
9724 * [originalContents] is the former contents of the file, and [newContents] 9758 * [originalContents] is the former contents of the file, and [newContents]
9725 * is the updated contents. If [notify] is true, a source changed event is 9759 * is the updated contents. If [notify] is true, a source changed event is
9726 * triggered. 9760 * triggered.
9727 * 9761 *
9728 * Normally it should not be necessary for clinets to call this function, 9762 * 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 9763 * since it will be automatically invoked in response to a call to
9730 * [applyChanges] or [setContents]. However, if this analysis context is 9764 * [applyChanges] or [setContents]. However, if this analysis context is
9731 * sharing its content cache with other contexts, then the client must 9765 * sharing its content cache with other contexts, then the client must
9732 * manually update the content cache and call this function for each context. 9766 * manually update the content cache and call this function for each context.
9733 * 9767 *
9734 * Return `true` if the change was significant to this context (i.e. [source] 9768 * 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 9769 * is either implicitly or explicitly analyzed by this context, and a change
9736 * actually occurred). 9770 * actually occurred).
9737 */ 9771 */
9738 bool handleContentsChanged(Source source, String originalContents, 9772 bool handleContentsChanged(Source source, String originalContents,
(...skipping 2582 matching lines...) Expand 10 before | Expand all | Expand 10 after
12321 if (element.id == _id) { 12355 if (element.id == _id) {
12322 result = element; 12356 result = element;
12323 throw new _ElementByIdFinderException(); 12357 throw new _ElementByIdFinderException();
12324 } 12358 }
12325 super.visitElement(element); 12359 super.visitElement(element);
12326 } 12360 }
12327 } 12361 }
12328 12362
12329 class _ElementByIdFinderException { 12363 class _ElementByIdFinderException {
12330 } 12364 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/analysis/update_content_test.dart ('k') | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698