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

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

Issue 680913002: Remove JavaIterator and MapEntry (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
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/lib/src/generated/html.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine; 8 library engine;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 @override 996 @override
997 void addSourceInfo(Source source, SourceEntry info) { 997 void addSourceInfo(Source source, SourceEntry info) {
998 // This implementation assumes that the access to the cache does not need to be synchronized 998 // This implementation assumes that the access to the cache does not need to be synchronized
999 // because no other object can have access to this context while this method is being invoked. 999 // because no other object can have access to this context while this method is being invoked.
1000 _cache.put(source, info); 1000 _cache.put(source, info);
1001 } 1001 }
1002 1002
1003 @override 1003 @override
1004 void applyAnalysisDelta(AnalysisDelta delta) { 1004 void applyAnalysisDelta(AnalysisDelta delta) {
1005 ChangeSet changeSet = new ChangeSet(); 1005 ChangeSet changeSet = new ChangeSet();
1006 for (MapEntry<Source, AnalysisLevel> entry in getMapEntrySet(delta.analysisL evels)) { 1006 delta.analysisLevels.forEach((Source source, AnalysisLevel level) {
1007 Source source = entry.getKey(); 1007 if (level == AnalysisLevel.NONE) {
1008 if (entry.getValue() == AnalysisLevel.NONE) {
1009 changeSet.removedSource(source); 1008 changeSet.removedSource(source);
1010 } else { 1009 } else {
1011 changeSet.addedSource(source); 1010 changeSet.addedSource(source);
1012 } 1011 }
1013 } 1012 });
1014 applyChanges(changeSet); 1013 applyChanges(changeSet);
1015 } 1014 }
1016 1015
1017 @override 1016 @override
1018 void applyChanges(ChangeSet changeSet) { 1017 void applyChanges(ChangeSet changeSet) {
1019 if (changeSet.isEmpty) { 1018 if (changeSet.isEmpty) {
1020 return; 1019 return;
1021 } 1020 }
1022 // 1021 //
1023 // First, compute the list of sources that have been removed. 1022 // First, compute the list of sources that have been removed.
(...skipping 12 matching lines...) Expand all
1036 } 1035 }
1037 } 1036 }
1038 for (Source source in changeSet.changedSources) { 1037 for (Source source in changeSet.changedSources) {
1039 if (_contentCache.getContents(source) != null) { 1038 if (_contentCache.getContents(source) != null) {
1040 // This source is overridden in the content cache, so the change will ha ve no effect. 1039 // This source is overridden in the content cache, so the change will ha ve no effect.
1041 // Just ignore it to avoid wasting time doing re-analysis. 1040 // Just ignore it to avoid wasting time doing re-analysis.
1042 continue; 1041 continue;
1043 } 1042 }
1044 _sourceChanged(source); 1043 _sourceChanged(source);
1045 } 1044 }
1046 for (MapEntry<Source, String> entry in getMapEntrySet(changeSet.changedConte nts)) { 1045 changeSet.changedContents.forEach((Source key, String value) {
1047 setContents(entry.getKey(), entry.getValue()); 1046 setContents(key, value);
1048 } 1047 });
1049 for (MapEntry<Source, ChangeSet_ContentChange> entry in getMapEntrySet(chang eSet.changedRanges)) { 1048 changeSet.changedRanges.forEach((Source source, ChangeSet_ContentChange chan ge) {
1050 ChangeSet_ContentChange change = entry.getValue(); 1049 setChangedContents(
1051 setChangedContents(entry.getKey(), change.contents, change.offset, change. oldLength, change.newLength); 1050 source,
1052 } 1051 change.contents,
1052 change.offset,
1053 change.oldLength,
1054 change.newLength);
1055 });
1053 for (Source source in changeSet.deletedSources) { 1056 for (Source source in changeSet.deletedSources) {
1054 _sourceDeleted(source); 1057 _sourceDeleted(source);
1055 } 1058 }
1056 for (Source source in removedSources) { 1059 for (Source source in removedSources) {
1057 _sourceRemoved(source); 1060 _sourceRemoved(source);
1058 } 1061 }
1059 if (addedDartSource) { 1062 if (addedDartSource) {
1060 // TODO(brianwilkerson) This is hugely inefficient, but we need to re-anal yze any libraries 1063 // TODO(brianwilkerson) This is hugely inefficient, but we need to re-anal yze any libraries
1061 // that might have been referencing the not-yet-existing source that was j ust added. Longer 1064 // that might have been referencing the not-yet-existing source that was j ust added. Longer
1062 // term we need to keep track of which libraries are referencing non-exist ing sources and 1065 // term we need to keep track of which libraries are referencing non-exist ing sources and
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 // notifyResolvedHtml(source, notice.getHtmlUnit()); 1751 // notifyResolvedHtml(source, notice.getHtmlUnit());
1749 // } 1752 // }
1750 _notifyErrors(source, notice.errors, notice.lineInfo); 1753 _notifyErrors(source, notice.errors, notice.lineInfo);
1751 } 1754 }
1752 return new AnalysisResult(notices, getEnd - getStart, task.runtimeType.toStr ing(), performEnd - performStart); 1755 return new AnalysisResult(notices, getEnd - getStart, task.runtimeType.toStr ing(), performEnd - performStart);
1753 } 1756 }
1754 1757
1755 @override 1758 @override
1756 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { 1759 void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
1757 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); 1760 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML);
1758 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap)) { 1761 elementMap.forEach((Source librarySource, LibraryElement library) {
1759 Source librarySource = entry.getKey();
1760 LibraryElement library = entry.getValue();
1761 // 1762 //
1762 // Cache the element in the library's info. 1763 // Cache the element in the library's info.
1763 // 1764 //
1764 DartEntry dartEntry = _getReadableDartEntry(librarySource); 1765 DartEntry dartEntry = _getReadableDartEntry(librarySource);
1765 if (dartEntry != null) { 1766 if (dartEntry != null) {
1766 _recordElementData(dartEntry, library, library.source, htmlSource); 1767 _recordElementData(dartEntry, library, library.source, htmlSource);
1767 dartEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED); 1768 dartEntry.setState(SourceEntry.CONTENT, CacheState.FLUSHED);
1768 dartEntry.setValue(SourceEntry.LINE_INFO, new LineInfo(<int> [0])); 1769 dartEntry.setValue(SourceEntry.LINE_INFO, new LineInfo(<int> [0]));
1769 dartEntry.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS); 1770 dartEntry.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS);
1770 // DartEntry.ELEMENT - set in recordElementData 1771 // DartEntry.ELEMENT - set in recordElementData
1771 dartEntry.setValue(DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY); 1772 dartEntry.setValue(DartEntry.EXPORTED_LIBRARIES, Source.EMPTY_ARRAY);
1772 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY); 1773 dartEntry.setValue(DartEntry.IMPORTED_LIBRARIES, Source.EMPTY_ARRAY);
1773 dartEntry.setValue(DartEntry.INCLUDED_PARTS, Source.EMPTY_ARRAY); 1774 dartEntry.setValue(DartEntry.INCLUDED_PARTS, Source.EMPTY_ARRAY);
1774 // DartEntry.IS_CLIENT - set in recordElementData 1775 // DartEntry.IS_CLIENT - set in recordElementData
1775 // DartEntry.IS_LAUNCHABLE - set in recordElementData 1776 // DartEntry.IS_LAUNCHABLE - set in recordElementData
1776 dartEntry.setValue(DartEntry.PARSE_ERRORS, AnalysisError.NO_ERRORS); 1777 dartEntry.setValue(DartEntry.PARSE_ERRORS, AnalysisError.NO_ERRORS);
1777 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); 1778 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
1778 dartEntry.setState(DartEntry.PUBLIC_NAMESPACE, CacheState.FLUSHED); 1779 dartEntry.setState(DartEntry.PUBLIC_NAMESPACE, CacheState.FLUSHED);
1779 dartEntry.setValue(DartEntry.SCAN_ERRORS, AnalysisError.NO_ERRORS); 1780 dartEntry.setValue(DartEntry.SCAN_ERRORS, AnalysisError.NO_ERRORS);
1780 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); 1781 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
1781 dartEntry.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED); 1782 dartEntry.setState(DartEntry.TOKEN_STREAM, CacheState.FLUSHED);
1782 dartEntry.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySource, AnalysisError.NO_ERRORS); 1783 dartEntry.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySource, AnalysisError.NO_ERRORS);
1783 dartEntry.setStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource, Cach eState.FLUSHED); 1784 dartEntry.setStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource, Cach eState.FLUSHED);
1784 dartEntry.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource , AnalysisError.NO_ERRORS); 1785 dartEntry.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource , AnalysisError.NO_ERRORS);
1785 dartEntry.setValueInLibrary(DartEntry.HINTS, librarySource, AnalysisErro r.NO_ERRORS); 1786 dartEntry.setValueInLibrary(DartEntry.HINTS, librarySource, AnalysisErro r.NO_ERRORS);
1786 } 1787 }
1787 } 1788 });
1788 } 1789 }
1789 1790
1790 @override 1791 @override
1791 void removeListener(AnalysisListener listener) { 1792 void removeListener(AnalysisListener listener) {
1792 _listeners.remove(listener); 1793 _listeners.remove(listener);
1793 } 1794 }
1794 1795
1795 @override 1796 @override
1796 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra ry) { 1797 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra ry) {
1797 if (library == null) { 1798 if (library == null) {
(...skipping 2425 matching lines...) Expand 10 before | Expand all | Expand 10 after
4223 4224
4224 /** 4225 /**
4225 * Remove the given libraries that are keys in the given map from the list of containing libraries 4226 * Remove the given libraries that are keys in the given map from the list of containing libraries
4226 * for each of the parts in the corresponding value. 4227 * for each of the parts in the corresponding value.
4227 * 4228 *
4228 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4229 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
4229 * 4230 *
4230 * @param oldPartMap the table containing the parts associated with each libra ry 4231 * @param oldPartMap the table containing the parts associated with each libra ry
4231 */ 4232 */
4232 void _removeFromPartsUsingMap(HashMap<Source, List<Source>> oldPartMap) { 4233 void _removeFromPartsUsingMap(HashMap<Source, List<Source>> oldPartMap) {
4233 for (MapEntry<Source, List<Source>> entry in getMapEntrySet(oldPartMap)) { 4234 oldPartMap.forEach((Source librarySource, List<Source> oldParts) {
4234 Source librarySource = entry.getKey();
4235 List<Source> oldParts = entry.getValue();
4236 for (int i = 0; i < oldParts.length; i++) { 4235 for (int i = 0; i < oldParts.length; i++) {
4237 Source partSource = oldParts[i]; 4236 Source partSource = oldParts[i];
4238 if (partSource != librarySource) { 4237 if (partSource != librarySource) {
4239 DartEntry partEntry = _getReadableDartEntry(partSource); 4238 DartEntry partEntry = _getReadableDartEntry(partSource);
4240 if (partEntry != null) { 4239 if (partEntry != null) {
4241 partEntry.removeContainingLibrary(librarySource); 4240 partEntry.removeContainingLibrary(librarySource);
4242 if (partEntry.containingLibraries.length == 0 && !exists(partSource) ) { 4241 if (partEntry.containingLibraries.length == 0 && !exists(partSource) ) {
4243 _cache.remove(partSource); 4242 _cache.remove(partSource);
4244 } 4243 }
4245 } 4244 }
4246 } 4245 }
4247 } 4246 }
4248 } 4247 });
4249 } 4248 }
4250 4249
4251 /** 4250 /**
4252 * Remove the given source from the priority order if it is in the list. 4251 * Remove the given source from the priority order if it is in the list.
4253 * 4252 *
4254 * @param source the source to be removed 4253 * @param source the source to be removed
4255 */ 4254 */
4256 void _removeFromPriorityOrder(Source source) { 4255 void _removeFromPriorityOrder(Source source) {
4257 int count = _priorityOrder.length; 4256 int count = _priorityOrder.length;
4258 List<Source> newOrder = new List<Source>(); 4257 List<Source> newOrder = new List<Source>();
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
5313 _appendSources(buffer, needsSeparator, AnalysisLevel.NONE); 5312 _appendSources(buffer, needsSeparator, AnalysisLevel.NONE);
5314 return buffer.toString(); 5313 return buffer.toString();
5315 } 5314 }
5316 5315
5317 /** 5316 /**
5318 * Appendto the given [builder] all sources with the given analysis [level], 5317 * Appendto the given [builder] all sources with the given analysis [level],
5319 * prefixed with a label and a separator if [needsSeparator] is `true`. 5318 * prefixed with a label and a separator if [needsSeparator] is `true`.
5320 */ 5319 */
5321 bool _appendSources(StringBuffer buffer, bool needsSeparator, AnalysisLevel le vel) { 5320 bool _appendSources(StringBuffer buffer, bool needsSeparator, AnalysisLevel le vel) {
5322 bool first = true; 5321 bool first = true;
5323 for (MapEntry<Source, AnalysisLevel> entry in getMapEntrySet(_analysisMap)) { 5322 _analysisMap.forEach((Source source, AnalysisLevel sourceLevel) {
5324 if (entry.getValue() == level) { 5323 if (sourceLevel == level) {
5325 if (first) { 5324 if (first) {
5326 first = false; 5325 first = false;
5327 if (needsSeparator) { 5326 if (needsSeparator) {
5328 buffer.write("; "); 5327 buffer.write("; ");
5329 } 5328 }
5330 buffer.write(level); 5329 buffer.write(level);
5331 buffer.write(" "); 5330 buffer.write(" ");
5332 } else { 5331 } else {
5333 buffer.write(", "); 5332 buffer.write(", ");
5334 } 5333 }
5335 buffer.write(entry.getKey().fullName); 5334 buffer.write(source.fullName);
5336 } 5335 }
5337 } 5336 });
5338 return needsSeparator || !first; 5337 return needsSeparator || !first;
5339 } 5338 }
5340 } 5339 }
5341 5340
5342 /** 5341 /**
5343 * The unique instance of the class `AnalysisEngine` serves as the entry point f or the 5342 * The unique instance of the class `AnalysisEngine` serves as the entry point f or the
5344 * functionality provided by the analysis engine. 5343 * functionality provided by the analysis engine.
5345 */ 5344 */
5346 class AnalysisEngine { 5345 class AnalysisEngine {
5347 /** 5346 /**
(...skipping 6275 matching lines...) Expand 10 before | Expand all | Expand 10 after
11623 onError(error); 11622 onError(error);
11624 } 11623 }
11625 } 11624 }
11626 11625
11627 /** 11626 /**
11628 * Answer the errors collected by the listener. 11627 * Answer the errors collected by the listener.
11629 * 11628 *
11630 * @return an array of errors (not `null`, contains no `null`s) 11629 * @return an array of errors (not `null`, contains no `null`s)
11631 */ 11630 */
11632 List<AnalysisError> get errors { 11631 List<AnalysisError> get errors {
11633 Iterable<MapEntry<Source, HashSet<AnalysisError>>> entrySet = getMapEntrySet (_errors); 11632 int numEntries = _errors.length;
11634 int numEntries = entrySet.length;
11635 if (numEntries == 0) { 11633 if (numEntries == 0) {
11636 return AnalysisError.NO_ERRORS; 11634 return AnalysisError.NO_ERRORS;
11637 } 11635 }
11638 List<AnalysisError> resultList = new List<AnalysisError>(); 11636 List<AnalysisError> resultList = new List<AnalysisError>();
11639 for (MapEntry<Source, HashSet<AnalysisError>> entry in entrySet) { 11637 for (HashSet<AnalysisError> errors in _errors.values) {
11640 resultList.addAll(entry.getValue()); 11638 resultList.addAll(errors);
11641 } 11639 }
11642 return new List.from(resultList); 11640 return new List.from(resultList);
11643 } 11641 }
11644 11642
11645 /** 11643 /**
11646 * Answer the errors collected by the listener for some passed [Source]. 11644 * Answer the errors collected by the listener for some passed [Source].
11647 * 11645 *
11648 * @param source some [Source] for which the caller wants the set of [Analysis Error]s 11646 * @param source some [Source] for which the caller wants the set of [Analysis Error]s
11649 * collected by this listener 11647 * collected by this listener
11650 * @return the errors collected by the listener for the passed [Source] 11648 * @return the errors collected by the listener for the passed [Source]
(...skipping 1824 matching lines...) Expand 10 before | Expand all | Expand 10 after
13475 _index++; 13473 _index++;
13476 if (_index >= _manager._workQueues[_queueIndex].length) { 13474 if (_index >= _manager._workQueues[_queueIndex].length) {
13477 _index = 0; 13475 _index = 0;
13478 _queueIndex++; 13476 _queueIndex++;
13479 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_ queueIndex].isEmpty) { 13477 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_ queueIndex].isEmpty) {
13480 _queueIndex++; 13478 _queueIndex++;
13481 } 13479 }
13482 } 13480 }
13483 } 13481 }
13484 } 13482 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/lib/src/generated/html.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698