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

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

Issue 475543002: New analyzer snapshot, add format/formatList. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 // 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 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after
1736 // 1736 //
1737 // Cache the element in the library's info. 1737 // Cache the element in the library's info.
1738 // 1738 //
1739 DartEntry dartEntry = _getReadableDartEntry(librarySource); 1739 DartEntry dartEntry = _getReadableDartEntry(librarySource);
1740 if (dartEntry != null) { 1740 if (dartEntry != null) {
1741 DartEntryImpl dartCopy = dartEntry.writableCopy; 1741 DartEntryImpl dartCopy = dartEntry.writableCopy;
1742 _recordElementData(dartCopy, library, library.source, htmlSource); 1742 _recordElementData(dartCopy, library, library.source, htmlSource);
1743 dartCopy.setValue(DartEntry.SCAN_ERRORS, AnalysisError.NO_ERRORS); 1743 dartCopy.setValue(DartEntry.SCAN_ERRORS, AnalysisError.NO_ERRORS);
1744 dartCopy.setValue(DartEntry.PARSE_ERRORS, AnalysisError.NO_ERRORS); 1744 dartCopy.setValue(DartEntry.PARSE_ERRORS, AnalysisError.NO_ERRORS);
1745 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); 1745 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED);
1746 dartCopy.setValueInLibrary(DartEntry.BUILD_ELEMENT_ERRORS, librarySource , AnalysisError.NO_ERRORS);
1747 dartCopy.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySource, A nalysisError.NO_ERRORS); 1746 dartCopy.setValueInLibrary(DartEntry.RESOLUTION_ERRORS, librarySource, A nalysisError.NO_ERRORS);
1748 dartCopy.setStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource, Cache State.FLUSHED); 1747 dartCopy.setStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource, Cache State.FLUSHED);
1749 dartCopy.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource, AnalysisError.NO_ERRORS); 1748 dartCopy.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource, AnalysisError.NO_ERRORS);
1750 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS); 1749 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS);
1751 dartCopy.setValueInLibrary(DartEntry.HINTS, librarySource, AnalysisError .NO_ERRORS); 1750 dartCopy.setValueInLibrary(DartEntry.HINTS, librarySource, AnalysisError .NO_ERRORS);
1752 _cache.put(librarySource, dartCopy); 1751 _cache.put(librarySource, dartCopy);
1753 } 1752 }
1754 } 1753 }
1755 } 1754 }
1756 1755
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
2587 bool _containsAny(List<Source> sources, List<Source> targetSources) { 2586 bool _containsAny(List<Source> sources, List<Source> targetSources) {
2588 for (Source targetSource in targetSources) { 2587 for (Source targetSource in targetSources) {
2589 if (_contains(sources, targetSource)) { 2588 if (_contains(sources, targetSource)) {
2590 return true; 2589 return true;
2591 } 2590 }
2592 } 2591 }
2593 return false; 2592 return false;
2594 } 2593 }
2595 2594
2596 /** 2595 /**
2597 * Create a [BuildDartElementModelTask] for the given source, marking the buil t unit as
2598 * being in-process.
2599 *
2600 * @param source the source for the library whose element model is to be built
2601 * @param dartEntry the entry for the source
2602 * @return task data representing the created task
2603 */
2604 AnalysisContextImpl_TaskData _createBuildDartElementModelTask(Source source, D artEntry dartEntry) {
2605 try {
2606 AnalysisContextImpl_CycleBuilder builder = new AnalysisContextImpl_CycleBu ilder(this);
2607 builder.computeCycleContaining(source);
2608 AnalysisContextImpl_TaskData taskData = builder.taskData;
2609 if (taskData != null) {
2610 return taskData;
2611 }
2612 DartEntryImpl dartCopy = dartEntry.writableCopy;
2613 dartCopy.setStateInLibrary(DartEntry.BUILT_UNIT, source, CacheState.IN_PRO CESS);
2614 _cache.put(source, dartCopy);
2615 return new AnalysisContextImpl_TaskData(new BuildDartElementModelTask(this , source, builder.librariesInCycle), false);
2616 } on AnalysisException catch (exception, stackTrace) {
2617 DartEntryImpl dartCopy = dartEntry.writableCopy;
2618 dartCopy.recordBuildElementErrorInLibrary(source, new CaughtException(exce ption, stackTrace));
2619 _cache.put(source, dartCopy);
2620 AnalysisEngine.instance.logger.logError2("Internal error trying to compute the next analysis task", new CaughtException(exception, stackTrace));
2621 }
2622 return new AnalysisContextImpl_TaskData(null, false);
2623 }
2624
2625 /**
2626 * Create a [GenerateDartErrorsTask] for the given source, marking the verific ation errors 2596 * Create a [GenerateDartErrorsTask] for the given source, marking the verific ation errors
2627 * as being in-process. The compilation unit and the library can be the same i f the compilation 2597 * as being in-process. The compilation unit and the library can be the same i f the compilation
2628 * unit is the defining compilation unit of the library. 2598 * unit is the defining compilation unit of the library.
2629 * 2599 *
2630 * @param unitSource the source for the compilation unit to be verified 2600 * @param unitSource the source for the compilation unit to be verified
2631 * @param unitEntry the entry for the compilation unit 2601 * @param unitEntry the entry for the compilation unit
2632 * @param librarySource the source for the library containing the compilation unit 2602 * @param librarySource the source for the library containing the compilation unit
2633 * @param libraryEntry the entry for the library 2603 * @param libraryEntry the entry for the library
2634 * @return task data representing the created task 2604 * @return task data representing the created task
2635 */ 2605 */
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
3901 // notify about Dart errors 3871 // notify about Dart errors
3902 ChangeNoticeImpl notice = _getNotice(elementSource); 3872 ChangeNoticeImpl notice = _getNotice(elementSource);
3903 notice.setErrors(dartCopy.allErrors, computeLineInfo(elementSource)); 3873 notice.setErrors(dartCopy.allErrors, computeLineInfo(elementSource));
3904 } 3874 }
3905 } 3875 }
3906 // remember Angular entry point 3876 // remember Angular entry point
3907 entry.setValue(HtmlEntry.ANGULAR_ENTRY, application); 3877 entry.setValue(HtmlEntry.ANGULAR_ENTRY, application);
3908 } 3878 }
3909 3879
3910 /** 3880 /**
3911 * Record the results produced by performing a [BuildDartElementModelTask]. If the results
3912 * were computed from data that is now out-of-date, then the results will not be recorded.
3913 *
3914 * @param task the task that was performed
3915 * @return an entry containing the recorded results
3916 * @throws AnalysisException if the results could not be recorded
3917 */
3918 DartEntry _recordBuildDartElementModelTask(BuildDartElementModelTask task) {
3919 Source targetLibrary = task.targetLibrary;
3920 List<ResolvableLibrary> builtLibraries = task.librariesInCycle;
3921 CaughtException thrownException = task.exception;
3922 DartEntry targetEntry = null;
3923 if (_allModificationTimesMatch(builtLibraries)) {
3924 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML);
3925 RecordingErrorListener errorListener = task.errorListener;
3926 for (ResolvableLibrary library in builtLibraries) {
3927 Source librarySource = library.librarySource;
3928 for (Source source in library.compilationUnitSources) {
3929 CompilationUnit unit = library.getAST(source);
3930 List<AnalysisError> errors = errorListener.getErrorsForSource(source);
3931 LineInfo lineInfo = getLineInfo(source);
3932 DartEntryImpl dartCopy = _cache.get(source).writableCopy as DartEntryI mpl;
3933 if (thrownException == null) {
3934 dartCopy.setValueInLibrary(DartEntry.BUILD_ELEMENT_ERRORS, librarySo urce, errors);
3935 dartCopy.setValueInLibrary(DartEntry.BUILT_UNIT, librarySource, unit );
3936 if (source == librarySource) {
3937 LibraryElementImpl libraryElement = library.libraryElement;
3938 dartCopy.setValue(DartEntry.ELEMENT, libraryElement);
3939 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, libraryElement.entryPoi nt != null);
3940 dartCopy.setValue(DartEntry.IS_CLIENT, _isClient(libraryElement, h tmlSource, new HashSet<LibraryElement>()));
3941 }
3942 } else {
3943 dartCopy.recordBuildElementErrorInLibrary(librarySource, thrownExcep tion);
3944 _cache.remove(source);
3945 }
3946 _cache.put(source, dartCopy);
3947 if (source != librarySource) {
3948 _workManager.add(librarySource, SourcePriority.PRIORITY_PART);
3949 }
3950 if (source == targetLibrary) {
3951 targetEntry = dartCopy;
3952 }
3953 ChangeNoticeImpl notice = _getNotice(source);
3954 notice.compilationUnit = unit;
3955 notice.setErrors(dartCopy.allErrors, lineInfo);
3956 }
3957 }
3958 } else {
3959 PrintStringWriter writer = new PrintStringWriter();
3960 writer.println("Build element model results discarded for");
3961 for (ResolvableLibrary library in builtLibraries) {
3962 Source librarySource = library.librarySource;
3963 for (Source source in library.compilationUnitSources) {
3964 DartEntry dartEntry = _getReadableDartEntry(source);
3965 if (dartEntry != null) {
3966 int resultTime = library.getModificationTime(source);
3967 writer.println(" ${_debuggingString(source)}; sourceTime = ${getMod ificationStamp(source)}, resultTime = ${resultTime}, cacheTime = ${dartEntry.mod ificationTime}");
3968 DartEntryImpl dartCopy = dartEntry.writableCopy;
3969 if (thrownException == null || resultTime >= 0) {
3970 //
3971 // The analysis was performed on out-of-date sources. Mark the cac he so that the
3972 // sources will be re-analyzed using the up-to-date sources.
3973 //
3974 dartCopy.recordBuildElementNotInProcess();
3975 } else {
3976 //
3977 // We could not determine whether the sources were up-to-date or o ut-of-date. Mark
3978 // the cache so that we won't attempt to re-analyze the sources un til there's a
3979 // good chance that we'll be able to do so without error.
3980 //
3981 dartCopy.recordBuildElementErrorInLibrary(librarySource, thrownExc eption);
3982 _cache.remove(source);
3983 }
3984 _cache.put(source, dartCopy);
3985 if (source == targetLibrary) {
3986 targetEntry = dartCopy;
3987 }
3988 } else {
3989 writer.println(" ${_debuggingString(source)}; sourceTime = ${getMod ificationStamp(source)}, no entry");
3990 }
3991 }
3992 }
3993 _logInformation(writer.toString());
3994 }
3995 if (thrownException != null) {
3996 throw new AnalysisException('<rethrow>', thrownException);
3997 }
3998 if (targetEntry == null) {
3999 targetEntry = _getReadableDartEntry(targetLibrary);
4000 if (targetEntry == null) {
4001 throw new AnalysisException("A Dart file became a non-Dart file: ${targe tLibrary.fullName}");
4002 }
4003 }
4004 return targetEntry;
4005 }
4006
4007 /**
4008 * Given a cache entry and a library element, record the library element and o ther information 3881 * Given a cache entry and a library element, record the library element and o ther information
4009 * gleaned from the element in the cache entry. 3882 * gleaned from the element in the cache entry.
4010 * 3883 *
4011 * @param dartCopy the cache entry in which data is to be recorded 3884 * @param dartCopy the cache entry in which data is to be recorded
4012 * @param library the library element used to record information 3885 * @param library the library element used to record information
4013 * @param librarySource the source for the library used to record information 3886 * @param librarySource the source for the library used to record information
4014 * @param htmlSource the source for the HTML library 3887 * @param htmlSource the source for the HTML library
4015 */ 3888 */
4016 void _recordElementData(DartEntryImpl dartCopy, LibraryElement library, Source librarySource, Source htmlSource) { 3889 void _recordElementData(DartEntryImpl dartCopy, LibraryElement library, Source librarySource, Source htmlSource) {
4017 dartCopy.setValue(DartEntry.ELEMENT, library); 3890 dartCopy.setValue(DartEntry.ELEMENT, library);
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after
5233 /** 5106 /**
5234 * Instances of the class `AnalysisTaskResultRecorder` are used by an analysis c ontext to 5107 * Instances of the class `AnalysisTaskResultRecorder` are used by an analysis c ontext to
5235 * record the results of a task. 5108 * record the results of a task.
5236 */ 5109 */
5237 class AnalysisContextImpl_AnalysisTaskResultRecorder implements AnalysisTaskVisi tor<SourceEntry> { 5110 class AnalysisContextImpl_AnalysisTaskResultRecorder implements AnalysisTaskVisi tor<SourceEntry> {
5238 final AnalysisContextImpl AnalysisContextImpl_this; 5111 final AnalysisContextImpl AnalysisContextImpl_this;
5239 5112
5240 AnalysisContextImpl_AnalysisTaskResultRecorder(this.AnalysisContextImpl_this); 5113 AnalysisContextImpl_AnalysisTaskResultRecorder(this.AnalysisContextImpl_this);
5241 5114
5242 @override 5115 @override
5243 DartEntry visitBuildDartElementModelTask(BuildDartElementModelTask task) => An alysisContextImpl_this._recordBuildDartElementModelTask(task);
5244
5245 @override
5246 DartEntry visitGenerateDartErrorsTask(GenerateDartErrorsTask task) => Analysis ContextImpl_this._recordGenerateDartErrorsTask(task); 5116 DartEntry visitGenerateDartErrorsTask(GenerateDartErrorsTask task) => Analysis ContextImpl_this._recordGenerateDartErrorsTask(task);
5247 5117
5248 @override 5118 @override
5249 DartEntry visitGenerateDartHintsTask(GenerateDartHintsTask task) => AnalysisCo ntextImpl_this._recordGenerateDartHintsTask(task); 5119 DartEntry visitGenerateDartHintsTask(GenerateDartHintsTask task) => AnalysisCo ntextImpl_this._recordGenerateDartHintsTask(task);
5250 5120
5251 @override 5121 @override
5252 SourceEntry visitGetContentTask(GetContentTask task) => AnalysisContextImpl_th is._recordGetContentsTask(task); 5122 SourceEntry visitGetContentTask(GetContentTask task) => AnalysisContextImpl_th is._recordGetContentsTask(task);
5253 5123
5254 @override 5124 @override
5255 DartEntry visitIncrementalAnalysisTask(IncrementalAnalysisTask task) => Analys isContextImpl_this._recordIncrementalAnalysisTaskResults(task); 5125 DartEntry visitIncrementalAnalysisTask(IncrementalAnalysisTask task) => Analys isContextImpl_this._recordIncrementalAnalysisTaskResults(task);
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
5705 * @param library the library for which resolvable compilation units must be a vailable 5575 * @param library the library for which resolvable compilation units must be a vailable
5706 * @return a list of (source, entry) pairs for all of the compilation units in the library 5576 * @return a list of (source, entry) pairs for all of the compilation units in the library
5707 */ 5577 */
5708 List<CycleBuilder_SourceEntryPair> _ensurePartsInLibrary(ResolvableLibrary lib rary) { 5578 List<CycleBuilder_SourceEntryPair> _ensurePartsInLibrary(ResolvableLibrary lib rary) {
5709 List<CycleBuilder_SourceEntryPair> pairs = new List<CycleBuilder_SourceEntry Pair>(); 5579 List<CycleBuilder_SourceEntryPair> pairs = new List<CycleBuilder_SourceEntry Pair>();
5710 Source librarySource = library.librarySource; 5580 Source librarySource = library.librarySource;
5711 DartEntry libraryEntry = AnalysisContextImpl_this._getReadableDartEntry(libr arySource); 5581 DartEntry libraryEntry = AnalysisContextImpl_this._getReadableDartEntry(libr arySource);
5712 if (libraryEntry == null) { 5582 if (libraryEntry == null) {
5713 throw new AnalysisException("Cannot find entry for ${librarySource.fullNam e}"); 5583 throw new AnalysisException("Cannot find entry for ${librarySource.fullNam e}");
5714 } else if (libraryEntry.getState(DartEntry.PARSED_UNIT) == CacheState.ERROR) { 5584 } else if (libraryEntry.getState(DartEntry.PARSED_UNIT) == CacheState.ERROR) {
5715 throw new AnalysisException("Cannot compute parsed unit for ${librarySourc e.fullName}"); 5585 String message = "Cannot compute parsed unit for ${librarySource.fullName} ";
5586 CaughtException exception = libraryEntry.exception;
5587 if (exception == null) {
5588 throw new AnalysisException(message);
5589 }
5590 throw new AnalysisException(message, new CaughtException(exception, null)) ;
5716 } 5591 }
5717 _ensureResolvableCompilationUnit(librarySource, libraryEntry); 5592 _ensureResolvableCompilationUnit(librarySource, libraryEntry);
5718 pairs.add(new CycleBuilder_SourceEntryPair(librarySource, libraryEntry)); 5593 pairs.add(new CycleBuilder_SourceEntryPair(librarySource, libraryEntry));
5719 List<Source> partSources = _getSources(librarySource, libraryEntry, DartEntr y.INCLUDED_PARTS); 5594 List<Source> partSources = _getSources(librarySource, libraryEntry, DartEntr y.INCLUDED_PARTS);
5720 int count = partSources.length; 5595 int count = partSources.length;
5721 for (int i = 0; i < count; i++) { 5596 for (int i = 0; i < count; i++) {
5722 Source partSource = partSources[i]; 5597 Source partSource = partSources[i];
5723 DartEntry partEntry = AnalysisContextImpl_this._getReadableDartEntry(partS ource); 5598 DartEntry partEntry = AnalysisContextImpl_this._getReadableDartEntry(partS ource);
5724 if (partEntry != null && partEntry.getState(DartEntry.PARSED_UNIT) != Cach eState.ERROR) { 5599 if (partEntry != null && partEntry.getState(DartEntry.PARSED_UNIT) != Cach eState.ERROR) {
5725 _ensureResolvableCompilationUnit(partSource, partEntry); 5600 _ensureResolvableCompilationUnit(partSource, partEntry);
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after
6657 } 6532 }
6658 } 6533 }
6659 6534
6660 /** 6535 /**
6661 * The interface `AnalysisTaskVisitor` defines the behavior of objects that can visit tasks. 6536 * The interface `AnalysisTaskVisitor` defines the behavior of objects that can visit tasks.
6662 * While tasks are not structured in any interesting way, this class provides th e ability to 6537 * While tasks are not structured in any interesting way, this class provides th e ability to
6663 * dispatch to an appropriate method. 6538 * dispatch to an appropriate method.
6664 */ 6539 */
6665 abstract class AnalysisTaskVisitor<E> { 6540 abstract class AnalysisTaskVisitor<E> {
6666 /** 6541 /**
6667 * Visit a [BuildDartElementModelTask].
6668 *
6669 * @param task the task to be visited
6670 * @return the result of visiting the task
6671 * @throws AnalysisException if the visitor throws an exception for some reaso n
6672 */
6673 E visitBuildDartElementModelTask(BuildDartElementModelTask task);
6674
6675 /**
6676 * Visit a [GenerateDartErrorsTask]. 6542 * Visit a [GenerateDartErrorsTask].
6677 * 6543 *
6678 * @param task the task to be visited 6544 * @param task the task to be visited
6679 * @return the result of visiting the task 6545 * @return the result of visiting the task
6680 * @throws AnalysisException if the visitor throws an exception for some reaso n 6546 * @throws AnalysisException if the visitor throws an exception for some reaso n
6681 */ 6547 */
6682 E visitGenerateDartErrorsTask(GenerateDartErrorsTask task); 6548 E visitGenerateDartErrorsTask(GenerateDartErrorsTask task);
6683 6549
6684 /** 6550 /**
6685 * Visit a [GenerateDartHintsTask]. 6551 * Visit a [GenerateDartHintsTask].
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
7720 AstNode node = new NodeLocator.con1(offset).searchWithin(root); 7586 AstNode node = new NodeLocator.con1(offset).searchWithin(root);
7721 if (node != null) { 7587 if (node != null) {
7722 Element element = ElementLocator.locate(node); 7588 Element element = ElementLocator.locate(node);
7723 return new ht.XmlExpression_Reference(element, node.offset, node.length); 7589 return new ht.XmlExpression_Reference(element, node.offset, node.length);
7724 } 7590 }
7725 return null; 7591 return null;
7726 } 7592 }
7727 } 7593 }
7728 7594
7729 /** 7595 /**
7730 * Instances of the class `BuildDartElementModelTask` build the element models f or all of the
7731 * libraries in a cycle.
7732 */
7733 class BuildDartElementModelTask extends AnalysisTask {
7734 /**
7735 * The library for which an element model was originally requested.
7736 */
7737 final Source targetLibrary;
7738
7739 /**
7740 * The libraries that are part of the cycle to be resolved.
7741 */
7742 final List<ResolvableLibrary> librariesInCycle;
7743
7744 /**
7745 * The listener to which analysis errors will be reported.
7746 */
7747 RecordingErrorListener _errorListener;
7748
7749 /**
7750 * A source object representing the core library (dart:core).
7751 */
7752 Source _coreLibrarySource;
7753
7754 /**
7755 * The object representing the core library.
7756 */
7757 ResolvableLibrary _coreLibrary;
7758
7759 /**
7760 * A table mapping library sources to the information being maintained for tho se libraries.
7761 */
7762 HashMap<Source, ResolvableLibrary> _libraryMap = new HashMap<Source, Resolvabl eLibrary>();
7763
7764 /**
7765 * Initialize a newly created task to perform analysis within the given contex t.
7766 *
7767 * @param context the context in which the task is to be performed
7768 * @param targetLibrary the library for which an element model was originally requested
7769 * @param librariesInCycle the libraries that are part of the cycle to be reso lved
7770 */
7771 BuildDartElementModelTask(InternalAnalysisContext context, this.targetLibrary, this.librariesInCycle) : super(context) {
7772 this._errorListener = new RecordingErrorListener();
7773 _coreLibrarySource = context.sourceFactory.forUri(DartSdk.DART_CORE);
7774 }
7775
7776 @override
7777 accept(AnalysisTaskVisitor visitor) => visitor.visitBuildDartElementModelTask( this);
7778
7779 /**
7780 * Return the listener to which analysis errors were (or will be) reported.
7781 *
7782 * @return the listener to which analysis errors were reported
7783 */
7784 RecordingErrorListener get errorListener => _errorListener;
7785
7786 @override
7787 String get taskDescription {
7788 Source librarySource = librariesInCycle[0].librarySource;
7789 if (librarySource == null) {
7790 return "build an element model for unknown library";
7791 }
7792 return "build an element model for ${librarySource.fullName}";
7793 }
7794
7795 @override
7796 void internalPerform() {
7797 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.BuildDartElementModel.internalPerform");
7798 try {
7799 //
7800 // Build the map of libraries that are known.
7801 //
7802 _libraryMap = _buildLibraryMap();
7803 _coreLibrary = _libraryMap[_coreLibrarySource];
7804 LibraryElement coreElement = _coreLibrary.libraryElement;
7805 if (coreElement == null) {
7806 throw new AnalysisException("Could not resolve dart:core");
7807 }
7808 instrumentation.metric3("buildLibraryMap", "complete");
7809 //
7810 // Build the element models representing the libraries being resolved. Thi s is done in three
7811 // steps.
7812 //
7813 // 1. Build the basic element models without making any connections betwee n elements other than
7814 // the basic parent/child relationships. This includes building the ele ments representing the
7815 // libraries.
7816 //
7817 _buildElementModels();
7818 instrumentation.metric3("buildElementModels", "complete");
7819 //
7820 // 2. Build the elements for the import and export directives. This requir es that we have the
7821 // elements built for the referenced libraries, but because of the poss ibility of circular
7822 // references needs to happen after all of the library elements have be en created.
7823 //
7824 _buildDirectiveModels();
7825 instrumentation.metric3("buildDirectiveModels", "complete");
7826 //
7827 // 3. Build the rest of the type model by connecting superclasses, mixins, and interfaces. This
7828 // requires that we be able to compute the names visible in the librari es being resolved,
7829 // which in turn requires that we have resolved the import directives.
7830 //
7831 _buildTypeHierarchies(new TypeProviderImpl(coreElement));
7832 instrumentation.metric3("buildTypeHierarchies", "complete");
7833 instrumentation.metric2("librariesInCycles", librariesInCycle.length);
7834 for (ResolvableLibrary lib in librariesInCycle) {
7835 instrumentation.metric2("librariesInCycles-CompilationUnitSources-Size", lib.compilationUnitSources.length);
7836 }
7837 } finally {
7838 instrumentation.log();
7839 }
7840 }
7841
7842 /**
7843 * Build the element model representing the combinators declared by the given directive.
7844 *
7845 * @param directive the directive that declares the combinators
7846 * @return an array containing the import combinators that were built
7847 */
7848 List<NamespaceCombinator> _buildCombinators(NamespaceDirective directive) {
7849 List<NamespaceCombinator> combinators = new List<NamespaceCombinator>();
7850 for (Combinator combinator in directive.combinators) {
7851 if (combinator is HideCombinator) {
7852 HideElementCombinatorImpl hide = new HideElementCombinatorImpl();
7853 hide.hiddenNames = _getIdentifiers(combinator.hiddenNames);
7854 combinators.add(hide);
7855 } else {
7856 ShowElementCombinatorImpl show = new ShowElementCombinatorImpl();
7857 show.offset = combinator.offset;
7858 show.end = combinator.end;
7859 show.shownNames = _getIdentifiers((combinator as ShowCombinator).shownNa mes);
7860 combinators.add(show);
7861 }
7862 }
7863 return new List.from(combinators);
7864 }
7865
7866 /**
7867 * Every library now has a corresponding [LibraryElement], so it is now possib le to resolve
7868 * the import and export directives.
7869 *
7870 * @throws AnalysisException if the defining compilation unit for any of the l ibraries could not
7871 * be accessed
7872 */
7873 void _buildDirectiveModels() {
7874 AnalysisContext analysisContext = context;
7875 for (ResolvableLibrary library in librariesInCycle) {
7876 HashMap<String, PrefixElementImpl> nameToPrefixMap = new HashMap<String, P refixElementImpl>();
7877 List<ImportElement> imports = new List<ImportElement>();
7878 List<ExportElement> exports = new List<ExportElement>();
7879 for (Directive directive in library.definingCompilationUnit.directives) {
7880 if (directive is ImportDirective) {
7881 ImportDirective importDirective = directive;
7882 String uriContent = importDirective.uriContent;
7883 if (DartUriResolver.isDartExtUri(uriContent)) {
7884 library.libraryElement.hasExtUri = true;
7885 }
7886 Source importedSource = importDirective.source;
7887 if (importedSource != null && analysisContext.exists(importedSource)) {
7888 // The imported source will be null if the URI in the import directi ve was invalid.
7889 ResolvableLibrary importedLibrary = _libraryMap[importedSource];
7890 if (importedLibrary != null) {
7891 ImportElementImpl importElement = new ImportElementImpl(directive. offset);
7892 StringLiteral uriLiteral = importDirective.uri;
7893 if (uriLiteral != null) {
7894 importElement.uriOffset = uriLiteral.offset;
7895 importElement.uriEnd = uriLiteral.end;
7896 }
7897 importElement.uri = uriContent;
7898 importElement.combinators = _buildCombinators(importDirective);
7899 LibraryElement importedLibraryElement = importedLibrary.libraryEle ment;
7900 if (importedLibraryElement != null) {
7901 importElement.importedLibrary = importedLibraryElement;
7902 }
7903 SimpleIdentifier prefixNode = directive.prefix;
7904 if (prefixNode != null) {
7905 importElement.prefixOffset = prefixNode.offset;
7906 String prefixName = prefixNode.name;
7907 PrefixElementImpl prefix = nameToPrefixMap[prefixName];
7908 if (prefix == null) {
7909 prefix = new PrefixElementImpl.forNode(prefixNode);
7910 nameToPrefixMap[prefixName] = prefix;
7911 }
7912 importElement.prefix = prefix;
7913 prefixNode.staticElement = prefix;
7914 }
7915 directive.element = importElement;
7916 imports.add(importElement);
7917 if (analysisContext.computeKindOf(importedSource) != SourceKind.LI BRARY) {
7918 ErrorCode errorCode = (importElement.isDeferred ? StaticWarningC ode.IMPORT_OF_NON_LIBRARY : CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY);
7919 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, errorCode, [uriLiteral.toSource()]));
7920 }
7921 }
7922 }
7923 } else if (directive is ExportDirective) {
7924 ExportDirective exportDirective = directive;
7925 Source exportedSource = exportDirective.source;
7926 if (exportedSource != null && analysisContext.exists(exportedSource)) {
7927 // The exported source will be null if the URI in the export directi ve was invalid.
7928 ResolvableLibrary exportedLibrary = _libraryMap[exportedSource];
7929 if (exportedLibrary != null) {
7930 ExportElementImpl exportElement = new ExportElementImpl();
7931 StringLiteral uriLiteral = exportDirective.uri;
7932 if (uriLiteral != null) {
7933 exportElement.uriOffset = uriLiteral.offset;
7934 exportElement.uriEnd = uriLiteral.end;
7935 }
7936 exportElement.uri = exportDirective.uriContent;
7937 exportElement.combinators = _buildCombinators(exportDirective);
7938 LibraryElement exportedLibraryElement = exportedLibrary.libraryEle ment;
7939 if (exportedLibraryElement != null) {
7940 exportElement.exportedLibrary = exportedLibraryElement;
7941 }
7942 directive.element = exportElement;
7943 exports.add(exportElement);
7944 if (analysisContext.computeKindOf(exportedSource) != SourceKind.LI BRARY) {
7945 _errorListener.onError(new AnalysisError.con2(library.librarySou rce, uriLiteral.offset, uriLiteral.length, CompileTimeErrorCode.EXPORT_OF_NON_LI BRARY, [uriLiteral.toSource()]));
7946 }
7947 }
7948 }
7949 }
7950 }
7951 Source librarySource = library.librarySource;
7952 if (!library.explicitlyImportsCore && _coreLibrarySource != librarySource) {
7953 ImportElementImpl importElement = new ImportElementImpl(-1);
7954 importElement.importedLibrary = _coreLibrary.libraryElement;
7955 importElement.synthetic = true;
7956 imports.add(importElement);
7957 }
7958 LibraryElementImpl libraryElement = library.libraryElement;
7959 libraryElement.imports = new List.from(imports);
7960 libraryElement.exports = new List.from(exports);
7961 if (libraryElement.entryPoint == null) {
7962 Namespace namespace = new NamespaceBuilder().createExportNamespaceForLib rary(libraryElement);
7963 Element element = namespace.get(LibraryElementBuilder.ENTRY_POINT_NAME);
7964 if (element is FunctionElement) {
7965 libraryElement.entryPoint = element;
7966 }
7967 }
7968 }
7969 }
7970
7971 /**
7972 * Build element models for all of the libraries in the current cycle.
7973 *
7974 * @throws AnalysisException if any of the element models cannot be built
7975 */
7976 void _buildElementModels() {
7977 for (ResolvableLibrary library in librariesInCycle) {
7978 LibraryElementBuilder builder = new LibraryElementBuilder(context, _errorL istener);
7979 LibraryElementImpl libraryElement = builder.buildLibrary2(library);
7980 library.libraryElement = libraryElement;
7981 }
7982 }
7983
7984 /**
7985 * Build a table mapping library sources to the resolvable libraries represent ing those libraries.
7986 *
7987 * @return the map that was built
7988 */
7989 HashMap<Source, ResolvableLibrary> _buildLibraryMap() {
7990 HashMap<Source, ResolvableLibrary> libraryMap = new HashMap<Source, Resolvab leLibrary>();
7991 int libraryCount = librariesInCycle.length;
7992 for (int i = 0; i < libraryCount; i++) {
7993 ResolvableLibrary library = librariesInCycle[i];
7994 library.errorListener = _errorListener;
7995 libraryMap[library.librarySource] = library;
7996 List<ResolvableLibrary> dependencies = library.importsAndExports;
7997 int dependencyCount = dependencies.length;
7998 for (int j = 0; j < dependencyCount; j++) {
7999 ResolvableLibrary dependency = dependencies[j];
8000 //dependency.setErrorListener(errorListener);
8001 libraryMap[dependency.librarySource] = dependency;
8002 }
8003 }
8004 return libraryMap;
8005 }
8006
8007 /**
8008 * Resolve the type hierarchy across all of the types declared in the librarie s in the current
8009 * cycle.
8010 *
8011 * @throws AnalysisException if any of the type hierarchies could not be resol ved
8012 */
8013 void _buildTypeHierarchies(TypeProvider typeProvider) {
8014 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art();
8015 try {
8016 for (ResolvableLibrary library in librariesInCycle) {
8017 for (ResolvableCompilationUnit unit in library.resolvableCompilationUnit s) {
8018 Source source = unit.source;
8019 CompilationUnit ast = unit.compilationUnit;
8020 TypeResolverVisitor visitor = new TypeResolverVisitor.con4(library, so urce, typeProvider);
8021 ast.accept(visitor);
8022 }
8023 }
8024 } finally {
8025 timeCounter.stop();
8026 }
8027 }
8028
8029 /**
8030 * Return an array containing the lexical identifiers associated with the node s in the given list.
8031 *
8032 * @param names the AST nodes representing the identifiers
8033 * @return the lexical identifiers associated with the nodes in the list
8034 */
8035 List<String> _getIdentifiers(NodeList<SimpleIdentifier> names) {
8036 int count = names.length;
8037 List<String> identifiers = new List<String>(count);
8038 for (int i = 0; i < count; i++) {
8039 identifiers[i] = names[i].name;
8040 }
8041 return identifiers;
8042 }
8043 }
8044
8045 /**
8046 * Instances of the class `CachePartition` implement a single partition in an LR U cache of 7596 * Instances of the class `CachePartition` implement a single partition in an LR U cache of
8047 * information related to analysis. 7597 * information related to analysis.
8048 */ 7598 */
8049 abstract class CachePartition { 7599 abstract class CachePartition {
8050 /** 7600 /**
8051 * A table mapping the sources known to the context to the information known a bout the source. 7601 * A table mapping the sources known to the context to the information known a bout the source.
8052 */ 7602 */
8053 HashMap<Source, SourceEntry> _sourceMap = new HashMap<Source, SourceEntry>(); 7603 HashMap<Source, SourceEntry> _sourceMap = new HashMap<Source, SourceEntry>();
8054 7604
8055 /** 7605 /**
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
8764 * The interface `DartEntry` defines the behavior of objects that maintain the i nformation 8314 * The interface `DartEntry` defines the behavior of objects that maintain the i nformation
8765 * cached by an analysis context about an individual Dart file. 8315 * cached by an analysis context about an individual Dart file.
8766 */ 8316 */
8767 abstract class DartEntry implements SourceEntry { 8317 abstract class DartEntry implements SourceEntry {
8768 /** 8318 /**
8769 * The data descriptor representing the errors reported during Angular resolut ion. 8319 * The data descriptor representing the errors reported during Angular resolut ion.
8770 */ 8320 */
8771 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS = new DataDesc riptor<List<AnalysisError>>("DartEntry.ANGULAR_ERRORS"); 8321 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS = new DataDesc riptor<List<AnalysisError>>("DartEntry.ANGULAR_ERRORS");
8772 8322
8773 /** 8323 /**
8774 * The data descriptor representing the errors reported while building an elem ent model.
8775 */
8776 static final DataDescriptor<List<AnalysisError>> BUILD_ELEMENT_ERRORS = new Da taDescriptor<List<AnalysisError>>("DartEntry.BUILD_ELEMENT_ERRORS");
8777
8778 /**
8779 * The data descriptor representing the AST structure resulting from building the element model.
8780 */
8781 static final DataDescriptor<CompilationUnit> BUILT_UNIT = new DataDescriptor<C ompilationUnit>("DartEntry.BUILT_UNIT");
8782
8783 /**
8784 * The data descriptor representing the list of libraries that contain this co mpilation unit. 8324 * The data descriptor representing the list of libraries that contain this co mpilation unit.
8785 */ 8325 */
8786 static final DataDescriptor<List<Source>> CONTAINING_LIBRARIES = new DataDescr iptor<List<Source>>("DartEntry.CONTAINING_LIBRARIES"); 8326 static final DataDescriptor<List<Source>> CONTAINING_LIBRARIES = new DataDescr iptor<List<Source>>("DartEntry.CONTAINING_LIBRARIES");
8787 8327
8788 /** 8328 /**
8789 * The data descriptor representing the library element for the library. This data is only 8329 * The data descriptor representing the library element for the library. This data is only
8790 * available for Dart files that are the defining compilation unit of a librar y. 8330 * available for Dart files that are the defining compilation unit of a librar y.
8791 */ 8331 */
8792 static final DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<Libra ryElement>("DartEntry.ELEMENT"); 8332 static final DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<Libra ryElement>("DartEntry.ELEMENT");
8793 8333
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
9266 } else { 8806 } else {
9267 return super.getState(descriptor); 8807 return super.getState(descriptor);
9268 } 8808 }
9269 } 8809 }
9270 8810
9271 @override 8811 @override
9272 CacheState getStateInLibrary(DataDescriptor descriptor, Source librarySource) { 8812 CacheState getStateInLibrary(DataDescriptor descriptor, Source librarySource) {
9273 DartEntryImpl_ResolutionState state = _resolutionState; 8813 DartEntryImpl_ResolutionState state = _resolutionState;
9274 while (state != null) { 8814 while (state != null) {
9275 if (librarySource == state._librarySource) { 8815 if (librarySource == state._librarySource) {
9276 if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS)) { 8816 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
9277 return state._buildElementErrorsState;
9278 } else if (identical(descriptor, DartEntry.BUILT_UNIT)) {
9279 return state._builtUnitState;
9280 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
9281 return state._resolutionErrorsState; 8817 return state._resolutionErrorsState;
9282 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 8818 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
9283 return state._resolvedUnitState; 8819 return state._resolvedUnitState;
9284 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 8820 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
9285 return state._verificationErrorsState; 8821 return state._verificationErrorsState;
9286 } else if (identical(descriptor, DartEntry.HINTS)) { 8822 } else if (identical(descriptor, DartEntry.HINTS)) {
9287 return state._hintsState; 8823 return state._hintsState;
9288 } else { 8824 } else {
9289 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" ); 8825 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" );
9290 } 8826 }
9291 } 8827 }
9292 state = state._nextState; 8828 state = state._nextState;
9293 } 8829 }
9294 ; 8830 ;
9295 if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS) || identical(descr iptor, DartEntry.BUILT_UNIT) || identical(descriptor, DartEntry.RESOLUTION_ERROR S) || identical(descriptor, DartEntry.RESOLVED_UNIT) || identical(descriptor, Da rtEntry.VERIFICATION_ERRORS) || identical(descriptor, DartEntry.HINTS)) { 8831 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript or, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICATION_ERR ORS) || identical(descriptor, DartEntry.HINTS)) {
9296 return CacheState.INVALID; 8832 return CacheState.INVALID;
9297 } else { 8833 } else {
9298 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 8834 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
9299 } 8835 }
9300 } 8836 }
9301 8837
9302 @override 8838 @override
9303 Object getValue(DataDescriptor descriptor) { 8839 Object getValue(DataDescriptor descriptor) {
9304 if (identical(descriptor, DartEntry.ANGULAR_ERRORS)) { 8840 if (identical(descriptor, DartEntry.ANGULAR_ERRORS)) {
9305 return _angularErrors; 8841 return _angularErrors;
(...skipping 26 matching lines...) Expand all
9332 return _tokenStream; 8868 return _tokenStream;
9333 } 8869 }
9334 return super.getValue(descriptor); 8870 return super.getValue(descriptor);
9335 } 8871 }
9336 8872
9337 @override 8873 @override
9338 Object getValueInLibrary(DataDescriptor descriptor, Source librarySource) { 8874 Object getValueInLibrary(DataDescriptor descriptor, Source librarySource) {
9339 DartEntryImpl_ResolutionState state = _resolutionState; 8875 DartEntryImpl_ResolutionState state = _resolutionState;
9340 while (state != null) { 8876 while (state != null) {
9341 if (librarySource == state._librarySource) { 8877 if (librarySource == state._librarySource) {
9342 if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS)) { 8878 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
9343 return state._buildElementErrors;
9344 } else if (identical(descriptor, DartEntry.BUILT_UNIT)) {
9345 return state._builtUnit;
9346 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
9347 return state._resolutionErrors; 8879 return state._resolutionErrors;
9348 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 8880 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
9349 return state._resolvedUnit; 8881 return state._resolvedUnit;
9350 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 8882 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
9351 return state._verificationErrors; 8883 return state._verificationErrors;
9352 } else if (identical(descriptor, DartEntry.HINTS)) { 8884 } else if (identical(descriptor, DartEntry.HINTS)) {
9353 return state._hints; 8885 return state._hints;
9354 } else { 8886 } else {
9355 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" ); 8887 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}" );
9356 } 8888 }
9357 } 8889 }
9358 state = state._nextState; 8890 state = state._nextState;
9359 } 8891 }
9360 ; 8892 ;
9361 if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS) || identical(descr iptor, DartEntry.RESOLUTION_ERRORS) || identical(descriptor, DartEntry.VERIFICAT ION_ERRORS) || identical(descriptor, DartEntry.HINTS)) { 8893 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript or, DartEntry.VERIFICATION_ERRORS) || identical(descriptor, DartEntry.HINTS)) {
9362 return AnalysisError.NO_ERRORS; 8894 return AnalysisError.NO_ERRORS;
9363 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 8895 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
9364 return null; 8896 return null;
9365 } else { 8897 } else {
9366 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 8898 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
9367 } 8899 }
9368 } 8900 }
9369 8901
9370 @override 8902 @override
9371 DartEntryImpl get writableCopy { 8903 DartEntryImpl get writableCopy {
(...skipping 21 matching lines...) Expand all
9393 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { 8925 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) {
9394 return _parsedUnitState == CacheState.INVALID; 8926 return _parsedUnitState == CacheState.INVALID;
9395 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { 8927 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) {
9396 return _publicNamespaceState == CacheState.INVALID; 8928 return _publicNamespaceState == CacheState.INVALID;
9397 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) { 8929 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) {
9398 return _scanErrorsState == CacheState.INVALID; 8930 return _scanErrorsState == CacheState.INVALID;
9399 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { 8931 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) {
9400 return _sourceKindState == CacheState.INVALID; 8932 return _sourceKindState == CacheState.INVALID;
9401 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) { 8933 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) {
9402 return _tokenStreamState == CacheState.INVALID; 8934 return _tokenStreamState == CacheState.INVALID;
9403 } else if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS) || identica l(descriptor, DartEntry.BUILT_UNIT) || identical(descriptor, DartEntry.RESOLUTIO N_ERRORS) || identical(descriptor, DartEntry.RESOLVED_UNIT) || identical(descrip tor, DartEntry.VERIFICATION_ERRORS) || identical(descriptor, DartEntry.HINTS)) { 8935 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(d escriptor, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICAT ION_ERRORS) || identical(descriptor, DartEntry.HINTS)) {
9404 DartEntryImpl_ResolutionState state = _resolutionState; 8936 DartEntryImpl_ResolutionState state = _resolutionState;
9405 while (state != null) { 8937 while (state != null) {
9406 if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS)) { 8938 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
9407 return state._buildElementErrorsState == CacheState.INVALID;
9408 } else if (identical(descriptor, DartEntry.BUILT_UNIT)) {
9409 return state._builtUnitState == CacheState.INVALID;
9410 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
9411 return state._resolutionErrorsState == CacheState.INVALID; 8939 return state._resolutionErrorsState == CacheState.INVALID;
9412 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 8940 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
9413 return state._resolvedUnitState == CacheState.INVALID; 8941 return state._resolvedUnitState == CacheState.INVALID;
9414 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 8942 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
9415 return state._verificationErrorsState == CacheState.INVALID; 8943 return state._verificationErrorsState == CacheState.INVALID;
9416 } else if (identical(descriptor, DartEntry.HINTS)) { 8944 } else if (identical(descriptor, DartEntry.HINTS)) {
9417 return state._hintsState == CacheState.INVALID; 8945 return state._hintsState == CacheState.INVALID;
9418 } 8946 }
9419 } 8947 }
9420 return false; 8948 return false;
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
9854 * Set the state of the data represented by the given descriptor in the contex t of the given 9382 * Set the state of the data represented by the given descriptor in the contex t of the given
9855 * library to the given state. 9383 * library to the given state.
9856 * 9384 *
9857 * @param descriptor the descriptor representing the data whose state is to be set 9385 * @param descriptor the descriptor representing the data whose state is to be set
9858 * @param librarySource the source of the defining compilation unit of the lib rary that is the 9386 * @param librarySource the source of the defining compilation unit of the lib rary that is the
9859 * context for the data 9387 * context for the data
9860 * @param cacheState the new state of the data represented by the given descri ptor 9388 * @param cacheState the new state of the data represented by the given descri ptor
9861 */ 9389 */
9862 void setStateInLibrary(DataDescriptor descriptor, Source librarySource, CacheS tate cacheState) { 9390 void setStateInLibrary(DataDescriptor descriptor, Source librarySource, CacheS tate cacheState) {
9863 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou rce); 9391 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou rce);
9864 if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS)) { 9392 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
9865 state._buildElementErrors = updatedValue(cacheState, state._buildElementEr rors, AnalysisError.NO_ERRORS);
9866 state._buildElementErrorsState = cacheState;
9867 } else if (identical(descriptor, DartEntry.BUILT_UNIT)) {
9868 state._builtUnit = updatedValue(cacheState, state._builtUnit, null);
9869 state._builtUnitState = cacheState;
9870 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
9871 state._resolutionErrors = updatedValue(cacheState, state._resolutionErrors , AnalysisError.NO_ERRORS); 9393 state._resolutionErrors = updatedValue(cacheState, state._resolutionErrors , AnalysisError.NO_ERRORS);
9872 state._resolutionErrorsState = cacheState; 9394 state._resolutionErrorsState = cacheState;
9873 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 9395 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
9874 state._resolvedUnit = updatedValue(cacheState, state._resolvedUnit, null); 9396 state._resolvedUnit = updatedValue(cacheState, state._resolvedUnit, null);
9875 state._resolvedUnitState = cacheState; 9397 state._resolvedUnitState = cacheState;
9876 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 9398 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
9877 state._verificationErrors = updatedValue(cacheState, state._verificationEr rors, AnalysisError.NO_ERRORS); 9399 state._verificationErrors = updatedValue(cacheState, state._verificationEr rors, AnalysisError.NO_ERRORS);
9878 state._verificationErrorsState = cacheState; 9400 state._verificationErrorsState = cacheState;
9879 } else if (identical(descriptor, DartEntry.HINTS)) { 9401 } else if (identical(descriptor, DartEntry.HINTS)) {
9880 state._hints = updatedValue(cacheState, state._hints, AnalysisError.NO_ERR ORS); 9402 state._hints = updatedValue(cacheState, state._hints, AnalysisError.NO_ERR ORS);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
9934 * Set the value of the data represented by the given descriptor in the contex t of the given 9456 * Set the value of the data represented by the given descriptor in the contex t of the given
9935 * library to the given value, and set the state of that data to [CacheState#V ALID]. 9457 * library to the given value, and set the state of that data to [CacheState#V ALID].
9936 * 9458 *
9937 * @param descriptor the descriptor representing which data is to have its val ue set 9459 * @param descriptor the descriptor representing which data is to have its val ue set
9938 * @param librarySource the source of the defining compilation unit of the lib rary that is the 9460 * @param librarySource the source of the defining compilation unit of the lib rary that is the
9939 * context for the data 9461 * context for the data
9940 * @param value the new value of the data represented by the given descriptor and library 9462 * @param value the new value of the data represented by the given descriptor and library
9941 */ 9463 */
9942 void setValueInLibrary(DataDescriptor descriptor, Source librarySource, Object value) { 9464 void setValueInLibrary(DataDescriptor descriptor, Source librarySource, Object value) {
9943 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou rce); 9465 DartEntryImpl_ResolutionState state = _getOrCreateResolutionState(librarySou rce);
9944 if (identical(descriptor, DartEntry.BUILD_ELEMENT_ERRORS)) { 9466 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
9945 state._buildElementErrors = value == null ? AnalysisError.NO_ERRORS : (val ue as List<AnalysisError>);
9946 state._buildElementErrorsState = CacheState.VALID;
9947 } else if (identical(descriptor, DartEntry.BUILT_UNIT)) {
9948 state._builtUnit = value as CompilationUnit;
9949 state._builtUnitState = CacheState.VALID;
9950 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) {
9951 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<AnalysisError>); 9467 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<AnalysisError>);
9952 state._resolutionErrorsState = CacheState.VALID; 9468 state._resolutionErrorsState = CacheState.VALID;
9953 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { 9469 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) {
9954 state._resolvedUnit = value as CompilationUnit; 9470 state._resolvedUnit = value as CompilationUnit;
9955 state._resolvedUnitState = CacheState.VALID; 9471 state._resolvedUnitState = CacheState.VALID;
9956 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { 9472 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) {
9957 state._verificationErrors = value == null ? AnalysisError.NO_ERRORS : (val ue as List<AnalysisError>); 9473 state._verificationErrors = value == null ? AnalysisError.NO_ERRORS : (val ue as List<AnalysisError>);
9958 state._verificationErrorsState = CacheState.VALID; 9474 state._verificationErrorsState = CacheState.VALID;
9959 } else if (identical(descriptor, DartEntry.HINTS)) { 9475 } else if (identical(descriptor, DartEntry.HINTS)) {
9960 state._hints = value == null ? AnalysisError.NO_ERRORS : (value as List<An alysisError>); 9476 state._hints = value == null ? AnalysisError.NO_ERRORS : (value as List<An alysisError>);
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
10413 9929
10414 /** 9930 /**
10415 * Write a textual representation of the difference between the old entry and this entry to the 9931 * Write a textual representation of the difference between the old entry and this entry to the
10416 * given string builder. 9932 * given string builder.
10417 * 9933 *
10418 * @param builder the string builder to which the difference is to be written 9934 * @param builder the string builder to which the difference is to be written
10419 * @param oldEntry the entry that was replaced by this entry 9935 * @param oldEntry the entry that was replaced by this entry
10420 * @return `true` if some difference was written 9936 * @return `true` if some difference was written
10421 */ 9937 */
10422 bool writeDiffOn(JavaStringBuilder builder, bool needsSeparator, DartEntry old Entry) { 9938 bool writeDiffOn(JavaStringBuilder builder, bool needsSeparator, DartEntry old Entry) {
10423 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.BUILT_UNIT, _builtUnitState, "builtUnit");
10424 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.BUILD_ELEMENT_ERRORS, _buildElementErrorsState, "buildElementErrors");
10425 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.RESOLVED_UNIT, _resolvedUnitState, "resolvedUnit"); 9939 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.RESOLVED_UNIT, _resolvedUnitState, "resolvedUnit");
10426 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.RESOLUTION_ERRORS, _resolutionErrorsState, "resolutionErrors"); 9940 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.RESOLUTION_ERRORS, _resolutionErrorsState, "resolutionErrors");
10427 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.VERIFICATION_ERRORS, _verificationErrorsState, "verificationErrors"); 9941 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.VERIFICATION_ERRORS, _verificationErrorsState, "verificationErrors");
10428 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.HINTS, _hintsState, "hints"); 9942 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt ry.HINTS, _hintsState, "hints");
10429 return needsSeparator; 9943 return needsSeparator;
10430 } 9944 }
10431 9945
10432 /** 9946 /**
10433 * Write a textual representation of this state to the given builder. The resu lt will only be 9947 * Write a textual representation of this state to the given builder. The resu lt will only be
10434 * used for debugging purposes. 9948 * used for debugging purposes.
(...skipping 5305 matching lines...) Expand 10 before | Expand all | Expand 10 after
15740 _index++; 15254 _index++;
15741 if (_index >= WorkManager_this._workQueues[_queueIndex].length) { 15255 if (_index >= WorkManager_this._workQueues[_queueIndex].length) {
15742 _index = 0; 15256 _index = 0;
15743 _queueIndex++; 15257 _queueIndex++;
15744 while (_queueIndex < WorkManager_this._workQueues.length && WorkManager_th is._workQueues[_queueIndex].isEmpty) { 15258 while (_queueIndex < WorkManager_this._workQueues.length && WorkManager_th is._workQueues[_queueIndex].isEmpty) {
15745 _queueIndex++; 15259 _queueIndex++;
15746 } 15260 }
15747 } 15261 }
15748 } 15262 }
15749 } 15263 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698