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

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

Issue 759083003: Allow the contents of the analysis cache to be inspected via html debugging. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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
« no previous file with comments | « pkg/analysis_server/lib/src/get_handler.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1673 return false; 1673 return false;
1674 } 1674 }
1675 if (_contentCache.getContents(source) != null) { 1675 if (_contentCache.getContents(source) != null) {
1676 return true; 1676 return true;
1677 } 1677 }
1678 return source.exists(); 1678 return source.exists();
1679 } 1679 }
1680 1680
1681 @override 1681 @override
1682 AngularApplication getAngularApplicationWithHtml(Source htmlSource) { 1682 AngularApplication getAngularApplicationWithHtml(Source htmlSource) {
1683 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(htmlSource); 1683 SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource);
1684 if (sourceEntry is HtmlEntry) { 1684 if (sourceEntry is HtmlEntry) {
1685 HtmlEntry htmlEntry = sourceEntry; 1685 HtmlEntry htmlEntry = sourceEntry;
1686 AngularApplication application = 1686 AngularApplication application =
1687 htmlEntry.getValue(HtmlEntry.ANGULAR_APPLICATION); 1687 htmlEntry.getValue(HtmlEntry.ANGULAR_APPLICATION);
1688 if (application != null) { 1688 if (application != null) {
1689 return application; 1689 return application;
1690 } 1690 }
1691 return htmlEntry.getValue(HtmlEntry.ANGULAR_ENTRY); 1691 return htmlEntry.getValue(HtmlEntry.ANGULAR_ENTRY);
1692 } 1692 }
1693 return null; 1693 return null;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 if (AnalysisEngine.isHtmlFileName(sourceName)) { 1751 if (AnalysisEngine.isHtmlFileName(sourceName)) {
1752 return computeHtmlElement(source); 1752 return computeHtmlElement(source);
1753 } 1753 }
1754 } on AnalysisException catch (exception) { 1754 } on AnalysisException catch (exception) {
1755 } 1755 }
1756 return null; 1756 return null;
1757 } 1757 }
1758 1758
1759 @override 1759 @override
1760 AnalysisErrorInfo getErrors(Source source) { 1760 AnalysisErrorInfo getErrors(Source source) {
1761 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source); 1761 SourceEntry sourceEntry = getReadableSourceEntryOrNull(source);
1762 if (sourceEntry is DartEntry) { 1762 if (sourceEntry is DartEntry) {
1763 DartEntry dartEntry = sourceEntry; 1763 DartEntry dartEntry = sourceEntry;
1764 return new AnalysisErrorInfoImpl( 1764 return new AnalysisErrorInfoImpl(
1765 dartEntry.allErrors, 1765 dartEntry.allErrors,
1766 dartEntry.getValue(SourceEntry.LINE_INFO)); 1766 dartEntry.getValue(SourceEntry.LINE_INFO));
1767 } else if (sourceEntry is HtmlEntry) { 1767 } else if (sourceEntry is HtmlEntry) {
1768 HtmlEntry htmlEntry = sourceEntry; 1768 HtmlEntry htmlEntry = sourceEntry;
1769 return new AnalysisErrorInfoImpl( 1769 return new AnalysisErrorInfoImpl(
1770 htmlEntry.allErrors, 1770 htmlEntry.allErrors,
1771 htmlEntry.getValue(SourceEntry.LINE_INFO)); 1771 htmlEntry.getValue(SourceEntry.LINE_INFO));
1772 } 1772 }
1773 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, null); 1773 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, null);
1774 } 1774 }
1775 1775
1776 @override 1776 @override
1777 HtmlElement getHtmlElement(Source source) { 1777 HtmlElement getHtmlElement(Source source) {
1778 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source); 1778 SourceEntry sourceEntry = getReadableSourceEntryOrNull(source);
1779 if (sourceEntry is HtmlEntry) { 1779 if (sourceEntry is HtmlEntry) {
1780 return sourceEntry.getValue(HtmlEntry.ELEMENT); 1780 return sourceEntry.getValue(HtmlEntry.ELEMENT);
1781 } 1781 }
1782 return null; 1782 return null;
1783 } 1783 }
1784 1784
1785 @override 1785 @override
1786 List<Source> getHtmlFilesReferencing(Source source) { 1786 List<Source> getHtmlFilesReferencing(Source source) {
1787 SourceKind sourceKind = getKindOf(source); 1787 SourceKind sourceKind = getKindOf(source);
1788 if (sourceKind == null) { 1788 if (sourceKind == null) {
(...skipping 30 matching lines...) Expand all
1819 break; 1819 break;
1820 } 1820 }
1821 if (htmlSources.isEmpty) { 1821 if (htmlSources.isEmpty) {
1822 return Source.EMPTY_ARRAY; 1822 return Source.EMPTY_ARRAY;
1823 } 1823 }
1824 return htmlSources; 1824 return htmlSources;
1825 } 1825 }
1826 1826
1827 @override 1827 @override
1828 SourceKind getKindOf(Source source) { 1828 SourceKind getKindOf(Source source) {
1829 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source); 1829 SourceEntry sourceEntry = getReadableSourceEntryOrNull(source);
1830 if (sourceEntry == null) { 1830 if (sourceEntry == null) {
1831 return SourceKind.UNKNOWN; 1831 return SourceKind.UNKNOWN;
1832 } 1832 }
1833 return sourceEntry.kind; 1833 return sourceEntry.kind;
1834 } 1834 }
1835 1835
1836 @override 1836 @override
1837 List<Source> getLibrariesContaining(Source source) { 1837 List<Source> getLibrariesContaining(Source source) {
1838 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source); 1838 SourceEntry sourceEntry = getReadableSourceEntryOrNull(source);
1839 if (sourceEntry is DartEntry) { 1839 if (sourceEntry is DartEntry) {
1840 return sourceEntry.containingLibraries; 1840 return sourceEntry.containingLibraries;
1841 } 1841 }
1842 return Source.EMPTY_ARRAY; 1842 return Source.EMPTY_ARRAY;
1843 } 1843 }
1844 1844
1845 @override 1845 @override
1846 List<Source> getLibrariesDependingOn(Source librarySource) { 1846 List<Source> getLibrariesDependingOn(Source librarySource) {
1847 List<Source> dependentLibraries = new List<Source>(); 1847 List<Source> dependentLibraries = new List<Source>();
1848 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); 1848 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
(...skipping 13 matching lines...) Expand all
1862 } 1862 }
1863 } 1863 }
1864 if (dependentLibraries.isEmpty) { 1864 if (dependentLibraries.isEmpty) {
1865 return Source.EMPTY_ARRAY; 1865 return Source.EMPTY_ARRAY;
1866 } 1866 }
1867 return dependentLibraries; 1867 return dependentLibraries;
1868 } 1868 }
1869 1869
1870 @override 1870 @override
1871 List<Source> getLibrariesReferencedFromHtml(Source htmlSource) { 1871 List<Source> getLibrariesReferencedFromHtml(Source htmlSource) {
1872 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(htmlSource); 1872 SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource);
1873 if (sourceEntry is HtmlEntry) { 1873 if (sourceEntry is HtmlEntry) {
1874 HtmlEntry htmlEntry = sourceEntry; 1874 HtmlEntry htmlEntry = sourceEntry;
1875 return htmlEntry.getValue(HtmlEntry.REFERENCED_LIBRARIES); 1875 return htmlEntry.getValue(HtmlEntry.REFERENCED_LIBRARIES);
1876 } 1876 }
1877 return Source.EMPTY_ARRAY; 1877 return Source.EMPTY_ARRAY;
1878 } 1878 }
1879 1879
1880 @override 1880 @override
1881 LibraryElement getLibraryElement(Source source) { 1881 LibraryElement getLibraryElement(Source source) {
1882 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source); 1882 SourceEntry sourceEntry = getReadableSourceEntryOrNull(source);
1883 if (sourceEntry is DartEntry) { 1883 if (sourceEntry is DartEntry) {
1884 return sourceEntry.getValue(DartEntry.ELEMENT); 1884 return sourceEntry.getValue(DartEntry.ELEMENT);
1885 } 1885 }
1886 return null; 1886 return null;
1887 } 1887 }
1888 1888
1889 @override 1889 @override
1890 LineInfo getLineInfo(Source source) { 1890 LineInfo getLineInfo(Source source) {
1891 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source); 1891 SourceEntry sourceEntry = getReadableSourceEntryOrNull(source);
1892 if (sourceEntry != null) { 1892 if (sourceEntry != null) {
1893 return sourceEntry.getValue(SourceEntry.LINE_INFO); 1893 return sourceEntry.getValue(SourceEntry.LINE_INFO);
1894 } 1894 }
1895 return null; 1895 return null;
1896 } 1896 }
1897 1897
1898 @override 1898 @override
1899 int getModificationStamp(Source source) { 1899 int getModificationStamp(Source source) {
1900 int stamp = _contentCache.getModificationStamp(source); 1900 int stamp = _contentCache.getModificationStamp(source);
1901 if (stamp != null) { 1901 if (stamp != null) {
(...skipping 26 matching lines...) Expand all
1928 null)); 1928 null));
1929 return null; 1929 return null;
1930 } 1930 }
1931 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { 1931 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) {
1932 dartEntry.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); 1932 dartEntry.setValue(DartEntry.PUBLIC_NAMESPACE, namespace);
1933 } 1933 }
1934 } 1934 }
1935 return namespace; 1935 return namespace;
1936 } 1936 }
1937 1937
1938 /**
1939 * Return the cache entry associated with the given source, or `null` if there is no entry
1940 * associated with the source.
1941 *
1942 * @param source the source for which a cache entry is being sought
1943 * @return the source cache entry associated with the given source
1944 */
1945 SourceEntry getReadableSourceEntryOrNull(Source source) => _cache.get(source);
1946
1938 @override 1947 @override
1939 CompilationUnit getResolvedCompilationUnit(Source unitSource, 1948 CompilationUnit getResolvedCompilationUnit(Source unitSource,
1940 LibraryElement library) { 1949 LibraryElement library) {
1941 if (library == null) { 1950 if (library == null) {
1942 return null; 1951 return null;
1943 } 1952 }
1944 return getResolvedCompilationUnit2(unitSource, library.source); 1953 return getResolvedCompilationUnit2(unitSource, library.source);
1945 } 1954 }
1946 1955
1947 @override 1956 @override
1948 CompilationUnit getResolvedCompilationUnit2(Source unitSource, 1957 CompilationUnit getResolvedCompilationUnit2(Source unitSource,
1949 Source librarySource) { 1958 Source librarySource) {
1950 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(unitSource); 1959 SourceEntry sourceEntry = getReadableSourceEntryOrNull(unitSource);
1951 if (sourceEntry is DartEntry) { 1960 if (sourceEntry is DartEntry) {
1952 return sourceEntry.getValueInLibrary( 1961 return sourceEntry.getValueInLibrary(
1953 DartEntry.RESOLVED_UNIT, 1962 DartEntry.RESOLVED_UNIT,
1954 librarySource); 1963 librarySource);
1955 } 1964 }
1956 return null; 1965 return null;
1957 } 1966 }
1958 1967
1959 @override 1968 @override
1960 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { 1969 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) {
1961 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(htmlSource); 1970 SourceEntry sourceEntry = getReadableSourceEntryOrNull(htmlSource);
1962 if (sourceEntry is HtmlEntry) { 1971 if (sourceEntry is HtmlEntry) {
1963 HtmlEntry htmlEntry = sourceEntry; 1972 HtmlEntry htmlEntry = sourceEntry;
1964 return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); 1973 return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT);
1965 } 1974 }
1966 return null; 1975 return null;
1967 } 1976 }
1968 1977
1969 @override 1978 @override
1970 bool isClientLibrary(Source librarySource) { 1979 bool isClientLibrary(Source librarySource) {
1971 SourceEntry sourceEntry = _getReadableSourceEntry(librarySource); 1980 SourceEntry sourceEntry = _getReadableSourceEntry(librarySource);
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2316 void setContents(Source source, String contents) { 2325 void setContents(Source source, String contents) {
2317 if (_contentsChanged(source, contents)) { 2326 if (_contentsChanged(source, contents)) {
2318 _onSourcesChangedController.add( 2327 _onSourcesChangedController.add(
2319 new SourcesChangedEvent.changedContent(source, contents)); 2328 new SourcesChangedEvent.changedContent(source, contents));
2320 } 2329 }
2321 } 2330 }
2322 2331
2323 @override 2332 @override
2324 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, 2333 void visitCacheItems(void callback(Source source, SourceEntry dartEntry,
2325 DataDescriptor rowDesc, CacheState state)) { 2334 DataDescriptor rowDesc, CacheState state)) {
2326 void handleCacheItem(Source source, SourceEntry dartEntry,
2327 DataDescriptor descriptor) {
2328 callback(source, dartEntry, descriptor, dartEntry.getState(descriptor));
2329 }
2330 void handleCacheItemInLibrary(DartEntry dartEntry, Source librarySource,
2331 DataDescriptor descriptor) {
2332 callback(
2333 librarySource,
2334 dartEntry,
2335 descriptor,
2336 dartEntry.getStateInLibrary(descriptor, librarySource));
2337 }
2338
2339 bool hintsEnabled = _options.hint; 2335 bool hintsEnabled = _options.hint;
2340 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); 2336 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
2341 while (iterator.moveNext()) { 2337 while (iterator.moveNext()) {
2342 Source source = iterator.key; 2338 Source source = iterator.key;
2343 SourceEntry sourceEntry = iterator.value; 2339 SourceEntry sourceEntry = iterator.value;
2344 if (sourceEntry is DartEntry) { 2340 for (DataDescriptor descriptor in sourceEntry.descriptors) {
2345 DartEntry dartEntry = sourceEntry; 2341 if (descriptor == DartEntry.SOURCE_KIND) {
2346 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); 2342 // The source kind is always valid, so the state isn't interesting.
2347 // get library independent values 2343 continue;
2348 handleCacheItem(source, dartEntry, SourceEntry.CONTENT); 2344 } else if (descriptor == DartEntry.CONTAINING_LIBRARIES) {
2349 handleCacheItem(source, dartEntry, SourceEntry.LINE_INFO); 2345 // The list of containing libraries is always valid, so the state isn' t
2350 // The list of containing libraries is always valid, so the state isn't 2346 // interesting.
2351 // interesting. 2347 continue;
2352 // handleCacheItem(source, dartEntry, DartEntry.CONTAINING_LIBRARIES); 2348 } else if (descriptor == DartEntry.PUBLIC_NAMESPACE) {
2353 handleCacheItem(source, dartEntry, DartEntry.PARSE_ERRORS);
2354 handleCacheItem(source, dartEntry, DartEntry.PARSED_UNIT);
2355 handleCacheItem(source, dartEntry, DartEntry.SCAN_ERRORS);
2356 handleCacheItem(source, dartEntry, DartEntry.SOURCE_KIND);
2357 handleCacheItem(source, dartEntry, DartEntry.TOKEN_STREAM);
2358 if (kind == SourceKind.LIBRARY) {
2359 handleCacheItem(source, dartEntry, DartEntry.ELEMENT);
2360 handleCacheItem(source, dartEntry, DartEntry.EXPORTED_LIBRARIES);
2361 handleCacheItem(source, dartEntry, DartEntry.IMPORTED_LIBRARIES);
2362 handleCacheItem(source, dartEntry, DartEntry.INCLUDED_PARTS);
2363 handleCacheItem(source, dartEntry, DartEntry.IS_CLIENT);
2364 handleCacheItem(source, dartEntry, DartEntry.IS_LAUNCHABLE);
2365 // The public namespace isn't computed by performAnalysisTask() 2349 // The public namespace isn't computed by performAnalysisTask()
2366 // and therefore isn't interesting. 2350 // and therefore isn't interesting.
2367 //handleCacheItem(key, dartEntry, DartEntry.PUBLIC_NAMESPACE); 2351 continue;
2352 } else if (descriptor == HtmlEntry.ANGULAR_APPLICATION ||
2353 descriptor == HtmlEntry.ANGULAR_COMPONENT ||
2354 descriptor == HtmlEntry.ANGULAR_ENTRY ||
2355 descriptor == HtmlEntry.ANGULAR_ERRORS ||
2356 descriptor == HtmlEntry.POLYMER_BUILD_ERRORS ||
2357 descriptor == HtmlEntry.POLYMER_RESOLUTION_ERRORS) {
2358 // These values are not currently being computed, so their state is
2359 // not interesting.
2360 continue;
2361 } else if (descriptor == HtmlEntry.HINTS) {
2362 // We are not currently recording any hints related to HTML.
2363 continue;
2368 } 2364 }
2365 callback(
2366 source,
2367 sourceEntry,
2368 descriptor,
2369 sourceEntry.getState(descriptor));
2370 }
2371 if (sourceEntry is DartEntry) {
2369 // get library-specific values 2372 // get library-specific values
2370 List<Source> librarySources = getLibrariesContaining(source); 2373 List<Source> librarySources = getLibrariesContaining(source);
2371 for (Source librarySource in librarySources) { 2374 for (Source librarySource in librarySources) {
2372 // These values are not currently being computed, so their state is 2375 for (DataDescriptor descriptor in sourceEntry.libraryDescriptors) {
2373 // not interesting. 2376 if (descriptor == DartEntry.ANGULAR_ERRORS ||
2374 // handleCacheItemInLibrary(dartEntry, librarySource, DartEntry.ANGULAR _ERRORS); 2377 descriptor == DartEntry.BUILT_ELEMENT ||
2375 // handleCacheItemInLibrary(dartEntry, librarySource, DartEntry.BUILT_E LEMENT); 2378 descriptor == DartEntry.BUILT_UNIT) {
2376 // handleCacheItemInLibrary(dartEntry, librarySource, DartEntry.BUILT_U NIT); 2379 // These values are not currently being computed, so their state i s
2377 handleCacheItemInLibrary( 2380 // not interesting.
2378 dartEntry, 2381 continue;
2379 librarySource, 2382 } else if (source.isInSystemLibrary &&
2380 DartEntry.RESOLUTION_ERRORS); 2383 !_generateSdkErrors &&
2381 handleCacheItemInLibrary( 2384 (descriptor == DartEntry.VERIFICATION_ERRORS ||
2382 dartEntry, 2385 descriptor == DartEntry.HINTS)) {
2383 librarySource, 2386 continue;
2384 DartEntry.RESOLVED_UNIT); 2387 } else if (!hintsEnabled && descriptor == DartEntry.HINTS) {
2385 if (_generateSdkErrors || !source.isInSystemLibrary) { 2388 continue;
2386 handleCacheItemInLibrary( 2389 }
2387 dartEntry, 2390 callback(
2388 librarySource, 2391 librarySource,
2389 DartEntry.VERIFICATION_ERRORS); 2392 sourceEntry,
2390 if (hintsEnabled) { 2393 descriptor,
2391 handleCacheItemInLibrary( 2394 sourceEntry.getStateInLibrary(descriptor, librarySource));
2392 dartEntry,
2393 librarySource,
2394 DartEntry.HINTS);
2395 }
2396 } 2395 }
2397 } 2396 }
2398 } else if (sourceEntry is HtmlEntry) {
2399 HtmlEntry htmlEntry = sourceEntry;
2400 handleCacheItem(source, htmlEntry, SourceEntry.CONTENT);
2401 handleCacheItem(source, htmlEntry, SourceEntry.LINE_INFO);
2402 // These values are not currently being computed, so their state is
2403 // not interesting.
2404 // handleCacheItem(source, htmlEntry, HtmlEntry.ANGULAR_APPLICATION);
2405 // handleCacheItem(source, htmlEntry, HtmlEntry.ANGULAR_COMPONENT);
2406 // handleCacheItem(source, htmlEntry, HtmlEntry.ANGULAR_ENTRY);
2407 // handleCacheItem(source, htmlEntry, HtmlEntry.ANGULAR_ERRORS);
2408 handleCacheItem(source, htmlEntry, HtmlEntry.ELEMENT);
2409 handleCacheItem(source, htmlEntry, HtmlEntry.PARSE_ERRORS);
2410 handleCacheItem(source, htmlEntry, HtmlEntry.PARSED_UNIT);
2411 // These values are not currently being computed, so their state is
2412 // not interesting.
2413 // handleCacheItem(source, htmlEntry, HtmlEntry.POLYMER_BUILD_ERRORS);
2414 // handleCacheItem(source, htmlEntry, HtmlEntry.POLYMER_RESOLUTION_ERRORS );
2415 handleCacheItem(source, htmlEntry, HtmlEntry.RESOLUTION_ERRORS);
2416 handleCacheItem(source, htmlEntry, HtmlEntry.RESOLVED_UNIT);
2417 // We are not currently recording any hints related to HTML.
2418 // handleCacheItem(key, htmlEntry, HtmlEntry.HINTS);
2419 } 2397 }
2420 } 2398 }
2421 } 2399 }
2422 2400
2423 /** 2401 /**
2424 * Record that we have accessed the AST structure associated with the given so urce. At the moment, 2402 * Record that we have accessed the AST structure associated with the given so urce. At the moment,
2425 * there is no differentiation between the parsed and resolved forms of the AS T. 2403 * there is no differentiation between the parsed and resolved forms of the AS T.
2426 * 2404 *
2427 * @param source the source whose AST structure was accessed 2405 * @param source the source whose AST structure was accessed
2428 */ 2406 */
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
2891 } 2869 }
2892 } else if (originalContents != null) { 2870 } else if (originalContents != null) {
2893 _incrementalAnalysisCache = 2871 _incrementalAnalysisCache =
2894 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); 2872 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source);
2895 _sourceChanged(source); 2873 _sourceChanged(source);
2896 changed = true; 2874 changed = true;
2897 } 2875 }
2898 return changed; 2876 return changed;
2899 } 2877 }
2900 2878
2879 // /**
2880 // * Create a [BuildUnitElementTask] for the given [source].
2881 // */
2882 // AnalysisContextImpl_TaskData _createBuildUnitElementTask(Source source,
2883 // DartEntry dartEntry, Source librarySource) {
2884 // CompilationUnit unit = dartEntry.resolvableCompilationUnit;
2885 // if (unit == null) {
2886 // return _createParseDartTask(source, dartEntry);
2887 // }
2888 // return new AnalysisContextImpl_TaskData(
2889 // new BuildUnitElementTask(this, source, librarySource, unit),
2890 // false);
2891 // }
2892
2901 /** 2893 /**
2902 * Set the contents of the given source to the given contents and mark the sou rce as having 2894 * Set the contents of the given source to the given contents and mark the sou rce as having
2903 * changed. This has the effect of overriding the default contents of the sour ce. If the contents 2895 * changed. This has the effect of overriding the default contents of the sour ce. If the contents
2904 * are `null` the override is removed so that the default contents will be ret urned. 2896 * are `null` the override is removed so that the default contents will be ret urned.
2905 * [setContents] triggers a source changed event where as this method does not . 2897 * [setContents] triggers a source changed event where as this method does not .
2906 * 2898 *
2907 * @param source the source whose contents are being overridden 2899 * @param source the source whose contents are being overridden
2908 * @param contents the new contents of the source 2900 * @param contents the new contents of the source
2909 */ 2901 */
2910 bool _contentsChanged(Source source, String contents) { 2902 bool _contentsChanged(Source source, String contents) {
(...skipping 17 matching lines...) Expand all
2928 } 2920 }
2929 } else if (originalContents != null) { 2921 } else if (originalContents != null) {
2930 _incrementalAnalysisCache = 2922 _incrementalAnalysisCache =
2931 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); 2923 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source);
2932 _sourceChanged(source); 2924 _sourceChanged(source);
2933 changed = true; 2925 changed = true;
2934 } 2926 }
2935 return changed; 2927 return changed;
2936 } 2928 }
2937 2929
2938 // /**
2939 // * Create a [BuildUnitElementTask] for the given [source].
2940 // */
2941 // AnalysisContextImpl_TaskData _createBuildUnitElementTask(Source source,
2942 // DartEntry dartEntry, Source librarySource) {
2943 // CompilationUnit unit = dartEntry.resolvableCompilationUnit;
2944 // if (unit == null) {
2945 // return _createParseDartTask(source, dartEntry);
2946 // }
2947 // return new AnalysisContextImpl_TaskData(
2948 // new BuildUnitElementTask(this, source, librarySource, unit),
2949 // false);
2950 // }
2951
2952 /** 2930 /**
2953 * Create a [GenerateDartErrorsTask] for the given source, marking the verific ation errors 2931 * Create a [GenerateDartErrorsTask] for the given source, marking the verific ation errors
2954 * as being in-process. The compilation unit and the library can be the same i f the compilation 2932 * as being in-process. The compilation unit and the library can be the same i f the compilation
2955 * unit is the defining compilation unit of the library. 2933 * unit is the defining compilation unit of the library.
2956 * 2934 *
2957 * @param unitSource the source for the compilation unit to be verified 2935 * @param unitSource the source for the compilation unit to be verified
2958 * @param unitEntry the entry for the compilation unit 2936 * @param unitEntry the entry for the compilation unit
2959 * @param librarySource the source for the library containing the compilation unit 2937 * @param librarySource the source for the library containing the compilation unit
2960 * @param libraryEntry the entry for the library 2938 * @param libraryEntry the entry for the library
2961 * @return task data representing the created task 2939 * @return task data representing the created task
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
3842 */ 3820 */
3843 SourceEntry _getReadableSourceEntry(Source source) { 3821 SourceEntry _getReadableSourceEntry(Source source) {
3844 SourceEntry sourceEntry = _cache.get(source); 3822 SourceEntry sourceEntry = _cache.get(source);
3845 if (sourceEntry == null) { 3823 if (sourceEntry == null) {
3846 sourceEntry = _createSourceEntry(source, false); 3824 sourceEntry = _createSourceEntry(source, false);
3847 } 3825 }
3848 return sourceEntry; 3826 return sourceEntry;
3849 } 3827 }
3850 3828
3851 /** 3829 /**
3852 * Return the cache entry associated with the given source, or `null` if there is no entry
3853 * associated with the source.
3854 *
3855 * @param source the source for which a cache entry is being sought
3856 * @return the source cache entry associated with the given source
3857 */
3858 SourceEntry _getReadableSourceEntryOrNull(Source source) =>
3859 _cache.get(source);
3860
3861 /**
3862 * Return a resolved compilation unit corresponding to the given element in th e given library, or 3830 * Return a resolved compilation unit corresponding to the given element in th e given library, or
3863 * `null` if the information is not cached. 3831 * `null` if the information is not cached.
3864 * 3832 *
3865 * @param element the element representing the compilation unit 3833 * @param element the element representing the compilation unit
3866 * @param librarySource the source representing the library containing the uni t 3834 * @param librarySource the source representing the library containing the uni t
3867 * @return the specified resolved compilation unit 3835 * @return the specified resolved compilation unit
3868 */ 3836 */
3869 TimestampedData<CompilationUnit> 3837 TimestampedData<CompilationUnit>
3870 _getResolvedUnit(CompilationUnitElement element, Source librarySource) { 3838 _getResolvedUnit(CompilationUnitElement element, Source librarySource) {
3871 SourceEntry sourceEntry = _cache.get(element.source); 3839 SourceEntry sourceEntry = _cache.get(element.source);
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
4914 dartEntry.recordContentError( 4882 dartEntry.recordContentError(
4915 new CaughtException( 4883 new CaughtException(
4916 new AnalysisException("This source was marked as being deleted"), 4884 new AnalysisException("This source was marked as being deleted"),
4917 null)); 4885 null));
4918 } 4886 }
4919 _workManager.remove(source); 4887 _workManager.remove(source);
4920 _removeFromPriorityOrder(source); 4888 _removeFromPriorityOrder(source);
4921 } 4889 }
4922 4890
4923 /** 4891 /**
4892 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
4893 *
4894 * @param source the source that has been removed
4895 */
4896 void _sourceRemoved(Source source) {
4897 SourceEntry sourceEntry = _cache.get(source);
4898 if (sourceEntry is HtmlEntry) {
4899 _invalidateAngularResolution(sourceEntry);
4900 } else if (sourceEntry is DartEntry) {
4901 HashSet<Source> libraries = new HashSet<Source>();
4902 for (Source librarySource in getLibrariesContaining(source)) {
4903 libraries.add(librarySource);
4904 for (Source dependentLibrary in getLibrariesDependingOn(
4905 librarySource)) {
4906 libraries.add(dependentLibrary);
4907 }
4908 }
4909 for (Source librarySource in libraries) {
4910 _invalidateLibraryResolution(librarySource);
4911 }
4912 }
4913 _cache.remove(source);
4914 _workManager.remove(source);
4915 _removeFromPriorityOrder(source);
4916 }
4917
4918 /**
4924 * TODO(scheglov) A hackish, limited incremental resolution implementation. 4919 * TODO(scheglov) A hackish, limited incremental resolution implementation.
4925 */ 4920 */
4926 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) { 4921 bool _tryPoorMansIncrementalResolution(Source unitSource, String newCode) {
4927 DartEntry dartEntry = _cache.get(unitSource); 4922 DartEntry dartEntry = _cache.get(unitSource);
4928 if (dartEntry == null) { 4923 if (dartEntry == null) {
4929 return false; 4924 return false;
4930 } 4925 }
4931 // prepare the (only) library 4926 // prepare the (only) library
4932 List<Source> librarySources = getLibrariesContaining(unitSource); 4927 List<Source> librarySources = getLibrariesContaining(unitSource);
4933 if (librarySources.length != 1) { 4928 if (librarySources.length != 1) {
(...skipping 17 matching lines...) Expand all
4951 notice.compilationUnit = oldUnit; 4946 notice.compilationUnit = oldUnit;
4952 // TODO(scheglov) apply updated errors 4947 // TODO(scheglov) apply updated errors
4953 { 4948 {
4954 LineInfo lineInfo = getLineInfo(unitSource); 4949 LineInfo lineInfo = getLineInfo(unitSource);
4955 notice.setErrors(dartEntry.allErrors, lineInfo); 4950 notice.setErrors(dartEntry.allErrors, lineInfo);
4956 } 4951 }
4957 return true; 4952 return true;
4958 } 4953 }
4959 4954
4960 /** 4955 /**
4961 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
4962 *
4963 * @param source the source that has been removed
4964 */
4965 void _sourceRemoved(Source source) {
4966 SourceEntry sourceEntry = _cache.get(source);
4967 if (sourceEntry is HtmlEntry) {
4968 _invalidateAngularResolution(sourceEntry);
4969 } else if (sourceEntry is DartEntry) {
4970 HashSet<Source> libraries = new HashSet<Source>();
4971 for (Source librarySource in getLibrariesContaining(source)) {
4972 libraries.add(librarySource);
4973 for (Source dependentLibrary in getLibrariesDependingOn(
4974 librarySource)) {
4975 libraries.add(dependentLibrary);
4976 }
4977 }
4978 for (Source librarySource in libraries) {
4979 _invalidateLibraryResolution(librarySource);
4980 }
4981 }
4982 _cache.remove(source);
4983 _workManager.remove(source);
4984 _removeFromPriorityOrder(source);
4985 }
4986
4987 /**
4988 * Check the cache for any invalid entries (entries whose modification time do es not match the 4956 * Check the cache for any invalid entries (entries whose modification time do es not match the
4989 * modification time of the source associated with the entry). Invalid entries will be marked as 4957 * modification time of the source associated with the entry). Invalid entries will be marked as
4990 * invalid so that the source will be re-analyzed. 4958 * invalid so that the source will be re-analyzed.
4991 * 4959 *
4992 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4960 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
4993 * 4961 *
4994 * @return `true` if at least one entry was invalid 4962 * @return `true` if at least one entry was invalid
4995 */ 4963 */
4996 bool _validateCacheConsistency() { 4964 bool _validateCacheConsistency() {
4997 int consistencyCheckStart = JavaSystem.nanoTime(); 4965 int consistencyCheckStart = JavaSystem.nanoTime();
(...skipping 3797 matching lines...) Expand 10 before | Expand all | Expand 10 after
8795 * only the given source. This method should only be invoked on entries that 8763 * only the given source. This method should only be invoked on entries that
8796 * represent a library. 8764 * represent a library.
8797 * 8765 *
8798 * @param librarySource the source of the single library that the list should contain 8766 * @param librarySource the source of the single library that the list should contain
8799 */ 8767 */
8800 void set containingLibrary(Source librarySource) { 8768 void set containingLibrary(Source librarySource) {
8801 _containingLibraries.clear(); 8769 _containingLibraries.clear();
8802 _containingLibraries.add(librarySource); 8770 _containingLibraries.add(librarySource);
8803 } 8771 }
8804 8772
8773 @override
8774 List<DataDescriptor> get descriptors {
8775 List<DataDescriptor> result = super.descriptors;
8776 result.addAll(
8777 <DataDescriptor>[
8778 DartEntry.SOURCE_KIND,
8779 DartEntry.CONTAINING_LIBRARIES,
8780 DartEntry.PARSE_ERRORS,
8781 DartEntry.PARSED_UNIT,
8782 DartEntry.SCAN_ERRORS,
8783 DartEntry.SOURCE_KIND,
8784 DartEntry.TOKEN_STREAM]);
8785 SourceKind kind = getValue(DartEntry.SOURCE_KIND);
8786 if (kind == SourceKind.LIBRARY) {
8787 result.addAll(
8788 <DataDescriptor>[
8789 DartEntry.ELEMENT,
8790 DartEntry.EXPORTED_LIBRARIES,
8791 DartEntry.IMPORTED_LIBRARIES,
8792 DartEntry.INCLUDED_PARTS,
8793 DartEntry.IS_CLIENT,
8794 DartEntry.IS_LAUNCHABLE,
8795 DartEntry.PUBLIC_NAMESPACE]);
8796 }
8797 return result;
8798 }
8799
8805 /** 8800 /**
8806 * Return `true` if this entry has an AST structure that can be resolved, even 8801 * Return `true` if this entry has an AST structure that can be resolved, even
8807 * if it needs to be copied. Returning `true` implies that the method 8802 * if it needs to be copied. Returning `true` implies that the method
8808 * [resolvableCompilationUnit] will return a non-`null` result. 8803 * [resolvableCompilationUnit] will return a non-`null` result.
8809 */ 8804 */
8810 bool get hasResolvableCompilationUnit { 8805 bool get hasResolvableCompilationUnit {
8811 if (getState(PARSED_UNIT) == CacheState.VALID) { 8806 if (getState(PARSED_UNIT) == CacheState.VALID) {
8812 return true; 8807 return true;
8813 } 8808 }
8814 ResolutionState state = _resolutionState; 8809 ResolutionState state = _resolutionState;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
8851 while (state != null) { 8846 while (state != null) {
8852 if (state._librarySource != null) { 8847 if (state._librarySource != null) {
8853 result.add(state._librarySource); 8848 result.add(state._librarySource);
8854 } 8849 }
8855 state = state._nextState; 8850 state = state._nextState;
8856 } 8851 }
8857 return result; 8852 return result;
8858 } 8853 }
8859 8854
8860 /** 8855 /**
8856 * Get a list of all the library-dependent descriptors for which values may
8857 * be stored in this SourceEntry.
8858 */
8859 List<DataDescriptor> get libraryDescriptors {
8860 return <DataDescriptor>[
8861 DartEntry.ANGULAR_ERRORS,
8862 DartEntry.BUILT_ELEMENT,
8863 DartEntry.BUILT_UNIT,
8864 DartEntry.RESOLUTION_ERRORS,
8865 DartEntry.RESOLVED_UNIT,
8866 DartEntry.VERIFICATION_ERRORS,
8867 DartEntry.HINTS];
8868 }
8869
8870 /**
8861 * A compilation unit that has not been accessed by any other client and can 8871 * A compilation unit that has not been accessed by any other client and can
8862 * therefore safely be modified by the reconciler, or `null` if the source has 8872 * therefore safely be modified by the reconciler, or `null` if the source has
8863 * not been parsed. 8873 * not been parsed.
8864 */ 8874 */
8865 CompilationUnit get resolvableCompilationUnit { 8875 CompilationUnit get resolvableCompilationUnit {
8866 if (getState(PARSED_UNIT) == CacheState.VALID) { 8876 if (getState(PARSED_UNIT) == CacheState.VALID) {
8867 CompilationUnit unit = getValue(PARSED_UNIT); 8877 CompilationUnit unit = getValue(PARSED_UNIT);
8868 setState(PARSED_UNIT, CacheState.FLUSHED); 8878 setState(PARSED_UNIT, CacheState.FLUSHED);
8869 return unit; 8879 return unit;
8870 } 8880 }
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
9973 if (getState(PARSED_UNIT) == CacheState.VALID) { 9983 if (getState(PARSED_UNIT) == CacheState.VALID) {
9974 return getValue(PARSED_UNIT); 9984 return getValue(PARSED_UNIT);
9975 } 9985 }
9976 if (getState(RESOLVED_UNIT) == CacheState.VALID) { 9986 if (getState(RESOLVED_UNIT) == CacheState.VALID) {
9977 return getValue(RESOLVED_UNIT); 9987 return getValue(RESOLVED_UNIT);
9978 } 9988 }
9979 return null; 9989 return null;
9980 } 9990 }
9981 9991
9982 @override 9992 @override
9993 List<DataDescriptor> get descriptors {
9994 List<DataDescriptor> result = super.descriptors;
9995 result.addAll(
9996 [
9997 HtmlEntry.ANGULAR_APPLICATION,
9998 HtmlEntry.ANGULAR_COMPONENT,
9999 HtmlEntry.ANGULAR_ENTRY,
10000 HtmlEntry.ANGULAR_ERRORS,
10001 HtmlEntry.ELEMENT,
10002 HtmlEntry.PARSE_ERRORS,
10003 HtmlEntry.PARSED_UNIT,
10004 HtmlEntry.POLYMER_BUILD_ERRORS,
10005 HtmlEntry.POLYMER_RESOLUTION_ERRORS,
10006 HtmlEntry.RESOLUTION_ERRORS,
10007 HtmlEntry.RESOLVED_UNIT,
10008 HtmlEntry.HINTS]);
10009 return result;
10010 }
10011
10012 @override
9983 SourceKind get kind => SourceKind.HTML; 10013 SourceKind get kind => SourceKind.HTML;
9984 10014
9985 /** 10015 /**
9986 * Flush any AST structures being maintained by this entry. 10016 * Flush any AST structures being maintained by this entry.
9987 */ 10017 */
9988 void flushAstStructures() { 10018 void flushAstStructures() {
9989 _flush(PARSED_UNIT); 10019 _flush(PARSED_UNIT);
9990 _flush(RESOLVED_UNIT); 10020 _flush(RESOLVED_UNIT);
9991 _flush(ANGULAR_ENTRY); 10021 _flush(ANGULAR_ENTRY);
9992 _flush(ANGULAR_ERRORS); 10022 _flush(ANGULAR_ERRORS);
(...skipping 4182 matching lines...) Expand 10 before | Expand all | Expand 10 after
14175 int _flags = 0; 14205 int _flags = 0;
14176 14206
14177 /** 14207 /**
14178 * A table mapping data descriptors to the cached results for those 14208 * A table mapping data descriptors to the cached results for those
14179 * descriptors. 14209 * descriptors.
14180 */ 14210 */
14181 Map<DataDescriptor, CachedResult> resultMap = 14211 Map<DataDescriptor, CachedResult> resultMap =
14182 new HashMap<DataDescriptor, CachedResult>(); 14212 new HashMap<DataDescriptor, CachedResult>();
14183 14213
14184 /** 14214 /**
14215 * Get a list of all the library-independent descriptors for which values may
14216 * be stored in this SourceEntry.
14217 */
14218 List<DataDescriptor> get descriptors {
14219 return <DataDescriptor>[SourceEntry.CONTENT, SourceEntry.LINE_INFO];
14220 }
14221
14222 /**
14185 * Return `true` if the source was explicitly added to the context or `false` 14223 * Return `true` if the source was explicitly added to the context or `false`
14186 * if the source was implicitly added because it was referenced by another 14224 * if the source was implicitly added because it was referenced by another
14187 * source. 14225 * source.
14188 */ 14226 */
14189 bool get explicitlyAdded => _getFlag(_EXPLICITLY_ADDED_FLAG); 14227 bool get explicitlyAdded => _getFlag(_EXPLICITLY_ADDED_FLAG);
14190 14228
14191 /** 14229 /**
14192 * Set whether the source was explicitly added to the context to match the 14230 * Set whether the source was explicitly added to the context to match the
14193 * [explicitlyAdded] flag. 14231 * [explicitlyAdded] flag.
14194 */ 14232 */
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
14880 14918
14881 @override 14919 @override
14882 Object visitPolymerTagDartElement(PolymerTagDartElement element) { 14920 Object visitPolymerTagDartElement(PolymerTagDartElement element) {
14883 if (element.name == PolymerHtmlUnitBuilder_this._elementName) { 14921 if (element.name == PolymerHtmlUnitBuilder_this._elementName) {
14884 throw new PolymerHtmlUnitBuilder_FoundTagDartElementError( 14922 throw new PolymerHtmlUnitBuilder_FoundTagDartElementError(
14885 element as PolymerTagDartElementImpl); 14923 element as PolymerTagDartElementImpl);
14886 } 14924 }
14887 return null; 14925 return null;
14888 } 14926 }
14889 } 14927 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/get_handler.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698