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

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

Issue 22285004: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 library engine; 3 library engine;
4 import 'dart:collection' show HasNextIterator;
5 import 'java_core.dart'; 4 import 'java_core.dart';
6 import 'java_engine.dart'; 5 import 'java_engine.dart';
6 import 'utilities_collection.dart';
7 import 'instrumentation.dart'; 7 import 'instrumentation.dart';
8 import 'error.dart'; 8 import 'error.dart';
9 import 'source.dart'; 9 import 'source.dart';
10 import 'scanner.dart' show Token, CharBufferScanner, StringScanner; 10 import 'scanner.dart' show Token, CharBufferScanner, StringScanner;
11 import 'ast.dart'; 11 import 'ast.dart';
12 import 'parser.dart' show Parser; 12 import 'parser.dart' show Parser;
13 import 'sdk.dart' show DartSdk; 13 import 'sdk.dart' show DartSdk;
14 import 'element.dart'; 14 import 'element.dart';
15 import 'resolver.dart'; 15 import 'resolver.dart';
16 import 'html.dart' show XmlTagNode, XmlAttributeNode, RecursiveXmlVisitor, HtmlS canner, HtmlScanResult, HtmlParser, HtmlParseResult, HtmlUnit; 16 import 'html.dart' show XmlTagNode, XmlAttributeNode, RecursiveXmlVisitor, HtmlS canner, HtmlScanResult, HtmlParser, HtmlParseResult, HtmlUnit;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 * given logger. 106 * given logger.
107 * 107 *
108 * @param logger the logger that should receive information about errors withi n the analysis 108 * @param logger the logger that should receive information about errors withi n the analysis
109 * engine 109 * engine
110 */ 110 */
111 void set logger(Logger logger2) { 111 void set logger(Logger logger2) {
112 this._logger = logger2 == null ? Logger.NULL : logger2; 112 this._logger = logger2 == null ? Logger.NULL : logger2;
113 } 113 }
114 } 114 }
115 /** 115 /**
116 * Container with statistics about the [AnalysisContext].
117 */
118 abstract class AnalysisContentStatistics {
119
120 /**
121 * @return the statistics for each kind of cached data.
122 */
123 List<AnalysisContentStatistics_CacheRow> get cacheRows;
124 }
125 /**
126 * Information about single item in the cache.
127 */
128 abstract class AnalysisContentStatistics_CacheRow {
129 int get errorCount;
130 int get flushedCount;
131 int get inProcessCount;
132 int get invalidCount;
133 String get name;
134 int get validCount;
135 }
136 /**
116 * The interface `AnalysisContext` defines the behavior of objects that represen t a context in 137 * The interface `AnalysisContext` defines the behavior of objects that represen t a context in
117 * which a single analysis can be performed and incrementally maintained. The co ntext includes such 138 * which a single analysis can be performed and incrementally maintained. The co ntext includes such
118 * information as the version of the SDK being analyzed against as well as the p ackage-root used to 139 * information as the version of the SDK being analyzed against as well as the p ackage-root used to
119 * resolve 'package:' URI's. (Both of which are known indirectly through the [So urceFactory 140 * resolve 'package:' URI's. (Both of which are known indirectly through the [So urceFactory
120 ].) 141 ].)
121 * 142 *
122 * An analysis context also represents the state of the analysis, which includes knowing which 143 * An analysis context also represents the state of the analysis, which includes knowing which
123 * sources have been included in the analysis (either directly or indirectly) an d the results of the 144 * sources have been included in the analysis (either directly or indirectly) an d the results of the
124 * analysis. Sources must be added and removed from the context using the method 145 * analysis. Sources must be added and removed from the context using the method
125 * [applyChanges], which is also used to notify the context when sources have be en 146 * [applyChanges], which is also used to notify the context when sources have be en
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 */ 959 */
939 CacheState _parseErrorsState = CacheState.INVALID; 960 CacheState _parseErrorsState = CacheState.INVALID;
940 961
941 /** 962 /**
942 * The errors produced while scanning and parsing the compilation unit, or `nu ll` if the 963 * The errors produced while scanning and parsing the compilation unit, or `nu ll` if the
943 * errors are not currently cached. 964 * errors are not currently cached.
944 */ 965 */
945 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS; 966 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS;
946 967
947 /** 968 /**
948 * The state of the cached list of included parts. 969 * The state of the cached list of imported libraries.
949 */ 970 */
950 CacheState _includedPartsState = CacheState.INVALID; 971 CacheState _importedLibrariesState = CacheState.INVALID;
951 972
952 /** 973 /**
953 * The list of parts included in the library, or an empty array if the list is not currently 974 * The list of libraries imported by the library, or an empty array if the lis t is not currently
954 * cached. The list will be empty if the Dart file is a part rather than a lib rary. 975 * cached. The list will be empty if the Dart file is a part rather than a lib rary.
955 */ 976 */
956 List<Source> _includedParts = Source.EMPTY_ARRAY; 977 List<Source> _importedLibraries = Source.EMPTY_ARRAY;
957 978
958 /** 979 /**
959 * The state of the cached list of exported libraries. 980 * The state of the cached list of exported libraries.
960 */ 981 */
961 CacheState _exportedLibrariesState = CacheState.INVALID; 982 CacheState _exportedLibrariesState = CacheState.INVALID;
962 983
963 /** 984 /**
964 * The list of libraries exported by the library, or an empty array if the lis t is not currently 985 * The list of libraries exported by the library, or an empty array if the lis t is not currently
965 * cached. The list will be empty if the Dart file is a part rather than a lib rary. 986 * cached. The list will be empty if the Dart file is a part rather than a lib rary.
966 */ 987 */
967 List<Source> _exportedLibraries = Source.EMPTY_ARRAY; 988 List<Source> _exportedLibraries = Source.EMPTY_ARRAY;
968 989
969 /** 990 /**
970 * The state of the cached list of imported libraries. 991 * The state of the cached list of included parts.
971 */ 992 */
972 CacheState _importedLibrariesState = CacheState.INVALID; 993 CacheState _includedPartsState = CacheState.INVALID;
973 994
974 /** 995 /**
975 * The list of libraries imported by the library, or an empty array if the lis t is not currently 996 * The list of parts included in the library, or an empty array if the list is not currently
976 * cached. The list will be empty if the Dart file is a part rather than a lib rary. 997 * cached. The list will be empty if the Dart file is a part rather than a lib rary.
977 */ 998 */
978 List<Source> _importedLibraries = Source.EMPTY_ARRAY; 999 List<Source> _includedParts = Source.EMPTY_ARRAY;
979 1000
980 /** 1001 /**
981 * The information known as a result of resolving this compilation unit as par t of the library 1002 * The information known as a result of resolving this compilation unit as par t of the library
982 * that contains this unit. This field will never be `null`. 1003 * that contains this unit. This field will never be `null`.
983 */ 1004 */
984 DartEntryImpl_ResolutionState _resolutionState = new DartEntryImpl_ResolutionS tate(); 1005 DartEntryImpl_ResolutionState _resolutionState = new DartEntryImpl_ResolutionS tate();
985 1006
986 /** 1007 /**
987 * The state of the cached library element. 1008 * The state of the cached library element.
988 */ 1009 */
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 _importedLibraries = other._importedLibraries; 1486 _importedLibraries = other._importedLibraries;
1466 _resolutionState.copyFrom(other._resolutionState); 1487 _resolutionState.copyFrom(other._resolutionState);
1467 _elementState = other._elementState; 1488 _elementState = other._elementState;
1468 _element = other._element; 1489 _element = other._element;
1469 _publicNamespaceState = other._publicNamespaceState; 1490 _publicNamespaceState = other._publicNamespaceState;
1470 _publicNamespace = other._publicNamespace; 1491 _publicNamespace = other._publicNamespace;
1471 _clientServerState = other._clientServerState; 1492 _clientServerState = other._clientServerState;
1472 _launchableState = other._launchableState; 1493 _launchableState = other._launchableState;
1473 _bitmask = other._bitmask; 1494 _bitmask = other._bitmask;
1474 } 1495 }
1496 void writeOn(JavaStringBuilder builder) {
1497 builder.append("Dart: ");
1498 super.writeOn(builder);
1499 builder.append("; sourceKind = ");
1500 builder.append(_sourceKindState);
1501 builder.append("; parsedUnit = ");
1502 builder.append(_parsedUnitState);
1503 builder.append("; parseErrors = ");
1504 builder.append(_parseErrorsState);
1505 builder.append("; exportedLibraries = ");
1506 builder.append(_exportedLibrariesState);
1507 builder.append("; importedLibraries = ");
1508 builder.append(_importedLibrariesState);
1509 builder.append("; includedParts = ");
1510 builder.append(_includedPartsState);
1511 builder.append("; element = ");
1512 builder.append(_elementState);
1513 builder.append("; publicNamespace = ");
1514 builder.append(_publicNamespaceState);
1515 builder.append("; clientServer = ");
1516 builder.append(_clientServerState);
1517 builder.append("; launchable = ");
1518 builder.append(_launchableState);
1519 _resolutionState.writeOn(builder);
1520 }
1475 1521
1476 /** 1522 /**
1477 * Return a resolution state for the specified library, creating one as necess ary. 1523 * Return a resolution state for the specified library, creating one as necess ary.
1478 * 1524 *
1479 * @param librarySource the library source (not `null`) 1525 * @param librarySource the library source (not `null`)
1480 * @return the resolution state (not `null`) 1526 * @return the resolution state (not `null`)
1481 */ 1527 */
1482 DartEntryImpl_ResolutionState getOrCreateResolutionState(Source librarySource2 ) { 1528 DartEntryImpl_ResolutionState getOrCreateResolutionState(Source librarySource2 ) {
1483 DartEntryImpl_ResolutionState state = _resolutionState; 1529 DartEntryImpl_ResolutionState state = _resolutionState;
1484 if (state._librarySource == null) { 1530 if (state._librarySource == null) {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 void recordResolutionError() { 1654 void recordResolutionError() {
1609 _nextState = null; 1655 _nextState = null;
1610 _librarySource = null; 1656 _librarySource = null;
1611 _resolvedUnitState = CacheState.ERROR; 1657 _resolvedUnitState = CacheState.ERROR;
1612 _resolvedUnit = null; 1658 _resolvedUnit = null;
1613 _resolutionErrorsState = CacheState.ERROR; 1659 _resolutionErrorsState = CacheState.ERROR;
1614 _resolutionErrors = AnalysisError.NO_ERRORS; 1660 _resolutionErrors = AnalysisError.NO_ERRORS;
1615 _hintsState = CacheState.ERROR; 1661 _hintsState = CacheState.ERROR;
1616 _hints = AnalysisError.NO_ERRORS; 1662 _hints = AnalysisError.NO_ERRORS;
1617 } 1663 }
1664
1665 /**
1666 * Write a textual representation of this state to the given builder. The resu lt will only be
1667 * used for debugging purposes.
1668 *
1669 * @param builder the builder to which the text should be written
1670 */
1671 void writeOn(JavaStringBuilder builder) {
1672 if (_librarySource != null) {
1673 builder.append("; resolvedUnit = ");
1674 builder.append(_resolvedUnitState);
1675 builder.append("; resolutionErrors = ");
1676 builder.append(_resolutionErrorsState);
1677 builder.append("; hints = ");
1678 builder.append(_hintsState);
1679 if (_nextState != null) {
1680 _nextState.writeOn(builder);
1681 }
1682 }
1683 }
1618 } 1684 }
1619 /** 1685 /**
1620 * Instances of the class `DataDescriptor` are immutable constants representing data that can 1686 * Instances of the class `DataDescriptor` are immutable constants representing data that can
1621 * be stored in the cache. 1687 * be stored in the cache.
1622 */ 1688 */
1623 class DataDescriptor<E> { 1689 class DataDescriptor<E> {
1624 1690
1625 /** 1691 /**
1626 * The name of the descriptor, used for debugging purposes. 1692 * The name of the descriptor, used for debugging purposes.
1627 */ 1693 */
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 _parsedUnit = other._parsedUnit; 1909 _parsedUnit = other._parsedUnit;
1844 _referencedLibrariesState = other._referencedLibrariesState; 1910 _referencedLibrariesState = other._referencedLibrariesState;
1845 _referencedLibraries = other._referencedLibraries; 1911 _referencedLibraries = other._referencedLibraries;
1846 _resolutionErrors = other._resolutionErrors; 1912 _resolutionErrors = other._resolutionErrors;
1847 _resolutionErrorsState = other._resolutionErrorsState; 1913 _resolutionErrorsState = other._resolutionErrorsState;
1848 _elementState = other._elementState; 1914 _elementState = other._elementState;
1849 _element = other._element; 1915 _element = other._element;
1850 _hints = other._hints; 1916 _hints = other._hints;
1851 _hintsState = other._hintsState; 1917 _hintsState = other._hintsState;
1852 } 1918 }
1919 void writeOn(JavaStringBuilder builder) {
1920 builder.append("Html: ");
1921 super.writeOn(builder);
1922 builder.append("; parsedUnit = ");
1923 builder.append(_parsedUnitState);
1924 builder.append("; resolutionErrors = ");
1925 builder.append(_resolutionErrorsState);
1926 builder.append("; referencedLibraries = ");
1927 builder.append(_referencedLibrariesState);
1928 builder.append("; element = ");
1929 builder.append(_elementState);
1930 }
1853 } 1931 }
1854 /** 1932 /**
1855 * The interface `SourceEntry` defines the behavior of objects that maintain the information 1933 * The interface `SourceEntry` defines the behavior of objects that maintain the information
1856 * cached by an analysis context about an individual source, no matter what kind of source it is. 1934 * cached by an analysis context about an individual source, no matter what kind of source it is.
1857 * 1935 *
1858 * Source entries should be treated as if they were immutable unless a writable copy of the entry 1936 * Source entries should be treated as if they were immutable unless a writable copy of the entry
1859 * has been obtained and has not yet been made visible to other threads. 1937 * has been obtained and has not yet been made visible to other threads.
1860 * 1938 *
1861 * @coverage dart.engine 1939 * @coverage dart.engine
1862 */ 1940 */
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 * @param value the new value of the data represented by the given descriptor 2057 * @param value the new value of the data represented by the given descriptor
1980 */ 2058 */
1981 void setValue(DataDescriptor descriptor, Object value) { 2059 void setValue(DataDescriptor descriptor, Object value) {
1982 if (identical(descriptor, SourceEntry.LINE_INFO)) { 2060 if (identical(descriptor, SourceEntry.LINE_INFO)) {
1983 _lineInfo = value as LineInfo; 2061 _lineInfo = value as LineInfo;
1984 _lineInfoState = CacheState.VALID; 2062 _lineInfoState = CacheState.VALID;
1985 } else { 2063 } else {
1986 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 2064 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
1987 } 2065 }
1988 } 2066 }
2067 String toString() {
2068 JavaStringBuilder builder = new JavaStringBuilder();
2069 writeOn(builder);
2070 return builder.toString();
2071 }
1989 2072
1990 /** 2073 /**
1991 * Copy the information from the given cache entry. 2074 * Copy the information from the given cache entry.
1992 * 2075 *
1993 * @param entry the cache entry from which information will be copied 2076 * @param entry the cache entry from which information will be copied
1994 */ 2077 */
1995 void copyFrom(SourceEntryImpl entry) { 2078 void copyFrom(SourceEntryImpl entry) {
1996 _modificationTime = entry._modificationTime; 2079 _modificationTime = entry._modificationTime;
1997 _lineInfoState = entry._lineInfoState; 2080 _lineInfoState = entry._lineInfoState;
1998 _lineInfo = entry._lineInfo; 2081 _lineInfo = entry._lineInfo;
1999 } 2082 }
2000 2083
2001 /** 2084 /**
2002 * Given that some data is being transitioned to the given state, return the v alue that should be 2085 * Given that some data is being transitioned to the given state, return the v alue that should be
2003 * kept in the cache. 2086 * kept in the cache.
2004 * 2087 *
2005 * @param state the state to which the data is being transitioned 2088 * @param state the state to which the data is being transitioned
2006 * @param currentValue the value of the data before the transition 2089 * @param currentValue the value of the data before the transition
2007 * @param defaultValue the value to be used if the current value is to be remo ved from the cache 2090 * @param defaultValue the value to be used if the current value is to be remo ved from the cache
2008 * @return the value of the data that should be kept in the cache 2091 * @return the value of the data that should be kept in the cache
2009 */ 2092 */
2010 Object updatedValue(CacheState state, Object currentValue, Object defaultValue ) { 2093 Object updatedValue(CacheState state, Object currentValue, Object defaultValue ) {
2011 if (identical(state, CacheState.VALID)) { 2094 if (identical(state, CacheState.VALID)) {
2012 throw new IllegalArgumentException("Use setValue() to set the state to VAL ID"); 2095 throw new IllegalArgumentException("Use setValue() to set the state to VAL ID");
2013 } else if (identical(state, CacheState.IN_PROCESS)) { 2096 } else if (identical(state, CacheState.IN_PROCESS)) {
2014 return currentValue; 2097 return currentValue;
2015 } 2098 }
2016 return defaultValue; 2099 return defaultValue;
2017 } 2100 }
2101
2102 /**
2103 * Write a textual representation of this entry to the given builder. The resu lt will only be used
2104 * for debugging purposes.
2105 *
2106 * @param builder the builder to which the text should be written
2107 */
2108 void writeOn(JavaStringBuilder builder) {
2109 builder.append("time = ");
2110 builder.append(_modificationTime.toRadixString(16));
2111 builder.append("; lineInfo = ");
2112 builder.append(_lineInfoState);
2113 }
2114 }
2115 /**
2116 * Implementation of the [AnalysisContentStatistics].
2117 */
2118 class AnalysisContentStatisticsImpl implements AnalysisContentStatistics {
2119 Map<String, AnalysisContentStatistics_CacheRow> _dataMap = new Map<String, Ana lysisContentStatistics_CacheRow>();
2120 List<AnalysisContentStatistics_CacheRow> get cacheRows {
2121 Iterable<AnalysisContentStatistics_CacheRow> items = _dataMap.values;
2122 return new List.from(items);
2123 }
2124 void putCacheItem(DataDescriptor<Object> rowDesc, CacheState state) {
2125 String rowName = rowDesc.toString();
2126 AnalysisContentStatisticsImpl_CacheRowImpl row = _dataMap[rowName] as Analys isContentStatisticsImpl_CacheRowImpl;
2127 if (row == null) {
2128 row = new AnalysisContentStatisticsImpl_CacheRowImpl(rowName);
2129 _dataMap[rowName] = row;
2130 }
2131 row.incState(state);
2132 }
2133 }
2134 class AnalysisContentStatisticsImpl_CacheRowImpl implements AnalysisContentStati stics_CacheRow {
2135 String _name;
2136 int _errorCount = 0;
2137 int _flushedCount = 0;
2138 int _inProcessCount = 0;
2139 int _invalidCount = 0;
2140 int _validCount = 0;
2141 AnalysisContentStatisticsImpl_CacheRowImpl(String name) {
2142 this._name = name;
2143 }
2144 bool operator ==(Object obj) => obj is AnalysisContentStatisticsImpl_CacheRowI mpl && ((obj as AnalysisContentStatisticsImpl_CacheRowImpl))._name == _name;
2145 int get errorCount => _errorCount;
2146 int get flushedCount => _flushedCount;
2147 int get inProcessCount => _inProcessCount;
2148 int get invalidCount => _invalidCount;
2149 String get name => _name;
2150 int get validCount => _validCount;
2151 int get hashCode => _name.hashCode;
2152 void incState(CacheState state) {
2153 if (identical(state, CacheState.ERROR)) {
2154 _errorCount++;
2155 }
2156 if (identical(state, CacheState.FLUSHED)) {
2157 _flushedCount++;
2158 }
2159 if (identical(state, CacheState.IN_PROCESS)) {
2160 _inProcessCount++;
2161 }
2162 if (identical(state, CacheState.INVALID)) {
2163 _invalidCount++;
2164 }
2165 if (identical(state, CacheState.VALID)) {
2166 _validCount++;
2167 }
2168 }
2018 } 2169 }
2019 /** 2170 /**
2020 * Instances of the class `AnalysisContextImpl` implement an [AnalysisContext]. 2171 * Instances of the class `AnalysisContextImpl` implement an [AnalysisContext].
2021 * 2172 *
2022 * @coverage dart.engine 2173 * @coverage dart.engine
2023 */ 2174 */
2024 class AnalysisContextImpl implements InternalAnalysisContext { 2175 class AnalysisContextImpl implements InternalAnalysisContext {
2025 2176
2026 /** 2177 /**
2178 * Helper for [getStatistics], puts the library-specific state into the given statistics
2179 * object.
2180 */
2181 static void putStatCacheItem(AnalysisContentStatisticsImpl statistics, DartEnt ry dartEntry, Source librarySource, DataDescriptor<Object> key) {
2182 statistics.putCacheItem(key, dartEntry.getState2(key, librarySource));
2183 }
2184
2185 /**
2186 * Helper for [getStatistics], puts the library independent state into the giv en
2187 * statistics object.
2188 */
2189 static void putStatCacheItem2(AnalysisContentStatisticsImpl statistics, Source Entry entry, DataDescriptor<Object> key) {
2190 statistics.putCacheItem(key, entry.getState(key));
2191 }
2192
2193 /**
2027 * The set of analysis options controlling the behavior of this context. 2194 * The set of analysis options controlling the behavior of this context.
2028 */ 2195 */
2029 AnalysisOptions _options = new AnalysisOptionsImpl(); 2196 AnalysisOptions _options = new AnalysisOptionsImpl();
2030 2197
2031 /** 2198 /**
2032 * The source factory used to create the sources that can be analyzed in this context. 2199 * The source factory used to create the sources that can be analyzed in this context.
2033 */ 2200 */
2034 SourceFactory _sourceFactory; 2201 SourceFactory _sourceFactory;
2035 2202
2036 /** 2203 /**
(...skipping 30 matching lines...) Expand all
2067 * The object used to synchronize access to all of the caches. 2234 * The object used to synchronize access to all of the caches.
2068 */ 2235 */
2069 Object _cacheLock = new Object(); 2236 Object _cacheLock = new Object();
2070 2237
2071 /** 2238 /**
2072 * The maximum number of sources for which data should be kept in the cache. 2239 * The maximum number of sources for which data should be kept in the cache.
2073 */ 2240 */
2074 static int _MAX_CACHE_SIZE = 64; 2241 static int _MAX_CACHE_SIZE = 64;
2075 2242
2076 /** 2243 /**
2244 * The maximum number of sources that can be on the priority list. This <b>mus t</b> be less than
2245 * the [MAX_CACHE_SIZE] in order to prevent an infinite loop in performAnalysi sTask().
2246 *
2247 * @see #setAnalysisPriorityOrder(List)
2248 */
2249 static int _MAX_PRIORITY_LIST_SIZE = _MAX_CACHE_SIZE - 4;
2250
2251 /**
2077 * The name of the 'src' attribute in a HTML tag. 2252 * The name of the 'src' attribute in a HTML tag.
2078 */ 2253 */
2079 static String _ATTRIBUTE_SRC = "src"; 2254 static String _ATTRIBUTE_SRC = "src";
2080 2255
2081 /** 2256 /**
2082 * The name of the 'type' attribute in a HTML tag. 2257 * The name of the 'type' attribute in a HTML tag.
2083 */ 2258 */
2084 static String _ATTRIBUTE_TYPE = "type"; 2259 static String _ATTRIBUTE_TYPE = "type";
2085 2260
2086 /** 2261 /**
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 } 2317 }
2143 NodeLocator locator = new NodeLocator.con1(element.nameOffset); 2318 NodeLocator locator = new NodeLocator.con1(element.nameOffset);
2144 ASTNode nameNode = locator.searchWithin(unit); 2319 ASTNode nameNode = locator.searchWithin(unit);
2145 while (nameNode != null) { 2320 while (nameNode != null) {
2146 if (nameNode is AnnotatedNode) { 2321 if (nameNode is AnnotatedNode) {
2147 Comment comment = ((nameNode as AnnotatedNode)).documentationComment; 2322 Comment comment = ((nameNode as AnnotatedNode)).documentationComment;
2148 if (comment == null) { 2323 if (comment == null) {
2149 return null; 2324 return null;
2150 } 2325 }
2151 JavaStringBuilder builder = new JavaStringBuilder(); 2326 JavaStringBuilder builder = new JavaStringBuilder();
2152 for (Token token in comment.tokens) { 2327 List<Token> tokens = comment.tokens;
2153 builder.append(token.lexeme); 2328 for (int i = 0; i < tokens.length; i++) {
2329 if (i > 0) {
2330 builder.append('\n');
2331 }
2332 builder.append(tokens[i].lexeme);
2154 } 2333 }
2155 return builder.toString(); 2334 return builder.toString();
2156 } 2335 }
2157 nameNode = nameNode.parent; 2336 nameNode = nameNode.parent;
2158 } 2337 }
2159 return null; 2338 return null;
2160 } 2339 }
2161 List<AnalysisError> computeErrors(Source source) { 2340 List<AnalysisError> computeErrors(Source source) {
2162 { 2341 SourceEntry sourceEntry = getReadableSourceEntry(source);
2163 SourceEntry sourceEntry = getSourceEntry(source); 2342 if (sourceEntry is DartEntry) {
2164 if (sourceEntry is DartEntry) { 2343 List<AnalysisError> errors = new List<AnalysisError>();
2165 DartEntry dartEntry = sourceEntry as DartEntry; 2344 DartEntry dartEntry = sourceEntry as DartEntry;
2166 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS) ; 2345 ListUtilities.addAll(errors, internalGetDartParseData(source, dartEntry, D artEntry.PARSE_ERRORS));
2167 if (parseErrorsState != CacheState.VALID && parseErrorsState != CacheSta te.ERROR) { 2346 if (identical(dartEntry.getValue(DartEntry.SOURCE_KIND), SourceKind.LIBRAR Y)) {
2168 parseCompilationUnit(source); 2347 ListUtilities.addAll(errors, internalGetDartResolutionData(source, sourc e, dartEntry, DartEntry.RESOLUTION_ERRORS));
2169 dartEntry = getSourceEntry(source) as DartEntry; 2348 } else {
2170 }
2171 List<Source> libraries = getLibrariesContaining(source); 2349 List<Source> libraries = getLibrariesContaining(source);
2172 for (Source librarySource in libraries) { 2350 for (Source librarySource in libraries) {
2173 CacheState resolutionErrorsState = dartEntry.getState2(DartEntry.RESOL UTION_ERRORS, librarySource); 2351 ListUtilities.addAll(errors, internalGetDartResolutionData(source, lib rarySource, dartEntry, DartEntry.RESOLUTION_ERRORS));
2174 if (resolutionErrorsState != CacheState.VALID && resolutionErrorsState != CacheState.ERROR) {
2175 }
2176 } 2352 }
2177 return dartEntry.allErrors;
2178 } else if (sourceEntry is HtmlEntry) {
2179 HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
2180 CacheState resolutionErrorsState = htmlEntry.getState(HtmlEntry.RESOLUTI ON_ERRORS);
2181 if (resolutionErrorsState != CacheState.VALID && resolutionErrorsState ! = CacheState.ERROR) {
2182 computeHtmlElement(source);
2183 htmlEntry = getSourceEntry(source) as HtmlEntry;
2184 }
2185 return htmlEntry.getValue(HtmlEntry.RESOLUTION_ERRORS);
2186 } 2353 }
2187 return AnalysisError.NO_ERRORS; 2354 if (errors.isEmpty) {
2355 return AnalysisError.NO_ERRORS;
2356 }
2357 return new List.from(errors);
2358 } else if (sourceEntry is HtmlEntry) {
2359 HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
2360 return internalGetHtmlResolutionData(source, htmlEntry, HtmlEntry.RESOLUTI ON_ERRORS, AnalysisError.NO_ERRORS);
2188 } 2361 }
2362 return AnalysisError.NO_ERRORS;
2189 } 2363 }
2190 List<Source> computeExportedLibraries(Source source) { 2364 List<Source> computeExportedLibraries(Source source) => internalGetDartParseDa ta2(source, DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY);
2191 {
2192 accessed(source);
2193 DartEntry dartEntry = getDartEntry(source);
2194 if (dartEntry == null || dartEntry.kind != SourceKind.LIBRARY) {
2195 return Source.EMPTY_ARRAY;
2196 }
2197 CacheState state = dartEntry.getState(DartEntry.EXPORTED_LIBRARIES);
2198 if (identical(state, CacheState.ERROR)) {
2199 return Source.EMPTY_ARRAY;
2200 } else if (identical(state, CacheState.VALID)) {
2201 return dartEntry.getValue(DartEntry.EXPORTED_LIBRARIES);
2202 } else {
2203 DartEntryImpl dartCopy = dartEntry.writableCopy;
2204 internalParseCompilationUnit(dartCopy, source);
2205 _sourceMap[source] = dartCopy;
2206 return dartCopy.getValue(DartEntry.EXPORTED_LIBRARIES);
2207 }
2208 }
2209 }
2210 HtmlElement computeHtmlElement(Source source) { 2365 HtmlElement computeHtmlElement(Source source) {
2211 if (!AnalysisEngine.isHtmlFileName(source.shortName)) { 2366 HtmlEntry htmlEntry = getReadableHtmlEntry(source);
2367 if (htmlEntry == null) {
2212 return null; 2368 return null;
2213 } 2369 }
2214 { 2370 CacheState elementState = htmlEntry.getState(HtmlEntry.ELEMENT);
2215 HtmlEntry htmlEntry = getHtmlEntry(source); 2371 if (elementState != CacheState.ERROR && elementState != CacheState.VALID) {
2216 if (htmlEntry == null) { 2372 htmlEntry = internalResolveHtml(source);
2217 return null;
2218 }
2219 try {
2220 HtmlElement element = htmlEntry.getValue(HtmlEntry.ELEMENT);
2221 if (element == null) {
2222 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT);
2223 if (unit == null) {
2224 unit = parseHtmlUnit(source);
2225 }
2226 HtmlUnitBuilder builder = new HtmlUnitBuilder(this);
2227 element = builder.buildHtmlElement2(source, unit);
2228 List<AnalysisError> resolutionErrors = builder.errorListener.getErrors 2(source);
2229 HtmlEntryImpl htmlCopy = getHtmlEntry(source).writableCopy;
2230 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, resolutionErrors);
2231 htmlCopy.setValue(HtmlEntry.ELEMENT, element);
2232 _sourceMap[source] = htmlCopy;
2233 getNotice(source).setErrors(htmlCopy.allErrors, htmlCopy.getValue(Sour ceEntry.LINE_INFO));
2234 }
2235 return element;
2236 } on AnalysisException catch (exception) {
2237 HtmlEntryImpl htmlCopy = getHtmlEntry(source).writableCopy;
2238 htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState.ERROR);
2239 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.ERROR);
2240 _sourceMap[source] = htmlCopy;
2241 throw exception;
2242 }
2243 } 2373 }
2374 return htmlEntry.getValue(HtmlEntry.ELEMENT);
2244 } 2375 }
2245 List<Source> computeImportedLibraries(Source source) { 2376 List<Source> computeImportedLibraries(Source source) => internalGetDartParseDa ta2(source, DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY);
2246 {
2247 accessed(source);
2248 DartEntry dartEntry = getDartEntry(source);
2249 if (dartEntry == null || dartEntry.kind != SourceKind.LIBRARY) {
2250 return Source.EMPTY_ARRAY;
2251 }
2252 CacheState state = dartEntry.getState(DartEntry.IMPORTED_LIBRARIES);
2253 if (identical(state, CacheState.ERROR)) {
2254 return Source.EMPTY_ARRAY;
2255 } else if (identical(state, CacheState.VALID)) {
2256 return dartEntry.getValue(DartEntry.IMPORTED_LIBRARIES);
2257 } else {
2258 DartEntryImpl dartCopy = dartEntry.writableCopy;
2259 internalParseCompilationUnit(dartCopy, source);
2260 _sourceMap[source] = dartCopy;
2261 return dartCopy.getValue(DartEntry.IMPORTED_LIBRARIES);
2262 }
2263 }
2264 }
2265 SourceKind computeKindOf(Source source) { 2377 SourceKind computeKindOf(Source source) {
2266 SourceEntry sourceEntry = getReadableSourceEntry(source); 2378 SourceEntry sourceEntry = getReadableSourceEntry(source);
2267 if (sourceEntry == null) { 2379 if (sourceEntry == null) {
2268 return SourceKind.UNKNOWN; 2380 return SourceKind.UNKNOWN;
2269 } else if (sourceEntry is DartEntry) { 2381 } else if (sourceEntry is DartEntry) {
2270 try { 2382 try {
2271 return internalGetDartParseData(source, (sourceEntry as DartEntry), Dart Entry.SOURCE_KIND, SourceKind.UNKNOWN); 2383 return internalGetDartParseData(source, (sourceEntry as DartEntry), Dart Entry.SOURCE_KIND);
2272 } on AnalysisException catch (exception) { 2384 } on AnalysisException catch (exception) {
2273 return SourceKind.UNKNOWN; 2385 return SourceKind.UNKNOWN;
2274 } 2386 }
2275 } 2387 }
2276 return sourceEntry.kind; 2388 return sourceEntry.kind;
2277 } 2389 }
2278 LibraryElement computeLibraryElement(Source source) { 2390 LibraryElement computeLibraryElement(Source source) {
2279 { 2391 {
2280 DartEntry dartEntry = getDartEntry(source); 2392 DartEntry dartEntry = getDartEntry(source);
2281 if (dartEntry == null) { 2393 if (dartEntry == null) {
(...skipping 18 matching lines...) Expand all
2300 LineInfo computeLineInfo(Source source) { 2412 LineInfo computeLineInfo(Source source) {
2301 SourceEntry sourceEntry = getReadableSourceEntry(source); 2413 SourceEntry sourceEntry = getReadableSourceEntry(source);
2302 if (sourceEntry is HtmlEntry) { 2414 if (sourceEntry is HtmlEntry) {
2303 return internalGetHtmlParseData(source, SourceEntry.LINE_INFO, null); 2415 return internalGetHtmlParseData(source, SourceEntry.LINE_INFO, null);
2304 } else if (sourceEntry is DartEntry) { 2416 } else if (sourceEntry is DartEntry) {
2305 return internalGetDartParseData2(source, SourceEntry.LINE_INFO, null); 2417 return internalGetDartParseData2(source, SourceEntry.LINE_INFO, null);
2306 } 2418 }
2307 return null; 2419 return null;
2308 } 2420 }
2309 CompilationUnit computeResolvableCompilationUnit(Source source) { 2421 CompilationUnit computeResolvableCompilationUnit(Source source) {
2310 { 2422 DartEntry dartEntry = getReadableDartEntry(source);
2311 DartEntry dartEntry = getDartEntry(source); 2423 if (dartEntry == null) {
2312 if (dartEntry == null) { 2424 return null;
2425 }
2426 CompilationUnit unit = dartEntry.anyParsedCompilationUnit;
2427 if (unit == null) {
2428 try {
2429 unit = parseCompilationUnit(source);
2430 } on AnalysisException catch (exception) {
2313 return null; 2431 return null;
2314 } 2432 }
2315 CompilationUnit unit = dartEntry.anyParsedCompilationUnit;
2316 if (unit != null) {
2317 return unit.accept(new ASTCloner()) as CompilationUnit;
2318 }
2319 DartEntryImpl dartCopy = dartEntry.writableCopy;
2320 unit = internalParseCompilationUnit(dartCopy, source);
2321 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
2322 _sourceMap[source] = dartCopy;
2323 return unit;
2324 } 2433 }
2434 return unit.accept(new ASTCloner()) as CompilationUnit;
2325 } 2435 }
2326 AnalysisContext extractContext(SourceContainer container) => extractContextInt o(container, (AnalysisEngine.instance.createAnalysisContext() as InternalAnalysi sContext)); 2436 AnalysisContext extractContext(SourceContainer container) => extractContextInt o(container, (AnalysisEngine.instance.createAnalysisContext() as InternalAnalysi sContext));
2327 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) { 2437 InternalAnalysisContext extractContextInto(SourceContainer container, Internal AnalysisContext newContext) {
2328 List<Source> sourcesToRemove = new List<Source>(); 2438 List<Source> sourcesToRemove = new List<Source>();
2329 { 2439 {
2330 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { 2440 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
2331 Source source = entry.getKey(); 2441 Source source = entry.getKey();
2332 if (container.contains(source)) { 2442 if (container.contains(source)) {
2333 sourcesToRemove.add(source); 2443 sourcesToRemove.add(source);
2334 newContext.addSourceInfo(source, entry.getValue().writableCopy); 2444 newContext.addSourceInfo(source, entry.getValue().writableCopy);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, null); 2476 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, null);
2367 } 2477 }
2368 HtmlElement getHtmlElement(Source source) { 2478 HtmlElement getHtmlElement(Source source) {
2369 SourceEntry sourceEntry = getReadableSourceEntry(source); 2479 SourceEntry sourceEntry = getReadableSourceEntry(source);
2370 if (sourceEntry is HtmlEntry) { 2480 if (sourceEntry is HtmlEntry) {
2371 return ((sourceEntry as HtmlEntry)).getValue(HtmlEntry.ELEMENT); 2481 return ((sourceEntry as HtmlEntry)).getValue(HtmlEntry.ELEMENT);
2372 } 2482 }
2373 return null; 2483 return null;
2374 } 2484 }
2375 List<Source> getHtmlFilesReferencing(Source source) { 2485 List<Source> getHtmlFilesReferencing(Source source) {
2486 SourceKind sourceKind = getKindOf(source);
2487 if (sourceKind == null) {
2488 return Source.EMPTY_ARRAY;
2489 }
2376 { 2490 {
2377 List<Source> htmlSources = new List<Source>(); 2491 List<Source> htmlSources = new List<Source>();
2378 while (true) { 2492 while (true) {
2379 if (getKindOf(source) == SourceKind.LIBRARY) { 2493 if (sourceKind == SourceKind.LIBRARY) {
2380 } else if (getKindOf(source) == SourceKind.PART) { 2494 } else if (sourceKind == SourceKind.PART) {
2381 List<Source> librarySources = getLibrariesContaining(source); 2495 List<Source> librarySources = getLibrariesContaining(source);
2382 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap) ) { 2496 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap) ) {
2383 if (identical(entry.getValue().kind, SourceKind.HTML)) { 2497 SourceEntry sourceEntry = entry.getValue();
2384 List<Source> referencedLibraries = ((entry.getValue() as HtmlEntry )).getValue(HtmlEntry.REFERENCED_LIBRARIES); 2498 if (identical(sourceEntry.kind, SourceKind.HTML)) {
2499 List<Source> referencedLibraries = ((sourceEntry as HtmlEntry)).ge tValue(HtmlEntry.REFERENCED_LIBRARIES);
2385 if (containsAny(referencedLibraries, librarySources)) { 2500 if (containsAny(referencedLibraries, librarySources)) {
2386 htmlSources.add(entry.getKey()); 2501 htmlSources.add(entry.getKey());
2387 } 2502 }
2388 } 2503 }
2389 } 2504 }
2390 } 2505 }
2391 break; 2506 break;
2392 } 2507 }
2393 if (htmlSources.isEmpty) { 2508 if (htmlSources.isEmpty) {
2394 return Source.EMPTY_ARRAY; 2509 return Source.EMPTY_ARRAY;
(...skipping 30 matching lines...) Expand all
2425 SourceEntry sourceEntry = entry.getValue(); 2540 SourceEntry sourceEntry = entry.getValue();
2426 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSyste mLibrary) { 2541 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSyste mLibrary) {
2427 sources.add(source); 2542 sources.add(source);
2428 } 2543 }
2429 } 2544 }
2430 } 2545 }
2431 return new List.from(sources); 2546 return new List.from(sources);
2432 } 2547 }
2433 List<Source> getLibrariesContaining(Source source) { 2548 List<Source> getLibrariesContaining(Source source) {
2434 { 2549 {
2550 SourceEntry sourceEntry = _sourceMap[source];
2551 if (sourceEntry != null && identical(sourceEntry.kind, SourceKind.LIBRARY) ) {
2552 return <Source> [source];
2553 }
2435 List<Source> librarySources = new List<Source>(); 2554 List<Source> librarySources = new List<Source>();
2436 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { 2555 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
2437 if (identical(entry.getValue().kind, SourceKind.LIBRARY)) { 2556 sourceEntry = entry.getValue();
2438 if (contains(((entry.getValue() as DartEntry)).getValue(DartEntry.INCL UDED_PARTS), source)) { 2557 if (identical(sourceEntry.kind, SourceKind.LIBRARY)) {
2558 if (contains(((sourceEntry as DartEntry)).getValue(DartEntry.INCLUDED_ PARTS), source)) {
2439 librarySources.add(entry.getKey()); 2559 librarySources.add(entry.getKey());
2440 } 2560 }
2441 } 2561 }
2442 } 2562 }
2443 if (librarySources.isEmpty) { 2563 if (librarySources.isEmpty) {
2444 return Source.EMPTY_ARRAY; 2564 return Source.EMPTY_ARRAY;
2445 } 2565 }
2446 return new List.from(librarySources); 2566 return new List.from(librarySources);
2447 } 2567 }
2448 } 2568 }
2449 List<Source> getLibrariesDependingOn(Source librarySource) { 2569 List<Source> getLibrariesDependingOn(Source librarySource) {
2450 { 2570 {
2451 List<Source> dependentLibraries = new List<Source>(); 2571 List<Source> dependentLibraries = new List<Source>();
2452 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { 2572 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
2453 if (identical(entry.getValue().kind, SourceKind.LIBRARY)) { 2573 SourceEntry sourceEntry = entry.getValue();
2454 if (contains(((entry.getValue() as DartEntry)).getValue(DartEntry.EXPO RTED_LIBRARIES), librarySource)) { 2574 if (identical(sourceEntry.kind, SourceKind.LIBRARY)) {
2575 if (contains(((sourceEntry as DartEntry)).getValue(DartEntry.EXPORTED_ LIBRARIES), librarySource)) {
2455 dependentLibraries.add(entry.getKey()); 2576 dependentLibraries.add(entry.getKey());
2456 } 2577 }
2457 if (contains(((entry.getValue() as DartEntry)).getValue(DartEntry.IMPO RTED_LIBRARIES), librarySource)) { 2578 if (contains(((sourceEntry as DartEntry)).getValue(DartEntry.IMPORTED_ LIBRARIES), librarySource)) {
2458 dependentLibraries.add(entry.getKey()); 2579 dependentLibraries.add(entry.getKey());
2459 } 2580 }
2460 } 2581 }
2461 } 2582 }
2462 if (dependentLibraries.isEmpty) { 2583 if (dependentLibraries.isEmpty) {
2463 return Source.EMPTY_ARRAY; 2584 return Source.EMPTY_ARRAY;
2464 } 2585 }
2465 return new List.from(dependentLibraries); 2586 return new List.from(dependentLibraries);
2466 } 2587 }
2467 } 2588 }
2468 LibraryElement getLibraryElement(Source source) { 2589 LibraryElement getLibraryElement(Source source) {
2469 SourceEntry sourceEntry = getReadableSourceEntry(source); 2590 SourceEntry sourceEntry = getReadableSourceEntry(source);
2470 if (sourceEntry is DartEntry) { 2591 if (sourceEntry is DartEntry) {
2471 return ((sourceEntry as DartEntry)).getValue(DartEntry.ELEMENT); 2592 return ((sourceEntry as DartEntry)).getValue(DartEntry.ELEMENT);
2472 } 2593 }
2473 return null; 2594 return null;
2474 } 2595 }
2475 List<Source> get librarySources => getSources(SourceKind.LIBRARY); 2596 List<Source> get librarySources => getSources(SourceKind.LIBRARY);
2476 LineInfo getLineInfo(Source source) { 2597 LineInfo getLineInfo(Source source) {
2477 SourceEntry sourceEntry = getReadableSourceEntry(source); 2598 SourceEntry sourceEntry = getReadableSourceEntry(source);
2478 if (sourceEntry != null) { 2599 if (sourceEntry != null) {
2479 return sourceEntry.getValue(SourceEntry.LINE_INFO); 2600 return sourceEntry.getValue(SourceEntry.LINE_INFO);
2480 } 2601 }
2481 return null; 2602 return null;
2482 } 2603 }
2483 Namespace getPublicNamespace(LibraryElement library) { 2604 Namespace getPublicNamespace(LibraryElement library) {
2484 Source source = library.definingCompilationUnit.source; 2605 Source source = library.definingCompilationUnit.source;
2606 DartEntry dartEntry = getReadableDartEntry(source);
2607 if (dartEntry == null) {
2608 return null;
2609 }
2485 { 2610 {
2486 DartEntry dartEntry = getDartEntry(source);
2487 if (dartEntry == null) {
2488 return null;
2489 }
2490 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); 2611 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE);
2491 if (namespace == null) { 2612 if (namespace == null) {
2492 NamespaceBuilder builder = new NamespaceBuilder(); 2613 NamespaceBuilder builder = new NamespaceBuilder();
2493 namespace = builder.createPublicNamespace(library); 2614 namespace = builder.createPublicNamespace(library);
2494 DartEntryImpl dartCopy = getDartEntry(source).writableCopy; 2615 DartEntryImpl dartCopy = getDartEntry(source).writableCopy;
2495 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); 2616 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace);
2496 _sourceMap[source] = dartCopy; 2617 _sourceMap[source] = dartCopy;
2497 } 2618 }
2498 return namespace; 2619 return namespace;
2499 } 2620 }
2500 } 2621 }
2501 Namespace getPublicNamespace2(Source source) { 2622 Namespace getPublicNamespace2(Source source) {
2623 DartEntry dartEntry = getReadableDartEntry(source);
2624 if (dartEntry == null) {
2625 return null;
2626 }
2502 { 2627 {
2503 DartEntry dartEntry = getDartEntry(source);
2504 if (dartEntry == null) {
2505 return null;
2506 }
2507 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); 2628 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE);
2508 if (namespace == null) { 2629 if (namespace == null) {
2509 LibraryElement library = computeLibraryElement(source); 2630 LibraryElement library = computeLibraryElement(source);
2510 if (library == null) { 2631 if (library == null) {
2511 return null; 2632 return null;
2512 } 2633 }
2513 NamespaceBuilder builder = new NamespaceBuilder(); 2634 NamespaceBuilder builder = new NamespaceBuilder();
2514 namespace = builder.createPublicNamespace(library); 2635 namespace = builder.createPublicNamespace(library);
2515 DartEntryImpl dartCopy = getDartEntry(source).writableCopy; 2636 DartEntryImpl dartCopy = getDartEntry(source).writableCopy;
2516 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); 2637 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace);
2517 _sourceMap[source] = dartCopy; 2638 _sourceMap[source] = dartCopy;
2518 } 2639 }
2519 return namespace; 2640 return namespace;
2520 } 2641 }
2521 } 2642 }
2522 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l ibrary) { 2643 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l ibrary) {
2523 if (library == null) { 2644 if (library == null) {
2524 return null; 2645 return null;
2525 } 2646 }
2526 return getResolvedCompilationUnit2(unitSource, library.source); 2647 return getResolvedCompilationUnit2(unitSource, library.source);
2527 } 2648 }
2528 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS ource) { 2649 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS ource) {
2529 SourceEntry sourceEntry = getReadableSourceEntry(unitSource); 2650 SourceEntry sourceEntry = getReadableSourceEntry(unitSource);
2530 if (sourceEntry is DartEntry) { 2651 if (sourceEntry is DartEntry) {
2531 return ((sourceEntry as DartEntry)).getValue2(DartEntry.RESOLVED_UNIT, lib rarySource); 2652 return ((sourceEntry as DartEntry)).getValue2(DartEntry.RESOLVED_UNIT, lib rarySource);
2532 } 2653 }
2533 return null; 2654 return null;
2534 } 2655 }
2535 SourceFactory get sourceFactory => _sourceFactory; 2656 SourceFactory get sourceFactory => _sourceFactory;
2657
2658 /**
2659 * Return a list of the sources that would be processed by [performAnalysisTas k]. This
2660 * method is intended to be used for testing purposes only.
2661 *
2662 * @return a list of the sources that would be processed by [performAnalysisTa sk]
2663 */
2664 List<Source> get sourcesNeedingProcessing {
2665 List<Source> sources = new List<Source>();
2666 {
2667 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
2668 SourceEntry sourceEntry = entry.getValue();
2669 if (sourceEntry is DartEntry) {
2670 DartEntry dartEntry = sourceEntry as DartEntry;
2671 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT) ;
2672 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT);
2673 if (identical(parsedUnitState, CacheState.INVALID) || identical(elemen tState, CacheState.INVALID)) {
2674 sources.add(entry.getKey());
2675 }
2676 } else if (sourceEntry is HtmlEntry) {
2677 HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
2678 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT) ;
2679 CacheState elementState = htmlEntry.getState(HtmlEntry.ELEMENT);
2680 if (identical(parsedUnitState, CacheState.INVALID) || identical(elemen tState, CacheState.INVALID)) {
2681 sources.add(entry.getKey());
2682 }
2683 }
2684 }
2685 }
2686 return sources;
2687 }
2688 AnalysisContentStatistics get statistics {
2689 AnalysisContentStatisticsImpl statistics = new AnalysisContentStatisticsImpl ();
2690 {
2691 for (MapEntry<Source, SourceEntry> mapEntry in getMapEntrySet(_sourceMap)) {
2692 SourceEntry entry = mapEntry.getValue();
2693 if (entry is DartEntry) {
2694 Source source = mapEntry.getKey();
2695 DartEntry dartEntry = entry as DartEntry;
2696 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND);
2697 putStatCacheItem2(statistics, dartEntry, DartEntry.PARSE_ERRORS);
2698 putStatCacheItem2(statistics, dartEntry, DartEntry.PARSED_UNIT);
2699 putStatCacheItem2(statistics, dartEntry, DartEntry.SOURCE_KIND);
2700 putStatCacheItem2(statistics, dartEntry, DartEntry.LINE_INFO);
2701 if (identical(kind, SourceKind.LIBRARY)) {
2702 putStatCacheItem2(statistics, dartEntry, DartEntry.ELEMENT);
2703 putStatCacheItem2(statistics, dartEntry, DartEntry.EXPORTED_LIBRARIE S);
2704 putStatCacheItem2(statistics, dartEntry, DartEntry.IMPORTED_LIBRARIE S);
2705 putStatCacheItem2(statistics, dartEntry, DartEntry.INCLUDED_PARTS);
2706 putStatCacheItem2(statistics, dartEntry, DartEntry.IS_CLIENT);
2707 putStatCacheItem2(statistics, dartEntry, DartEntry.IS_LAUNCHABLE);
2708 }
2709 List<Source> librarySources = getLibrariesContaining(source);
2710 for (Source librarySource in librarySources) {
2711 putStatCacheItem(statistics, dartEntry, librarySource, DartEntry.RES OLUTION_ERRORS);
2712 putStatCacheItem(statistics, dartEntry, librarySource, DartEntry.RES OLVED_UNIT);
2713 }
2714 }
2715 }
2716 }
2717 return statistics;
2718 }
2536 bool isClientLibrary(Source librarySource) { 2719 bool isClientLibrary(Source librarySource) {
2537 SourceEntry sourceEntry = getReadableSourceEntry(librarySource); 2720 SourceEntry sourceEntry = getReadableSourceEntry(librarySource);
2538 if (sourceEntry is DartEntry) { 2721 if (sourceEntry is DartEntry) {
2539 DartEntry dartEntry = sourceEntry as DartEntry; 2722 DartEntry dartEntry = sourceEntry as DartEntry;
2540 return dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(DartE ntry.IS_LAUNCHABLE); 2723 return dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(DartE ntry.IS_LAUNCHABLE);
2541 } 2724 }
2542 return false; 2725 return false;
2543 } 2726 }
2544 bool isServerLibrary(Source librarySource) { 2727 bool isServerLibrary(Source librarySource) {
2545 SourceEntry sourceEntry = getReadableSourceEntry(librarySource); 2728 SourceEntry sourceEntry = getReadableSourceEntry(librarySource);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2660 { 2843 {
2661 this._options = options2; 2844 this._options = options2;
2662 invalidateAllResults(); 2845 invalidateAllResults();
2663 } 2846 }
2664 } 2847 }
2665 void set analysisPriorityOrder(List<Source> sources) { 2848 void set analysisPriorityOrder(List<Source> sources) {
2666 { 2849 {
2667 if (sources == null || sources.isEmpty) { 2850 if (sources == null || sources.isEmpty) {
2668 _priorityOrder = Source.EMPTY_ARRAY; 2851 _priorityOrder = Source.EMPTY_ARRAY;
2669 } else { 2852 } else {
2670 _priorityOrder = new List.from(sources); 2853 while (sources.remove(null)) {
2854 }
2855 int count = Math.min(sources.length, _MAX_PRIORITY_LIST_SIZE);
2856 _priorityOrder = new List<Source>(count);
2857 for (int i = 0; i < count; i++) {
2858 _priorityOrder[i] = sources[i];
2859 }
2671 } 2860 }
2672 } 2861 }
2673 } 2862 }
2674 void setContents(Source source, String contents) { 2863 void setContents(Source source, String contents) {
2675 { 2864 {
2676 _sourceFactory.setContents(source, contents); 2865 if (_sourceFactory.setContents(source, contents)) {
2677 sourceChanged(source); 2866 sourceChanged(source);
2867 }
2678 } 2868 }
2679 } 2869 }
2680 void set sourceFactory(SourceFactory factory) { 2870 void set sourceFactory(SourceFactory factory) {
2681 { 2871 {
2682 if (identical(_sourceFactory, factory)) { 2872 if (identical(_sourceFactory, factory)) {
2683 return; 2873 return;
2684 } else if (factory.context != null) { 2874 } else if (factory.context != null) {
2685 throw new IllegalStateException("Source factories cannot be shared betwe en contexts"); 2875 throw new IllegalStateException("Source factories cannot be shared betwe en contexts");
2686 } 2876 }
2687 if (_sourceFactory != null) { 2877 if (_sourceFactory != null) {
2688 _sourceFactory.context = null; 2878 _sourceFactory.context = null;
2689 } 2879 }
2690 factory.context = this; 2880 factory.context = this;
2691 _sourceFactory = factory; 2881 _sourceFactory = factory;
2692 invalidateAllResults(); 2882 invalidateAllResults();
2693 } 2883 }
2694 } 2884 }
2695 Iterable<Source> sourcesToResolve(List<Source> changedSources) { 2885 Iterable<Source> sourcesToResolve(List<Source> changedSources) {
2696 List<Source> librarySources = new List<Source>(); 2886 List<Source> librarySources = new List<Source>();
2697 for (Source source in changedSources) { 2887 for (Source source in changedSources) {
2698 if (identical(computeKindOf(source), SourceKind.LIBRARY)) { 2888 if (identical(computeKindOf(source), SourceKind.LIBRARY)) {
2699 librarySources.add(source); 2889 librarySources.add(source);
2700 } 2890 }
2701 } 2891 }
2702 return librarySources; 2892 return librarySources;
2703 } 2893 }
2704 2894
2705 /** 2895 /**
2706 * Return a list of the sources that would be processed by [performAnalysisTas k]. This
2707 * method is intended to be used for testing purposes only.
2708 *
2709 * @return a list of the sources that would be processed by [performAnalysisTa sk]
2710 */
2711 List<Source> get sourcesNeedingProcessing {
2712 List<Source> sources = new List<Source>();
2713 {
2714 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
2715 SourceEntry sourceEntry = entry.getValue();
2716 if (sourceEntry is DartEntry) {
2717 DartEntry dartEntry = sourceEntry as DartEntry;
2718 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT) ;
2719 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT);
2720 if (identical(parsedUnitState, CacheState.INVALID) || identical(elemen tState, CacheState.INVALID)) {
2721 sources.add(entry.getKey());
2722 }
2723 } else if (sourceEntry is HtmlEntry) {
2724 HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
2725 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT) ;
2726 CacheState elementState = htmlEntry.getState(HtmlEntry.ELEMENT);
2727 if (identical(parsedUnitState, CacheState.INVALID) || identical(elemen tState, CacheState.INVALID)) {
2728 sources.add(entry.getKey());
2729 }
2730 }
2731 }
2732 }
2733 return sources;
2734 }
2735
2736 /**
2737 * Record that the given source was just accessed for some unspecified purpose . 2896 * Record that the given source was just accessed for some unspecified purpose .
2738 * 2897 *
2739 * Note: This method must only be invoked while we are synchronized on [cacheL ock]. 2898 * Note: This method must only be invoked while we are synchronized on [cacheL ock].
2740 * 2899 *
2741 * @param source the source that was accessed 2900 * @param source the source that was accessed
2742 */ 2901 */
2743 void accessed(Source source) { 2902 void accessed(Source source) {
2744 if (_recentlyUsed.remove(source)) { 2903 if (_recentlyUsed.remove(source)) {
2745 _recentlyUsed.add(source); 2904 _recentlyUsed.add(source);
2746 return; 2905 return;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2876 } 3035 }
2877 return null; 3036 return null;
2878 } 3037 }
2879 3038
2880 /** 3039 /**
2881 * Flush one AST structure from the cache. 3040 * Flush one AST structure from the cache.
2882 * 3041 *
2883 * Note: This method must only be invoked while we are synchronized on [cacheL ock]. 3042 * Note: This method must only be invoked while we are synchronized on [cacheL ock].
2884 */ 3043 */
2885 void flushAstFromCache() { 3044 void flushAstFromCache() {
2886 Source removedSource = _recentlyUsed.removeAt(0); 3045 Source removedSource = removeAstToFlush();
2887 SourceEntry sourceEntry = _sourceMap[removedSource]; 3046 SourceEntry sourceEntry = _sourceMap[removedSource];
2888 if (sourceEntry is HtmlEntry) { 3047 if (sourceEntry is HtmlEntry) {
2889 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; 3048 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy;
2890 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); 3049 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED);
2891 _sourceMap[removedSource] = htmlCopy; 3050 _sourceMap[removedSource] = htmlCopy;
2892 } else if (sourceEntry is DartEntry) { 3051 } else if (sourceEntry is DartEntry) {
2893 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy; 3052 DartEntryImpl dartCopy = ((sourceEntry as DartEntry)).writableCopy;
2894 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); 3053 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
2895 for (Source librarySource in getLibrariesContaining(removedSource)) { 3054 for (Source librarySource in getLibrariesContaining(removedSource)) {
2896 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.FL USHED); 3055 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.FL USHED);
(...skipping 20 matching lines...) Expand all
2917 sourceEntry = new DartEntryImpl(); 3076 sourceEntry = new DartEntryImpl();
2918 _sourceMap[source] = sourceEntry; 3077 _sourceMap[source] = sourceEntry;
2919 return sourceEntry as DartEntry; 3078 return sourceEntry as DartEntry;
2920 } else if (sourceEntry is DartEntry) { 3079 } else if (sourceEntry is DartEntry) {
2921 return sourceEntry as DartEntry; 3080 return sourceEntry as DartEntry;
2922 } 3081 }
2923 return null; 3082 return null;
2924 } 3083 }
2925 3084
2926 /** 3085 /**
2927 * Return the HTML unit information associated with the given source, or `null ` if the
2928 * source is not known to this context. This method should be used to access t he HTML unit
2929 * information rather than accessing the HTML unit map directly because source s in the SDK are
2930 * implicitly part of every analysis context and are therefore only added to t he map when first
2931 * accessed.
2932 *
2933 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
2934 *
2935 * @param source the source for which information is being sought
2936 * @return the HTML unit information associated with the given source
2937 */
2938 HtmlEntry getHtmlEntry(Source source) {
2939 SourceEntry sourceEntry = getSourceEntry(source);
2940 if (sourceEntry == null) {
2941 sourceEntry = new HtmlEntryImpl();
2942 _sourceMap[source] = sourceEntry;
2943 return sourceEntry as HtmlEntry;
2944 } else if (sourceEntry is HtmlEntry) {
2945 return sourceEntry as HtmlEntry;
2946 }
2947 return null;
2948 }
2949
2950 /**
2951 * Return the sources of libraries that are referenced in the specified HTML f ile. 3086 * Return the sources of libraries that are referenced in the specified HTML f ile.
2952 * 3087 *
2953 * @param htmlSource the source of the HTML file being analyzed 3088 * @param htmlSource the source of the HTML file being analyzed
2954 * @param htmlUnit the AST for the HTML file being analyzed 3089 * @param htmlUnit the AST for the HTML file being analyzed
2955 * @return the sources of libraries that are referenced in the HTML file 3090 * @return the sources of libraries that are referenced in the HTML file
2956 */ 3091 */
2957 List<Source> getLibrarySources2(Source htmlSource, HtmlUnit htmlUnit) { 3092 List<Source> getLibrarySources2(Source htmlSource, HtmlUnit htmlUnit) {
2958 List<Source> libraries = new List<Source>(); 3093 List<Source> libraries = new List<Source>();
2959 htmlUnit.accept(new RecursiveXmlVisitor_6(this, htmlSource, libraries)); 3094 htmlUnit.accept(new RecursiveXmlVisitor_6(this, htmlSource, libraries));
2960 if (libraries.isEmpty) { 3095 if (libraries.isEmpty) {
2961 return Source.EMPTY_ARRAY; 3096 return Source.EMPTY_ARRAY;
2962 } 3097 }
2963 return new List.from(libraries); 3098 return new List.from(libraries);
2964 } 3099 }
2965 3100
2966 /** 3101 /**
3102 * Look through the cache for a task that needs to be performed. Return the ta sk that was found,
3103 * or `null` if there is no more work to be done.
3104 *
3105 * @return the next task that needs to be performed
3106 */
3107 AnalysisContextImpl_AnalysisTask get nextTaskAnalysisTask {
3108 {
3109 for (Source source in _priorityOrder) {
3110 SourceEntry sourceEntry = _sourceMap[source];
3111 if (sourceEntry is DartEntry) {
3112 DartEntry dartEntry = sourceEntry as DartEntry;
3113 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERROR S);
3114 if (identical(parseErrorsState, CacheState.INVALID) || identical(parse ErrorsState, CacheState.FLUSHED)) {
3115 DartEntryImpl dartCopy = dartEntry.writableCopy;
3116 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.IN_PROCESS);
3117 _sourceMap[source] = dartCopy;
3118 return new AnalysisContextImpl_ParseDartTask(this, source);
3119 }
3120 CacheState parseUnitState = dartEntry.getState(DartEntry.PARSED_UNIT);
3121 if (identical(parseUnitState, CacheState.INVALID) || identical(parseUn itState, CacheState.FLUSHED)) {
3122 DartEntryImpl dartCopy = dartEntry.writableCopy;
3123 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.IN_PROCESS);
3124 _sourceMap[source] = dartCopy;
3125 return new AnalysisContextImpl_ParseDartTask(this, source);
3126 }
3127 for (Source librarySource in getLibrariesContaining(source)) {
3128 SourceEntry libraryEntry = _sourceMap[librarySource];
3129 if (libraryEntry is DartEntry) {
3130 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT) ;
3131 if (identical(elementState, CacheState.INVALID) || identical(eleme ntState, CacheState.FLUSHED)) {
3132 DartEntryImpl libraryCopy = ((libraryEntry as DartEntry)).writab leCopy;
3133 libraryCopy.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS);
3134 _sourceMap[librarySource] = libraryCopy;
3135 return new AnalysisContextImpl_ResolveDartLibraryTask(this, libr arySource);
3136 }
3137 }
3138 CacheState resolvedUnitState = dartEntry.getState2(DartEntry.RESOLVE D_UNIT, librarySource);
3139 if (identical(resolvedUnitState, CacheState.INVALID) || identical(re solvedUnitState, CacheState.FLUSHED)) {
3140 DartEntryImpl dartCopy = dartEntry.writableCopy;
3141 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheSt ate.IN_PROCESS);
3142 _sourceMap[source] = dartCopy;
3143 return new AnalysisContextImpl_ResolveDartUnitTask(this, source, l ibrarySource);
3144 }
3145 }
3146 } else if (sourceEntry is HtmlEntry) {
3147 HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
3148 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT) ;
3149 if (identical(parsedUnitState, CacheState.INVALID) || identical(parsed UnitState, CacheState.FLUSHED)) {
3150 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
3151 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.IN_PROCESS);
3152 _sourceMap[source] = htmlCopy;
3153 return new AnalysisContextImpl_ParseHtmlTask(this, source);
3154 }
3155 CacheState elementState = htmlEntry.getState(HtmlEntry.ELEMENT);
3156 if (identical(elementState, CacheState.INVALID) || identical(elementSt ate, CacheState.FLUSHED)) {
3157 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
3158 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.IN_PROCESS);
3159 _sourceMap[source] = htmlCopy;
3160 return new AnalysisContextImpl_ResolveHtmlTask(this, source);
3161 }
3162 }
3163 }
3164 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
3165 SourceEntry sourceEntry = entry.getValue();
3166 if (sourceEntry is DartEntry) {
3167 DartEntry dartEntry = sourceEntry as DartEntry;
3168 if (identical(dartEntry.getState(DartEntry.PARSED_UNIT), CacheState.IN VALID)) {
3169 Source source = entry.getKey();
3170 DartEntryImpl dartCopy = dartEntry.writableCopy;
3171 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.IN_PROCESS);
3172 _sourceMap[source] = dartCopy;
3173 return new AnalysisContextImpl_ParseDartTask(this, source);
3174 }
3175 } else if (sourceEntry is HtmlEntry) {
3176 HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
3177 if (identical(htmlEntry.getState(HtmlEntry.PARSED_UNIT), CacheState.IN VALID)) {
3178 Source source = entry.getKey();
3179 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
3180 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.IN_PROCESS);
3181 _sourceMap[source] = htmlCopy;
3182 return new AnalysisContextImpl_ParseHtmlTask(this, source);
3183 }
3184 }
3185 }
3186 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
3187 SourceEntry sourceEntry = entry.getValue();
3188 if (sourceEntry is DartEntry && identical(sourceEntry.kind, SourceKind.L IBRARY)) {
3189 DartEntry dartEntry = sourceEntry as DartEntry;
3190 if (identical(dartEntry.getState(DartEntry.ELEMENT), CacheState.INVALI D)) {
3191 Source source = entry.getKey();
3192 DartEntryImpl dartCopy = dartEntry.writableCopy;
3193 dartCopy.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS);
3194 _sourceMap[source] = dartCopy;
3195 return new AnalysisContextImpl_ResolveDartLibraryTask(this, source);
3196 }
3197 } else if (sourceEntry is HtmlEntry) {
3198 HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
3199 if (identical(htmlEntry.getState(HtmlEntry.ELEMENT), CacheState.INVALI D)) {
3200 Source source = entry.getKey();
3201 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
3202 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.IN_PROCESS);
3203 _sourceMap[source] = htmlCopy;
3204 return new AnalysisContextImpl_ResolveHtmlTask(this, source);
3205 }
3206 }
3207 }
3208 return null;
3209 }
3210 }
3211
3212 /**
2967 * Return a change notice for the given source, creating one if one does not a lready exist. 3213 * Return a change notice for the given source, creating one if one does not a lready exist.
2968 * 3214 *
2969 * @param source the source for which changes are being reported 3215 * @param source the source for which changes are being reported
2970 * @return a change notice for the given source 3216 * @return a change notice for the given source
2971 */ 3217 */
2972 ChangeNoticeImpl getNotice(Source source) { 3218 ChangeNoticeImpl getNotice(Source source) {
2973 ChangeNoticeImpl notice = _pendingNotices[source]; 3219 ChangeNoticeImpl notice = _pendingNotices[source];
2974 if (notice == null) { 3220 if (notice == null) {
2975 notice = new ChangeNoticeImpl(source); 3221 notice = new ChangeNoticeImpl(source);
2976 _pendingNotices[source] = notice; 3222 _pendingNotices[source] = notice;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
3071 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { 3317 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
3072 if (identical(entry.getValue().kind, kind2)) { 3318 if (identical(entry.getValue().kind, kind2)) {
3073 sources.add(entry.getKey()); 3319 sources.add(entry.getKey());
3074 } 3320 }
3075 } 3321 }
3076 } 3322 }
3077 return new List.from(sources); 3323 return new List.from(sources);
3078 } 3324 }
3079 3325
3080 /** 3326 /**
3081 * Given a source for a Dart file, return the data represented by the given de scriptor that is 3327 * Given a source for an HTML file, return a cache entry in which all of the d ata represented by
3082 * associated with that source, or the given default value if the source is no t a Dart file. This 3328 * the given descriptors is available. This method assumes that the data can b e produced by
3083 * method assumes that the data can be produced by parsing the source if it is not already cached. 3329 * parsing the source if it is not already cached.
3330 *
3331 * @param htmlEntry the cache entry associated with the HTML file
3332 * @param descriptor the descriptor representing the data to be returned
3333 * @return a cache entry containing the required data
3334 */
3335 bool hasHtmlParseDataCached(HtmlEntry htmlEntry, List<DataDescriptor<Object>> descriptors) {
3336 for (DataDescriptor<Object> descriptor in descriptors) {
3337 CacheState state = htmlEntry.getState(descriptor);
3338 if (state != CacheState.VALID && state != CacheState.ERROR) {
3339 return false;
3340 }
3341 }
3342 return true;
3343 }
3344
3345 /**
3346 * Given a source for a Dart file, return a cache entry in which the data repr esented by the given
3347 * descriptor is available. This method assumes that the data can be produced by parsing the
3348 * source if it is not already cached.
3084 * 3349 *
3085 * @param source the source representing the Dart file 3350 * @param source the source representing the Dart file
3086 * @param dartEntry the cache entry associated with the Dart file 3351 * @param dartEntry the cache entry associated with the Dart file
3087 * @param descriptor the descriptor representing the data to be returned 3352 * @param descriptor the descriptor representing the data to be returned
3088 * @param defaultValue the value to be returned if the source is not a Dart fi le 3353 * @return a cache entry containing the required data
3089 * @return the requested data about the given source 3354 * @throws AnalysisException if data could not be returned because the source could not be
3090 * @throws AnalysisException if data could not be returned because the source could not be parsed 3355 * resolved
3091 */ 3356 */
3092 Object internalGetDartParseData(Source source, DartEntry dartEntry, DataDescri ptor descriptor, Object defaultValue) { 3357 DartEntry internalCacheDartParseData(Source source, DartEntry dartEntry, DataD escriptor<Object> descriptor) {
3093 if (dartEntry == null) {
3094 return defaultValue;
3095 }
3096 CacheState state = dartEntry.getState(descriptor); 3358 CacheState state = dartEntry.getState(descriptor);
3097 while (state != CacheState.ERROR && state != CacheState.VALID) { 3359 while (state != CacheState.ERROR && state != CacheState.VALID) {
3098 dartEntry = internalParseDart(source); 3360 dartEntry = internalParseDart(source);
3099 state = dartEntry.getState(descriptor); 3361 state = dartEntry.getState(descriptor);
3100 } 3362 }
3363 return dartEntry;
3364 }
3365
3366 /**
3367 * Given a source for a Dart file and the library that contains it, return a c ache entry in which
3368 * all of the data represented by the given descriptors is available. This met hod assumes that the
3369 * data can be produced by resolving the source in the context of the library if it is not already
3370 * cached.
3371 *
3372 * @param unitSource the source representing the Dart file
3373 * @param librarySource the source representing the library containing the Dar t file
3374 * @param dartEntry the cache entry associated with the Dart file
3375 * @param descriptor the descriptor representing the data to be returned
3376 * @return the requested data about the given source
3377 * @throws AnalysisException if data could not be returned because the source could not be parsed
3378 */
3379 DartEntry internalCacheDartResolutionData(Source unitSource, Source librarySou rce, DartEntry dartEntry, DataDescriptor<Object> descriptor) {
3380 CacheState state = dartEntry.getState2(descriptor, librarySource);
3381 while (state != CacheState.ERROR && state != CacheState.VALID) {
3382 dartEntry = internalResolveDart(unitSource, librarySource);
3383 state = dartEntry.getState2(descriptor, librarySource);
3384 }
3385 return dartEntry;
3386 }
3387
3388 /**
3389 * Given a source for an HTML file, return a cache entry in which all of the d ata represented by
3390 * the given descriptors is available. This method assumes that the data can b e produced by
3391 * parsing the source if it is not already cached.
3392 *
3393 * @param source the source representing the HTML file
3394 * @param htmlEntry the cache entry associated with the HTML file
3395 * @param descriptor the descriptor representing the data to be returned
3396 * @return a cache entry containing the required data
3397 * @throws AnalysisException if data could not be returned because the source could not be
3398 * resolved
3399 */
3400 HtmlEntry internalCacheHtmlParseData(Source source, HtmlEntry htmlEntry, List< DataDescriptor<Object>> descriptors) {
3401 while (!hasHtmlParseDataCached(htmlEntry, descriptors)) {
3402 htmlEntry = internalParseHtml(source);
3403 }
3404 return htmlEntry;
3405 }
3406
3407 /**
3408 * Given a source for a Dart file, return the data represented by the given de scriptor that is
3409 * associated with that source. This method assumes that the data can be produ ced by parsing the
3410 * source if it is not already cached.
3411 *
3412 * @param source the source representing the Dart file
3413 * @param dartEntry the cache entry associated with the Dart file
3414 * @param descriptor the descriptor representing the data to be returned
3415 * @return the requested data about the given source
3416 * @throws AnalysisException if data could not be returned because the source could not be parsed
3417 */
3418 Object internalGetDartParseData(Source source, DartEntry dartEntry, DataDescri ptor descriptor) {
3419 dartEntry = internalCacheDartParseData(source, dartEntry, descriptor);
3101 return dartEntry.getValue(descriptor); 3420 return dartEntry.getValue(descriptor);
3102 } 3421 }
3103 3422
3104 /** 3423 /**
3105 * Given a source for a Dart file, return the data represented by the given de scriptor that is 3424 * Given a source for a Dart file, return the data represented by the given de scriptor that is
3106 * associated with that source, or the given default value if the source is no t a Dart file. This 3425 * associated with that source, or the given default value if the source is no t a Dart file. This
3107 * method assumes that the data can be produced by parsing the source if it is not already cached. 3426 * method assumes that the data can be produced by parsing the source if it is not already cached.
3108 * 3427 *
3109 * @param source the source representing the Dart file 3428 * @param source the source representing the Dart file
3110 * @param descriptor the descriptor representing the data to be returned 3429 * @param descriptor the descriptor representing the data to be returned
3111 * @param defaultValue the value to be returned if the source is not a Dart fi le 3430 * @param defaultValue the value to be returned if the source is not a Dart fi le
3112 * @return the requested data about the given source 3431 * @return the requested data about the given source
3113 * @throws AnalysisException if data could not be returned because the source could not be parsed 3432 * @throws AnalysisException if data could not be returned because the source could not be parsed
3114 */ 3433 */
3115 Object internalGetDartParseData2(Source source, DataDescriptor descriptor, Obj ect defaultValue) => internalGetDartParseData(source, getReadableDartEntry(sourc e), descriptor, defaultValue); 3434 Object internalGetDartParseData2(Source source, DataDescriptor descriptor, Obj ect defaultValue) {
3435 DartEntry dartEntry = getReadableDartEntry(source);
3436 if (dartEntry == null) {
3437 return defaultValue;
3438 }
3439 return internalGetDartParseData(source, dartEntry, descriptor);
3440 }
3441
3442 /**
3443 * Given a source for a Dart file and the library that contains it, return the data represented by
3444 * the given descriptor that is associated with that source. This method assum es that the data can
3445 * be produced by resolving the source in the context of the library if it is not already cached.
3446 *
3447 * @param unitSource the source representing the Dart file
3448 * @param librarySource the source representing the library containing the Dar t file
3449 * @param dartEntry the entry representing the Dart file
3450 * @param descriptor the descriptor representing the data to be returned
3451 * @return the requested data about the given source
3452 * @throws AnalysisException if data could not be returned because the source could not be parsed
3453 */
3454 Object internalGetDartResolutionData(Source unitSource, Source librarySource, DartEntry dartEntry, DataDescriptor descriptor) {
3455 dartEntry = internalCacheDartResolutionData(unitSource, librarySource, dartE ntry, descriptor);
3456 return dartEntry.getValue2(descriptor, librarySource);
3457 }
3458
3459 /**
3460 * Given a source for a Dart file and the library that contains it, return the data represented by
3461 * the given descriptor that is associated with that source. This method assum es that the data can
3462 * be produced by resolving the source in the context of the library if it is not already cached.
3463 *
3464 * @param unitSource the source representing the Dart file
3465 * @param librarySource the source representing the library containing the Dar t file
3466 * @param descriptor the descriptor representing the data to be returned
3467 * @param defaultValue the value to be returned if the file is not a Dart file
3468 * @return the requested data about the given source
3469 * @throws AnalysisException if data could not be returned because the source could not be parsed
3470 */
3471 Object internalGetDartResolutionData2(Source unitSource, Source librarySource, DataDescriptor descriptor, Object defaultValue) {
3472 DartEntry dartEntry = getReadableDartEntry(unitSource);
3473 if (dartEntry == null) {
3474 return defaultValue;
3475 }
3476 dartEntry = internalCacheDartResolutionData(unitSource, librarySource, dartE ntry, descriptor);
3477 return dartEntry.getValue(descriptor);
3478 }
3116 3479
3117 /** 3480 /**
3118 * Given a source for an HTML file, return the data represented by the given d escriptor that is 3481 * Given a source for an HTML file, return the data represented by the given d escriptor that is
3119 * associated with that source, or the given default value if the source is no t an HTML file. This 3482 * associated with that source, or the given default value if the source is no t an HTML file. This
3120 * method assumes that the data can be produced by parsing the source if it is not already cached. 3483 * method assumes that the data can be produced by parsing the source if it is not already cached.
3121 * 3484 *
3122 * @param source the source representing the Dart file 3485 * @param source the source representing the Dart file
3123 * @param descriptor the descriptor representing the data to be returned 3486 * @param descriptor the descriptor representing the data to be returned
3124 * @param defaultValue the value to be returned if the source is not a Dart fi le 3487 * @param defaultValue the value to be returned if the source is not a Dart fi le
3125 * @return the requested data about the given source 3488 * @return the requested data about the given source
3126 * @throws AnalysisException if data could not be returned because the source could not be parsed 3489 * @throws AnalysisException if data could not be returned because the source could not be parsed
3127 */ 3490 */
3128 Object internalGetHtmlParseData(Source source, DataDescriptor descriptor, Obje ct defaultValue) { 3491 Object internalGetHtmlParseData(Source source, DataDescriptor descriptor, Obje ct defaultValue) {
3129 HtmlEntry htmlEntry = getReadableHtmlEntry(source); 3492 HtmlEntry htmlEntry = getReadableHtmlEntry(source);
3130 if (htmlEntry == null) { 3493 if (htmlEntry == null) {
3131 return defaultValue; 3494 return defaultValue;
3132 } 3495 }
3496 htmlEntry = internalCacheHtmlParseData(source, htmlEntry, [descriptor]);
3497 return htmlEntry.getValue(descriptor);
3498 }
3499
3500 /**
3501 * Given a source for an HTML file, return the data represented by the given d escriptor that is
3502 * associated with that source, or the given default value if the source is no t an HTML file. This
3503 * method assumes that the data can be produced by resolving the source if it is not already
3504 * cached.
3505 *
3506 * @param source the source representing the HTML file
3507 * @param descriptor the descriptor representing the data to be returned
3508 * @param defaultValue the value to be returned if the source is not an HTML f ile
3509 * @return the requested data about the given source
3510 * @throws AnalysisException if data could not be returned because the source could not be
3511 * resolved
3512 */
3513 Object internalGetHtmlResolutionData(Source source, HtmlEntry htmlEntry, DataD escriptor descriptor, Object defaultValue) {
3514 if (htmlEntry == null) {
3515 return defaultValue;
3516 }
3133 CacheState state = htmlEntry.getState(descriptor); 3517 CacheState state = htmlEntry.getState(descriptor);
3134 while (state != CacheState.ERROR && state != CacheState.VALID) { 3518 while (state != CacheState.ERROR && state != CacheState.VALID) {
3135 htmlEntry = internalParseHtml(source); 3519 htmlEntry = internalResolveHtml(source);
3136 state = htmlEntry.getState(descriptor); 3520 state = htmlEntry.getState(descriptor);
3137 } 3521 }
3138 return htmlEntry.getValue(descriptor); 3522 return htmlEntry.getValue(descriptor);
3139 } 3523 }
3140 CompilationUnit internalParseCompilationUnit(DartEntryImpl dartCopy, Source so urce) { 3524 CompilationUnit internalParseCompilationUnit(DartEntryImpl dartCopy, Source so urce) {
3141 try { 3525 try {
3142 accessed(source); 3526 accessed(source);
3143 RecordingErrorListener errorListener = new RecordingErrorListener(); 3527 RecordingErrorListener errorListener = new RecordingErrorListener();
3144 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorList ener); 3528 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorList ener);
3145 Parser parser = new Parser(source, errorListener); 3529 Parser parser = new Parser(source, errorListener);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
3247 } 3631 }
3248 } else if (directive is PartOfDirective) { 3632 } else if (directive is PartOfDirective) {
3249 hasPartOfDirective = true; 3633 hasPartOfDirective = true;
3250 } 3634 }
3251 } 3635 }
3252 unit.parsingErrors = errors; 3636 unit.parsingErrors = errors;
3253 unit.lineInfo = lineInfo; 3637 unit.lineInfo = lineInfo;
3254 } on AnalysisException catch (exception) { 3638 } on AnalysisException catch (exception) {
3255 thrownException = exception; 3639 thrownException = exception;
3256 } 3640 }
3257 DartEntryImpl dartCopy = null; 3641 DartEntry dartEntry = null;
3258 { 3642 {
3259 SourceEntry sourceEntry = _sourceMap[source]; 3643 SourceEntry sourceEntry = _sourceMap[source];
3260 if (sourceEntry is! DartEntry) { 3644 if (sourceEntry is! DartEntry) {
3261 throw new AnalysisException.con1("Internal error: attempting to parse no n-Dart file as a Dart file: ${source.fullName}"); 3645 throw new AnalysisException.con1("Internal error: attempting to parse no n-Dart file as a Dart file: ${source.fullName}");
3262 } 3646 }
3647 dartEntry = sourceEntry as DartEntry;
3263 accessed(source); 3648 accessed(source);
3264 int resultTime = scanResult == null ? source.modificationStamp : scanResul t.modificationTime; 3649 int sourceTime = source.modificationStamp;
3265 if (sourceEntry.modificationTime == resultTime) { 3650 int resultTime = scanResult == null ? sourceTime : scanResult.modification Time;
3266 dartCopy = ((sourceEntry as DartEntry)).writableCopy; 3651 if (sourceTime == resultTime) {
3652 if (dartEntry.modificationTime != sourceTime) {
3653 sourceChanged(source);
3654 dartEntry = getReadableDartEntry(source);
3655 }
3656 DartEntryImpl dartCopy = dartEntry.writableCopy;
3267 if (thrownException == null) { 3657 if (thrownException == null) {
3268 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); 3658 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo);
3269 if (hasPartOfDirective && !hasLibraryDirective) { 3659 if (hasPartOfDirective && !hasLibraryDirective) {
3270 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); 3660 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART);
3271 } else { 3661 } else {
3272 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); 3662 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
3273 } 3663 }
3274 dartCopy.setValue(DartEntry.PARSED_UNIT, unit); 3664 dartCopy.setValue(DartEntry.PARSED_UNIT, unit);
3275 dartCopy.setValue(DartEntry.PARSE_ERRORS, errors); 3665 dartCopy.setValue(DartEntry.PARSE_ERRORS, errors);
3276 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, toArray(exportedSource s)); 3666 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, toArray(exportedSource s));
3277 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, toArray(importedSource s)); 3667 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, toArray(importedSource s));
3278 dartCopy.setValue(DartEntry.INCLUDED_PARTS, toArray(includedSources)); 3668 dartCopy.setValue(DartEntry.INCLUDED_PARTS, toArray(includedSources));
3279 } else { 3669 } else {
3280 dartCopy.recordParseError(); 3670 dartCopy.recordParseError();
3281 } 3671 }
3282 _sourceMap[source] = dartCopy; 3672 _sourceMap[source] = dartCopy;
3673 dartEntry = dartCopy;
3283 } 3674 }
3284 } 3675 }
3285 if (thrownException != null) { 3676 if (thrownException != null) {
3286 AnalysisEngine.instance.logger.logError2("Could not parse ${source.fullNam e}", thrownException); 3677 if (thrownException.cause is! IOException) {
3678 AnalysisEngine.instance.logger.logError2("Could not parse ${source.fullN ame}", thrownException);
3679 }
3287 throw thrownException; 3680 throw thrownException;
3288 } 3681 }
3289 return dartCopy; 3682 return dartEntry;
3290 } 3683 }
3291 3684
3292 /** 3685 /**
3293 * Scan and parse the given HTML file, updating the cache as appropriate, and return the updated 3686 * Scan and parse the given HTML file, updating the cache as appropriate, and return the updated
3294 * cache entry associated with the source. 3687 * cache entry associated with the source.
3295 * 3688 *
3296 * @param source the source representing the HTML file to be parsed 3689 * @param source the source representing the HTML file to be parsed
3297 * @return the updated cache entry associated with the source 3690 * @return the updated cache entry associated with the source
3298 * @throws AnalysisException if the source does not represent an HTML file or if the file cannot 3691 * @throws AnalysisException if the source does not represent an HTML file or if the file cannot
3299 * be parsed for some reason 3692 * be parsed for some reason
3300 */ 3693 */
3301 HtmlEntry internalParseHtml(Source source) { 3694 HtmlEntry internalParseHtml(Source source) {
3302 HtmlParseResult result = null; 3695 HtmlParseResult result = null;
3303 LineInfo lineInfo = null; 3696 LineInfo lineInfo = null;
3304 AnalysisException thrownException = null; 3697 AnalysisException thrownException = null;
3305 try { 3698 try {
3306 result = new HtmlParser(source).parse(scanHtml(source)); 3699 result = new HtmlParser(source).parse(scanHtml(source));
3307 lineInfo = new LineInfo(result.lineStarts); 3700 lineInfo = new LineInfo(result.lineStarts);
3308 } on AnalysisException catch (exception) { 3701 } on AnalysisException catch (exception) {
3309 thrownException = exception; 3702 thrownException = exception;
3310 } 3703 }
3311 HtmlEntryImpl htmlCopy = null; 3704 HtmlEntry htmlEntry = null;
3312 { 3705 {
3313 SourceEntry sourceEntry = _sourceMap[source]; 3706 SourceEntry sourceEntry = _sourceMap[source];
3314 if (sourceEntry is! HtmlEntry) { 3707 if (sourceEntry is! HtmlEntry) {
3315 throw new AnalysisException.con1("Internal error: attempting to parse no n-HTML file as a HTML file: ${source.fullName}"); 3708 throw new AnalysisException.con1("Internal error: attempting to parse no n-HTML file as a HTML file: ${source.fullName}");
3316 } 3709 }
3710 htmlEntry = sourceEntry as HtmlEntry;
3317 accessed(source); 3711 accessed(source);
3318 int resultTime = result == null ? source.modificationStamp : result.modifi cationTime; 3712 int sourceTime = source.modificationStamp;
3319 if (sourceEntry.modificationTime == resultTime) { 3713 int resultTime = result == null ? sourceTime : result.modificationTime;
3320 htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy; 3714 if (sourceTime == resultTime) {
3715 if (htmlEntry.modificationTime != sourceTime) {
3716 sourceChanged(source);
3717 htmlEntry = getReadableHtmlEntry(source);
3718 }
3719 HtmlEntryImpl htmlCopy = ((sourceEntry as HtmlEntry)).writableCopy;
3321 if (thrownException == null) { 3720 if (thrownException == null) {
3322 HtmlUnit unit = result.htmlUnit; 3721 HtmlUnit unit = result.htmlUnit;
3323 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo); 3722 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo);
3324 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); 3723 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit);
3325 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, getLibrarySources2(s ource, unit)); 3724 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, getLibrarySources2(s ource, unit));
3326 } else { 3725 } else {
3327 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR); 3726 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR);
3328 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR); 3727 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR);
3329 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.ERROR); 3728 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.ERROR);
3330 } 3729 }
3331 _sourceMap[source] = htmlCopy; 3730 _sourceMap[source] = htmlCopy;
3731 htmlEntry = htmlCopy;
3332 } 3732 }
3333 } 3733 }
3334 if (thrownException != null) { 3734 if (thrownException != null) {
3335 AnalysisEngine.instance.logger.logError2("Could not parse ${source.fullNam e}", thrownException); 3735 AnalysisEngine.instance.logger.logError2("Could not parse ${source.fullNam e}", thrownException);
3336 throw thrownException; 3736 throw thrownException;
3337 } 3737 }
3338 ChangeNoticeImpl notice = getNotice(source); 3738 ChangeNoticeImpl notice = getNotice(source);
3339 notice.setErrors(htmlCopy.allErrors, lineInfo); 3739 notice.setErrors(htmlEntry.allErrors, lineInfo);
3340 return htmlCopy; 3740 return htmlEntry;
3741 }
3742 DartEntry internalResolveDart(Source unitSource, Source librarySource) {
3743 DartEntry dartEntry = getReadableDartEntry(unitSource);
3744 if (dartEntry == null) {
3745 throw new AnalysisException.con1("Internal error: attempting to parse non- Dart file as a Dart file: ${unitSource.fullName}");
3746 }
3747 LibraryResolver resolver = null;
3748 AnalysisException thrownException = null;
3749 try {
3750 resolver = new LibraryResolver(this);
3751 resolver.resolveLibrary(librarySource, true);
3752 } on AnalysisException catch (exception) {
3753 thrownException = exception;
3754 }
3755 if (thrownException == null) {
3756 {
3757 accessed(unitSource);
3758 }
3759 recordResolutionResults(resolver);
3760 dartEntry = getReadableDartEntry(unitSource);
3761 } else {
3762 AnalysisEngine.instance.logger.logError2("Could not resolve ${unitSource.f ullName}", thrownException);
3763 bool unitIsLibrary = unitSource == librarySource;
3764 DartEntryImpl dartCopy = dartEntry.writableCopy;
3765 dartCopy.setState2(DartEntry.RESOLUTION_ERRORS, librarySource, CacheState. ERROR);
3766 if (unitIsLibrary) {
3767 dartCopy.setState(DartEntry.ELEMENT, CacheState.ERROR);
3768 }
3769 _sourceMap[unitSource] = dartCopy;
3770 if (!unitIsLibrary) {
3771 DartEntry libraryEntry = getReadableDartEntry(librarySource);
3772 if (libraryEntry != null) {
3773 DartEntryImpl libraryCopy = dartEntry.writableCopy;
3774 libraryCopy.setState2(DartEntry.RESOLUTION_ERRORS, librarySource, Cach eState.ERROR);
3775 libraryCopy.setState(DartEntry.ELEMENT, CacheState.ERROR);
3776 _sourceMap[librarySource] = libraryCopy;
3777 }
3778 }
3779 throw thrownException;
3780 }
3781 ChangeNoticeImpl notice = getNotice(unitSource);
3782 notice.setErrors(dartEntry.allErrors, dartEntry.getValue(SourceEntry.LINE_IN FO));
3783 return dartEntry;
3784 }
3785
3786 /**
3787 * Scan and parse the given HTML file, updating the cache as appropriate, and return the updated
3788 * cache entry associated with the source.
3789 *
3790 * @param source the source representing the HTML file to be parsed
3791 * @return the updated cache entry associated with the source
3792 * @throws AnalysisException if the source does not represent an HTML file or if the file cannot
3793 * be parsed for some reason
3794 */
3795 HtmlEntry internalResolveHtml(Source source) {
3796 HtmlEntry htmlEntry = getReadableHtmlEntry(source);
3797 if (htmlEntry == null) {
3798 throw new AnalysisException.con1("Internal error: attempting to parse non- HTML file as a HTML file: ${source.fullName}");
3799 }
3800 int resultTime = 0;
3801 HtmlElement element = null;
3802 List<AnalysisError> resolutionErrors = null;
3803 AnalysisException thrownException = null;
3804 try {
3805 htmlEntry = internalCacheHtmlParseData(source, htmlEntry, [HtmlEntry.PARSE D_UNIT]);
3806 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT);
3807 if (unit == null) {
3808 throw new AnalysisException.con1("Internal error: internalCacheHtmlParse Data returned an entry without a parsed HTML unit");
3809 }
3810 resultTime = htmlEntry.modificationTime;
3811 HtmlUnitBuilder builder = new HtmlUnitBuilder(this);
3812 element = builder.buildHtmlElement2(source, unit);
3813 resolutionErrors = builder.errorListener.getErrors2(source);
3814 } on AnalysisException catch (exception) {
3815 thrownException = exception;
3816 }
3817 {
3818 SourceEntry sourceEntry = _sourceMap[source];
3819 if (sourceEntry is! HtmlEntry) {
3820 throw new AnalysisException.con1("Internal error: attempting to resolve non-HTML file as a HTML file: ${source.fullName}");
3821 }
3822 htmlEntry = sourceEntry as HtmlEntry;
3823 accessed(source);
3824 int sourceTime = source.modificationStamp;
3825 if (sourceTime == resultTime) {
3826 if (htmlEntry.modificationTime != sourceTime) {
3827 sourceChanged(source);
3828 htmlEntry = getReadableHtmlEntry(source);
3829 }
3830 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
3831 if (thrownException == null) {
3832 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, resolutionErrors);
3833 htmlCopy.setValue(HtmlEntry.ELEMENT, element);
3834 } else {
3835 htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheState.ERROR);
3836 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.ERROR);
3837 }
3838 _sourceMap[source] = htmlCopy;
3839 htmlEntry = htmlCopy;
3840 }
3841 }
3842 if (thrownException != null) {
3843 AnalysisEngine.instance.logger.logError2("Could not resolve ${source.fullN ame}", thrownException);
3844 throw thrownException;
3845 }
3846 ChangeNoticeImpl notice = getNotice(source);
3847 notice.setErrors(htmlEntry.allErrors, htmlEntry.getValue(SourceEntry.LINE_IN FO));
3848 return htmlEntry;
3341 } 3849 }
3342 AnalysisContextImpl_ScanResult internalScan(Source source, AnalysisErrorListen er errorListener) { 3850 AnalysisContextImpl_ScanResult internalScan(Source source, AnalysisErrorListen er errorListener) {
3343 AnalysisContextImpl_ScanResult result = new AnalysisContextImpl_ScanResult() ; 3851 AnalysisContextImpl_ScanResult result = new AnalysisContextImpl_ScanResult() ;
3344 Source_ContentReceiver receiver = new Source_ContentReceiver_7(source, error Listener, result); 3852 Source_ContentReceiver receiver = new Source_ContentReceiver_7(source, error Listener, result);
3345 try { 3853 try {
3346 source.getContents(receiver); 3854 source.getContents(receiver);
3347 } catch (exception) { 3855 } catch (exception) {
3348 throw new AnalysisException.con3(exception); 3856 throw new AnalysisException.con3(exception);
3349 } 3857 }
3350 return result; 3858 return result;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
3418 } 3926 }
3419 for (LibraryElement exported in library.exportedLibraries) { 3927 for (LibraryElement exported in library.exportedLibraries) {
3420 if (isClient(exported, htmlSource, visitedLibraries)) { 3928 if (isClient(exported, htmlSource, visitedLibraries)) {
3421 return true; 3929 return true;
3422 } 3930 }
3423 } 3931 }
3424 return false; 3932 return false;
3425 } 3933 }
3426 3934
3427 /** 3935 /**
3936 * Return `true` if the given source is in the array of priority sources.
3937 *
3938 * Note: This method must only be invoked while we are synchronized on [cacheL ock].
3939 */
3940 bool isPrioritySource(Source source) {
3941 for (Source prioritySource in _priorityOrder) {
3942 if (source == prioritySource) {
3943 return true;
3944 }
3945 }
3946 return false;
3947 }
3948
3949 /**
3428 * Perform a single analysis task. 3950 * Perform a single analysis task.
3429 * 3951 *
3430 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 3952 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
3431 * 3953 *
3432 * @return `true` if work was done, implying that there might be more work to be done 3954 * @return `true` if work was done, implying that there might be more work to be done
3433 */ 3955 */
3434 bool performSingleAnalysisTask() { 3956 bool performSingleAnalysisTask() {
3435 for (Source source in _priorityOrder) { 3957 for (Source source in _priorityOrder) {
3436 SourceEntry sourceEntry = _sourceMap[source]; 3958 SourceEntry sourceEntry = _sourceMap[source];
3437 if (sourceEntry is DartEntry) { 3959 if (sourceEntry is DartEntry) {
3438 DartEntry dartEntry = sourceEntry as DartEntry; 3960 DartEntry dartEntry = sourceEntry as DartEntry;
3439 if (identical(dartEntry.getState(DartEntry.PARSED_UNIT), CacheState.INVA LID)) { 3961 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT);
3962 if (identical(parsedUnitState, CacheState.INVALID) || identical(parsedUn itState, CacheState.FLUSHED)) {
3440 safelyParseCompilationUnit(source, dartEntry); 3963 safelyParseCompilationUnit(source, dartEntry);
3441 return true; 3964 return true;
3442 } else if (identical(dartEntry.getState(DartEntry.RESOLVED_UNIT), CacheS tate.INVALID)) { 3965 }
3443 safelyResolveCompilationUnit(source); 3966 for (Source librarySource in getLibrariesContaining(source)) {
3444 return true; 3967 SourceEntry libraryEntry = _sourceMap[librarySource];
3968 if (libraryEntry is DartEntry) {
3969 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT);
3970 if (identical(elementState, CacheState.INVALID) || identical(element State, CacheState.FLUSHED)) {
3971 safelyResolveCompilationUnit(librarySource);
3972 return true;
3973 }
3974 }
3975 if (identical(dartEntry.getState2(DartEntry.RESOLVED_UNIT, librarySour ce), CacheState.FLUSHED)) {
3976 safelyResolveCompilationUnit2(source, librarySource);
3977 return true;
3978 }
3445 } 3979 }
3446 } else if (sourceEntry is HtmlEntry) { 3980 } else if (sourceEntry is HtmlEntry) {
3447 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; 3981 HtmlEntry htmlEntry = sourceEntry as HtmlEntry;
3448 if (identical(htmlEntry.getState(HtmlEntry.PARSED_UNIT), CacheState.INVA LID)) { 3982 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT);
3983 if (identical(parsedUnitState, CacheState.INVALID) || identical(parsedUn itState, CacheState.FLUSHED)) {
3449 safelyParseHtmlUnit(source); 3984 safelyParseHtmlUnit(source);
3450 return true; 3985 return true;
3451 } else if (identical(htmlEntry.getState(HtmlEntry.ELEMENT), CacheState.I NVALID)) { 3986 }
3987 CacheState elementState = htmlEntry.getState(HtmlEntry.ELEMENT);
3988 if (identical(elementState, CacheState.INVALID) || identical(elementStat e, CacheState.FLUSHED)) {
3452 safelyResolveHtmlUnit(source); 3989 safelyResolveHtmlUnit(source);
3453 return true; 3990 return true;
3454 } 3991 }
3455 } 3992 }
3456 } 3993 }
3457 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { 3994 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) {
3458 SourceEntry sourceEntry = entry.getValue(); 3995 SourceEntry sourceEntry = entry.getValue();
3459 if (sourceEntry is DartEntry) { 3996 if (sourceEntry is DartEntry) {
3460 DartEntry dartEntry = sourceEntry as DartEntry; 3997 DartEntry dartEntry = sourceEntry as DartEntry;
3461 if (identical(dartEntry.getState(DartEntry.PARSED_UNIT), CacheState.INVA LID)) { 3998 if (identical(dartEntry.getState(DartEntry.PARSED_UNIT), CacheState.INVA LID)) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
3522 for (Library library in resolver.resolvedLibraries) { 4059 for (Library library in resolver.resolvedLibraries) {
3523 Source librarySource = library.librarySource; 4060 Source librarySource = library.librarySource;
3524 for (Source source in library.compilationUnitSources) { 4061 for (Source source in library.compilationUnitSources) {
3525 CompilationUnit unit = library.getAST(source); 4062 CompilationUnit unit = library.getAST(source);
3526 List<AnalysisError> errors = errorListener.getErrors2(source); 4063 List<AnalysisError> errors = errorListener.getErrors2(source);
3527 unit.resolutionErrors = errors; 4064 unit.resolutionErrors = errors;
3528 LineInfo lineInfo = unit.lineInfo; 4065 LineInfo lineInfo = unit.lineInfo;
3529 { 4066 {
3530 DartEntry dartEntry = getDartEntry(source); 4067 DartEntry dartEntry = getDartEntry(source);
3531 if (dartEntry != null) { 4068 if (dartEntry != null) {
3532 DartEntryImpl dartCopy = dartEntry.writableCopy; 4069 int sourceTime = source.modificationStamp;
3533 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); 4070 int resultTime = dartEntry.modificationTime;
3534 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); 4071 if (sourceTime == resultTime) {
3535 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, unit); 4072 DartEntryImpl dartCopy = dartEntry.writableCopy;
3536 dartCopy.setValue2(DartEntry.RESOLUTION_ERRORS, librarySource, error s); 4073 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo);
3537 if (identical(source, librarySource)) { 4074 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
3538 recordElementData(dartCopy, library.libraryElement, htmlSource); 4075 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, unit);
4076 dartCopy.setValue2(DartEntry.RESOLUTION_ERRORS, librarySource, err ors);
4077 if (identical(source, librarySource)) {
4078 recordElementData(dartCopy, library.libraryElement, htmlSource);
4079 }
4080 _sourceMap[source] = dartCopy;
4081 ChangeNoticeImpl notice = getNotice(source);
4082 notice.compilationUnit = unit;
4083 notice.setErrors(dartCopy.allErrors, lineInfo);
4084 } else {
4085 sourceChanged(source);
3539 } 4086 }
3540 _sourceMap[source] = dartCopy;
3541 ChangeNoticeImpl notice = getNotice(source);
3542 notice.compilationUnit = unit;
3543 notice.setErrors(dartCopy.allErrors, lineInfo);
3544 } 4087 }
3545 } 4088 }
3546 } 4089 }
3547 } 4090 }
3548 } 4091 }
3549 4092
3550 /** 4093 /**
4094 * Remove and return one source from the list of recently used sources whose A ST structure can be
4095 * flushed from the cache. The source that will be returned will be the source that has been
4096 * unreferenced for the longest period of time but that is not a priority for analysis.
4097 *
4098 * @return the source that was removed
4099 *
4100 * Note: This method must only be invoked while we are synchronized on [cacheLock].
4101 */
4102 Source removeAstToFlush() {
4103 for (int i = 0; i < _recentlyUsed.length; i++) {
4104 Source source = _recentlyUsed[i];
4105 if (!isPrioritySource(source)) {
4106 return _recentlyUsed.removeAt(i);
4107 }
4108 }
4109 AnalysisEngine.instance.logger.logError2("Internal error: The number of prio rity sources is greater than the maximum cache size", new JavaException());
4110 return _recentlyUsed.removeAt(0);
4111 }
4112
4113 /**
3551 * Return the result of resolving the URI of the given URI-based directive aga inst the URI of the 4114 * Return the result of resolving the URI of the given URI-based directive aga inst the URI of the
3552 * given library, or `null` if the URI is not valid. 4115 * given library, or `null` if the URI is not valid.
3553 * 4116 *
3554 * @param librarySource the source representing the library containing the dir ective 4117 * @param librarySource the source representing the library containing the dir ective
3555 * @param directive the directive which URI should be resolved 4118 * @param directive the directive which URI should be resolved
3556 * @return the result of resolving the URI against the URI of the library 4119 * @return the result of resolving the URI against the URI of the library
3557 */ 4120 */
3558 Source resolveSource(Source librarySource, UriBasedDirective directive) { 4121 Source resolveSource(Source librarySource, UriBasedDirective directive) {
3559 StringLiteral uriLiteral = directive.uri; 4122 StringLiteral uriLiteral = directive.uri;
3560 if (uriLiteral is StringInterpolation) { 4123 if (uriLiteral is StringInterpolation) {
3561 return null; 4124 return null;
3562 } 4125 }
3563 String uriContent = uriLiteral.stringValue.trim(); 4126 String uriContent = uriLiteral.stringValue.trim();
3564 if (uriContent == null) { 4127 if (uriContent == null) {
3565 return null; 4128 return null;
3566 } 4129 }
4130 uriContent = Uri.encodeFull(uriContent);
3567 try { 4131 try {
3568 parseUriWithException(uriContent); 4132 parseUriWithException(uriContent);
3569 return _sourceFactory.resolveUri(librarySource, uriContent); 4133 return _sourceFactory.resolveUri(librarySource, uriContent);
3570 } on URISyntaxException catch (exception) { 4134 } on URISyntaxException catch (exception) {
3571 return null; 4135 return null;
3572 } 4136 }
3573 } 4137 }
3574 4138
3575 /** 4139 /**
3576 * Parse the given source and update the cache. 4140 * Parse the given source and update the cache.
3577 * 4141 *
3578 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4142 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
3579 * 4143 *
3580 * @param source the source to be parsed 4144 * @param source the source to be parsed
3581 * @param dartEntry the cache entry associated with the source 4145 * @param dartEntry the cache entry associated with the source
3582 */ 4146 */
3583 void safelyParseCompilationUnit(Source source, DartEntry dartEntry) { 4147 void safelyParseCompilationUnit(Source source, DartEntry dartEntry) {
3584 DartEntryImpl dartCopy = dartEntry.writableCopy; 4148 DartEntryImpl dartCopy = dartEntry.writableCopy;
3585 try { 4149 try {
3586 internalParseCompilationUnit(dartCopy, source); 4150 internalParseCompilationUnit(dartCopy, source);
3587 } on AnalysisException catch (exception) { 4151 } on AnalysisException catch (exception) {
3588 AnalysisEngine.instance.logger.logError2("Could not parse ${source.fullNam e}", exception); 4152 if (exception.cause is! IOException) {
4153 AnalysisEngine.instance.logger.logError2("Could not parse ${source.fullN ame}", exception);
4154 }
3589 } 4155 }
3590 _sourceMap[source] = dartCopy; 4156 _sourceMap[source] = dartCopy;
3591 } 4157 }
3592 4158
3593 /** 4159 /**
3594 * Parse the given source and update the cache. 4160 * Parse the given source and update the cache.
3595 * 4161 *
3596 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4162 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
3597 * 4163 *
3598 * @param source the source to be parsed 4164 * @param source the source to be parsed
(...skipping 14 matching lines...) Expand all
3613 * @param source the source to be resolved 4179 * @param source the source to be resolved
3614 */ 4180 */
3615 void safelyResolveCompilationUnit(Source source) { 4181 void safelyResolveCompilationUnit(Source source) {
3616 try { 4182 try {
3617 computeLibraryElement(source); 4183 computeLibraryElement(source);
3618 } on AnalysisException catch (exception) { 4184 } on AnalysisException catch (exception) {
3619 } 4185 }
3620 } 4186 }
3621 4187
3622 /** 4188 /**
4189 * Resolve the given source within the given library and update the cache.
4190 *
4191 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
4192 *
4193 * @param unitSource the source to be resolved
4194 * @param librarySource the source
4195 */
4196 void safelyResolveCompilationUnit2(Source unitSource, Source librarySource) {
4197 try {
4198 resolveCompilationUnit2(unitSource, librarySource);
4199 } on AnalysisException catch (exception) {
4200 DartEntryImpl dartCopy = getReadableDartEntry(unitSource).writableCopy;
4201 dartCopy.recordResolutionError();
4202 _sourceMap[unitSource] = dartCopy;
4203 AnalysisEngine.instance.logger.logError2("Could not resolve ${unitSource.f ullName} in ${librarySource.fullName}", exception);
4204 }
4205 }
4206
4207 /**
3623 * Resolve the given source and update the cache. 4208 * Resolve the given source and update the cache.
3624 * 4209 *
3625 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4210 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
3626 * 4211 *
3627 * @param source the source to be resolved 4212 * @param source the source to be resolved
3628 */ 4213 */
3629 void safelyResolveHtmlUnit(Source source) { 4214 void safelyResolveHtmlUnit(Source source) {
3630 try { 4215 try {
3631 computeHtmlElement(source); 4216 computeHtmlElement(source);
3632 } on AnalysisException catch (exception) { 4217 } on AnalysisException catch (exception) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
3726 */ 4311 */
3727 List<Source> toArray(Set<Source> sources) { 4312 List<Source> toArray(Set<Source> sources) {
3728 int size = sources.length; 4313 int size = sources.length;
3729 if (size == 0) { 4314 if (size == 0) {
3730 return Source.EMPTY_ARRAY; 4315 return Source.EMPTY_ARRAY;
3731 } 4316 }
3732 return new List.from(sources); 4317 return new List.from(sources);
3733 } 4318 }
3734 } 4319 }
3735 /** 4320 /**
4321 * The interface `AnalysisTask` defines the behavior of objects used to perform an analysis
4322 * task.
4323 */
4324 abstract class AnalysisContextImpl_AnalysisTask {
4325
4326 /**
4327 * Perform a single analysis task. Implementors should assume that the cache i s not locked.
4328 */
4329 void perform();
4330 }
4331 /**
4332 * Instances of the class `ParseDartTask` parse a specific source as a Dart file .
4333 */
4334 class AnalysisContextImpl_ParseDartTask implements AnalysisContextImpl_AnalysisT ask {
4335 final AnalysisContextImpl AnalysisContextImpl_this;
4336
4337 /**
4338 * The source to be parsed.
4339 */
4340 Source _source;
4341
4342 /**
4343 * Initialize a newly created task to parse the given source as a Dart file.
4344 *
4345 * @param source the source to be resolved
4346 */
4347 AnalysisContextImpl_ParseDartTask(this.AnalysisContextImpl_this, Source source ) {
4348 this._source = source;
4349 }
4350 void perform() {
4351 try {
4352 AnalysisContextImpl_this.internalParseDart(_source);
4353 } on AnalysisException catch (exception) {
4354 AnalysisEngine.instance.logger.logError2("Could not parse ${_source.fullNa me}", exception);
4355 }
4356 }
4357 }
4358 /**
4359 * Instances of the class `ParseHtmlTask` parse a specific source as an HTML fil e.
4360 */
4361 class AnalysisContextImpl_ParseHtmlTask implements AnalysisContextImpl_AnalysisT ask {
4362 final AnalysisContextImpl AnalysisContextImpl_this;
4363
4364 /**
4365 * The source to be parsed.
4366 */
4367 Source _source;
4368
4369 /**
4370 * Initialize a newly created task to parse the given source as an HTML file.
4371 *
4372 * @param source the source to be resolved
4373 */
4374 AnalysisContextImpl_ParseHtmlTask(this.AnalysisContextImpl_this, Source source ) {
4375 this._source = source;
4376 }
4377 void perform() {
4378 try {
4379 AnalysisContextImpl_this.internalParseHtml(_source);
4380 } on AnalysisException catch (exception) {
4381 AnalysisEngine.instance.logger.logError2("Could not parse ${_source.fullNa me}", exception);
4382 }
4383 }
4384 }
4385 /**
4386 * Instances of the class `ResolveDartLibraryTask` resolve a specific source as a Dart
4387 * library.
4388 */
4389 class AnalysisContextImpl_ResolveDartLibraryTask implements AnalysisContextImpl_ AnalysisTask {
4390 final AnalysisContextImpl AnalysisContextImpl_this;
4391
4392 /**
4393 * The source to be resolved.
4394 */
4395 Source _source;
4396
4397 /**
4398 * Initialize a newly created task to resolve the given source as a Dart file.
4399 *
4400 * @param source the source to be resolved
4401 */
4402 AnalysisContextImpl_ResolveDartLibraryTask(this.AnalysisContextImpl_this, Sour ce source) {
4403 this._source = source;
4404 }
4405 void perform() {
4406 try {
4407 AnalysisContextImpl_this.computeLibraryElement(_source);
4408 } on AnalysisException catch (exception) {
4409 AnalysisEngine.instance.logger.logError2("Could not resolve ${_source.full Name}", exception);
4410 }
4411 }
4412 }
4413 /**
4414 * Instances of the class `ResolveDartUnitTask` resolve a specific source as a D art file
4415 * within a library.
4416 */
4417 class AnalysisContextImpl_ResolveDartUnitTask implements AnalysisContextImpl_Ana lysisTask {
4418 final AnalysisContextImpl AnalysisContextImpl_this;
4419
4420 /**
4421 * The source to be resolved.
4422 */
4423 Source _unitSource;
4424
4425 /**
4426 * The source of the library in which the source is to be resolved.
4427 */
4428 Source _librarySource;
4429
4430 /**
4431 * Initialize a newly created task to resolve the given source as a Dart file.
4432 *
4433 * @param unitSource the source to be resolved
4434 * @param librarySource the source of the library in which the source is to be resolved
4435 */
4436 AnalysisContextImpl_ResolveDartUnitTask(this.AnalysisContextImpl_this, Source unitSource, Source librarySource) {
4437 this._unitSource = unitSource;
4438 this._librarySource = librarySource;
4439 }
4440 void perform() {
4441 try {
4442 AnalysisContextImpl_this.resolveCompilationUnit2(_unitSource, _librarySour ce);
4443 } on AnalysisException catch (exception) {
4444 DartEntryImpl dartCopy = AnalysisContextImpl_this.getReadableDartEntry(_un itSource).writableCopy;
4445 dartCopy.recordResolutionError();
4446 AnalysisContextImpl_this._sourceMap[_unitSource] = dartCopy;
4447 AnalysisEngine.instance.logger.logError2("Could not resolve ${_unitSource. fullName} in ${_librarySource.fullName}", exception);
4448 }
4449 }
4450 }
4451 /**
4452 * Instances of the class `ResolveHtmlTask` resolve a specific source as an HTML file.
4453 */
4454 class AnalysisContextImpl_ResolveHtmlTask implements AnalysisContextImpl_Analysi sTask {
4455 final AnalysisContextImpl AnalysisContextImpl_this;
4456
4457 /**
4458 * The source to be resolved.
4459 */
4460 Source _source;
4461
4462 /**
4463 * Initialize a newly created task to resolve the given source as an HTML file .
4464 *
4465 * @param source the source to be resolved
4466 */
4467 AnalysisContextImpl_ResolveHtmlTask(this.AnalysisContextImpl_this, Source sour ce) {
4468 this._source = source;
4469 }
4470 void perform() {
4471 try {
4472 AnalysisContextImpl_this.computeHtmlElement(_source);
4473 } on AnalysisException catch (exception) {
4474 AnalysisEngine.instance.logger.logError2("Could not resolve ${_source.full Name}", exception);
4475 }
4476 }
4477 }
4478 /**
3736 * Instances of the class `ScanResult` represent the results of scanning a sourc e. 4479 * Instances of the class `ScanResult` represent the results of scanning a sourc e.
3737 */ 4480 */
3738 class AnalysisContextImpl_ScanResult { 4481 class AnalysisContextImpl_ScanResult {
3739 4482
3740 /** 4483 /**
3741 * The time at which the contents of the source were last modified. 4484 * The time at which the contents of the source were last modified.
3742 */ 4485 */
3743 int _modificationTime = 0; 4486 int _modificationTime = 0;
3744 4487
3745 /** 4488 /**
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3779 } 4522 }
3780 if (isDartScript && scriptAttribute != null) { 4523 if (isDartScript && scriptAttribute != null) {
3781 try { 4524 try {
3782 Uri uri = new Uri(path: scriptAttribute.text); 4525 Uri uri = new Uri(path: scriptAttribute.text);
3783 String fileName = uri.path; 4526 String fileName = uri.path;
3784 Source librarySource = AnalysisContextImpl_this._sourceFactory.resolve Uri(htmlSource, fileName); 4527 Source librarySource = AnalysisContextImpl_this._sourceFactory.resolve Uri(htmlSource, fileName);
3785 if (librarySource.exists()) { 4528 if (librarySource.exists()) {
3786 libraries.add(librarySource); 4529 libraries.add(librarySource);
3787 } 4530 }
3788 } catch (exception) { 4531 } catch (exception) {
3789 AnalysisEngine.instance.logger.logError2("Invalid URL ('${scriptAttrib ute.text}') in script tag in '${htmlSource.fullName}'", exception); 4532 AnalysisEngine.instance.logger.logInformation2("Invalid URL ('${script Attribute.text}') in script tag in '${htmlSource.fullName}'", exception);
3790 } 4533 }
3791 } 4534 }
3792 } 4535 }
3793 return super.visitXmlTagNode(node); 4536 return super.visitXmlTagNode(node);
3794 } 4537 }
3795 } 4538 }
3796 class Source_ContentReceiver_7 implements Source_ContentReceiver { 4539 class Source_ContentReceiver_7 implements Source_ContentReceiver {
3797 Source source; 4540 Source source;
3798 AnalysisErrorListener errorListener; 4541 AnalysisErrorListener errorListener;
3799 AnalysisContextImpl_ScanResult result; 4542 AnalysisContextImpl_ScanResult result;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
3896 * 4639 *
3897 * @param isStrict `true` if analysis is to use strict mode 4640 * @param isStrict `true` if analysis is to use strict mode
3898 */ 4641 */
3899 void set strictMode(bool isStrict) { 4642 void set strictMode(bool isStrict) {
3900 _strictMode = isStrict; 4643 _strictMode = isStrict;
3901 } 4644 }
3902 } 4645 }
3903 /** 4646 /**
3904 * The enumeration `CacheState` defines the possible states of cached data. 4647 * The enumeration `CacheState` defines the possible states of cached data.
3905 */ 4648 */
3906 class CacheState implements Comparable<CacheState> { 4649 class CacheState implements Enum<CacheState> {
3907 4650
3908 /** 4651 /**
3909 * The data is not in the cache and the last time an attempt was made to compu te the data an 4652 * The data is not in the cache and the last time an attempt was made to compu te the data an
3910 * exception occurred, making it pointless to attempt. 4653 * exception occurred, making it pointless to attempt.
3911 * 4654 *
3912 * Valid Transitions: 4655 * Valid Transitions:
3913 * 4656 *
3914 * * [INVALID] if a source was modified that might cause the data to be comput able 4657 * * [INVALID] if a source was modified that might cause the data to be comput able
3915 * 4658 *
3916 */ 4659 */
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
4575 List<Source> getLibrariesContaining(Source source) { 5318 List<Source> getLibrariesContaining(Source source) {
4576 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLibrariesContaining"); 5319 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLibrariesContaining");
4577 try { 5320 try {
4578 instrumentation.metric3("contextId", _contextId); 5321 instrumentation.metric3("contextId", _contextId);
4579 List<Source> ret = _basis.getLibrariesContaining(source); 5322 List<Source> ret = _basis.getLibrariesContaining(source);
4580 if (ret != null) { 5323 if (ret != null) {
4581 instrumentation.metric2("Source-count", ret.length); 5324 instrumentation.metric2("Source-count", ret.length);
4582 } 5325 }
4583 return ret; 5326 return ret;
4584 } finally { 5327 } finally {
4585 instrumentation.log(); 5328 instrumentation.log2(2);
4586 } 5329 }
4587 } 5330 }
4588 List<Source> getLibrariesDependingOn(Source librarySource) { 5331 List<Source> getLibrariesDependingOn(Source librarySource) {
4589 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLibrariesDependingOn"); 5332 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getLibrariesDependingOn");
4590 try { 5333 try {
4591 instrumentation.metric3("contextId", _contextId); 5334 instrumentation.metric3("contextId", _contextId);
4592 List<Source> ret = _basis.getLibrariesDependingOn(librarySource); 5335 List<Source> ret = _basis.getLibrariesDependingOn(librarySource);
4593 if (ret != null) { 5336 if (ret != null) {
4594 instrumentation.metric2("Source-count", ret.length); 5337 instrumentation.metric2("Source-count", ret.length);
4595 } 5338 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
4639 } finally { 5382 } finally {
4640 instrumentation.log(); 5383 instrumentation.log();
4641 } 5384 }
4642 } 5385 }
4643 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS ource) { 5386 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS ource) {
4644 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getResolvedCompilationUnit"); 5387 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getResolvedCompilationUnit");
4645 try { 5388 try {
4646 instrumentation.metric3("contextId", _contextId); 5389 instrumentation.metric3("contextId", _contextId);
4647 return _basis.getResolvedCompilationUnit2(unitSource, librarySource); 5390 return _basis.getResolvedCompilationUnit2(unitSource, librarySource);
4648 } finally { 5391 } finally {
4649 instrumentation.log(); 5392 instrumentation.log2(2);
4650 } 5393 }
4651 } 5394 }
4652 SourceFactory get sourceFactory { 5395 SourceFactory get sourceFactory {
4653 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getSourceFactory"); 5396 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- getSourceFactory");
4654 try { 5397 try {
4655 instrumentation.metric3("contextId", _contextId); 5398 instrumentation.metric3("contextId", _contextId);
4656 return _basis.sourceFactory; 5399 return _basis.sourceFactory;
4657 } finally { 5400 } finally {
4658 instrumentation.log(); 5401 instrumentation.log2(2);
4659 } 5402 }
4660 } 5403 }
5404 AnalysisContentStatistics get statistics => _basis.statistics;
4661 bool isClientLibrary(Source librarySource) { 5405 bool isClientLibrary(Source librarySource) {
4662 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- isClientLibrary"); 5406 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- isClientLibrary");
4663 try { 5407 try {
4664 instrumentation.metric3("contextId", _contextId); 5408 instrumentation.metric3("contextId", _contextId);
4665 return _basis.isClientLibrary(librarySource); 5409 return _basis.isClientLibrary(librarySource);
4666 } finally { 5410 } finally {
4667 instrumentation.log(); 5411 instrumentation.log();
4668 } 5412 }
4669 } 5413 }
4670 bool isServerLibrary(Source librarySource) { 5414 bool isServerLibrary(Source librarySource) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4715 List<ChangeNotice> performAnalysisTask() { 5459 List<ChangeNotice> performAnalysisTask() {
4716 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- performAnalysisTask"); 5460 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- performAnalysisTask");
4717 try { 5461 try {
4718 instrumentation.metric3("contextId", _contextId); 5462 instrumentation.metric3("contextId", _contextId);
4719 List<ChangeNotice> ret = _basis.performAnalysisTask(); 5463 List<ChangeNotice> ret = _basis.performAnalysisTask();
4720 if (ret != null) { 5464 if (ret != null) {
4721 instrumentation.metric2("ChangeNotice-count", ret.length); 5465 instrumentation.metric2("ChangeNotice-count", ret.length);
4722 } 5466 }
4723 return ret; 5467 return ret;
4724 } finally { 5468 } finally {
4725 instrumentation.log(); 5469 instrumentation.log2(2);
4726 } 5470 }
4727 } 5471 }
4728 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { 5472 void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
4729 _basis.recordLibraryElements(elementMap); 5473 _basis.recordLibraryElements(elementMap);
4730 } 5474 }
4731 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra ry) { 5475 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra ry) {
4732 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- resolveCompilationUnit"); 5476 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- resolveCompilationUnit");
4733 try { 5477 try {
4734 instrumentation.metric3("contextId", _contextId); 5478 instrumentation.metric3("contextId", _contextId);
4735 return _basis.resolveCompilationUnit(unitSource, library); 5479 return _basis.resolveCompilationUnit(unitSource, library);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
4881 * Return a namespace containing mappings for all of the public names defined by the library 5625 * Return a namespace containing mappings for all of the public names defined by the library
4882 * defined by the given source. 5626 * defined by the given source.
4883 * 5627 *
4884 * @param source the source defining the library whose public namespace is to be returned 5628 * @param source the source defining the library whose public namespace is to be returned
4885 * @return the public namespace corresponding to the library defined by the gi ven source 5629 * @return the public namespace corresponding to the library defined by the gi ven source
4886 * @throws AnalysisException if the public namespace could not be computed 5630 * @throws AnalysisException if the public namespace could not be computed
4887 */ 5631 */
4888 Namespace getPublicNamespace2(Source source); 5632 Namespace getPublicNamespace2(Source source);
4889 5633
4890 /** 5634 /**
5635 * Returns a statistics about this context.
5636 */
5637 AnalysisContentStatistics get statistics;
5638
5639 /**
4891 * Given a table mapping the source for the libraries represented by the corre sponding elements to 5640 * Given a table mapping the source for the libraries represented by the corre sponding elements to
4892 * the elements representing the libraries, record those mappings. 5641 * the elements representing the libraries, record those mappings.
4893 * 5642 *
4894 * @param elementMap a table mapping the source for the libraries represented by the elements to 5643 * @param elementMap a table mapping the source for the libraries represented by the elements to
4895 * the elements representing the libraries 5644 * the elements representing the libraries
4896 */ 5645 */
4897 void recordLibraryElements(Map<Source, LibraryElement> elementMap); 5646 void recordLibraryElements(Map<Source, LibraryElement> elementMap);
4898 } 5647 }
4899 /** 5648 /**
4900 * Instances of the class `RecordingErrorListener` implement an error listener t hat will 5649 * Instances of the class `RecordingErrorListener` implement an error listener t hat will
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
4964 errorsForSource.add(event); 5713 errorsForSource.add(event);
4965 } 5714 }
4966 } 5715 }
4967 /** 5716 /**
4968 * Instances of the class `ResolutionEraser` remove any resolution information f rom an AST 5717 * Instances of the class `ResolutionEraser` remove any resolution information f rom an AST
4969 * structure when used to visit that structure. 5718 * structure when used to visit that structure.
4970 */ 5719 */
4971 class ResolutionEraser extends GeneralizingASTVisitor<Object> { 5720 class ResolutionEraser extends GeneralizingASTVisitor<Object> {
4972 Object visitAssignmentExpression(AssignmentExpression node) { 5721 Object visitAssignmentExpression(AssignmentExpression node) {
4973 node.staticElement = null; 5722 node.staticElement = null;
4974 node.element = null; 5723 node.propagatedElement = null;
4975 return super.visitAssignmentExpression(node); 5724 return super.visitAssignmentExpression(node);
4976 } 5725 }
4977 Object visitBinaryExpression(BinaryExpression node) { 5726 Object visitBinaryExpression(BinaryExpression node) {
4978 node.staticElement = null; 5727 node.staticElement = null;
4979 node.element = null; 5728 node.propagatedElement = null;
4980 return super.visitBinaryExpression(node); 5729 return super.visitBinaryExpression(node);
4981 } 5730 }
4982 Object visitCompilationUnit(CompilationUnit node) { 5731 Object visitCompilationUnit(CompilationUnit node) {
4983 node.element = null; 5732 node.element = null;
4984 return super.visitCompilationUnit(node); 5733 return super.visitCompilationUnit(node);
4985 } 5734 }
4986 Object visitConstructorDeclaration(ConstructorDeclaration node) { 5735 Object visitConstructorDeclaration(ConstructorDeclaration node) {
4987 node.element = null; 5736 node.element = null;
4988 return super.visitConstructorDeclaration(node); 5737 return super.visitConstructorDeclaration(node);
4989 } 5738 }
(...skipping 10 matching lines...) Expand all
5000 node.staticType = null; 5749 node.staticType = null;
5001 node.propagatedType = null; 5750 node.propagatedType = null;
5002 return super.visitExpression(node); 5751 return super.visitExpression(node);
5003 } 5752 }
5004 Object visitFunctionExpression(FunctionExpression node) { 5753 Object visitFunctionExpression(FunctionExpression node) {
5005 node.element = null; 5754 node.element = null;
5006 return super.visitFunctionExpression(node); 5755 return super.visitFunctionExpression(node);
5007 } 5756 }
5008 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) { 5757 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
5009 node.staticElement = null; 5758 node.staticElement = null;
5010 node.element = null; 5759 node.propagatedElement = null;
5011 return super.visitFunctionExpressionInvocation(node); 5760 return super.visitFunctionExpressionInvocation(node);
5012 } 5761 }
5013 Object visitIndexExpression(IndexExpression node) { 5762 Object visitIndexExpression(IndexExpression node) {
5014 node.staticElement = null; 5763 node.staticElement = null;
5015 node.element = null; 5764 node.propagatedElement = null;
5016 return super.visitIndexExpression(node); 5765 return super.visitIndexExpression(node);
5017 } 5766 }
5018 Object visitInstanceCreationExpression(InstanceCreationExpression node) { 5767 Object visitInstanceCreationExpression(InstanceCreationExpression node) {
5019 node.staticElement = null; 5768 node.staticElement = null;
5020 node.element = null; 5769 node.element = null;
5021 return super.visitInstanceCreationExpression(node); 5770 return super.visitInstanceCreationExpression(node);
5022 } 5771 }
5023 Object visitPostfixExpression(PostfixExpression node) { 5772 Object visitPostfixExpression(PostfixExpression node) {
5024 node.staticElement = null; 5773 node.staticElement = null;
5025 node.element = null; 5774 node.propagatedElement = null;
5026 return super.visitPostfixExpression(node); 5775 return super.visitPostfixExpression(node);
5027 } 5776 }
5028 Object visitPrefixExpression(PrefixExpression node) { 5777 Object visitPrefixExpression(PrefixExpression node) {
5029 node.staticElement = null; 5778 node.staticElement = null;
5030 node.element = null; 5779 node.propagatedElement = null;
5031 return super.visitPrefixExpression(node); 5780 return super.visitPrefixExpression(node);
5032 } 5781 }
5033 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) { 5782 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) {
5034 node.staticElement = null; 5783 node.staticElement = null;
5035 node.element = null; 5784 node.element = null;
5036 return super.visitRedirectingConstructorInvocation(node); 5785 return super.visitRedirectingConstructorInvocation(node);
5037 } 5786 }
5038 Object visitSimpleIdentifier(SimpleIdentifier node) { 5787 Object visitSimpleIdentifier(SimpleIdentifier node) {
5039 node.staticElement = null; 5788 node.staticElement = null;
5040 node.element = null; 5789 node.element = null;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
5103 } 5852 }
5104 void logError2(String message, Exception exception) { 5853 void logError2(String message, Exception exception) {
5105 } 5854 }
5106 void logError3(Exception exception) { 5855 void logError3(Exception exception) {
5107 } 5856 }
5108 void logInformation(String message) { 5857 void logInformation(String message) {
5109 } 5858 }
5110 void logInformation2(String message, Exception exception) { 5859 void logInformation2(String message, Exception exception) {
5111 } 5860 }
5112 } 5861 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698