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

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

Issue 685863003: Make table entries on analysis server's '/status' page clickable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine; 8 library engine;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 841
842 /** 842 /**
843 * Set the source factory used to create the sources that can be analyzed in t his context to the 843 * Set the source factory used to create the sources that can be analyzed in t his context to the
844 * given source factory. Clients can safely assume that all analysis results h ave been 844 * given source factory. Clients can safely assume that all analysis results h ave been
845 * invalidated. 845 * invalidated.
846 * 846 *
847 * @param factory the source factory used to create the sources that can be an alyzed in this 847 * @param factory the source factory used to create the sources that can be an alyzed in this
848 * context 848 * context
849 */ 849 */
850 void set sourceFactory(SourceFactory factory); 850 void set sourceFactory(SourceFactory factory);
851
852 /**
853 * Call the given callback function for eache cache item in the context.
854 */
855 void visitCacheItems(void callback(Source source, SourceEntry dartEntry,
Brian Wilkerson 2014/10/29 13:51:02 AnalysisContext represents the public API, and I r
Paul Berry 2014/10/29 18:39:11 Ok. As discussed in person, I've moved this funct
856 DataDescriptor rowDesc,
857 CacheState state));
851 } 858 }
852 859
853 /** 860 /**
854 * Instances of the class `AnalysisContextImpl` implement an [AnalysisContext]. 861 * Instances of the class `AnalysisContextImpl` implement an [AnalysisContext].
855 */ 862 */
856 class AnalysisContextImpl implements InternalAnalysisContext { 863 class AnalysisContextImpl implements InternalAnalysisContext {
857 /** 864 /**
858 * The difference between the maximum cache size and the maximum priority orde r size. The priority 865 * The difference between the maximum cache size and the maximum priority orde r size. The priority
859 * list must be capped so that it is less than the cache size. Failure to do s o can result in an 866 * list must be capped so that it is less than the cache size. Failure to do s o can result in an
860 * infinite loop in performAnalysisTask() because re-caching one AST structure can cause another 867 * infinite loop in performAnalysisTask() because re-caching one AST structure can cause another
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 // 1613 //
1607 WorkManager_WorkIterator iterator = _workManager.iterator(); 1614 WorkManager_WorkIterator iterator = _workManager.iterator();
1608 while (iterator.hasNext) { 1615 while (iterator.hasNext) {
1609 Source source = iterator.next(); 1616 Source source = iterator.next();
1610 _getSourcesNeedingProcessing(source, _cache.get(source), false, hintsEnabl ed, sources); 1617 _getSourcesNeedingProcessing(source, _cache.get(source), false, hintsEnabl ed, sources);
1611 } 1618 }
1612 return new List<Source>.from(sources); 1619 return new List<Source>.from(sources);
1613 } 1620 }
1614 1621
1615 @override 1622 @override
1616 AnalysisContextStatistics get statistics { 1623 void visitCacheItems(void callback(Source source, SourceEntry dartEntry,
1624 DataDescriptor rowDesc,
1625 CacheState state)) {
1626 void handleCacheItem(Source source, SourceEntry dartEntry,
1627 DataDescriptor descriptor) {
1628 callback(source, dartEntry, descriptor, dartEntry.getState(descriptor));
1629 }
1630 void handleCacheItemInLibrary(DartEntry dartEntry, Source librarySource,
1631 DataDescriptor descriptor) {
1632 callback(librarySource, dartEntry, descriptor,
1633 dartEntry.getStateInLibrary(descriptor, librarySource));
1634 }
1635
1617 bool hintsEnabled = _options.hint; 1636 bool hintsEnabled = _options.hint;
1618 AnalysisContextStatisticsImpl statistics = new AnalysisContextStatisticsImpl ();
1619 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); 1637 MapIterator<Source, SourceEntry> iterator = _cache.iterator();
1620 while (iterator.moveNext()) { 1638 while (iterator.moveNext()) {
1639 Source source = iterator.key;
1621 SourceEntry sourceEntry = iterator.value; 1640 SourceEntry sourceEntry = iterator.value;
1622 if (sourceEntry is DartEntry) { 1641 if (sourceEntry is DartEntry) {
1623 Source source = iterator.key;
1624 DartEntry dartEntry = sourceEntry; 1642 DartEntry dartEntry = sourceEntry;
1625 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); 1643 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND);
1626 // get library independent values 1644 // get library independent values
1627 statistics.putCacheItem(dartEntry, SourceEntry.LINE_INFO); 1645 handleCacheItem(source, dartEntry, SourceEntry.LINE_INFO);
1628 statistics.putCacheItem(dartEntry, DartEntry.PARSE_ERRORS); 1646 handleCacheItem(source, dartEntry, DartEntry.PARSE_ERRORS);
1629 statistics.putCacheItem(dartEntry, DartEntry.PARSED_UNIT); 1647 handleCacheItem(source, dartEntry, DartEntry.PARSED_UNIT);
1630 statistics.putCacheItem(dartEntry, DartEntry.SOURCE_KIND); 1648 handleCacheItem(source, dartEntry, DartEntry.SOURCE_KIND);
1631 if (kind == SourceKind.LIBRARY) { 1649 if (kind == SourceKind.LIBRARY) {
1632 statistics.putCacheItem(dartEntry, DartEntry.ELEMENT); 1650 handleCacheItem(source, dartEntry, DartEntry.ELEMENT);
1633 statistics.putCacheItem(dartEntry, DartEntry.EXPORTED_LIBRARIES); 1651 handleCacheItem(source, dartEntry, DartEntry.EXPORTED_LIBRARIES);
1634 statistics.putCacheItem(dartEntry, DartEntry.IMPORTED_LIBRARIES); 1652 handleCacheItem(source, dartEntry, DartEntry.IMPORTED_LIBRARIES);
1635 statistics.putCacheItem(dartEntry, DartEntry.INCLUDED_PARTS); 1653 handleCacheItem(source, dartEntry, DartEntry.INCLUDED_PARTS);
1636 statistics.putCacheItem(dartEntry, DartEntry.IS_CLIENT); 1654 handleCacheItem(source, dartEntry, DartEntry.IS_CLIENT);
1637 statistics.putCacheItem(dartEntry, DartEntry.IS_LAUNCHABLE); 1655 handleCacheItem(source, dartEntry, DartEntry.IS_LAUNCHABLE);
1638 // The public namespace isn't computed by performAnalysisTask() and th erefore isn't 1656 // The public namespace isn't computed by performAnalysisTask() and th erefore isn't
1639 // interesting. 1657 // interesting.
1640 //statistics.putCacheItem(dartEntry, DartEntry.PUBLIC_NAMESPACE); 1658 //handleCacheItem(key, dartEntry, DartEntry.PUBLIC_NAMESPACE);
1641 } 1659 }
1642 // get library-specific values 1660 // get library-specific values
1643 List<Source> librarySources = getLibrariesContaining(source); 1661 List<Source> librarySources = getLibrariesContaining(source);
1644 for (Source librarySource in librarySources) { 1662 for (Source librarySource in librarySources) {
1645 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry.R ESOLUTION_ERRORS); 1663 handleCacheItemInLibrary(dartEntry, librarySource, DartEntry.RESOLUTIO N_ERRORS);
1646 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry.R ESOLVED_UNIT); 1664 handleCacheItemInLibrary(dartEntry, librarySource, DartEntry.RESOLVED_ UNIT);
1647 if (_generateSdkErrors || !source.isInSystemLibrary) { 1665 if (_generateSdkErrors || !source.isInSystemLibrary) {
1648 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEntry .VERIFICATION_ERRORS); 1666 handleCacheItemInLibrary(dartEntry, librarySource, DartEntry.VERIFIC ATION_ERRORS);
1649 if (hintsEnabled) { 1667 if (hintsEnabled) {
1650 statistics.putCacheItemInLibrary(dartEntry, librarySource, DartEnt ry.HINTS); 1668 handleCacheItemInLibrary(dartEntry, librarySource, DartEntry.HINTS );
1651 } 1669 }
1652 } 1670 }
1653 } 1671 }
1654 } else if (sourceEntry is HtmlEntry) { 1672 } else if (sourceEntry is HtmlEntry) {
1655 HtmlEntry htmlEntry = sourceEntry; 1673 HtmlEntry htmlEntry = sourceEntry;
1656 statistics.putCacheItem(htmlEntry, SourceEntry.LINE_INFO); 1674 handleCacheItem(source, htmlEntry, SourceEntry.LINE_INFO);
1657 statistics.putCacheItem(htmlEntry, HtmlEntry.PARSE_ERRORS); 1675 handleCacheItem(source, htmlEntry, HtmlEntry.PARSE_ERRORS);
1658 statistics.putCacheItem(htmlEntry, HtmlEntry.PARSED_UNIT); 1676 handleCacheItem(source, htmlEntry, HtmlEntry.PARSED_UNIT);
1659 statistics.putCacheItem(htmlEntry, HtmlEntry.RESOLUTION_ERRORS); 1677 handleCacheItem(source, htmlEntry, HtmlEntry.RESOLUTION_ERRORS);
1660 statistics.putCacheItem(htmlEntry, HtmlEntry.RESOLVED_UNIT); 1678 handleCacheItem(source, htmlEntry, HtmlEntry.RESOLVED_UNIT);
1661 // We are not currently recording any hints related to HTML. 1679 // We are not currently recording any hints related to HTML.
1662 // statistics.putCacheItem(htmlEntry, HtmlEntry.HINTS); 1680 // handleCacheItem(key, htmlEntry, HtmlEntry.HINTS);
1663 } 1681 }
1664 } 1682 }
1683 }
1684
1685 @override
1686 AnalysisContextStatistics get statistics {
1687 AnalysisContextStatisticsImpl statistics = new AnalysisContextStatisticsImpl ();
1688 visitCacheItems(statistics._internalPutCacheItem);
1665 statistics.partitionData = _cache.partitionData; 1689 statistics.partitionData = _cache.partitionData;
1666 return statistics; 1690 return statistics;
1667 } 1691 }
1668 1692
1669 @override 1693 @override
1670 TypeProvider get typeProvider { 1694 TypeProvider get typeProvider {
1671 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); 1695 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE);
1672 if (coreSource == null) { 1696 if (coreSource == null) {
1673 throw new AnalysisException("Could not create a source for dart:core"); 1697 throw new AnalysisException("Could not create a source for dart:core");
1674 } 1698 }
(...skipping 3431 matching lines...) Expand 10 before | Expand all | Expand 10 after
5106 5130
5107 @override 5131 @override
5108 List<CaughtException> get exceptions => new List.from(_exceptions); 5132 List<CaughtException> get exceptions => new List.from(_exceptions);
5109 5133
5110 @override 5134 @override
5111 List<AnalysisContextStatistics_PartitionData> get partitionData => _partitionD ata; 5135 List<AnalysisContextStatistics_PartitionData> get partitionData => _partitionD ata;
5112 5136
5113 @override 5137 @override
5114 List<Source> get sources => _sources; 5138 List<Source> get sources => _sources;
5115 5139
5116 void putCacheItem(SourceEntry dartEntry, DataDescriptor descriptor) {
5117 _internalPutCacheItem(dartEntry, descriptor, dartEntry.getState(descriptor)) ;
5118 }
5119
5120 void putCacheItemInLibrary(DartEntry dartEntry, Source librarySource, DataDesc riptor descriptor) {
5121 _internalPutCacheItem(dartEntry, descriptor, dartEntry.getStateInLibrary(des criptor, librarySource));
5122 }
5123
5124 /** 5140 /**
5125 * Set the partition data returned by this object to the given data. 5141 * Set the partition data returned by this object to the given data.
5126 */ 5142 */
5127 void set partitionData(List<AnalysisContextStatistics_PartitionData> data) { 5143 void set partitionData(List<AnalysisContextStatistics_PartitionData> data) {
5128 _partitionData = data; 5144 _partitionData = data;
5129 } 5145 }
5130 5146
5131 void _internalPutCacheItem(SourceEntry dartEntry, DataDescriptor rowDesc, Cach eState state) { 5147 void _internalPutCacheItem(Source source, SourceEntry dartEntry,
5148 DataDescriptor rowDesc, CacheState state) {
5132 String rowName = rowDesc.toString(); 5149 String rowName = rowDesc.toString();
5133 AnalysisContextStatisticsImpl_CacheRowImpl row = _dataMap[rowName] as Analys isContextStatisticsImpl_CacheRowImpl; 5150 AnalysisContextStatisticsImpl_CacheRowImpl row = _dataMap[rowName] as Analys isContextStatisticsImpl_CacheRowImpl;
5134 if (row == null) { 5151 if (row == null) {
5135 row = new AnalysisContextStatisticsImpl_CacheRowImpl(rowName); 5152 row = new AnalysisContextStatisticsImpl_CacheRowImpl(rowName);
5136 _dataMap[rowName] = row; 5153 _dataMap[rowName] = row;
5137 } 5154 }
5138 row._incState(state); 5155 row._incState(state);
5139 if (state == CacheState.ERROR) { 5156 if (state == CacheState.ERROR) {
5140 CaughtException exception = dartEntry.exception; 5157 CaughtException exception = dartEntry.exception;
5141 if (exception != null) { 5158 if (exception != null) {
5142 _exceptions.add(exception); 5159 _exceptions.add(exception);
5143 } 5160 }
5144 } 5161 }
5145 } 5162 }
5146 } 5163 }
5147 5164
5148 class AnalysisContextStatisticsImpl_CacheRowImpl implements AnalysisContextStati stics_CacheRow { 5165 class AnalysisContextStatisticsImpl_CacheRowImpl implements AnalysisContextStati stics_CacheRow {
5149 final String name; 5166 final String name;
5150 5167
5151 int _errorCount = 0; 5168 Map<CacheState, int> _counts = <CacheState, int>{};
5152
5153 int _flushedCount = 0;
5154
5155 int _inProcessCount = 0;
5156
5157 int _invalidCount = 0;
5158
5159 int _validCount = 0;
5160 5169
5161 AnalysisContextStatisticsImpl_CacheRowImpl(this.name); 5170 AnalysisContextStatisticsImpl_CacheRowImpl(this.name);
5162 5171
5163 @override 5172 @override
5164 bool operator ==(Object obj) => obj is AnalysisContextStatisticsImpl_CacheRowI mpl && obj.name == name; 5173 bool operator ==(Object obj) => obj is AnalysisContextStatisticsImpl_CacheRowI mpl && obj.name == name;
5165 5174
5166 @override 5175 @override
5167 int get errorCount => _errorCount; 5176 int get errorCount => getCount(CacheState.ERROR);
5168 5177
5169 @override 5178 @override
5170 int get flushedCount => _flushedCount; 5179 int get flushedCount => getCount(CacheState.FLUSHED);
5171 5180
5172 @override 5181 @override
5173 int get inProcessCount => _inProcessCount; 5182 int get inProcessCount => getCount(CacheState.IN_PROCESS);
5174 5183
5175 @override 5184 @override
5176 int get invalidCount => _invalidCount; 5185 int get invalidCount => getCount(CacheState.INVALID);
5177 5186
5178 @override 5187 @override
5179 int get validCount => _validCount; 5188 int get validCount => getCount(CacheState.VALID);
5180 5189
5181 @override 5190 @override
5182 int get hashCode => name.hashCode; 5191 int get hashCode => name.hashCode;
5183 5192
5193 @override
5194 int getCount(CacheState state) {
5195 int count = _counts[state];
5196 if (count != null) {
5197 return count;
5198 } else {
5199 return 0;
5200 }
5201 }
5202
5184 void _incState(CacheState state) { 5203 void _incState(CacheState state) {
5185 if (state == CacheState.ERROR) { 5204 if (_counts[state] == null) {
5186 _errorCount++; 5205 _counts[state] = 1;
5187 } 5206 } else {
5188 if (state == CacheState.FLUSHED) { 5207 _counts[state]++;
5189 _flushedCount++;
5190 }
5191 if (state == CacheState.IN_PROCESS) {
5192 _inProcessCount++;
5193 }
5194 if (state == CacheState.INVALID) {
5195 _invalidCount++;
5196 }
5197 if (state == CacheState.VALID) {
5198 _validCount++;
5199 } 5208 }
5200 } 5209 }
5201 } 5210 }
5202 5211
5203 class AnalysisContextStatisticsImpl_PartitionDataImpl implements AnalysisContext Statistics_PartitionData { 5212 class AnalysisContextStatisticsImpl_PartitionDataImpl implements AnalysisContext Statistics_PartitionData {
5204 final int astCount; 5213 final int astCount;
5205 5214
5206 final int totalCount; 5215 final int totalCount;
5207 5216
5208 AnalysisContextStatisticsImpl_PartitionDataImpl(this.astCount, this.totalCount ); 5217 AnalysisContextStatisticsImpl_PartitionDataImpl(this.astCount, this.totalCount );
5209 } 5218 }
5210 5219
5211 /** 5220 /**
5212 * Information about single piece of data in the cache. 5221 * Information about single piece of data in the cache.
5213 */ 5222 */
5214 abstract class AnalysisContextStatistics_CacheRow { 5223 abstract class AnalysisContextStatistics_CacheRow {
5215 /** 5224 /**
5225 * List of possible states which can be queried.
5226 */
5227 static const List<CacheState> STATES = const <CacheState>[
Brian Wilkerson 2014/10/29 13:51:02 Use CacheState.values instead?
Paul Berry 2014/10/29 18:39:11 Done.
5228 CacheState.ERROR, CacheState.FLUSHED, CacheState.IN_PROCESS,
5229 CacheState.INVALID, CacheState.VALID];
5230
5231 /**
5232 * Return the number of entries whose state is [state].
5233 */
5234 int getCount(CacheState state);
5235
5236 /**
5216 * Return the number of entries whose state is [CacheState.ERROR]. 5237 * Return the number of entries whose state is [CacheState.ERROR].
5217 */ 5238 */
5218 int get errorCount; 5239 int get errorCount;
5219 5240
5220 /** 5241 /**
5221 * Return the number of entries whose state is [CacheState.FLUSHED]. 5242 * Return the number of entries whose state is [CacheState.FLUSHED].
5222 */ 5243 */
5223 int get flushedCount; 5244 int get flushedCount;
5224 5245
5225 /** 5246 /**
(...skipping 4976 matching lines...) Expand 10 before | Expand all | Expand 10 after
10202 void set sourceFactory(SourceFactory factory) { 10223 void set sourceFactory(SourceFactory factory) {
10203 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- setSourceFactory"); 10224 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis- setSourceFactory");
10204 _checkThread(instrumentation); 10225 _checkThread(instrumentation);
10205 try { 10226 try {
10206 instrumentation.metric3("contextId", _contextId); 10227 instrumentation.metric3("contextId", _contextId);
10207 _basis.sourceFactory = factory; 10228 _basis.sourceFactory = factory;
10208 } finally { 10229 } finally {
10209 instrumentation.log(); 10230 instrumentation.log();
10210 } 10231 }
10211 } 10232 }
10233
10234 @override
10235 void visitCacheItems(void callback(Source source, SourceEntry dartEntry,
10236 DataDescriptor rowDesc,
10237 CacheState state)) {
10238 _basis.visitCacheItems(callback);
10239 }
10212 } 10240 }
10213 10241
10214 /** 10242 /**
10215 * The interface `InternalAnalysisContext` defines additional behavior for an an alysis context 10243 * The interface `InternalAnalysisContext` defines additional behavior for an an alysis context
10216 * that is required by internal users of the context. 10244 * that is required by internal users of the context.
10217 */ 10245 */
10218 abstract class InternalAnalysisContext implements AnalysisContext { 10246 abstract class InternalAnalysisContext implements AnalysisContext {
10219 /** 10247 /**
10220 * Add the given source with the given information to this context. 10248 * Add the given source with the given information to this context.
10221 * 10249 *
(...skipping 3250 matching lines...) Expand 10 before | Expand all | Expand 10 after
13472 _index++; 13500 _index++;
13473 if (_index >= _manager._workQueues[_queueIndex].length) { 13501 if (_index >= _manager._workQueues[_queueIndex].length) {
13474 _index = 0; 13502 _index = 0;
13475 _queueIndex++; 13503 _queueIndex++;
13476 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_ queueIndex].isEmpty) { 13504 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_ queueIndex].isEmpty) {
13477 _queueIndex++; 13505 _queueIndex++;
13478 } 13506 }
13479 } 13507 }
13480 } 13508 }
13481 } 13509 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698