| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 | 3 |
| 4 library engine; | 4 library engine; |
| 5 | 5 |
| 6 import 'java_core.dart'; | 6 import 'java_core.dart'; |
| 7 import 'java_engine.dart'; | 7 import 'java_engine.dart'; |
| 8 import 'utilities_collection.dart'; | 8 import 'utilities_collection.dart'; |
| 9 import 'utilities_general.dart'; | 9 import 'utilities_general.dart'; |
| 10 import 'instrumentation.dart'; | 10 import 'instrumentation.dart'; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 static String SUFFIX_HTM = "htm"; | 36 static String SUFFIX_HTM = "htm"; |
| 37 | 37 |
| 38 /** | 38 /** |
| 39 * The long suffix used for HTML files. | 39 * The long suffix used for HTML files. |
| 40 */ | 40 */ |
| 41 static String SUFFIX_HTML = "html"; | 41 static String SUFFIX_HTML = "html"; |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * The unique instance of this class. | 44 * The unique instance of this class. |
| 45 */ | 45 */ |
| 46 static final AnalysisEngine instance = new AnalysisEngine(); | 46 static AnalysisEngine _UniqueInstance = new AnalysisEngine(); |
| 47 |
| 48 /** |
| 49 * Return the unique instance of this class. |
| 50 * |
| 51 * @return the unique instance of this class |
| 52 */ |
| 53 static AnalysisEngine get instance => _UniqueInstance; |
| 47 | 54 |
| 48 /** | 55 /** |
| 49 * Return `true` if the given file name is assumed to contain Dart source code
. | 56 * Return `true` if the given file name is assumed to contain Dart source code
. |
| 50 * | 57 * |
| 51 * @param fileName the name of the file being tested | 58 * @param fileName the name of the file being tested |
| 52 * @return `true` if the given file name is assumed to contain Dart source cod
e | 59 * @return `true` if the given file name is assumed to contain Dart source cod
e |
| 53 */ | 60 */ |
| 54 static bool isDartFileName(String fileName) { | 61 static bool isDartFileName(String fileName) { |
| 55 if (fileName == null) { | 62 if (fileName == null) { |
| 56 return false; | 63 return false; |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 } | 742 } |
| 736 | 743 |
| 737 /** | 744 /** |
| 738 * Instances of the class `AnalysisResult` | 745 * Instances of the class `AnalysisResult` |
| 739 */ | 746 */ |
| 740 class AnalysisResult { | 747 class AnalysisResult { |
| 741 /** | 748 /** |
| 742 * The change notices associated with this result, or `null` if there were no
changes and | 749 * The change notices associated with this result, or `null` if there were no
changes and |
| 743 * there is no more work to be done. | 750 * there is no more work to be done. |
| 744 */ | 751 */ |
| 745 List<ChangeNotice> changeNotices; | 752 List<ChangeNotice> _notices; |
| 746 | 753 |
| 747 /** | 754 /** |
| 748 * The number of milliseconds required to determine which task was to be perfo
rmed. | 755 * The number of milliseconds required to determine which task was to be perfo
rmed. |
| 749 */ | 756 */ |
| 750 int getTime = 0; | 757 final int getTime; |
| 751 | 758 |
| 752 /** | 759 /** |
| 753 * The name of the class of the task that was performed. | 760 * The name of the class of the task that was performed. |
| 754 */ | 761 */ |
| 755 String taskClassName; | 762 final String taskClassName; |
| 756 | 763 |
| 757 /** | 764 /** |
| 758 * The number of milliseconds required to perform the task. | 765 * The number of milliseconds required to perform the task. |
| 759 */ | 766 */ |
| 760 int performTime = 0; | 767 final int performTime; |
| 761 | 768 |
| 762 /** | 769 /** |
| 763 * Initialize a newly created analysis result to have the given values. | 770 * Initialize a newly created analysis result to have the given values. |
| 764 * | 771 * |
| 765 * @param notices the change notices associated with this result | 772 * @param notices the change notices associated with this result |
| 766 * @param getTime the number of milliseconds required to determine which task
was to be performed | 773 * @param getTime the number of milliseconds required to determine which task
was to be performed |
| 767 * @param taskClassName the name of the class of the task that was performed | 774 * @param taskClassName the name of the class of the task that was performed |
| 768 * @param performTime the number of milliseconds required to perform the task | 775 * @param performTime the number of milliseconds required to perform the task |
| 769 */ | 776 */ |
| 770 AnalysisResult(List<ChangeNotice> notices, int getTime, String taskClassName,
int performTime) { | 777 AnalysisResult(List<ChangeNotice> notices, this.getTime, this.taskClassName, t
his.performTime) { |
| 771 this.changeNotices = notices; | 778 this._notices = notices; |
| 772 this.getTime = getTime; | |
| 773 this.taskClassName = taskClassName; | |
| 774 this.performTime = performTime; | |
| 775 } | 779 } |
| 780 |
| 781 /** |
| 782 * Return the change notices associated with this result, or `null` if there w
ere no changes |
| 783 * and there is no more work to be done. |
| 784 * |
| 785 * @return the change notices associated with this result |
| 786 */ |
| 787 List<ChangeNotice> get changeNotices => _notices; |
| 776 } | 788 } |
| 777 | 789 |
| 778 /** | 790 /** |
| 779 * The interface `ChangeNotice` defines the behavior of objects that represent a
change to the | 791 * The interface `ChangeNotice` defines the behavior of objects that represent a
change to the |
| 780 * analysis results associated with a given source. | 792 * analysis results associated with a given source. |
| 781 * | 793 * |
| 782 * @coverage dart.engine | 794 * @coverage dart.engine |
| 783 */ | 795 */ |
| 784 abstract class ChangeNotice implements AnalysisErrorInfo { | 796 abstract class ChangeNotice implements AnalysisErrorInfo { |
| 785 /** | 797 /** |
| (...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2770 abstract class SourceEntryImpl implements SourceEntry { | 2782 abstract class SourceEntryImpl implements SourceEntry { |
| 2771 /** | 2783 /** |
| 2772 * The most recent time at which the state of the source matched the state rep
resented by this | 2784 * The most recent time at which the state of the source matched the state rep
resented by this |
| 2773 * entry. | 2785 * entry. |
| 2774 */ | 2786 */ |
| 2775 int _modificationTime = 0; | 2787 int _modificationTime = 0; |
| 2776 | 2788 |
| 2777 /** | 2789 /** |
| 2778 * The exception that caused one or more values to have a state of [CacheState
#ERROR]. | 2790 * The exception that caused one or more values to have a state of [CacheState
#ERROR]. |
| 2779 */ | 2791 */ |
| 2780 AnalysisException _exception; | 2792 AnalysisException exception; |
| 2781 | 2793 |
| 2782 /** | 2794 /** |
| 2783 * The state of the cached line information. | 2795 * The state of the cached line information. |
| 2784 */ | 2796 */ |
| 2785 CacheState _lineInfoState = CacheState.INVALID; | 2797 CacheState _lineInfoState = CacheState.INVALID; |
| 2786 | 2798 |
| 2787 /** | 2799 /** |
| 2788 * The line information computed for the source, or `null` if the line informa
tion is not | 2800 * The line information computed for the source, or `null` if the line informa
tion is not |
| 2789 * currently cached. | 2801 * currently cached. |
| 2790 */ | 2802 */ |
| 2791 LineInfo _lineInfo; | 2803 LineInfo _lineInfo; |
| 2792 | 2804 |
| 2793 /** | |
| 2794 * Return the exception that caused one or more values to have a state of [Cac
heState#ERROR] | |
| 2795 * . | |
| 2796 * | |
| 2797 * @return the exception that caused one or more values to be uncomputable | |
| 2798 */ | |
| 2799 AnalysisException get exception => _exception; | |
| 2800 | |
| 2801 int get modificationTime => _modificationTime; | 2805 int get modificationTime => _modificationTime; |
| 2802 | 2806 |
| 2803 CacheState getState(DataDescriptor descriptor) { | 2807 CacheState getState(DataDescriptor descriptor) { |
| 2804 if (identical(descriptor, SourceEntry.LINE_INFO)) { | 2808 if (identical(descriptor, SourceEntry.LINE_INFO)) { |
| 2805 return _lineInfoState; | 2809 return _lineInfoState; |
| 2806 } else { | 2810 } else { |
| 2807 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 2811 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 2808 } | 2812 } |
| 2809 } | 2813 } |
| 2810 | 2814 |
| 2811 Object getValue(DataDescriptor descriptor) { | 2815 Object getValue(DataDescriptor descriptor) { |
| 2812 if (identical(descriptor, SourceEntry.LINE_INFO)) { | 2816 if (identical(descriptor, SourceEntry.LINE_INFO)) { |
| 2813 return _lineInfo as Object; | 2817 return _lineInfo as Object; |
| 2814 } else { | 2818 } else { |
| 2815 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 2819 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 2816 } | 2820 } |
| 2817 } | 2821 } |
| 2818 | 2822 |
| 2819 /** | 2823 /** |
| 2820 * Set the exception that caused one or more values to have a state of [CacheS
tate#ERROR] to | |
| 2821 * the given exception. | |
| 2822 * | |
| 2823 * @param exception the exception that caused one or more values to be uncompu
table | |
| 2824 */ | |
| 2825 void set exception(AnalysisException exception) { | |
| 2826 this._exception = exception; | |
| 2827 } | |
| 2828 | |
| 2829 /** | |
| 2830 * Set the most recent time at which the state of the source matched the state
represented by this | 2824 * Set the most recent time at which the state of the source matched the state
represented by this |
| 2831 * entry to the given time. | 2825 * entry to the given time. |
| 2832 * | 2826 * |
| 2833 * @param time the new modification time of this entry | 2827 * @param time the new modification time of this entry |
| 2834 */ | 2828 */ |
| 2835 void set modificationTime(int time) { | 2829 void set modificationTime(int time) { |
| 2836 _modificationTime = time; | 2830 _modificationTime = time; |
| 2837 } | 2831 } |
| 2838 | 2832 |
| 2839 /** | 2833 /** |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2949 if (identical(state, CacheState.ERROR)) { | 2943 if (identical(state, CacheState.ERROR)) { |
| 2950 AnalysisException exception = dartEntry.exception; | 2944 AnalysisException exception = dartEntry.exception; |
| 2951 if (exception != null) { | 2945 if (exception != null) { |
| 2952 _exceptions.add(exception); | 2946 _exceptions.add(exception); |
| 2953 } | 2947 } |
| 2954 } | 2948 } |
| 2955 } | 2949 } |
| 2956 } | 2950 } |
| 2957 | 2951 |
| 2958 class AnalysisContentStatisticsImpl_CacheRowImpl implements AnalysisContentStati
stics_CacheRow { | 2952 class AnalysisContentStatisticsImpl_CacheRowImpl implements AnalysisContentStati
stics_CacheRow { |
| 2959 String _name; | 2953 final String name; |
| 2960 | 2954 |
| 2961 int _errorCount = 0; | 2955 int _errorCount = 0; |
| 2962 | 2956 |
| 2963 int _flushedCount = 0; | 2957 int _flushedCount = 0; |
| 2964 | 2958 |
| 2965 int _inProcessCount = 0; | 2959 int _inProcessCount = 0; |
| 2966 | 2960 |
| 2967 int _invalidCount = 0; | 2961 int _invalidCount = 0; |
| 2968 | 2962 |
| 2969 int _validCount = 0; | 2963 int _validCount = 0; |
| 2970 | 2964 |
| 2971 AnalysisContentStatisticsImpl_CacheRowImpl(String name) { | 2965 AnalysisContentStatisticsImpl_CacheRowImpl(this.name); |
| 2972 this._name = name; | |
| 2973 } | |
| 2974 | 2966 |
| 2975 bool operator ==(Object obj) => obj is AnalysisContentStatisticsImpl_CacheRowI
mpl && (obj as AnalysisContentStatisticsImpl_CacheRowImpl)._name == _name; | 2967 bool operator ==(Object obj) => obj is AnalysisContentStatisticsImpl_CacheRowI
mpl && (obj as AnalysisContentStatisticsImpl_CacheRowImpl).name == name; |
| 2976 | 2968 |
| 2977 int get errorCount => _errorCount; | 2969 int get errorCount => _errorCount; |
| 2978 | 2970 |
| 2979 int get flushedCount => _flushedCount; | 2971 int get flushedCount => _flushedCount; |
| 2980 | 2972 |
| 2981 int get inProcessCount => _inProcessCount; | 2973 int get inProcessCount => _inProcessCount; |
| 2982 | 2974 |
| 2983 int get invalidCount => _invalidCount; | 2975 int get invalidCount => _invalidCount; |
| 2984 | 2976 |
| 2985 String get name => _name; | |
| 2986 | |
| 2987 int get validCount => _validCount; | 2977 int get validCount => _validCount; |
| 2988 | 2978 |
| 2989 int get hashCode => _name.hashCode; | 2979 int get hashCode => name.hashCode; |
| 2990 | 2980 |
| 2991 void incState(CacheState state) { | 2981 void incState(CacheState state) { |
| 2992 if (identical(state, CacheState.ERROR)) { | 2982 if (identical(state, CacheState.ERROR)) { |
| 2993 _errorCount++; | 2983 _errorCount++; |
| 2994 } | 2984 } |
| 2995 if (identical(state, CacheState.FLUSHED)) { | 2985 if (identical(state, CacheState.FLUSHED)) { |
| 2996 _flushedCount++; | 2986 _flushedCount++; |
| 2997 } | 2987 } |
| 2998 if (identical(state, CacheState.IN_PROCESS)) { | 2988 if (identical(state, CacheState.IN_PROCESS)) { |
| 2999 _inProcessCount++; | 2989 _inProcessCount++; |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3578 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.RESOLUT
ION_ERRORS); | 3568 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.RESOLUT
ION_ERRORS); |
| 3579 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.RESOLVE
D_UNIT); | 3569 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.RESOLVE
D_UNIT); |
| 3580 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.VERIFIC
ATION_ERRORS); | 3570 statistics.putCacheItem2(dartEntry, librarySource, DartEntry.VERIFIC
ATION_ERRORS); |
| 3581 } | 3571 } |
| 3582 } | 3572 } |
| 3583 } | 3573 } |
| 3584 } | 3574 } |
| 3585 return statistics; | 3575 return statistics; |
| 3586 } | 3576 } |
| 3587 | 3577 |
| 3578 TypeProvider get typeProvider { |
| 3579 Source coreSource = sourceFactory.forUri(DartSdk.DART_CORE); |
| 3580 return new TypeProviderImpl(computeLibraryElement(coreSource)); |
| 3581 } |
| 3582 |
| 3588 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou
rce, LibraryElement libraryElement) { | 3583 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou
rce, LibraryElement libraryElement) { |
| 3589 DartEntry dartEntry = getReadableDartEntry(unitSource); | 3584 DartEntry dartEntry = getReadableDartEntry(unitSource); |
| 3590 if (dartEntry == null) { | 3585 if (dartEntry == null) { |
| 3591 throw new AnalysisException.con1("internalResolveCompilationUnit invoked f
or non-Dart file: ${unitSource.fullName}"); | 3586 throw new AnalysisException.con1("internalResolveCompilationUnit invoked f
or non-Dart file: ${unitSource.fullName}"); |
| 3592 } | 3587 } |
| 3593 Source librarySource = libraryElement.source; | 3588 Source librarySource = libraryElement.source; |
| 3594 dartEntry = cacheDartResolutionData(unitSource, librarySource, dartEntry, Da
rtEntry.RESOLVED_UNIT); | 3589 dartEntry = cacheDartResolutionData(unitSource, librarySource, dartEntry, Da
rtEntry.RESOLVED_UNIT); |
| 3595 return new TimestampedData<CompilationUnit>(dartEntry.modificationTime, dart
Entry.getValue2(DartEntry.RESOLVED_UNIT, librarySource)); | 3590 return new TimestampedData<CompilationUnit>(dartEntry.modificationTime, dart
Entry.getValue2(DartEntry.RESOLVED_UNIT, librarySource)); |
| 3596 } | 3591 } |
| 3597 | 3592 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3778 List<Source> librarySources = new List<Source>(); | 3773 List<Source> librarySources = new List<Source>(); |
| 3779 for (Source source in changedSources) { | 3774 for (Source source in changedSources) { |
| 3780 if (identical(computeKindOf(source), SourceKind.LIBRARY)) { | 3775 if (identical(computeKindOf(source), SourceKind.LIBRARY)) { |
| 3781 librarySources.add(source); | 3776 librarySources.add(source); |
| 3782 } | 3777 } |
| 3783 } | 3778 } |
| 3784 return librarySources; | 3779 return librarySources; |
| 3785 } | 3780 } |
| 3786 | 3781 |
| 3787 /** | 3782 /** |
| 3783 * Record the results produced by performing a [ResolveDartLibraryTask]. If th
e results were |
| 3784 * computed from data that is now out-of-date, then the results will not be re
corded. |
| 3785 * |
| 3786 * @param task the task that was performed |
| 3787 * @return an entry containing the computed results |
| 3788 * @throws AnalysisException if the results could not be recorded |
| 3789 */ |
| 3790 DartEntry recordResolveDartLibraryTaskResults(ResolveDartLibraryTask task) { |
| 3791 LibraryResolver resolver = task.libraryResolver; |
| 3792 AnalysisException thrownException = task.exception; |
| 3793 DartEntry unitEntry = null; |
| 3794 Source unitSource = task.unitSource; |
| 3795 if (resolver != null) { |
| 3796 Set<Library> resolvedLibraries = resolver.resolvedLibraries; |
| 3797 if (resolvedLibraries == null) { |
| 3798 unitEntry = getReadableDartEntry(unitSource); |
| 3799 if (unitEntry == null) { |
| 3800 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${unitSource.fullName}"); |
| 3801 } |
| 3802 DartEntryImpl dartCopy = unitEntry.writableCopy; |
| 3803 dartCopy.recordResolutionError(); |
| 3804 dartCopy.exception = thrownException; |
| 3805 _cache.put(unitSource, dartCopy); |
| 3806 if (thrownException != null) { |
| 3807 throw thrownException; |
| 3808 } |
| 3809 return dartCopy; |
| 3810 } |
| 3811 { |
| 3812 if (allModificationTimesMatch(resolvedLibraries)) { |
| 3813 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); |
| 3814 RecordingErrorListener errorListener = resolver.errorListener; |
| 3815 for (Library library in resolvedLibraries) { |
| 3816 Source librarySource = library.librarySource; |
| 3817 for (Source source in library.compilationUnitSources) { |
| 3818 CompilationUnit unit = library.getAST(source); |
| 3819 List<AnalysisError> errors = errorListener.getErrors2(source); |
| 3820 LineInfo lineInfo = getLineInfo(source); |
| 3821 DartEntry dartEntry = _cache.get(source) as DartEntry; |
| 3822 int sourceTime = source.modificationStamp; |
| 3823 if (dartEntry.modificationTime != sourceTime) { |
| 3824 sourceChanged(source); |
| 3825 dartEntry = getReadableDartEntry(source); |
| 3826 if (dartEntry == null) { |
| 3827 throw new AnalysisException.con1("A Dart file became a non-Dar
t file: ${source.fullName}"); |
| 3828 } |
| 3829 } |
| 3830 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 3831 if (thrownException == null) { |
| 3832 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 3833 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 3834 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, unit)
; |
| 3835 dartCopy.setValue2(DartEntry.RESOLUTION_ERRORS, librarySource, e
rrors); |
| 3836 if (identical(source, librarySource)) { |
| 3837 recordElementData(dartCopy, library.libraryElement, htmlSource
); |
| 3838 } |
| 3839 } else { |
| 3840 dartCopy.recordResolutionError(); |
| 3841 } |
| 3842 dartCopy.exception = thrownException; |
| 3843 _cache.put(source, dartCopy); |
| 3844 if (source == unitSource) { |
| 3845 unitEntry = dartCopy; |
| 3846 } |
| 3847 ChangeNoticeImpl notice = getNotice(source); |
| 3848 notice.compilationUnit = unit; |
| 3849 notice.setErrors(dartCopy.allErrors, lineInfo); |
| 3850 } |
| 3851 } |
| 3852 } else { |
| 3853 for (Library library in resolvedLibraries) { |
| 3854 for (Source source in library.compilationUnitSources) { |
| 3855 DartEntry dartEntry = getReadableDartEntry(source); |
| 3856 if (dartEntry != null) { |
| 3857 int resultTime = library.getModificationTime(source); |
| 3858 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 3859 if (thrownException == null || resultTime >= 0) { |
| 3860 dartCopy.recordResolutionNotInProcess(); |
| 3861 } else { |
| 3862 dartCopy.recordResolutionError(); |
| 3863 } |
| 3864 dartCopy.exception = thrownException; |
| 3865 _cache.put(source, dartCopy); |
| 3866 if (source == unitSource) { |
| 3867 unitEntry = dartCopy; |
| 3868 } |
| 3869 } |
| 3870 } |
| 3871 } |
| 3872 } |
| 3873 } |
| 3874 } |
| 3875 if (thrownException != null) { |
| 3876 throw thrownException; |
| 3877 } |
| 3878 if (unitEntry == null) { |
| 3879 unitEntry = getReadableDartEntry(unitSource); |
| 3880 if (unitEntry == null) { |
| 3881 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${
unitSource.fullName}"); |
| 3882 } |
| 3883 } |
| 3884 return unitEntry; |
| 3885 } |
| 3886 |
| 3887 /** |
| 3788 * Add all of the sources contained in the given source container to the given
list of sources. | 3888 * Add all of the sources contained in the given source container to the given
list of sources. |
| 3789 * | 3889 * |
| 3790 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. | 3890 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. |
| 3791 * | 3891 * |
| 3792 * @param sources the list to which sources are to be added | 3892 * @param sources the list to which sources are to be added |
| 3793 * @param container the source container containing the sources to be added to
the list | 3893 * @param container the source container containing the sources to be added to
the list |
| 3794 */ | 3894 */ |
| 3795 void addSourcesInContainer(List<Source> sources, SourceContainer container) { | 3895 void addSourcesInContainer(List<Source> sources, SourceContainer container) { |
| 3796 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 3896 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 3797 Source source = entry.getKey(); | 3897 Source source = entry.getKey(); |
| (...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4937 htmlEntry = htmlCopy; | 5037 htmlEntry = htmlCopy; |
| 4938 } | 5038 } |
| 4939 } | 5039 } |
| 4940 if (thrownException != null) { | 5040 if (thrownException != null) { |
| 4941 throw thrownException; | 5041 throw thrownException; |
| 4942 } | 5042 } |
| 4943 return htmlEntry; | 5043 return htmlEntry; |
| 4944 } | 5044 } |
| 4945 | 5045 |
| 4946 /** | 5046 /** |
| 4947 * Record the results produced by performing a [ResolveDartLibraryTask]. If th
e results were | |
| 4948 * computed from data that is now out-of-date, then the results will not be re
corded. | |
| 4949 * | |
| 4950 * @param task the task that was performed | |
| 4951 * @return an entry containing the computed results | |
| 4952 * @throws AnalysisException if the results could not be recorded | |
| 4953 */ | |
| 4954 DartEntry recordResolveDartLibraryTaskResults(ResolveDartLibraryTask task) { | |
| 4955 LibraryResolver resolver = task.libraryResolver; | |
| 4956 AnalysisException thrownException = task.exception; | |
| 4957 DartEntry unitEntry = null; | |
| 4958 Source unitSource = task.unitSource; | |
| 4959 if (resolver != null) { | |
| 4960 Set<Library> resolvedLibraries = resolver.resolvedLibraries; | |
| 4961 if (resolvedLibraries == null) { | |
| 4962 unitEntry = getReadableDartEntry(unitSource); | |
| 4963 if (unitEntry == null) { | |
| 4964 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${unitSource.fullName}"); | |
| 4965 } | |
| 4966 DartEntryImpl dartCopy = unitEntry.writableCopy; | |
| 4967 dartCopy.recordResolutionError(); | |
| 4968 dartCopy.exception = thrownException; | |
| 4969 _cache.put(unitSource, dartCopy); | |
| 4970 if (thrownException != null) { | |
| 4971 throw thrownException; | |
| 4972 } | |
| 4973 return dartCopy; | |
| 4974 } | |
| 4975 { | |
| 4976 if (allModificationTimesMatch(resolvedLibraries)) { | |
| 4977 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); | |
| 4978 RecordingErrorListener errorListener = resolver.errorListener; | |
| 4979 for (Library library in resolvedLibraries) { | |
| 4980 Source librarySource = library.librarySource; | |
| 4981 for (Source source in library.compilationUnitSources) { | |
| 4982 CompilationUnit unit = library.getAST(source); | |
| 4983 List<AnalysisError> errors = errorListener.getErrors2(source); | |
| 4984 LineInfo lineInfo = getLineInfo(source); | |
| 4985 DartEntry dartEntry = _cache.get(source) as DartEntry; | |
| 4986 int sourceTime = source.modificationStamp; | |
| 4987 if (dartEntry.modificationTime != sourceTime) { | |
| 4988 sourceChanged(source); | |
| 4989 dartEntry = getReadableDartEntry(source); | |
| 4990 if (dartEntry == null) { | |
| 4991 throw new AnalysisException.con1("A Dart file became a non-Dar
t file: ${source.fullName}"); | |
| 4992 } | |
| 4993 } | |
| 4994 DartEntryImpl dartCopy = dartEntry.writableCopy; | |
| 4995 if (thrownException == null) { | |
| 4996 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | |
| 4997 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); | |
| 4998 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, unit)
; | |
| 4999 dartCopy.setValue2(DartEntry.RESOLUTION_ERRORS, librarySource, e
rrors); | |
| 5000 if (identical(source, librarySource)) { | |
| 5001 recordElementData(dartCopy, library.libraryElement, htmlSource
); | |
| 5002 } | |
| 5003 } else { | |
| 5004 dartCopy.recordResolutionError(); | |
| 5005 } | |
| 5006 dartCopy.exception = thrownException; | |
| 5007 _cache.put(source, dartCopy); | |
| 5008 if (source == unitSource) { | |
| 5009 unitEntry = dartCopy; | |
| 5010 } | |
| 5011 ChangeNoticeImpl notice = getNotice(source); | |
| 5012 notice.compilationUnit = unit; | |
| 5013 notice.setErrors(dartCopy.allErrors, lineInfo); | |
| 5014 } | |
| 5015 } | |
| 5016 } else { | |
| 5017 for (Library library in resolvedLibraries) { | |
| 5018 for (Source source in library.compilationUnitSources) { | |
| 5019 DartEntry dartEntry = getReadableDartEntry(source); | |
| 5020 if (dartEntry != null) { | |
| 5021 int resultTime = library.getModificationTime(source); | |
| 5022 DartEntryImpl dartCopy = dartEntry.writableCopy; | |
| 5023 if (thrownException == null || resultTime >= 0) { | |
| 5024 dartCopy.recordResolutionNotInProcess(); | |
| 5025 } else { | |
| 5026 dartCopy.recordResolutionError(); | |
| 5027 } | |
| 5028 dartCopy.exception = thrownException; | |
| 5029 _cache.put(source, dartCopy); | |
| 5030 if (source == unitSource) { | |
| 5031 unitEntry = dartCopy; | |
| 5032 } | |
| 5033 } | |
| 5034 } | |
| 5035 } | |
| 5036 } | |
| 5037 } | |
| 5038 } | |
| 5039 if (thrownException != null) { | |
| 5040 throw thrownException; | |
| 5041 } | |
| 5042 if (unitEntry == null) { | |
| 5043 unitEntry = getReadableDartEntry(unitSource); | |
| 5044 if (unitEntry == null) { | |
| 5045 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${
unitSource.fullName}"); | |
| 5046 } | |
| 5047 } | |
| 5048 return unitEntry; | |
| 5049 } | |
| 5050 | |
| 5051 /** | |
| 5052 * Record the results produced by performing a [ResolveDartUnitTask]. If the r
esults were | 5047 * Record the results produced by performing a [ResolveDartUnitTask]. If the r
esults were |
| 5053 * computed from data that is now out-of-date, then the results will not be re
corded. | 5048 * computed from data that is now out-of-date, then the results will not be re
corded. |
| 5054 * | 5049 * |
| 5055 * @param task the task that was performed | 5050 * @param task the task that was performed |
| 5056 * @return an entry containing the computed results | 5051 * @return an entry containing the computed results |
| 5057 * @throws AnalysisException if the results could not be recorded | 5052 * @throws AnalysisException if the results could not be recorded |
| 5058 */ | 5053 */ |
| 5059 SourceEntry recordResolveDartUnitTaskResults(ResolveDartUnitTask task) { | 5054 SourceEntry recordResolveDartUnitTaskResults(ResolveDartUnitTask task) { |
| 5060 Source unitSource = task.source; | 5055 Source unitSource = task.source; |
| 5061 Source librarySource = task.librarySource; | 5056 Source librarySource = task.librarySource; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5192 return sourceEntry is DartEntry; | 5187 return sourceEntry is DartEntry; |
| 5193 } | 5188 } |
| 5194 | 5189 |
| 5195 /** | 5190 /** |
| 5196 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 5191 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 5197 * | 5192 * |
| 5198 * @param source the source that has been changed | 5193 * @param source the source that has been changed |
| 5199 */ | 5194 */ |
| 5200 void sourceChanged(Source source) { | 5195 void sourceChanged(Source source) { |
| 5201 SourceEntry sourceEntry = _cache.get(source); | 5196 SourceEntry sourceEntry = _cache.get(source); |
| 5197 if (sourceEntry == null || sourceEntry.modificationTime == source.modificati
onStamp) { |
| 5198 return; |
| 5199 } |
| 5202 if (sourceEntry is HtmlEntry) { | 5200 if (sourceEntry is HtmlEntry) { |
| 5203 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; | 5201 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; |
| 5204 htmlCopy.modificationTime = source.modificationStamp; | 5202 htmlCopy.modificationTime = source.modificationStamp; |
| 5205 htmlCopy.invalidateAllInformation(); | 5203 htmlCopy.invalidateAllInformation(); |
| 5206 _cache.put(source, htmlCopy); | 5204 _cache.put(source, htmlCopy); |
| 5207 } else if (sourceEntry is DartEntry) { | 5205 } else if (sourceEntry is DartEntry) { |
| 5208 List<Source> containingLibraries = getLibrariesContaining(source); | 5206 List<Source> containingLibraries = getLibrariesContaining(source); |
| 5209 Set<Source> librariesToInvalidate = new Set<Source>(); | 5207 Set<Source> librariesToInvalidate = new Set<Source>(); |
| 5210 for (Source containingLibrary in containingLibraries) { | 5208 for (Source containingLibrary in containingLibraries) { |
| 5211 librariesToInvalidate.add(containingLibrary); | 5209 librariesToInvalidate.add(containingLibrary); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5296 } | 5294 } |
| 5297 | 5295 |
| 5298 /** | 5296 /** |
| 5299 * Instances of the class `AnalysisErrorInfoImpl` represent the analysis errors
and line info | 5297 * Instances of the class `AnalysisErrorInfoImpl` represent the analysis errors
and line info |
| 5300 * associated with a source. | 5298 * associated with a source. |
| 5301 */ | 5299 */ |
| 5302 class AnalysisErrorInfoImpl implements AnalysisErrorInfo { | 5300 class AnalysisErrorInfoImpl implements AnalysisErrorInfo { |
| 5303 /** | 5301 /** |
| 5304 * The analysis errors associated with a source, or `null` if there are no err
ors. | 5302 * The analysis errors associated with a source, or `null` if there are no err
ors. |
| 5305 */ | 5303 */ |
| 5306 List<AnalysisError> _errors; | 5304 final List<AnalysisError> errors; |
| 5307 | 5305 |
| 5308 /** | 5306 /** |
| 5309 * The line information associated with the errors, or `null` if there are no
errors. | 5307 * The line information associated with the errors, or `null` if there are no
errors. |
| 5310 */ | 5308 */ |
| 5311 LineInfo _lineInfo; | 5309 final LineInfo lineInfo; |
| 5312 | 5310 |
| 5313 /** | 5311 /** |
| 5314 * Initialize an newly created error info with the errors and line information | 5312 * Initialize an newly created error info with the errors and line information |
| 5315 * | 5313 * |
| 5316 * @param errors the errors as a result of analysis | 5314 * @param errors the errors as a result of analysis |
| 5317 * @param lineinfo the line info for the errors | 5315 * @param lineinfo the line info for the errors |
| 5318 */ | 5316 */ |
| 5319 AnalysisErrorInfoImpl(List<AnalysisError> errors, LineInfo lineInfo) { | 5317 AnalysisErrorInfoImpl(this.errors, this.lineInfo); |
| 5320 this._errors = errors; | |
| 5321 this._lineInfo = lineInfo; | |
| 5322 } | |
| 5323 | |
| 5324 /** | |
| 5325 * Return the errors of analysis, or `null` if there were no errors. | |
| 5326 * | |
| 5327 * @return the errors as a result of the analysis | |
| 5328 */ | |
| 5329 List<AnalysisError> get errors => _errors; | |
| 5330 | |
| 5331 /** | |
| 5332 * Return the line information associated with the errors, or `null` if there
were no | |
| 5333 * errors. | |
| 5334 * | |
| 5335 * @return the line information associated with the errors | |
| 5336 */ | |
| 5337 LineInfo get lineInfo => _lineInfo; | |
| 5338 } | 5318 } |
| 5339 | 5319 |
| 5340 /** | 5320 /** |
| 5341 * Instances of the class `AnalysisOptions` represent a set of analysis options
used to | 5321 * Instances of the class `AnalysisOptions` represent a set of analysis options
used to |
| 5342 * control the behavior of an analysis context. | 5322 * control the behavior of an analysis context. |
| 5343 */ | 5323 */ |
| 5344 class AnalysisOptionsImpl implements AnalysisOptions { | 5324 class AnalysisOptionsImpl implements AnalysisOptions { |
| 5345 /** | 5325 /** |
| 5346 * The maximum number of sources for which data should be kept in the cache. | 5326 * The maximum number of sources for which data should be kept in the cache. |
| 5347 */ | 5327 */ |
| 5348 static int DEFAULT_CACHE_SIZE = 64; | 5328 static int DEFAULT_CACHE_SIZE = 64; |
| 5349 | 5329 |
| 5350 /** | 5330 /** |
| 5351 * The maximum number of sources for which AST structures should be kept in th
e cache. | 5331 * The maximum number of sources for which AST structures should be kept in th
e cache. |
| 5352 */ | 5332 */ |
| 5353 int _cacheSize = DEFAULT_CACHE_SIZE; | 5333 int cacheSize = DEFAULT_CACHE_SIZE; |
| 5354 | 5334 |
| 5355 /** | 5335 /** |
| 5356 * A flag indicating whether analysis is to parse and analyze function bodies. | 5336 * A flag indicating whether analysis is to parse and analyze function bodies. |
| 5357 */ | 5337 */ |
| 5358 bool _analyzeFunctionBodies = true; | 5338 bool analyzeFunctionBodies = true; |
| 5359 | 5339 |
| 5360 /** | 5340 /** |
| 5361 * A flag indicating whether analysis is to generate dart2js related hint resu
lts. | 5341 * A flag indicating whether analysis is to generate dart2js related hint resu
lts. |
| 5362 */ | 5342 */ |
| 5363 bool _dart2jsHint = true; | 5343 bool dart2jsHint = true; |
| 5364 | 5344 |
| 5365 /** | 5345 /** |
| 5366 * A flag indicating whether analysis is to generate hint results (e.g. type i
nference based | 5346 * A flag indicating whether analysis is to generate hint results (e.g. type i
nference based |
| 5367 * information and pub best practices). | 5347 * information and pub best practices). |
| 5368 */ | 5348 */ |
| 5369 bool _hint = true; | 5349 bool hint = true; |
| 5370 | 5350 |
| 5371 /** | 5351 /** |
| 5372 * A flag indicating whether incremental analysis should be used. | 5352 * A flag indicating whether incremental analysis should be used. |
| 5373 */ | 5353 */ |
| 5374 bool _incremental = false; | 5354 bool incremental = false; |
| 5375 | 5355 |
| 5376 /** | 5356 /** |
| 5377 * flag indicating whether analysis is to parse comments. | 5357 * flag indicating whether analysis is to parse comments. |
| 5378 */ | 5358 */ |
| 5379 bool _preserveComments = true; | 5359 bool preserveComments = true; |
| 5380 | 5360 |
| 5381 /** | 5361 /** |
| 5382 * Initialize a newly created set of analysis options to have their default va
lues. | 5362 * Initialize a newly created set of analysis options to have their default va
lues. |
| 5383 */ | 5363 */ |
| 5384 AnalysisOptionsImpl(); | 5364 AnalysisOptionsImpl(); |
| 5385 | 5365 |
| 5386 /** | 5366 /** |
| 5387 * Initialize a newly created set of analysis options to have the same values
as those in the | 5367 * Initialize a newly created set of analysis options to have the same values
as those in the |
| 5388 * given set of analysis options. | 5368 * given set of analysis options. |
| 5389 * | 5369 * |
| 5390 * @param options the analysis options whose values are being copied | 5370 * @param options the analysis options whose values are being copied |
| 5391 */ | 5371 */ |
| 5392 AnalysisOptionsImpl.con1(AnalysisOptions options) { | 5372 AnalysisOptionsImpl.con1(AnalysisOptions options) { |
| 5393 _cacheSize = options.cacheSize; | 5373 cacheSize = options.cacheSize; |
| 5394 _dart2jsHint = options.dart2jsHint; | 5374 dart2jsHint = options.dart2jsHint; |
| 5395 _hint = options.hint; | 5375 hint = options.hint; |
| 5396 _incremental = options.incremental; | 5376 incremental = options.incremental; |
| 5397 } | |
| 5398 | |
| 5399 bool get analyzeFunctionBodies => _analyzeFunctionBodies; | |
| 5400 | |
| 5401 int get cacheSize => _cacheSize; | |
| 5402 | |
| 5403 bool get dart2jsHint => _dart2jsHint; | |
| 5404 | |
| 5405 bool get hint => _hint; | |
| 5406 | |
| 5407 bool get incremental => _incremental; | |
| 5408 | |
| 5409 bool get preserveComments => _preserveComments; | |
| 5410 | |
| 5411 /** | |
| 5412 * Set whether analysis is to parse and analyze function bodies. | |
| 5413 * | |
| 5414 * @param analyzeFunctionBodies `true` if analysis is to parse and analyze fun
ction bodies | |
| 5415 */ | |
| 5416 void set analyzeFunctionBodies(bool analyzeFunctionBodies) { | |
| 5417 this._analyzeFunctionBodies = analyzeFunctionBodies; | |
| 5418 } | |
| 5419 | |
| 5420 /** | |
| 5421 * Set the maximum number of sources for which AST structures should be kept i
n the cache to the | |
| 5422 * given size. | |
| 5423 * | |
| 5424 * @param cacheSize the maximum number of sources for which AST structures sho
uld be kept in the | |
| 5425 * cache | |
| 5426 */ | |
| 5427 void set cacheSize(int cacheSize) { | |
| 5428 this._cacheSize = cacheSize; | |
| 5429 } | |
| 5430 | |
| 5431 /** | |
| 5432 * Set whether analysis is to generate dart2js related hint results. | |
| 5433 * | |
| 5434 * @param hint `true` if analysis is to generate dart2js related hint results | |
| 5435 */ | |
| 5436 void set dart2jsHint(bool dart2jsHints) { | |
| 5437 this._dart2jsHint = dart2jsHints; | |
| 5438 } | |
| 5439 | |
| 5440 /** | |
| 5441 * Set whether analysis is to generate hint results (e.g. type inference based
information and pub | |
| 5442 * best practices). | |
| 5443 * | |
| 5444 * @param hint `true` if analysis is to generate hint results | |
| 5445 */ | |
| 5446 void set hint(bool hint) { | |
| 5447 this._hint = hint; | |
| 5448 } | |
| 5449 | |
| 5450 /** | |
| 5451 * Set whether incremental analysis should be used. | |
| 5452 * | |
| 5453 * @param incremental `true` if incremental analysis should be used | |
| 5454 */ | |
| 5455 void set incremental(bool incremental) { | |
| 5456 this._incremental = incremental; | |
| 5457 } | |
| 5458 | |
| 5459 /** | |
| 5460 * Set whether analysis is to parse comments. | |
| 5461 * | |
| 5462 * @param preserveComments `true` if analysis is to parse comments | |
| 5463 */ | |
| 5464 void set preserveComments(bool preserveComments) { | |
| 5465 this._preserveComments = preserveComments; | |
| 5466 } | 5377 } |
| 5467 } | 5378 } |
| 5468 | 5379 |
| 5469 /** | 5380 /** |
| 5470 * Instances of the class `ChangeNoticeImpl` represent a change to the analysis
results | 5381 * Instances of the class `ChangeNoticeImpl` represent a change to the analysis
results |
| 5471 * associated with a given source. | 5382 * associated with a given source. |
| 5472 * | 5383 * |
| 5473 * @coverage dart.engine | 5384 * @coverage dart.engine |
| 5474 */ | 5385 */ |
| 5475 class ChangeNoticeImpl implements ChangeNotice { | 5386 class ChangeNoticeImpl implements ChangeNotice { |
| 5476 /** | 5387 /** |
| 5477 * The source for which the result is being reported. | 5388 * The source for which the result is being reported. |
| 5478 */ | 5389 */ |
| 5479 Source _source; | 5390 final Source source; |
| 5480 | 5391 |
| 5481 /** | 5392 /** |
| 5482 * The fully resolved AST that changed as a result of the analysis, or `null`
if the AST was | 5393 * The fully resolved AST that changed as a result of the analysis, or `null`
if the AST was |
| 5483 * not changed. | 5394 * not changed. |
| 5484 */ | 5395 */ |
| 5485 CompilationUnit _compilationUnit; | 5396 CompilationUnit compilationUnit; |
| 5486 | 5397 |
| 5487 /** | 5398 /** |
| 5488 * The errors that changed as a result of the analysis, or `null` if errors we
re not | 5399 * The errors that changed as a result of the analysis, or `null` if errors we
re not |
| 5489 * changed. | 5400 * changed. |
| 5490 */ | 5401 */ |
| 5491 List<AnalysisError> _errors; | 5402 List<AnalysisError> _errors; |
| 5492 | 5403 |
| 5493 /** | 5404 /** |
| 5494 * The line information associated with the source, or `null` if errors were n
ot changed. | 5405 * The line information associated with the source, or `null` if errors were n
ot changed. |
| 5495 */ | 5406 */ |
| 5496 LineInfo _lineInfo; | 5407 LineInfo _lineInfo; |
| 5497 | 5408 |
| 5498 /** | 5409 /** |
| 5499 * An empty array of change notices. | 5410 * An empty array of change notices. |
| 5500 */ | 5411 */ |
| 5501 static List<ChangeNoticeImpl> EMPTY_ARRAY = new List<ChangeNoticeImpl>(0); | 5412 static List<ChangeNoticeImpl> EMPTY_ARRAY = new List<ChangeNoticeImpl>(0); |
| 5502 | 5413 |
| 5503 /** | 5414 /** |
| 5504 * Initialize a newly created notice associated with the given source. | 5415 * Initialize a newly created notice associated with the given source. |
| 5505 * | 5416 * |
| 5506 * @param source the source for which the change is being reported | 5417 * @param source the source for which the change is being reported |
| 5507 */ | 5418 */ |
| 5508 ChangeNoticeImpl(Source source) { | 5419 ChangeNoticeImpl(this.source); |
| 5509 this._source = source; | |
| 5510 } | |
| 5511 | |
| 5512 /** | |
| 5513 * Return the fully resolved AST that changed as a result of the analysis, or
`null` if the | |
| 5514 * AST was not changed. | |
| 5515 * | |
| 5516 * @return the fully resolved AST that changed as a result of the analysis | |
| 5517 */ | |
| 5518 CompilationUnit get compilationUnit => _compilationUnit; | |
| 5519 | 5420 |
| 5520 /** | 5421 /** |
| 5521 * Return the errors that changed as a result of the analysis, or `null` if er
rors were not | 5422 * Return the errors that changed as a result of the analysis, or `null` if er
rors were not |
| 5522 * changed. | 5423 * changed. |
| 5523 * | 5424 * |
| 5524 * @return the errors that changed as a result of the analysis | 5425 * @return the errors that changed as a result of the analysis |
| 5525 */ | 5426 */ |
| 5526 List<AnalysisError> get errors => _errors; | 5427 List<AnalysisError> get errors => _errors; |
| 5527 | 5428 |
| 5528 /** | 5429 /** |
| 5529 * Return the line information associated with the source, or `null` if errors
were not | 5430 * Return the line information associated with the source, or `null` if errors
were not |
| 5530 * changed. | 5431 * changed. |
| 5531 * | 5432 * |
| 5532 * @return the line information associated with the source | 5433 * @return the line information associated with the source |
| 5533 */ | 5434 */ |
| 5534 LineInfo get lineInfo => _lineInfo; | 5435 LineInfo get lineInfo => _lineInfo; |
| 5535 | 5436 |
| 5536 /** | 5437 /** |
| 5537 * Return the source for which the result is being reported. | |
| 5538 * | |
| 5539 * @return the source for which the result is being reported | |
| 5540 */ | |
| 5541 Source get source => _source; | |
| 5542 | |
| 5543 /** | |
| 5544 * Set the fully resolved AST that changed as a result of the analysis to the
given AST. | |
| 5545 * | |
| 5546 * @param compilationUnit the fully resolved AST that changed as a result of t
he analysis | |
| 5547 */ | |
| 5548 void set compilationUnit(CompilationUnit compilationUnit) { | |
| 5549 this._compilationUnit = compilationUnit; | |
| 5550 } | |
| 5551 | |
| 5552 /** | |
| 5553 * Set the errors that changed as a result of the analysis to the given errors
and set the line | 5438 * Set the errors that changed as a result of the analysis to the given errors
and set the line |
| 5554 * information to the given line information. | 5439 * information to the given line information. |
| 5555 * | 5440 * |
| 5556 * @param errors the errors that changed as a result of the analysis | 5441 * @param errors the errors that changed as a result of the analysis |
| 5557 * @param lineInfo the line information associated with the source | 5442 * @param lineInfo the line information associated with the source |
| 5558 */ | 5443 */ |
| 5559 void setErrors(List<AnalysisError> errors, LineInfo lineInfo) { | 5444 void setErrors(List<AnalysisError> errors, LineInfo lineInfo) { |
| 5560 this._errors = errors; | 5445 this._errors = errors; |
| 5561 this._lineInfo = lineInfo; | 5446 this._lineInfo = lineInfo; |
| 5562 if (lineInfo == null) { | 5447 if (lineInfo == null) { |
| 5563 AnalysisEngine.instance.logger.logError2("No line info: ${_source}", new J
avaException()); | 5448 AnalysisEngine.instance.logger.logError2("No line info: ${source}", new Ja
vaException()); |
| 5564 } | 5449 } |
| 5565 } | 5450 } |
| 5566 | 5451 |
| 5567 String toString() => "Changes for ${_source.fullName}"; | 5452 String toString() => "Changes for ${source.fullName}"; |
| 5568 } | 5453 } |
| 5569 | 5454 |
| 5570 /** | 5455 /** |
| 5571 * Instances of the class `DelegatingAnalysisContextImpl` extend [AnalysisContex
tImpl | 5456 * Instances of the class `DelegatingAnalysisContextImpl` extend [AnalysisContex
tImpl |
| 5572 ] to delegate sources to the appropriate analysis context. For instance, if the | 5457 ] to delegate sources to the appropriate analysis context. For instance, if the |
| 5573 * source is in a system library then the analysis context from the [DartSdk] is
used. | 5458 * source is in a system library then the analysis context from the [DartSdk] is
used. |
| 5574 * | 5459 * |
| 5575 * @coverage dart.engine | 5460 * @coverage dart.engine |
| 5576 */ | 5461 */ |
| 5577 class DelegatingAnalysisContextImpl extends AnalysisContextImpl { | 5462 class DelegatingAnalysisContextImpl extends AnalysisContextImpl { |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5864 /** | 5749 /** |
| 5865 * Determine if the incremental analysis result can be cached for the next inc
remental analysis. | 5750 * Determine if the incremental analysis result can be cached for the next inc
remental analysis. |
| 5866 * | 5751 * |
| 5867 * @param cache the prior incremental analysis cache | 5752 * @param cache the prior incremental analysis cache |
| 5868 * @param unit the incrementally updated compilation unit | 5753 * @param unit the incrementally updated compilation unit |
| 5869 * @return the cache used for incremental analysis or `null` if incremental an
alysis results | 5754 * @return the cache used for incremental analysis or `null` if incremental an
alysis results |
| 5870 * cannot be cached for the next incremental analysis | 5755 * cannot be cached for the next incremental analysis |
| 5871 */ | 5756 */ |
| 5872 static IncrementalAnalysisCache cacheResult(IncrementalAnalysisCache cache, Co
mpilationUnit unit) { | 5757 static IncrementalAnalysisCache cacheResult(IncrementalAnalysisCache cache, Co
mpilationUnit unit) { |
| 5873 if (cache != null && unit != null) { | 5758 if (cache != null && unit != null) { |
| 5874 return new IncrementalAnalysisCache(cache.librarySource, cache.source, uni
t, cache.newContents, cache.newContents, 0, 0, 0); | 5759 return new IncrementalAnalysisCache(cache.librarySource, cache.source, uni
t, cache._newContents, cache._newContents, 0, 0, 0); |
| 5875 } | 5760 } |
| 5876 return null; | 5761 return null; |
| 5877 } | 5762 } |
| 5878 | 5763 |
| 5879 /** | 5764 /** |
| 5880 * Determine if the cache should be cleared. | 5765 * Determine if the cache should be cleared. |
| 5881 * | 5766 * |
| 5882 * @param cache the prior cache or `null` if none | 5767 * @param cache the prior cache or `null` if none |
| 5883 * @param source the source being updated (not `null`) | 5768 * @param source the source being updated (not `null`) |
| 5884 * @return the cache used for incremental analysis or `null` if incremental an
alysis cannot | 5769 * @return the cache used for incremental analysis or `null` if incremental an
alysis cannot |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5923 return null; | 5808 return null; |
| 5924 } | 5809 } |
| 5925 if (oldContents == null) { | 5810 if (oldContents == null) { |
| 5926 if (oldLength != 0) { | 5811 if (oldLength != 0) { |
| 5927 return null; | 5812 return null; |
| 5928 } | 5813 } |
| 5929 oldContents = "${newContents.substring(0, offset)}${newContents.substrin
g(offset + newLength)}"; | 5814 oldContents = "${newContents.substring(0, offset)}${newContents.substrin
g(offset + newLength)}"; |
| 5930 } | 5815 } |
| 5931 return new IncrementalAnalysisCache(librarySource, source, unit, oldConten
ts, newContents, offset, oldLength, newLength); | 5816 return new IncrementalAnalysisCache(librarySource, source, unit, oldConten
ts, newContents, offset, oldLength, newLength); |
| 5932 } | 5817 } |
| 5933 if (cache.oldLength == 0 && cache.newLength == 0) { | 5818 if (cache._oldLength == 0 && cache._newLength == 0) { |
| 5934 cache.offset = offset; | 5819 cache._offset = offset; |
| 5935 cache.oldLength = oldLength; | 5820 cache._oldLength = oldLength; |
| 5936 cache.newLength = newLength; | 5821 cache._newLength = newLength; |
| 5937 } else { | 5822 } else { |
| 5938 if (cache.offset > offset || offset > cache.offset + cache.newLength) { | 5823 if (cache._offset > offset || offset > cache._offset + cache._newLength) { |
| 5939 return null; | 5824 return null; |
| 5940 } | 5825 } |
| 5941 cache.newLength += newLength - oldLength; | 5826 cache._newLength += newLength - oldLength; |
| 5942 } | 5827 } |
| 5943 cache.newContents = newContents; | 5828 cache._newContents = newContents; |
| 5944 return cache; | 5829 return cache; |
| 5945 } | 5830 } |
| 5946 | 5831 |
| 5947 /** | 5832 /** |
| 5948 * Verify that the incrementally parsed and resolved unit in the incremental c
ache is structurally | 5833 * Verify that the incrementally parsed and resolved unit in the incremental c
ache is structurally |
| 5949 * equivalent to the fully parsed unit. | 5834 * equivalent to the fully parsed unit. |
| 5950 * | 5835 * |
| 5951 * @param cache the prior cache or `null` if none | 5836 * @param cache the prior cache or `null` if none |
| 5952 * @param source the source of the compilation unit that was parsed (not `null
`) | 5837 * @param source the source of the compilation unit that was parsed (not `null
`) |
| 5953 * @param unit the compilation unit that was just parsed | 5838 * @param unit the compilation unit that was just parsed |
| 5954 * @return the cache used for incremental analysis or `null` if incremental an
alysis results | 5839 * @return the cache used for incremental analysis or `null` if incremental an
alysis results |
| 5955 * cannot be cached for the next incremental analysis | 5840 * cannot be cached for the next incremental analysis |
| 5956 */ | 5841 */ |
| 5957 static IncrementalAnalysisCache verifyStructure(IncrementalAnalysisCache cache
, Source source, CompilationUnit unit) { | 5842 static IncrementalAnalysisCache verifyStructure(IncrementalAnalysisCache cache
, Source source, CompilationUnit unit) { |
| 5958 if (cache != null && unit != null && cache.source == source) { | 5843 if (cache != null && unit != null && cache.source == source) { |
| 5959 if (!ASTComparator.equals4(cache.resolvedUnit, unit)) { | 5844 if (!ASTComparator.equals4(cache.resolvedUnit, unit)) { |
| 5960 return null; | 5845 return null; |
| 5961 } | 5846 } |
| 5962 } | 5847 } |
| 5963 return cache; | 5848 return cache; |
| 5964 } | 5849 } |
| 5965 | 5850 |
| 5966 Source librarySource; | 5851 final Source librarySource; |
| 5967 | 5852 |
| 5968 Source source; | 5853 final Source source; |
| 5969 | 5854 |
| 5970 String oldContents; | 5855 final String oldContents; |
| 5971 | 5856 |
| 5972 CompilationUnit resolvedUnit; | 5857 final CompilationUnit resolvedUnit; |
| 5973 | 5858 |
| 5974 String newContents; | 5859 String _newContents; |
| 5975 | 5860 |
| 5976 int offset = 0; | 5861 int _offset = 0; |
| 5977 | 5862 |
| 5978 int oldLength = 0; | 5863 int _oldLength = 0; |
| 5979 | 5864 |
| 5980 int newLength = 0; | 5865 int _newLength = 0; |
| 5981 | 5866 |
| 5982 IncrementalAnalysisCache(Source librarySource, Source source, CompilationUnit
resolvedUnit, String oldContents, String newContents, int offset, int oldLength,
int newLength) { | 5867 IncrementalAnalysisCache(this.librarySource, this.source, this.resolvedUnit, t
his.oldContents, String newContents, int offset, int oldLength, int newLength) { |
| 5983 this.librarySource = librarySource; | 5868 this._newContents = newContents; |
| 5984 this.source = source; | 5869 this._offset = offset; |
| 5985 this.resolvedUnit = resolvedUnit; | 5870 this._oldLength = oldLength; |
| 5986 this.oldContents = oldContents; | 5871 this._newLength = newLength; |
| 5987 this.newContents = newContents; | |
| 5988 this.offset = offset; | |
| 5989 this.oldLength = oldLength; | |
| 5990 this.newLength = newLength; | |
| 5991 } | 5872 } |
| 5992 | 5873 |
| 5993 /** | 5874 /** |
| 5875 * Return the current contents for the receiver's source. |
| 5876 * |
| 5877 * @return the contents (not `null`) |
| 5878 */ |
| 5879 String get newContents => _newContents; |
| 5880 |
| 5881 /** |
| 5882 * Return the number of characters in the replacement text. |
| 5883 * |
| 5884 * @return the replacement length (zero or greater) |
| 5885 */ |
| 5886 int get newLength => _newLength; |
| 5887 |
| 5888 /** |
| 5889 * Return the character position of the first changed character. |
| 5890 * |
| 5891 * @return the offset (zero or greater) |
| 5892 */ |
| 5893 int get offset => _offset; |
| 5894 |
| 5895 /** |
| 5896 * Return the number of characters that were replaced. |
| 5897 * |
| 5898 * @return the replaced length (zero or greater) |
| 5899 */ |
| 5900 int get oldLength => _oldLength; |
| 5901 |
| 5902 /** |
| 5994 * Determine if the cache contains source changes that need to be analyzed | 5903 * Determine if the cache contains source changes that need to be analyzed |
| 5995 * | 5904 * |
| 5996 * @return `true` if the cache contains changes to be analyzed, else `false` | 5905 * @return `true` if the cache contains changes to be analyzed, else `false` |
| 5997 */ | 5906 */ |
| 5998 bool hasWork() => oldLength > 0 || newLength > 0; | 5907 bool hasWork() => _oldLength > 0 || _newLength > 0; |
| 5999 } | 5908 } |
| 6000 | 5909 |
| 6001 /** | 5910 /** |
| 6002 * Instances of the class `InstrumentedAnalysisContextImpl` implement an | 5911 * Instances of the class `InstrumentedAnalysisContextImpl` implement an |
| 6003 * [AnalysisContext] by recording instrumentation data and delegating to | 5912 * [AnalysisContext] by recording instrumentation data and delegating to |
| 6004 * another analysis context to do the non-instrumentation work. | 5913 * another analysis context to do the non-instrumentation work. |
| 6005 * | 5914 * |
| 6006 * @coverage dart.engine | 5915 * @coverage dart.engine |
| 6007 */ | 5916 */ |
| 6008 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext { | 5917 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext { |
| 6009 /** | 5918 /** |
| 6010 * Record an exception that was thrown during analysis. | 5919 * Record an exception that was thrown during analysis. |
| 6011 * | 5920 * |
| 6012 * @param instrumentation the instrumentation builder being used to record the
exception | 5921 * @param instrumentation the instrumentation builder being used to record the
exception |
| 6013 * @param exception the exception being reported | 5922 * @param exception the exception being reported |
| 6014 */ | 5923 */ |
| 6015 static void recordAnalysisException(InstrumentationBuilder instrumentation, An
alysisException exception) { | 5924 static void recordAnalysisException(InstrumentationBuilder instrumentation, An
alysisException exception) { |
| 6016 instrumentation.record(exception); | 5925 instrumentation.record(exception); |
| 6017 } | 5926 } |
| 6018 | 5927 |
| 6019 /** | 5928 /** |
| 6020 * The unique identifier used to identify this analysis context in the instrum
entation data. | 5929 * The unique identifier used to identify this analysis context in the instrum
entation data. |
| 6021 */ | 5930 */ |
| 6022 String _contextId = UUID.randomUUID().toString(); | 5931 String _contextId = UUID.randomUUID().toString(); |
| 6023 | 5932 |
| 6024 /** | 5933 /** |
| 6025 * The analysis context to which all of the non-instrumentation work is delega
ted. | 5934 * The analysis context to which all of the non-instrumentation work is delega
ted. |
| 6026 */ | 5935 */ |
| 6027 InternalAnalysisContext basis; | 5936 InternalAnalysisContext _basis; |
| 6028 | 5937 |
| 6029 /** | 5938 /** |
| 6030 * Create a new [InstrumentedAnalysisContextImpl] which wraps a new | 5939 * Create a new [InstrumentedAnalysisContextImpl] which wraps a new |
| 6031 * [AnalysisContextImpl] as the basis context. | 5940 * [AnalysisContextImpl] as the basis context. |
| 6032 */ | 5941 */ |
| 6033 InstrumentedAnalysisContextImpl() : this.con1(new DelegatingAnalysisContextImp
l()); | 5942 InstrumentedAnalysisContextImpl() : this.con1(new DelegatingAnalysisContextImp
l()); |
| 6034 | 5943 |
| 6035 /** | 5944 /** |
| 6036 * Create a new [InstrumentedAnalysisContextImpl] with a specified basis conte
xt, aka the | 5945 * Create a new [InstrumentedAnalysisContextImpl] with a specified basis conte
xt, aka the |
| 6037 * context to wrap and instrument. | 5946 * context to wrap and instrument. |
| 6038 * | 5947 * |
| 6039 * @param context some [InstrumentedAnalysisContext] to wrap and instrument | 5948 * @param context some [InstrumentedAnalysisContext] to wrap and instrument |
| 6040 */ | 5949 */ |
| 6041 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) { | 5950 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) { |
| 6042 basis = context; | 5951 _basis = context; |
| 6043 } | 5952 } |
| 6044 | 5953 |
| 6045 void addSourceInfo(Source source, SourceEntry info) { | 5954 void addSourceInfo(Source source, SourceEntry info) { |
| 6046 basis.addSourceInfo(source, info); | 5955 _basis.addSourceInfo(source, info); |
| 6047 } | 5956 } |
| 6048 | 5957 |
| 6049 void applyChanges(ChangeSet changeSet) { | 5958 void applyChanges(ChangeSet changeSet) { |
| 6050 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
applyChanges"); | 5959 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
applyChanges"); |
| 6051 try { | 5960 try { |
| 6052 instrumentation.metric3("contextId", _contextId); | 5961 instrumentation.metric3("contextId", _contextId); |
| 6053 basis.applyChanges(changeSet); | 5962 _basis.applyChanges(changeSet); |
| 6054 } finally { | 5963 } finally { |
| 6055 instrumentation.log(); | 5964 instrumentation.log(); |
| 6056 } | 5965 } |
| 6057 } | 5966 } |
| 6058 | 5967 |
| 6059 String computeDocumentationComment(Element element) { | 5968 String computeDocumentationComment(Element element) { |
| 6060 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeDocumentationComment"); | 5969 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeDocumentationComment"); |
| 6061 try { | 5970 try { |
| 6062 instrumentation.metric3("contextId", _contextId); | 5971 instrumentation.metric3("contextId", _contextId); |
| 6063 return basis.computeDocumentationComment(element); | 5972 return _basis.computeDocumentationComment(element); |
| 6064 } finally { | 5973 } finally { |
| 6065 instrumentation.log(); | 5974 instrumentation.log(); |
| 6066 } | 5975 } |
| 6067 } | 5976 } |
| 6068 | 5977 |
| 6069 List<AnalysisError> computeErrors(Source source) { | 5978 List<AnalysisError> computeErrors(Source source) { |
| 6070 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeErrors"); | 5979 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeErrors"); |
| 6071 try { | 5980 try { |
| 6072 instrumentation.metric3("contextId", _contextId); | 5981 instrumentation.metric3("contextId", _contextId); |
| 6073 List<AnalysisError> errors = basis.computeErrors(source); | 5982 List<AnalysisError> errors = _basis.computeErrors(source); |
| 6074 instrumentation.metric2("Errors-count", errors.length); | 5983 instrumentation.metric2("Errors-count", errors.length); |
| 6075 return errors; | 5984 return errors; |
| 6076 } finally { | 5985 } finally { |
| 6077 instrumentation.log(); | 5986 instrumentation.log(); |
| 6078 } | 5987 } |
| 6079 } | 5988 } |
| 6080 | 5989 |
| 6081 List<Source> computeExportedLibraries(Source source) { | 5990 List<Source> computeExportedLibraries(Source source) { |
| 6082 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeExportedLibraries"); | 5991 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeExportedLibraries"); |
| 6083 try { | 5992 try { |
| 6084 instrumentation.metric3("contextId", _contextId); | 5993 instrumentation.metric3("contextId", _contextId); |
| 6085 return basis.computeExportedLibraries(source); | 5994 return _basis.computeExportedLibraries(source); |
| 6086 } finally { | 5995 } finally { |
| 6087 instrumentation.log(); | 5996 instrumentation.log(); |
| 6088 } | 5997 } |
| 6089 } | 5998 } |
| 6090 | 5999 |
| 6091 HtmlElement computeHtmlElement(Source source) { | 6000 HtmlElement computeHtmlElement(Source source) { |
| 6092 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeHtmlElement"); | 6001 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeHtmlElement"); |
| 6093 try { | 6002 try { |
| 6094 instrumentation.metric3("contextId", _contextId); | 6003 instrumentation.metric3("contextId", _contextId); |
| 6095 return basis.computeHtmlElement(source); | 6004 return _basis.computeHtmlElement(source); |
| 6096 } on AnalysisException catch (e) { | 6005 } on AnalysisException catch (e) { |
| 6097 recordAnalysisException(instrumentation, e); | 6006 recordAnalysisException(instrumentation, e); |
| 6098 throw e; | 6007 throw e; |
| 6099 } finally { | 6008 } finally { |
| 6100 instrumentation.log(); | 6009 instrumentation.log(); |
| 6101 } | 6010 } |
| 6102 } | 6011 } |
| 6103 | 6012 |
| 6104 List<Source> computeImportedLibraries(Source source) { | 6013 List<Source> computeImportedLibraries(Source source) { |
| 6105 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeImportedLibraries"); | 6014 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeImportedLibraries"); |
| 6106 try { | 6015 try { |
| 6107 instrumentation.metric3("contextId", _contextId); | 6016 instrumentation.metric3("contextId", _contextId); |
| 6108 return basis.computeImportedLibraries(source); | 6017 return _basis.computeImportedLibraries(source); |
| 6109 } finally { | 6018 } finally { |
| 6110 instrumentation.log(); | 6019 instrumentation.log(); |
| 6111 } | 6020 } |
| 6112 } | 6021 } |
| 6113 | 6022 |
| 6114 SourceKind computeKindOf(Source source) { | 6023 SourceKind computeKindOf(Source source) { |
| 6115 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeKindOf"); | 6024 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeKindOf"); |
| 6116 try { | 6025 try { |
| 6117 instrumentation.metric3("contextId", _contextId); | 6026 instrumentation.metric3("contextId", _contextId); |
| 6118 return basis.computeKindOf(source); | 6027 return _basis.computeKindOf(source); |
| 6119 } finally { | 6028 } finally { |
| 6120 instrumentation.log(); | 6029 instrumentation.log(); |
| 6121 } | 6030 } |
| 6122 } | 6031 } |
| 6123 | 6032 |
| 6124 LibraryElement computeLibraryElement(Source source) { | 6033 LibraryElement computeLibraryElement(Source source) { |
| 6125 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeLibraryElement"); | 6034 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeLibraryElement"); |
| 6126 try { | 6035 try { |
| 6127 instrumentation.metric3("contextId", _contextId); | 6036 instrumentation.metric3("contextId", _contextId); |
| 6128 return basis.computeLibraryElement(source); | 6037 return _basis.computeLibraryElement(source); |
| 6129 } on AnalysisException catch (e) { | 6038 } on AnalysisException catch (e) { |
| 6130 recordAnalysisException(instrumentation, e); | 6039 recordAnalysisException(instrumentation, e); |
| 6131 throw e; | 6040 throw e; |
| 6132 } finally { | 6041 } finally { |
| 6133 instrumentation.log(); | 6042 instrumentation.log(); |
| 6134 } | 6043 } |
| 6135 } | 6044 } |
| 6136 | 6045 |
| 6137 LineInfo computeLineInfo(Source source) { | 6046 LineInfo computeLineInfo(Source source) { |
| 6138 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeLineInfo"); | 6047 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeLineInfo"); |
| 6139 try { | 6048 try { |
| 6140 instrumentation.metric3("contextId", _contextId); | 6049 instrumentation.metric3("contextId", _contextId); |
| 6141 return basis.computeLineInfo(source); | 6050 return _basis.computeLineInfo(source); |
| 6142 } on AnalysisException catch (e) { | 6051 } on AnalysisException catch (e) { |
| 6143 recordAnalysisException(instrumentation, e); | 6052 recordAnalysisException(instrumentation, e); |
| 6144 throw e; | 6053 throw e; |
| 6145 } finally { | 6054 } finally { |
| 6146 instrumentation.log(); | 6055 instrumentation.log(); |
| 6147 } | 6056 } |
| 6148 } | 6057 } |
| 6149 | 6058 |
| 6150 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) => b
asis.computeResolvableCompilationUnit(source); | 6059 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) => _
basis.computeResolvableCompilationUnit(source); |
| 6151 | 6060 |
| 6152 ResolvableHtmlUnit computeResolvableHtmlUnit(Source source) => basis.computeRe
solvableHtmlUnit(source); | 6061 ResolvableHtmlUnit computeResolvableHtmlUnit(Source source) => _basis.computeR
esolvableHtmlUnit(source); |
| 6153 | 6062 |
| 6154 AnalysisContext extractContext(SourceContainer container) { | 6063 AnalysisContext extractContext(SourceContainer container) { |
| 6155 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
extractContext"); | 6064 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
extractContext"); |
| 6156 try { | 6065 try { |
| 6157 instrumentation.metric3("contextId", _contextId); | 6066 instrumentation.metric3("contextId", _contextId); |
| 6158 InstrumentedAnalysisContextImpl newContext = new InstrumentedAnalysisConte
xtImpl(); | 6067 InstrumentedAnalysisContextImpl newContext = new InstrumentedAnalysisConte
xtImpl(); |
| 6159 basis.extractContextInto(container, newContext.basis); | 6068 _basis.extractContextInto(container, newContext._basis); |
| 6160 return newContext; | 6069 return newContext; |
| 6161 } finally { | 6070 } finally { |
| 6162 instrumentation.log(); | 6071 instrumentation.log(); |
| 6163 } | 6072 } |
| 6164 } | 6073 } |
| 6165 | 6074 |
| 6166 InternalAnalysisContext extractContextInto(SourceContainer container, Internal
AnalysisContext newContext) => basis.extractContextInto(container, newContext); | 6075 InternalAnalysisContext extractContextInto(SourceContainer container, Internal
AnalysisContext newContext) => _basis.extractContextInto(container, newContext); |
| 6167 | 6076 |
| 6168 AnalysisOptions get analysisOptions { | 6077 AnalysisOptions get analysisOptions { |
| 6169 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getAnalysisOptions"); | 6078 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getAnalysisOptions"); |
| 6170 try { | 6079 try { |
| 6171 instrumentation.metric3("contextId", _contextId); | 6080 instrumentation.metric3("contextId", _contextId); |
| 6172 return basis.analysisOptions; | 6081 return _basis.analysisOptions; |
| 6173 } finally { | 6082 } finally { |
| 6174 instrumentation.log(); | 6083 instrumentation.log(); |
| 6175 } | 6084 } |
| 6176 } | 6085 } |
| 6177 | 6086 |
| 6087 /** |
| 6088 * @return the underlying [AnalysisContext]. |
| 6089 */ |
| 6090 AnalysisContext get basis => _basis; |
| 6091 |
| 6178 Element getElement(ElementLocation location) { | 6092 Element getElement(ElementLocation location) { |
| 6179 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getElement"); | 6093 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getElement"); |
| 6180 try { | 6094 try { |
| 6181 instrumentation.metric3("contextId", _contextId); | 6095 instrumentation.metric3("contextId", _contextId); |
| 6182 return basis.getElement(location); | 6096 return _basis.getElement(location); |
| 6183 } finally { | 6097 } finally { |
| 6184 instrumentation.log(); | 6098 instrumentation.log(); |
| 6185 } | 6099 } |
| 6186 } | 6100 } |
| 6187 | 6101 |
| 6188 AnalysisErrorInfo getErrors(Source source) { | 6102 AnalysisErrorInfo getErrors(Source source) { |
| 6189 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getErrors"); | 6103 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getErrors"); |
| 6190 try { | 6104 try { |
| 6191 instrumentation.metric3("contextId", _contextId); | 6105 instrumentation.metric3("contextId", _contextId); |
| 6192 AnalysisErrorInfo ret = basis.getErrors(source); | 6106 AnalysisErrorInfo ret = _basis.getErrors(source); |
| 6193 if (ret != null) { | 6107 if (ret != null) { |
| 6194 instrumentation.metric2("Errors-count", ret.errors.length); | 6108 instrumentation.metric2("Errors-count", ret.errors.length); |
| 6195 } | 6109 } |
| 6196 return ret; | 6110 return ret; |
| 6197 } finally { | 6111 } finally { |
| 6198 instrumentation.log(); | 6112 instrumentation.log(); |
| 6199 } | 6113 } |
| 6200 } | 6114 } |
| 6201 | 6115 |
| 6202 HtmlElement getHtmlElement(Source source) { | 6116 HtmlElement getHtmlElement(Source source) { |
| 6203 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getHtmlElement"); | 6117 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getHtmlElement"); |
| 6204 try { | 6118 try { |
| 6205 instrumentation.metric3("contextId", _contextId); | 6119 instrumentation.metric3("contextId", _contextId); |
| 6206 return basis.getHtmlElement(source); | 6120 return _basis.getHtmlElement(source); |
| 6207 } finally { | 6121 } finally { |
| 6208 instrumentation.log(); | 6122 instrumentation.log(); |
| 6209 } | 6123 } |
| 6210 } | 6124 } |
| 6211 | 6125 |
| 6212 List<Source> getHtmlFilesReferencing(Source source) { | 6126 List<Source> getHtmlFilesReferencing(Source source) { |
| 6213 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getHtmlFilesReferencing"); | 6127 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getHtmlFilesReferencing"); |
| 6214 try { | 6128 try { |
| 6215 instrumentation.metric3("contextId", _contextId); | 6129 instrumentation.metric3("contextId", _contextId); |
| 6216 List<Source> ret = basis.getHtmlFilesReferencing(source); | 6130 List<Source> ret = _basis.getHtmlFilesReferencing(source); |
| 6217 if (ret != null) { | 6131 if (ret != null) { |
| 6218 instrumentation.metric2("Source-count", ret.length); | 6132 instrumentation.metric2("Source-count", ret.length); |
| 6219 } | 6133 } |
| 6220 return ret; | 6134 return ret; |
| 6221 } finally { | 6135 } finally { |
| 6222 instrumentation.log(); | 6136 instrumentation.log(); |
| 6223 } | 6137 } |
| 6224 } | 6138 } |
| 6225 | 6139 |
| 6226 List<Source> get htmlSources { | 6140 List<Source> get htmlSources { |
| 6227 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getHtmlSources"); | 6141 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getHtmlSources"); |
| 6228 try { | 6142 try { |
| 6229 instrumentation.metric3("contextId", _contextId); | 6143 instrumentation.metric3("contextId", _contextId); |
| 6230 List<Source> ret = basis.htmlSources; | 6144 List<Source> ret = _basis.htmlSources; |
| 6231 if (ret != null) { | 6145 if (ret != null) { |
| 6232 instrumentation.metric2("Source-count", ret.length); | 6146 instrumentation.metric2("Source-count", ret.length); |
| 6233 } | 6147 } |
| 6234 return ret; | 6148 return ret; |
| 6235 } finally { | 6149 } finally { |
| 6236 instrumentation.log(); | 6150 instrumentation.log(); |
| 6237 } | 6151 } |
| 6238 } | 6152 } |
| 6239 | 6153 |
| 6240 SourceKind getKindOf(Source source) { | 6154 SourceKind getKindOf(Source source) { |
| 6241 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getKindOf"); | 6155 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getKindOf"); |
| 6242 try { | 6156 try { |
| 6243 instrumentation.metric3("contextId", _contextId); | 6157 instrumentation.metric3("contextId", _contextId); |
| 6244 return basis.getKindOf(source); | 6158 return _basis.getKindOf(source); |
| 6245 } finally { | 6159 } finally { |
| 6246 instrumentation.log(); | 6160 instrumentation.log(); |
| 6247 } | 6161 } |
| 6248 } | 6162 } |
| 6249 | 6163 |
| 6250 List<Source> get launchableClientLibrarySources { | 6164 List<Source> get launchableClientLibrarySources { |
| 6251 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLaunchableClientLibrarySources"); | 6165 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLaunchableClientLibrarySources"); |
| 6252 try { | 6166 try { |
| 6253 instrumentation.metric3("contextId", _contextId); | 6167 instrumentation.metric3("contextId", _contextId); |
| 6254 List<Source> ret = basis.launchableClientLibrarySources; | 6168 List<Source> ret = _basis.launchableClientLibrarySources; |
| 6255 if (ret != null) { | 6169 if (ret != null) { |
| 6256 instrumentation.metric2("Source-count", ret.length); | 6170 instrumentation.metric2("Source-count", ret.length); |
| 6257 } | 6171 } |
| 6258 return ret; | 6172 return ret; |
| 6259 } finally { | 6173 } finally { |
| 6260 instrumentation.log(); | 6174 instrumentation.log(); |
| 6261 } | 6175 } |
| 6262 } | 6176 } |
| 6263 | 6177 |
| 6264 List<Source> get launchableServerLibrarySources { | 6178 List<Source> get launchableServerLibrarySources { |
| 6265 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLaunchableServerLibrarySources"); | 6179 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLaunchableServerLibrarySources"); |
| 6266 try { | 6180 try { |
| 6267 instrumentation.metric3("contextId", _contextId); | 6181 instrumentation.metric3("contextId", _contextId); |
| 6268 List<Source> ret = basis.launchableServerLibrarySources; | 6182 List<Source> ret = _basis.launchableServerLibrarySources; |
| 6269 if (ret != null) { | 6183 if (ret != null) { |
| 6270 instrumentation.metric2("Source-count", ret.length); | 6184 instrumentation.metric2("Source-count", ret.length); |
| 6271 } | 6185 } |
| 6272 return ret; | 6186 return ret; |
| 6273 } finally { | 6187 } finally { |
| 6274 instrumentation.log(); | 6188 instrumentation.log(); |
| 6275 } | 6189 } |
| 6276 } | 6190 } |
| 6277 | 6191 |
| 6278 List<Source> getLibrariesContaining(Source source) { | 6192 List<Source> getLibrariesContaining(Source source) { |
| 6279 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibrariesContaining"); | 6193 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibrariesContaining"); |
| 6280 try { | 6194 try { |
| 6281 instrumentation.metric3("contextId", _contextId); | 6195 instrumentation.metric3("contextId", _contextId); |
| 6282 List<Source> ret = basis.getLibrariesContaining(source); | 6196 List<Source> ret = _basis.getLibrariesContaining(source); |
| 6283 if (ret != null) { | 6197 if (ret != null) { |
| 6284 instrumentation.metric2("Source-count", ret.length); | 6198 instrumentation.metric2("Source-count", ret.length); |
| 6285 } | 6199 } |
| 6286 return ret; | 6200 return ret; |
| 6287 } finally { | 6201 } finally { |
| 6288 instrumentation.log2(2); | 6202 instrumentation.log2(2); |
| 6289 } | 6203 } |
| 6290 } | 6204 } |
| 6291 | 6205 |
| 6292 List<Source> getLibrariesDependingOn(Source librarySource) { | 6206 List<Source> getLibrariesDependingOn(Source librarySource) { |
| 6293 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibrariesDependingOn"); | 6207 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibrariesDependingOn"); |
| 6294 try { | 6208 try { |
| 6295 instrumentation.metric3("contextId", _contextId); | 6209 instrumentation.metric3("contextId", _contextId); |
| 6296 List<Source> ret = basis.getLibrariesDependingOn(librarySource); | 6210 List<Source> ret = _basis.getLibrariesDependingOn(librarySource); |
| 6297 if (ret != null) { | 6211 if (ret != null) { |
| 6298 instrumentation.metric2("Source-count", ret.length); | 6212 instrumentation.metric2("Source-count", ret.length); |
| 6299 } | 6213 } |
| 6300 return ret; | 6214 return ret; |
| 6301 } finally { | 6215 } finally { |
| 6302 instrumentation.log(); | 6216 instrumentation.log(); |
| 6303 } | 6217 } |
| 6304 } | 6218 } |
| 6305 | 6219 |
| 6306 LibraryElement getLibraryElement(Source source) { | 6220 LibraryElement getLibraryElement(Source source) { |
| 6307 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibraryElement"); | 6221 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibraryElement"); |
| 6308 try { | 6222 try { |
| 6309 instrumentation.metric3("contextId", _contextId); | 6223 instrumentation.metric3("contextId", _contextId); |
| 6310 return basis.getLibraryElement(source); | 6224 return _basis.getLibraryElement(source); |
| 6311 } finally { | 6225 } finally { |
| 6312 instrumentation.log(); | 6226 instrumentation.log(); |
| 6313 } | 6227 } |
| 6314 } | 6228 } |
| 6315 | 6229 |
| 6316 List<Source> get librarySources { | 6230 List<Source> get librarySources { |
| 6317 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibrarySources"); | 6231 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibrarySources"); |
| 6318 try { | 6232 try { |
| 6319 instrumentation.metric3("contextId", _contextId); | 6233 instrumentation.metric3("contextId", _contextId); |
| 6320 List<Source> ret = basis.librarySources; | 6234 List<Source> ret = _basis.librarySources; |
| 6321 if (ret != null) { | 6235 if (ret != null) { |
| 6322 instrumentation.metric2("Source-count", ret.length); | 6236 instrumentation.metric2("Source-count", ret.length); |
| 6323 } | 6237 } |
| 6324 return ret; | 6238 return ret; |
| 6325 } finally { | 6239 } finally { |
| 6326 instrumentation.log(); | 6240 instrumentation.log(); |
| 6327 } | 6241 } |
| 6328 } | 6242 } |
| 6329 | 6243 |
| 6330 LineInfo getLineInfo(Source source) { | 6244 LineInfo getLineInfo(Source source) { |
| 6331 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLineInfo"); | 6245 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLineInfo"); |
| 6332 try { | 6246 try { |
| 6333 instrumentation.metric3("contextId", _contextId); | 6247 instrumentation.metric3("contextId", _contextId); |
| 6334 return basis.getLineInfo(source); | 6248 return _basis.getLineInfo(source); |
| 6335 } finally { | 6249 } finally { |
| 6336 instrumentation.log(); | 6250 instrumentation.log(); |
| 6337 } | 6251 } |
| 6338 } | 6252 } |
| 6339 | 6253 |
| 6340 Namespace getPublicNamespace(LibraryElement library) => basis.getPublicNamespa
ce(library); | 6254 Namespace getPublicNamespace(LibraryElement library) => _basis.getPublicNamesp
ace(library); |
| 6341 | 6255 |
| 6342 Namespace getPublicNamespace2(Source source) => basis.getPublicNamespace2(sour
ce); | 6256 Namespace getPublicNamespace2(Source source) => _basis.getPublicNamespace2(sou
rce); |
| 6343 | 6257 |
| 6344 List<Source> get refactoringUnsafeSources => basis.refactoringUnsafeSources; | 6258 List<Source> get refactoringUnsafeSources => _basis.refactoringUnsafeSources; |
| 6345 | 6259 |
| 6346 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary) { | 6260 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary) { |
| 6347 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getResolvedCompilationUnit"); | 6261 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getResolvedCompilationUnit"); |
| 6348 try { | 6262 try { |
| 6349 instrumentation.metric3("contextId", _contextId); | 6263 instrumentation.metric3("contextId", _contextId); |
| 6350 return basis.getResolvedCompilationUnit(unitSource, library); | 6264 return _basis.getResolvedCompilationUnit(unitSource, library); |
| 6351 } finally { | 6265 } finally { |
| 6352 instrumentation.log(); | 6266 instrumentation.log(); |
| 6353 } | 6267 } |
| 6354 } | 6268 } |
| 6355 | 6269 |
| 6356 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS
ource) { | 6270 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS
ource) { |
| 6357 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getResolvedCompilationUnit"); | 6271 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getResolvedCompilationUnit"); |
| 6358 try { | 6272 try { |
| 6359 instrumentation.metric3("contextId", _contextId); | 6273 instrumentation.metric3("contextId", _contextId); |
| 6360 return basis.getResolvedCompilationUnit2(unitSource, librarySource); | 6274 return _basis.getResolvedCompilationUnit2(unitSource, librarySource); |
| 6361 } finally { | 6275 } finally { |
| 6362 instrumentation.log2(2); | 6276 instrumentation.log2(2); |
| 6363 } | 6277 } |
| 6364 } | 6278 } |
| 6365 | 6279 |
| 6366 SourceFactory get sourceFactory { | 6280 SourceFactory get sourceFactory { |
| 6367 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getSourceFactory"); | 6281 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getSourceFactory"); |
| 6368 try { | 6282 try { |
| 6369 instrumentation.metric3("contextId", _contextId); | 6283 instrumentation.metric3("contextId", _contextId); |
| 6370 return basis.sourceFactory; | 6284 return _basis.sourceFactory; |
| 6371 } finally { | 6285 } finally { |
| 6372 instrumentation.log2(2); | 6286 instrumentation.log2(2); |
| 6373 } | 6287 } |
| 6374 } | 6288 } |
| 6375 | 6289 |
| 6376 AnalysisContentStatistics get statistics => basis.statistics; | 6290 AnalysisContentStatistics get statistics => _basis.statistics; |
| 6377 | 6291 |
| 6378 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou
rce, LibraryElement libraryElement) => basis.internalResolveCompilationUnit(unit
Source, libraryElement); | 6292 TypeProvider get typeProvider => _basis.typeProvider; |
| 6293 |
| 6294 TimestampedData<CompilationUnit> internalResolveCompilationUnit(Source unitSou
rce, LibraryElement libraryElement) => _basis.internalResolveCompilationUnit(uni
tSource, libraryElement); |
| 6379 | 6295 |
| 6380 bool isClientLibrary(Source librarySource) { | 6296 bool isClientLibrary(Source librarySource) { |
| 6381 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
isClientLibrary"); | 6297 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
isClientLibrary"); |
| 6382 try { | 6298 try { |
| 6383 instrumentation.metric3("contextId", _contextId); | 6299 instrumentation.metric3("contextId", _contextId); |
| 6384 return basis.isClientLibrary(librarySource); | 6300 return _basis.isClientLibrary(librarySource); |
| 6385 } finally { | 6301 } finally { |
| 6386 instrumentation.log(); | 6302 instrumentation.log(); |
| 6387 } | 6303 } |
| 6388 } | 6304 } |
| 6389 | 6305 |
| 6390 bool isServerLibrary(Source librarySource) { | 6306 bool isServerLibrary(Source librarySource) { |
| 6391 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
isServerLibrary"); | 6307 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
isServerLibrary"); |
| 6392 try { | 6308 try { |
| 6393 instrumentation.metric3("contextId", _contextId); | 6309 instrumentation.metric3("contextId", _contextId); |
| 6394 return basis.isServerLibrary(librarySource); | 6310 return _basis.isServerLibrary(librarySource); |
| 6395 } finally { | 6311 } finally { |
| 6396 instrumentation.log(); | 6312 instrumentation.log(); |
| 6397 } | 6313 } |
| 6398 } | 6314 } |
| 6399 | 6315 |
| 6400 void mergeContext(AnalysisContext context) { | 6316 void mergeContext(AnalysisContext context) { |
| 6401 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
mergeContext"); | 6317 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
mergeContext"); |
| 6402 try { | 6318 try { |
| 6403 instrumentation.metric3("contextId", _contextId); | 6319 instrumentation.metric3("contextId", _contextId); |
| 6404 if (context is InstrumentedAnalysisContextImpl) { | 6320 if (context is InstrumentedAnalysisContextImpl) { |
| 6405 context = (context as InstrumentedAnalysisContextImpl).basis; | 6321 context = (context as InstrumentedAnalysisContextImpl)._basis; |
| 6406 } | 6322 } |
| 6407 basis.mergeContext(context); | 6323 _basis.mergeContext(context); |
| 6408 } finally { | 6324 } finally { |
| 6409 instrumentation.log(); | 6325 instrumentation.log(); |
| 6410 } | 6326 } |
| 6411 } | 6327 } |
| 6412 | 6328 |
| 6413 CompilationUnit parseCompilationUnit(Source source) { | 6329 CompilationUnit parseCompilationUnit(Source source) { |
| 6414 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
parseCompilationUnit"); | 6330 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
parseCompilationUnit"); |
| 6415 try { | 6331 try { |
| 6416 instrumentation.metric3("contextId", _contextId); | 6332 instrumentation.metric3("contextId", _contextId); |
| 6417 return basis.parseCompilationUnit(source); | 6333 return _basis.parseCompilationUnit(source); |
| 6418 } on AnalysisException catch (e) { | 6334 } on AnalysisException catch (e) { |
| 6419 recordAnalysisException(instrumentation, e); | 6335 recordAnalysisException(instrumentation, e); |
| 6420 throw e; | 6336 throw e; |
| 6421 } finally { | 6337 } finally { |
| 6422 instrumentation.log(); | 6338 instrumentation.log(); |
| 6423 } | 6339 } |
| 6424 } | 6340 } |
| 6425 | 6341 |
| 6426 HtmlUnit parseHtmlUnit(Source source) { | 6342 HtmlUnit parseHtmlUnit(Source source) { |
| 6427 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
parseHtmlUnit"); | 6343 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
parseHtmlUnit"); |
| 6428 try { | 6344 try { |
| 6429 instrumentation.metric3("contextId", _contextId); | 6345 instrumentation.metric3("contextId", _contextId); |
| 6430 return basis.parseHtmlUnit(source); | 6346 return _basis.parseHtmlUnit(source); |
| 6431 } on AnalysisException catch (e) { | 6347 } on AnalysisException catch (e) { |
| 6432 recordAnalysisException(instrumentation, e); | 6348 recordAnalysisException(instrumentation, e); |
| 6433 throw e; | 6349 throw e; |
| 6434 } finally { | 6350 } finally { |
| 6435 instrumentation.log(); | 6351 instrumentation.log(); |
| 6436 } | 6352 } |
| 6437 } | 6353 } |
| 6438 | 6354 |
| 6439 AnalysisResult performAnalysisTask() { | 6355 AnalysisResult performAnalysisTask() { |
| 6440 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
performAnalysisTask"); | 6356 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
performAnalysisTask"); |
| 6441 try { | 6357 try { |
| 6442 instrumentation.metric3("contextId", _contextId); | 6358 instrumentation.metric3("contextId", _contextId); |
| 6443 AnalysisResult result = basis.performAnalysisTask(); | 6359 AnalysisResult result = _basis.performAnalysisTask(); |
| 6444 if (result.changeNotices != null) { | 6360 if (result.changeNotices != null) { |
| 6445 instrumentation.metric2("ChangeNotice-count", result.changeNotices.lengt
h); | 6361 instrumentation.metric2("ChangeNotice-count", result.changeNotices.lengt
h); |
| 6446 } | 6362 } |
| 6447 return result; | 6363 return result; |
| 6448 } finally { | 6364 } finally { |
| 6449 instrumentation.log2(2); | 6365 instrumentation.log2(2); |
| 6450 } | 6366 } |
| 6451 } | 6367 } |
| 6452 | 6368 |
| 6453 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { | 6369 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { |
| 6454 basis.recordLibraryElements(elementMap); | 6370 _basis.recordLibraryElements(elementMap); |
| 6455 } | 6371 } |
| 6456 | 6372 |
| 6457 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry) { | 6373 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry) { |
| 6458 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveCompilationUnit"); | 6374 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveCompilationUnit"); |
| 6459 try { | 6375 try { |
| 6460 instrumentation.metric3("contextId", _contextId); | 6376 instrumentation.metric3("contextId", _contextId); |
| 6461 return basis.resolveCompilationUnit(unitSource, library); | 6377 return _basis.resolveCompilationUnit(unitSource, library); |
| 6462 } on AnalysisException catch (e) { | 6378 } on AnalysisException catch (e) { |
| 6463 recordAnalysisException(instrumentation, e); | 6379 recordAnalysisException(instrumentation, e); |
| 6464 throw e; | 6380 throw e; |
| 6465 } finally { | 6381 } finally { |
| 6466 instrumentation.log(); | 6382 instrumentation.log(); |
| 6467 } | 6383 } |
| 6468 } | 6384 } |
| 6469 | 6385 |
| 6470 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) { | 6386 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) { |
| 6471 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveCompilationUnit"); | 6387 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveCompilationUnit"); |
| 6472 try { | 6388 try { |
| 6473 instrumentation.metric3("contextId", _contextId); | 6389 instrumentation.metric3("contextId", _contextId); |
| 6474 return basis.resolveCompilationUnit2(unitSource, librarySource); | 6390 return _basis.resolveCompilationUnit2(unitSource, librarySource); |
| 6475 } on AnalysisException catch (e) { | 6391 } on AnalysisException catch (e) { |
| 6476 recordAnalysisException(instrumentation, e); | 6392 recordAnalysisException(instrumentation, e); |
| 6477 throw e; | 6393 throw e; |
| 6478 } finally { | 6394 } finally { |
| 6479 instrumentation.log(); | 6395 instrumentation.log(); |
| 6480 } | 6396 } |
| 6481 } | 6397 } |
| 6482 | 6398 |
| 6483 HtmlUnit resolveHtmlUnit(Source htmlSource) { | 6399 HtmlUnit resolveHtmlUnit(Source htmlSource) { |
| 6484 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveHtmlUnit"); | 6400 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveHtmlUnit"); |
| 6485 try { | 6401 try { |
| 6486 instrumentation.metric3("contextId", _contextId); | 6402 instrumentation.metric3("contextId", _contextId); |
| 6487 return basis.resolveHtmlUnit(htmlSource); | 6403 return _basis.resolveHtmlUnit(htmlSource); |
| 6488 } on AnalysisException catch (e) { | 6404 } on AnalysisException catch (e) { |
| 6489 recordAnalysisException(instrumentation, e); | 6405 recordAnalysisException(instrumentation, e); |
| 6490 throw e; | 6406 throw e; |
| 6491 } finally { | 6407 } finally { |
| 6492 instrumentation.log(); | 6408 instrumentation.log(); |
| 6493 } | 6409 } |
| 6494 } | 6410 } |
| 6495 | 6411 |
| 6496 void set analysisOptions(AnalysisOptions options) { | 6412 void set analysisOptions(AnalysisOptions options) { |
| 6497 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setAnalysisOptions"); | 6413 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setAnalysisOptions"); |
| 6498 try { | 6414 try { |
| 6499 instrumentation.metric3("contextId", _contextId); | 6415 instrumentation.metric3("contextId", _contextId); |
| 6500 basis.analysisOptions = options; | 6416 _basis.analysisOptions = options; |
| 6501 } finally { | 6417 } finally { |
| 6502 instrumentation.log(); | 6418 instrumentation.log(); |
| 6503 } | 6419 } |
| 6504 } | 6420 } |
| 6505 | 6421 |
| 6506 void set analysisPriorityOrder(List<Source> sources) { | 6422 void set analysisPriorityOrder(List<Source> sources) { |
| 6507 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setAnalysisPriorityOrder"); | 6423 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setAnalysisPriorityOrder"); |
| 6508 try { | 6424 try { |
| 6509 instrumentation.metric3("contextId", _contextId); | 6425 instrumentation.metric3("contextId", _contextId); |
| 6510 basis.analysisPriorityOrder = sources; | 6426 _basis.analysisPriorityOrder = sources; |
| 6511 } finally { | 6427 } finally { |
| 6512 instrumentation.log(); | 6428 instrumentation.log(); |
| 6513 } | 6429 } |
| 6514 } | 6430 } |
| 6515 | 6431 |
| 6516 void setChangedContents(Source source, String contents, int offset, int oldLen
gth, int newLength) { | 6432 void setChangedContents(Source source, String contents, int offset, int oldLen
gth, int newLength) { |
| 6517 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setChangedContents"); | 6433 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setChangedContents"); |
| 6518 try { | 6434 try { |
| 6519 instrumentation.metric3("contextId", _contextId); | 6435 instrumentation.metric3("contextId", _contextId); |
| 6520 basis.setChangedContents(source, contents, offset, oldLength, newLength); | 6436 _basis.setChangedContents(source, contents, offset, oldLength, newLength); |
| 6521 } finally { | 6437 } finally { |
| 6522 instrumentation.log(); | 6438 instrumentation.log(); |
| 6523 } | 6439 } |
| 6524 } | 6440 } |
| 6525 | 6441 |
| 6526 void setContents(Source source, String contents) { | 6442 void setContents(Source source, String contents) { |
| 6527 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setContents"); | 6443 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setContents"); |
| 6528 try { | 6444 try { |
| 6529 instrumentation.metric3("contextId", _contextId); | 6445 instrumentation.metric3("contextId", _contextId); |
| 6530 basis.setContents(source, contents); | 6446 _basis.setContents(source, contents); |
| 6531 } finally { | 6447 } finally { |
| 6532 instrumentation.log(); | 6448 instrumentation.log(); |
| 6533 } | 6449 } |
| 6534 } | 6450 } |
| 6535 | 6451 |
| 6536 void set sourceFactory(SourceFactory factory) { | 6452 void set sourceFactory(SourceFactory factory) { |
| 6537 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setSourceFactory"); | 6453 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
setSourceFactory"); |
| 6538 try { | 6454 try { |
| 6539 instrumentation.metric3("contextId", _contextId); | 6455 instrumentation.metric3("contextId", _contextId); |
| 6540 basis.sourceFactory = factory; | 6456 _basis.sourceFactory = factory; |
| 6541 } finally { | 6457 } finally { |
| 6542 instrumentation.log(); | 6458 instrumentation.log(); |
| 6543 } | 6459 } |
| 6544 } | 6460 } |
| 6545 | 6461 |
| 6546 Iterable<Source> sourcesToResolve(List<Source> changedSources) { | 6462 Iterable<Source> sourcesToResolve(List<Source> changedSources) { |
| 6547 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
sourcesToResolve"); | 6463 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
sourcesToResolve"); |
| 6548 try { | 6464 try { |
| 6549 instrumentation.metric3("contextId", _contextId); | 6465 instrumentation.metric3("contextId", _contextId); |
| 6550 return basis.sourcesToResolve(changedSources); | 6466 return _basis.sourcesToResolve(changedSources); |
| 6551 } finally { | 6467 } finally { |
| 6552 instrumentation.log(); | 6468 instrumentation.log(); |
| 6553 } | 6469 } |
| 6554 } | 6470 } |
| 6555 } | 6471 } |
| 6556 | 6472 |
| 6557 /** | 6473 /** |
| 6558 * The interface `InternalAnalysisContext` defines additional behavior for an an
alysis context | 6474 * The interface `InternalAnalysisContext` defines additional behavior for an an
alysis context |
| 6559 * that is required by internal users of the context. | 6475 * that is required by internal users of the context. |
| 6560 */ | 6476 */ |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6639 * @throws AnalysisException if the public namespace could not be computed | 6555 * @throws AnalysisException if the public namespace could not be computed |
| 6640 */ | 6556 */ |
| 6641 Namespace getPublicNamespace2(Source source); | 6557 Namespace getPublicNamespace2(Source source); |
| 6642 | 6558 |
| 6643 /** | 6559 /** |
| 6644 * Returns a statistics about this context. | 6560 * Returns a statistics about this context. |
| 6645 */ | 6561 */ |
| 6646 AnalysisContentStatistics get statistics; | 6562 AnalysisContentStatistics get statistics; |
| 6647 | 6563 |
| 6648 /** | 6564 /** |
| 6565 * Returns a type provider for this context or throws an exception if dart:cor
e cannot be |
| 6566 * resolved. |
| 6567 * |
| 6568 * @return the type provider (not `null`) |
| 6569 * @throws AnalysisException if dart:core cannot be resolved |
| 6570 */ |
| 6571 TypeProvider get typeProvider; |
| 6572 |
| 6573 /** |
| 6649 * Return a time-stamped fully-resolved compilation unit for the given source
in the given | 6574 * Return a time-stamped fully-resolved compilation unit for the given source
in the given |
| 6650 * library. | 6575 * library. |
| 6651 * | 6576 * |
| 6652 * @param unitSource the source of the compilation unit for which a resolved A
ST structure is to | 6577 * @param unitSource the source of the compilation unit for which a resolved A
ST structure is to |
| 6653 * be returned | 6578 * be returned |
| 6654 * @param libraryElement the element representing the library in which the com
pilation unit is to | 6579 * @param libraryElement the element representing the library in which the com
pilation unit is to |
| 6655 * be resolved | 6580 * be resolved |
| 6656 * @return a time-stamped fully-resolved compilation unit for the source | 6581 * @return a time-stamped fully-resolved compilation unit for the source |
| 6657 * @throws AnalysisException if the resolved compilation unit could not be com
puted | 6582 * @throws AnalysisException if the resolved compilation unit could not be com
puted |
| 6658 */ | 6583 */ |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6906 } | 6831 } |
| 6907 | 6832 |
| 6908 /** | 6833 /** |
| 6909 * Instances of the class `TimestampedData` represent analysis data for which we
have a | 6834 * Instances of the class `TimestampedData` represent analysis data for which we
have a |
| 6910 * modification time. | 6835 * modification time. |
| 6911 */ | 6836 */ |
| 6912 class TimestampedData<E> { | 6837 class TimestampedData<E> { |
| 6913 /** | 6838 /** |
| 6914 * The modification time of the source from which the data was created. | 6839 * The modification time of the source from which the data was created. |
| 6915 */ | 6840 */ |
| 6916 int modificationTime = 0; | 6841 final int modificationTime; |
| 6917 | 6842 |
| 6918 /** | 6843 /** |
| 6919 * The data that was created from the source. | 6844 * The data that was created from the source. |
| 6920 */ | 6845 */ |
| 6921 E data; | 6846 final E data; |
| 6922 | 6847 |
| 6923 /** | 6848 /** |
| 6924 * Initialize a newly created holder to hold the given values. | 6849 * Initialize a newly created holder to hold the given values. |
| 6925 * | 6850 * |
| 6926 * @param modificationTime the modification time of the source from which the
data was created | 6851 * @param modificationTime the modification time of the source from which the
data was created |
| 6927 * @param unit the data that was created from the source | 6852 * @param unit the data that was created from the source |
| 6928 */ | 6853 */ |
| 6929 TimestampedData(int modificationTime, E data) { | 6854 TimestampedData(this.modificationTime, this.data); |
| 6930 this.modificationTime = modificationTime; | |
| 6931 this.data = data; | |
| 6932 } | |
| 6933 } | 6855 } |
| 6934 | 6856 |
| 6935 /** | 6857 /** |
| 6936 * The abstract class `AnalysisTask` defines the behavior of objects used to per
form an | 6858 * The abstract class `AnalysisTask` defines the behavior of objects used to per
form an |
| 6937 * analysis task. | 6859 * analysis task. |
| 6938 */ | 6860 */ |
| 6939 abstract class AnalysisTask { | 6861 abstract class AnalysisTask { |
| 6940 /** | 6862 /** |
| 6941 * The context in which the task is to be performed. | 6863 * The context in which the task is to be performed. |
| 6942 */ | 6864 */ |
| 6943 InternalAnalysisContext context; | 6865 final InternalAnalysisContext context; |
| 6944 | 6866 |
| 6945 /** | 6867 /** |
| 6946 * The exception that was thrown while performing this task, or `null` if the
task completed | 6868 * The exception that was thrown while performing this task, or `null` if the
task completed |
| 6947 * successfully. | 6869 * successfully. |
| 6948 */ | 6870 */ |
| 6949 AnalysisException exception; | 6871 AnalysisException _thrownException; |
| 6950 | 6872 |
| 6951 /** | 6873 /** |
| 6952 * Initialize a newly created task to perform analysis within the given contex
t. | 6874 * Initialize a newly created task to perform analysis within the given contex
t. |
| 6953 * | 6875 * |
| 6954 * @param context the context in which the task is to be performed | 6876 * @param context the context in which the task is to be performed |
| 6955 */ | 6877 */ |
| 6956 AnalysisTask(InternalAnalysisContext context) { | 6878 AnalysisTask(this.context); |
| 6957 this.context = context; | |
| 6958 } | |
| 6959 | 6879 |
| 6960 /** | 6880 /** |
| 6961 * Use the given visitor to visit this task. | 6881 * Use the given visitor to visit this task. |
| 6962 * | 6882 * |
| 6963 * @param visitor the visitor that should be used to visit this task | 6883 * @param visitor the visitor that should be used to visit this task |
| 6964 * @return the value returned by the visitor | 6884 * @return the value returned by the visitor |
| 6965 * @throws AnalysisException if the visitor throws the exception | 6885 * @throws AnalysisException if the visitor throws the exception |
| 6966 */ | 6886 */ |
| 6967 accept(AnalysisTaskVisitor visitor); | 6887 accept(AnalysisTaskVisitor visitor); |
| 6968 | 6888 |
| 6969 /** | 6889 /** |
| 6890 * Return the exception that was thrown while performing this task, or `null`
if the task |
| 6891 * completed successfully. |
| 6892 * |
| 6893 * @return the exception that was thrown while performing this task |
| 6894 */ |
| 6895 AnalysisException get exception => _thrownException; |
| 6896 |
| 6897 /** |
| 6970 * Perform this analysis task and use the given visitor to visit this task aft
er it has completed. | 6898 * Perform this analysis task and use the given visitor to visit this task aft
er it has completed. |
| 6971 * | 6899 * |
| 6972 * @param visitor the visitor used to visit this task after it has completed | 6900 * @param visitor the visitor used to visit this task after it has completed |
| 6973 * @return the value returned by the visitor | 6901 * @return the value returned by the visitor |
| 6974 * @throws AnalysisException if the visitor throws the exception | 6902 * @throws AnalysisException if the visitor throws the exception |
| 6975 */ | 6903 */ |
| 6976 Object perform(AnalysisTaskVisitor visitor) { | 6904 Object perform(AnalysisTaskVisitor visitor) { |
| 6977 try { | 6905 try { |
| 6978 safelyPerform(); | 6906 safelyPerform(); |
| 6979 } on AnalysisException catch (exception) { | 6907 } on AnalysisException catch (exception) { |
| 6980 this.exception = exception; | 6908 _thrownException = exception; |
| 6981 AnalysisEngine.instance.logger.logInformation2("Task failed: ${taskDescrip
tion}", exception); | 6909 AnalysisEngine.instance.logger.logInformation2("Task failed: ${taskDescrip
tion}", exception); |
| 6982 } | 6910 } |
| 6983 return accept(visitor); | 6911 return accept(visitor); |
| 6984 } | 6912 } |
| 6985 | 6913 |
| 6986 String toString() => taskDescription; | 6914 String toString() => taskDescription; |
| 6987 | 6915 |
| 6988 /** | 6916 /** |
| 6989 * Return a textual description of this task. | 6917 * Return a textual description of this task. |
| 6990 * | 6918 * |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7096 } | 7024 } |
| 7097 | 7025 |
| 7098 /** | 7026 /** |
| 7099 * Instances of the class `GenerateDartErrorsTask` generate errors and warnings
for a single | 7027 * Instances of the class `GenerateDartErrorsTask` generate errors and warnings
for a single |
| 7100 * Dart source. | 7028 * Dart source. |
| 7101 */ | 7029 */ |
| 7102 class GenerateDartErrorsTask extends AnalysisTask { | 7030 class GenerateDartErrorsTask extends AnalysisTask { |
| 7103 /** | 7031 /** |
| 7104 * The source for which errors and warnings are to be produced. | 7032 * The source for which errors and warnings are to be produced. |
| 7105 */ | 7033 */ |
| 7106 Source source; | 7034 final Source source; |
| 7107 | 7035 |
| 7108 /** | 7036 /** |
| 7109 * The element model for the library containing the source. | 7037 * The element model for the library containing the source. |
| 7110 */ | 7038 */ |
| 7111 LibraryElement libraryElement; | 7039 final LibraryElement libraryElement; |
| 7112 | 7040 |
| 7113 /** | 7041 /** |
| 7114 * The time at which the contents of the source were last modified. | 7042 * The time at which the contents of the source were last modified. |
| 7115 */ | 7043 */ |
| 7116 int modificationTime = -1; | 7044 int _modificationTime = -1; |
| 7117 | 7045 |
| 7118 /** | 7046 /** |
| 7119 * The errors that were generated for the source. | 7047 * The errors that were generated for the source. |
| 7120 */ | 7048 */ |
| 7121 List<AnalysisError> errors; | 7049 List<AnalysisError> _errors; |
| 7122 | 7050 |
| 7123 /** | 7051 /** |
| 7124 * Initialize a newly created task to perform analysis within the given contex
t. | 7052 * Initialize a newly created task to perform analysis within the given contex
t. |
| 7125 * | 7053 * |
| 7126 * @param context the context in which the task is to be performed | 7054 * @param context the context in which the task is to be performed |
| 7127 * @param source the source for which errors and warnings are to be produced | 7055 * @param source the source for which errors and warnings are to be produced |
| 7128 * @param libraryElement the element model for the library containing the sour
ce | 7056 * @param libraryElement the element model for the library containing the sour
ce |
| 7129 */ | 7057 */ |
| 7130 GenerateDartErrorsTask(InternalAnalysisContext context, Source source, Library
Element libraryElement) : super(context) { | 7058 GenerateDartErrorsTask(InternalAnalysisContext context, this.source, this.libr
aryElement) : super(context); |
| 7131 this.source = source; | |
| 7132 this.libraryElement = libraryElement; | |
| 7133 } | |
| 7134 | 7059 |
| 7135 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartErrorsTask(thi
s); | 7060 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartErrorsTask(thi
s); |
| 7136 | 7061 |
| 7062 /** |
| 7063 * Return the errors that were generated for the source. |
| 7064 * |
| 7065 * @return the errors that were generated for the source |
| 7066 */ |
| 7067 List<AnalysisError> get errors => _errors; |
| 7068 |
| 7069 /** |
| 7070 * Return the time at which the contents of the source that was verified were
last modified, or a |
| 7071 * negative value if the task has not yet been performed or if an exception oc
curred. |
| 7072 * |
| 7073 * @return the time at which the contents of the source that was verified were
last modified |
| 7074 */ |
| 7075 int get modificationTime => _modificationTime; |
| 7076 |
| 7137 String get taskDescription => "generate errors and warnings for ${source.fullN
ame}"; | 7077 String get taskDescription => "generate errors and warnings for ${source.fullN
ame}"; |
| 7138 | 7078 |
| 7139 void internalPerform() { | 7079 void internalPerform() { |
| 7140 InternalAnalysisContext context = this.context; | 7080 InternalAnalysisContext context = this.context; |
| 7141 TimestampedData<CompilationUnit> data = context.internalResolveCompilationUn
it(source, libraryElement); | 7081 TimestampedData<CompilationUnit> data = context.internalResolveCompilationUn
it(source, libraryElement); |
| 7142 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.errors.sta
rt(); | 7082 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.errors.sta
rt(); |
| 7143 try { | 7083 try { |
| 7144 modificationTime = data.modificationTime; | 7084 _modificationTime = data.modificationTime; |
| 7145 CompilationUnit unit = data.data; | 7085 CompilationUnit unit = data.data; |
| 7146 RecordingErrorListener errorListener = new RecordingErrorListener(); | 7086 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 7147 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); | 7087 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); |
| 7148 Source coreSource = context.sourceFactory.forUri(DartSdk.DART_CORE); | 7088 TypeProvider typeProvider = context.typeProvider; |
| 7149 LibraryElement coreLibrary = context.getLibraryElement(coreSource); | |
| 7150 TypeProvider typeProvider = new TypeProviderImpl(coreLibrary); | |
| 7151 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, ty
peProvider); | 7089 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, ty
peProvider); |
| 7152 unit.accept(constantVerifier); | 7090 unit.accept(constantVerifier); |
| 7153 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, libraryElem
ent, typeProvider, new InheritanceManager(libraryElement)); | 7091 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, libraryElem
ent, typeProvider, new InheritanceManager(libraryElement)); |
| 7154 unit.accept(errorVerifier); | 7092 unit.accept(errorVerifier); |
| 7155 errors = errorListener.getErrors2(source); | 7093 _errors = errorListener.getErrors2(source); |
| 7156 } finally { | 7094 } finally { |
| 7157 timeCounter.stop(); | 7095 timeCounter.stop(); |
| 7158 } | 7096 } |
| 7159 } | 7097 } |
| 7160 } | 7098 } |
| 7161 | 7099 |
| 7162 /** | 7100 /** |
| 7163 * Instances of the class `GenerateDartHintsTask` generate hints for a single Da
rt library. | 7101 * Instances of the class `GenerateDartHintsTask` generate hints for a single Da
rt library. |
| 7164 */ | 7102 */ |
| 7165 class GenerateDartHintsTask extends AnalysisTask { | 7103 class GenerateDartHintsTask extends AnalysisTask { |
| 7166 /** | 7104 /** |
| 7167 * The element model for the library being analyzed. | 7105 * The element model for the library being analyzed. |
| 7168 */ | 7106 */ |
| 7169 LibraryElement libraryElement; | 7107 final LibraryElement libraryElement; |
| 7170 | 7108 |
| 7171 /** | 7109 /** |
| 7172 * A table mapping the sources that were analyzed to the hints that were gener
ated for the | 7110 * A table mapping the sources that were analyzed to the hints that were gener
ated for the |
| 7173 * sources. | 7111 * sources. |
| 7174 */ | 7112 */ |
| 7175 Map<Source, TimestampedData<List<AnalysisError>>> hintMap; | 7113 Map<Source, TimestampedData<List<AnalysisError>>> _hintMap; |
| 7176 | 7114 |
| 7177 /** | 7115 /** |
| 7178 * Initialize a newly created task to perform analysis within the given contex
t. | 7116 * Initialize a newly created task to perform analysis within the given contex
t. |
| 7179 * | 7117 * |
| 7180 * @param context the context in which the task is to be performed | 7118 * @param context the context in which the task is to be performed |
| 7181 * @param libraryElement the element model for the library being analyzed | 7119 * @param libraryElement the element model for the library being analyzed |
| 7182 */ | 7120 */ |
| 7183 GenerateDartHintsTask(InternalAnalysisContext context, LibraryElement libraryE
lement) : super(context) { | 7121 GenerateDartHintsTask(InternalAnalysisContext context, this.libraryElement) :
super(context); |
| 7184 this.libraryElement = libraryElement; | |
| 7185 } | |
| 7186 | 7122 |
| 7187 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartHintsTask(this
); | 7123 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartHintsTask(this
); |
| 7188 | 7124 |
| 7125 /** |
| 7126 * Return a table mapping the sources that were analyzed to the hints that wer
e generated for the |
| 7127 * sources, or `null` if the task has not been performed or if the analysis di
d not complete |
| 7128 * normally. |
| 7129 * |
| 7130 * @return a table mapping the sources that were analyzed to the hints that we
re generated for the |
| 7131 * sources |
| 7132 */ |
| 7133 Map<Source, TimestampedData<List<AnalysisError>>> get hintMap => _hintMap; |
| 7134 |
| 7189 String get taskDescription { | 7135 String get taskDescription { |
| 7190 Source librarySource = libraryElement.source; | 7136 Source librarySource = libraryElement.source; |
| 7191 if (librarySource == null) { | 7137 if (librarySource == null) { |
| 7192 return "generate Dart hints for library without source"; | 7138 return "generate Dart hints for library without source"; |
| 7193 } | 7139 } |
| 7194 return "generate Dart hints for ${librarySource.fullName}"; | 7140 return "generate Dart hints for ${librarySource.fullName}"; |
| 7195 } | 7141 } |
| 7196 | 7142 |
| 7197 void internalPerform() { | 7143 void internalPerform() { |
| 7198 RecordingErrorListener errorListener = new RecordingErrorListener(); | 7144 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 7213 resolvedUnit = getCompilationUnit(unitSource); | 7159 resolvedUnit = getCompilationUnit(unitSource); |
| 7214 timestampMap[unitSource] = resolvedUnit; | 7160 timestampMap[unitSource] = resolvedUnit; |
| 7215 unit = resolvedUnit.data; | 7161 unit = resolvedUnit.data; |
| 7216 if (unit == null) { | 7162 if (unit == null) { |
| 7217 throw new AnalysisException.con1("Internal error: GenerateDartHintsTask
failed to access resolved compilation unit for ${unitSource.fullName}"); | 7163 throw new AnalysisException.con1("Internal error: GenerateDartHintsTask
failed to access resolved compilation unit for ${unitSource.fullName}"); |
| 7218 } | 7164 } |
| 7219 compilationUnits[i + 1] = unit; | 7165 compilationUnits[i + 1] = unit; |
| 7220 } | 7166 } |
| 7221 HintGenerator hintGenerator = new HintGenerator(compilationUnits, context, e
rrorListener); | 7167 HintGenerator hintGenerator = new HintGenerator(compilationUnits, context, e
rrorListener); |
| 7222 hintGenerator.generateForLibrary(); | 7168 hintGenerator.generateForLibrary(); |
| 7223 hintMap = new Map<Source, TimestampedData<List<AnalysisError>>>(); | 7169 _hintMap = new Map<Source, TimestampedData<List<AnalysisError>>>(); |
| 7224 for (MapEntry<Source, TimestampedData<CompilationUnit>> entry in getMapEntry
Set(timestampMap)) { | 7170 for (MapEntry<Source, TimestampedData<CompilationUnit>> entry in getMapEntry
Set(timestampMap)) { |
| 7225 Source source = entry.getKey(); | 7171 Source source = entry.getKey(); |
| 7226 TimestampedData<CompilationUnit> unitData = entry.getValue(); | 7172 TimestampedData<CompilationUnit> unitData = entry.getValue(); |
| 7227 List<AnalysisError> errors = errorListener.getErrors2(source); | 7173 List<AnalysisError> errors = errorListener.getErrors2(source); |
| 7228 hintMap[source] = new TimestampedData<List<AnalysisError>>(unitData.modifi
cationTime, errors); | 7174 _hintMap[source] = new TimestampedData<List<AnalysisError>>(unitData.modif
icationTime, errors); |
| 7229 } | 7175 } |
| 7230 } | 7176 } |
| 7231 | 7177 |
| 7232 /** | 7178 /** |
| 7233 * Return the resolved compilation unit associated with the given source. | 7179 * Return the resolved compilation unit associated with the given source. |
| 7234 * | 7180 * |
| 7235 * @param unitSource the source for the compilation unit whose resolved AST is
to be returned | 7181 * @param unitSource the source for the compilation unit whose resolved AST is
to be returned |
| 7236 * @return the resolved compilation unit associated with the given source | 7182 * @return the resolved compilation unit associated with the given source |
| 7237 * @throws AnalysisException if the resolved compilation unit could not be com
puted | 7183 * @throws AnalysisException if the resolved compilation unit could not be com
puted |
| 7238 */ | 7184 */ |
| 7239 TimestampedData<CompilationUnit> getCompilationUnit(Source unitSource) => cont
ext.internalResolveCompilationUnit(unitSource, libraryElement); | 7185 TimestampedData<CompilationUnit> getCompilationUnit(Source unitSource) => cont
ext.internalResolveCompilationUnit(unitSource, libraryElement); |
| 7240 } | 7186 } |
| 7241 | 7187 |
| 7242 /** | 7188 /** |
| 7243 * Instances of the class `IncrementalAnalysisTask` incrementally update existin
g analysis. | 7189 * Instances of the class `IncrementalAnalysisTask` incrementally update existin
g analysis. |
| 7244 */ | 7190 */ |
| 7245 class IncrementalAnalysisTask extends AnalysisTask { | 7191 class IncrementalAnalysisTask extends AnalysisTask { |
| 7246 /** | 7192 /** |
| 7247 * The information used to perform incremental analysis. | 7193 * The information used to perform incremental analysis. |
| 7248 */ | 7194 */ |
| 7249 IncrementalAnalysisCache cache; | 7195 final IncrementalAnalysisCache cache; |
| 7250 | 7196 |
| 7251 /** | 7197 /** |
| 7252 * The compilation unit that was produced by incrementally updating the existi
ng unit. | 7198 * The compilation unit that was produced by incrementally updating the existi
ng unit. |
| 7253 */ | 7199 */ |
| 7254 CompilationUnit compilationUnit; | 7200 CompilationUnit _updatedUnit; |
| 7255 | 7201 |
| 7256 /** | 7202 /** |
| 7257 * Initialize a newly created task to perform analysis within the given contex
t. | 7203 * Initialize a newly created task to perform analysis within the given contex
t. |
| 7258 * | 7204 * |
| 7259 * @param context the context in which the task is to be performed | 7205 * @param context the context in which the task is to be performed |
| 7260 * @param cache the incremental analysis cache used to perform the analysis | 7206 * @param cache the incremental analysis cache used to perform the analysis |
| 7261 */ | 7207 */ |
| 7262 IncrementalAnalysisTask(InternalAnalysisContext context, IncrementalAnalysisCa
che cache) : super(context) { | 7208 IncrementalAnalysisTask(InternalAnalysisContext context, this.cache) : super(c
ontext); |
| 7263 this.cache = cache; | |
| 7264 } | |
| 7265 | 7209 |
| 7266 accept(AnalysisTaskVisitor visitor) => visitor.visitIncrementalAnalysisTask(th
is); | 7210 accept(AnalysisTaskVisitor visitor) => visitor.visitIncrementalAnalysisTask(th
is); |
| 7267 | 7211 |
| 7268 /** | 7212 /** |
| 7213 * Return the compilation unit that was produced by incrementally updating the
existing |
| 7214 * compilation unit, or `null` if the task has not yet been performed, could n
ot be |
| 7215 * performed, or if an exception occurred. |
| 7216 * |
| 7217 * @return the compilation unit |
| 7218 */ |
| 7219 CompilationUnit get compilationUnit => _updatedUnit; |
| 7220 |
| 7221 /** |
| 7269 * Return the source that is to be incrementally analyzed. | 7222 * Return the source that is to be incrementally analyzed. |
| 7270 * | 7223 * |
| 7271 * @return the source | 7224 * @return the source |
| 7272 */ | 7225 */ |
| 7273 Source get source => cache != null ? cache.source : null; | 7226 Source get source => cache != null ? cache.source : null; |
| 7274 | 7227 |
| 7275 String get taskDescription => "incremental analysis ${(cache != null ? cache.s
ource : "null")}"; | 7228 String get taskDescription => "incremental analysis ${(cache != null ? cache.s
ource : "null")}"; |
| 7276 | 7229 |
| 7277 void internalPerform() { | 7230 void internalPerform() { |
| 7278 if (cache == null) { | 7231 if (cache == null) { |
| 7279 return; | 7232 return; |
| 7280 } | 7233 } |
| 7281 if (cache.oldLength > 0 || cache.newLength > 30) { | 7234 if (cache.oldLength > 0 || cache.newLength > 30) { |
| 7282 return; | 7235 return; |
| 7283 } | 7236 } |
| 7284 CharacterReader reader = new CharSequenceReader(new CharSequence(cache.newCo
ntents)); | 7237 CharacterReader reader = new CharSequenceReader(new CharSequence(cache.newCo
ntents)); |
| 7285 BooleanErrorListener errorListener = new BooleanErrorListener(); | 7238 BooleanErrorListener errorListener = new BooleanErrorListener(); |
| 7286 IncrementalScanner scanner = new IncrementalScanner(cache.source, reader, er
rorListener); | 7239 IncrementalScanner scanner = new IncrementalScanner(cache.source, reader, er
rorListener); |
| 7287 Token oldTokens = cache.resolvedUnit.beginToken; | 7240 scanner.rescan(cache.resolvedUnit.beginToken, cache.offset, cache.oldLength,
cache.newLength); |
| 7288 Token newTokens = scanner.rescan(oldTokens, cache.offset, cache.oldLength, c
ache.newLength); | |
| 7289 if (errorListener.errorReported) { | 7241 if (errorListener.errorReported) { |
| 7290 return; | 7242 return; |
| 7291 } | 7243 } |
| 7292 IncrementalParser parser = new IncrementalParser(cache.source, scanner.token
Map, AnalysisErrorListener.NULL_LISTENER); | 7244 IncrementalParser parser = new IncrementalParser(cache.source, scanner.token
Map, AnalysisErrorListener.NULL_LISTENER); |
| 7293 compilationUnit = parser.reparse(cache.resolvedUnit, scanner.leftToken, scan
ner.rightToken, cache.offset, cache.offset + cache.oldLength); | 7245 _updatedUnit = parser.reparse(cache.resolvedUnit, scanner.leftToken, scanner
.rightToken, cache.offset, cache.offset + cache.oldLength); |
| 7246 TypeProvider typeProvider = this.typeProvider; |
| 7247 if (_updatedUnit != null && typeProvider != null) { |
| 7248 CompilationUnitElement element = _updatedUnit.element; |
| 7249 if (element != null) { |
| 7250 LibraryElement library = element.library; |
| 7251 if (library != null) { |
| 7252 IncrementalResolver resolver = new IncrementalResolver(library, cache.
source, typeProvider, errorListener); |
| 7253 resolver.resolve(parser.updatedNode); |
| 7254 } |
| 7255 } |
| 7256 } |
| 7257 } |
| 7258 |
| 7259 /** |
| 7260 * Return the type provider used for incremental resolution. |
| 7261 * |
| 7262 * @return the type provider (or `null` if an exception occurs) |
| 7263 */ |
| 7264 TypeProvider get typeProvider { |
| 7265 try { |
| 7266 return context.typeProvider; |
| 7267 } on AnalysisException catch (exception) { |
| 7268 return null; |
| 7269 } |
| 7294 } | 7270 } |
| 7295 } | 7271 } |
| 7296 | 7272 |
| 7297 /** | 7273 /** |
| 7298 * Instances of the class `ParseDartTask` parse a specific source as a Dart file
. | 7274 * Instances of the class `ParseDartTask` parse a specific source as a Dart file
. |
| 7299 */ | 7275 */ |
| 7300 class ParseDartTask extends AnalysisTask { | 7276 class ParseDartTask extends AnalysisTask { |
| 7301 /** | 7277 /** |
| 7302 * The source to be parsed. | 7278 * The source to be parsed. |
| 7303 */ | 7279 */ |
| 7304 Source source; | 7280 final Source source; |
| 7305 | 7281 |
| 7306 /** | 7282 /** |
| 7307 * The time at which the contents of the source were last modified. | 7283 * The time at which the contents of the source were last modified. |
| 7308 */ | 7284 */ |
| 7309 int modificationTime = -1; | 7285 int _modificationTime = -1; |
| 7310 | 7286 |
| 7311 /** | 7287 /** |
| 7312 * The line information that was produced. | 7288 * The line information that was produced. |
| 7313 */ | 7289 */ |
| 7314 LineInfo lineInfo; | 7290 LineInfo _lineInfo; |
| 7315 | 7291 |
| 7316 /** | 7292 /** |
| 7317 * The compilation unit that was produced by parsing the source. | 7293 * The compilation unit that was produced by parsing the source. |
| 7318 */ | 7294 */ |
| 7319 CompilationUnit compilationUnit; | 7295 CompilationUnit _unit; |
| 7320 | 7296 |
| 7321 /** | 7297 /** |
| 7322 * The errors that were produced by scanning and parsing the source. | 7298 * The errors that were produced by scanning and parsing the source. |
| 7323 */ | 7299 */ |
| 7324 List<AnalysisError> errors = AnalysisError.NO_ERRORS; | 7300 List<AnalysisError> _errors = AnalysisError.NO_ERRORS; |
| 7325 | 7301 |
| 7326 /** | 7302 /** |
| 7327 * A flag indicating whether the source contains a 'part of' directive. | 7303 * A flag indicating whether the source contains a 'part of' directive. |
| 7328 */ | 7304 */ |
| 7329 bool _hasPartOfDirective2 = false; | 7305 bool _hasPartOfDirective2 = false; |
| 7330 | 7306 |
| 7331 /** | 7307 /** |
| 7332 * A flag indicating whether the source contains a 'library' directive. | 7308 * A flag indicating whether the source contains a 'library' directive. |
| 7333 */ | 7309 */ |
| 7334 bool _hasLibraryDirective2 = false; | 7310 bool _hasLibraryDirective2 = false; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 7347 * A set containing the sources referenced by 'part' directives. | 7323 * A set containing the sources referenced by 'part' directives. |
| 7348 */ | 7324 */ |
| 7349 Set<Source> _includedSources = new Set<Source>(); | 7325 Set<Source> _includedSources = new Set<Source>(); |
| 7350 | 7326 |
| 7351 /** | 7327 /** |
| 7352 * Initialize a newly created task to perform analysis within the given contex
t. | 7328 * Initialize a newly created task to perform analysis within the given contex
t. |
| 7353 * | 7329 * |
| 7354 * @param context the context in which the task is to be performed | 7330 * @param context the context in which the task is to be performed |
| 7355 * @param source the source to be parsed | 7331 * @param source the source to be parsed |
| 7356 */ | 7332 */ |
| 7357 ParseDartTask(InternalAnalysisContext context, Source source) : super(context)
{ | 7333 ParseDartTask(InternalAnalysisContext context, this.source) : super(context); |
| 7358 this.source = source; | |
| 7359 } | |
| 7360 | 7334 |
| 7361 accept(AnalysisTaskVisitor visitor) => visitor.visitParseDartTask(this); | 7335 accept(AnalysisTaskVisitor visitor) => visitor.visitParseDartTask(this); |
| 7362 | 7336 |
| 7363 /** | 7337 /** |
| 7338 * Return the compilation unit that was produced by parsing the source, or `nu
ll` if the |
| 7339 * task has not yet been performed or if an exception occurred. |
| 7340 * |
| 7341 * @return the compilation unit that was produced by parsing the source |
| 7342 */ |
| 7343 CompilationUnit get compilationUnit => _unit; |
| 7344 |
| 7345 /** |
| 7346 * Return the errors that were produced by scanning and parsing the source, or
`null` if the |
| 7347 * task has not yet been performed or if an exception occurred. |
| 7348 * |
| 7349 * @return the errors that were produced by scanning and parsing the source |
| 7350 */ |
| 7351 List<AnalysisError> get errors => _errors; |
| 7352 |
| 7353 /** |
| 7364 * Return an array containing the sources referenced by 'export' directives, o
r an empty array if | 7354 * Return an array containing the sources referenced by 'export' directives, o
r an empty array if |
| 7365 * the task has not yet been performed or if an exception occurred. | 7355 * the task has not yet been performed or if an exception occurred. |
| 7366 * | 7356 * |
| 7367 * @return an array containing the sources referenced by 'export' directives | 7357 * @return an array containing the sources referenced by 'export' directives |
| 7368 */ | 7358 */ |
| 7369 List<Source> get exportedSources => toArray(_exportedSources); | 7359 List<Source> get exportedSources => toArray(_exportedSources); |
| 7370 | 7360 |
| 7371 /** | 7361 /** |
| 7372 * Return an array containing the sources referenced by 'import' directives, o
r an empty array if | 7362 * Return an array containing the sources referenced by 'import' directives, o
r an empty array if |
| 7373 * the task has not yet been performed or if an exception occurred. | 7363 * the task has not yet been performed or if an exception occurred. |
| 7374 * | 7364 * |
| 7375 * @return an array containing the sources referenced by 'import' directives | 7365 * @return an array containing the sources referenced by 'import' directives |
| 7376 */ | 7366 */ |
| 7377 List<Source> get importedSources => toArray(_importedSources); | 7367 List<Source> get importedSources => toArray(_importedSources); |
| 7378 | 7368 |
| 7379 /** | 7369 /** |
| 7380 * Return an array containing the sources referenced by 'part' directives, or
an empty array if | 7370 * Return an array containing the sources referenced by 'part' directives, or
an empty array if |
| 7381 * the task has not yet been performed or if an exception occurred. | 7371 * the task has not yet been performed or if an exception occurred. |
| 7382 * | 7372 * |
| 7383 * @return an array containing the sources referenced by 'part' directives | 7373 * @return an array containing the sources referenced by 'part' directives |
| 7384 */ | 7374 */ |
| 7385 List<Source> get includedSources => toArray(_includedSources); | 7375 List<Source> get includedSources => toArray(_includedSources); |
| 7386 | 7376 |
| 7387 /** | 7377 /** |
| 7378 * Return the line information that was produced, or `null` if the task has no
t yet been |
| 7379 * performed or if an exception occurred. |
| 7380 * |
| 7381 * @return the line information that was produced |
| 7382 */ |
| 7383 LineInfo get lineInfo => _lineInfo; |
| 7384 |
| 7385 /** |
| 7386 * Return the time at which the contents of the source that was parsed were la
st modified, or a |
| 7387 * negative value if the task has not yet been performed or if an exception oc
curred. |
| 7388 * |
| 7389 * @return the time at which the contents of the source that was parsed were l
ast modified |
| 7390 */ |
| 7391 int get modificationTime => _modificationTime; |
| 7392 |
| 7393 /** |
| 7388 * Return `true` if the source contains a 'library' directive, or `false` if t
he task | 7394 * Return `true` if the source contains a 'library' directive, or `false` if t
he task |
| 7389 * has not yet been performed or if an exception occurred. | 7395 * has not yet been performed or if an exception occurred. |
| 7390 * | 7396 * |
| 7391 * @return `true` if the source contains a 'library' directive | 7397 * @return `true` if the source contains a 'library' directive |
| 7392 */ | 7398 */ |
| 7393 bool hasLibraryDirective() => _hasLibraryDirective2; | 7399 bool hasLibraryDirective() => _hasLibraryDirective2; |
| 7394 | 7400 |
| 7395 /** | 7401 /** |
| 7396 * Return `true` if the source contains a 'part of' directive, or `false` if t
he task | 7402 * Return `true` if the source contains a 'part of' directive, or `false` if t
he task |
| 7397 * has not yet been performed or if an exception occurred. | 7403 * has not yet been performed or if an exception occurred. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7409 | 7415 |
| 7410 void internalPerform() { | 7416 void internalPerform() { |
| 7411 RecordingErrorListener errorListener = new RecordingErrorListener(); | 7417 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 7412 List<Token> token = [null]; | 7418 List<Token> token = [null]; |
| 7413 TimeCounter_TimeCounterHandle timeCounterScan = PerformanceStatistics.scan.s
tart(); | 7419 TimeCounter_TimeCounterHandle timeCounterScan = PerformanceStatistics.scan.s
tart(); |
| 7414 try { | 7420 try { |
| 7415 Source_ContentReceiver receiver = new Source_ContentReceiver_11(this, erro
rListener, token); | 7421 Source_ContentReceiver receiver = new Source_ContentReceiver_11(this, erro
rListener, token); |
| 7416 try { | 7422 try { |
| 7417 source.getContents(receiver); | 7423 source.getContents(receiver); |
| 7418 } on JavaException catch (exception) { | 7424 } on JavaException catch (exception) { |
| 7419 modificationTime = source.modificationStamp; | 7425 _modificationTime = source.modificationStamp; |
| 7420 throw new AnalysisException.con3(exception); | 7426 throw new AnalysisException.con3(exception); |
| 7421 } | 7427 } |
| 7422 } finally { | 7428 } finally { |
| 7423 timeCounterScan.stop(); | 7429 timeCounterScan.stop(); |
| 7424 } | 7430 } |
| 7425 TimeCounter_TimeCounterHandle timeCounterParse = PerformanceStatistics.parse
.start(); | 7431 TimeCounter_TimeCounterHandle timeCounterParse = PerformanceStatistics.parse
.start(); |
| 7426 try { | 7432 try { |
| 7427 Parser parser = new Parser(source, errorListener); | 7433 Parser parser = new Parser(source, errorListener); |
| 7428 parser.parseFunctionBodies = context.analysisOptions.analyzeFunctionBodies
; | 7434 parser.parseFunctionBodies = context.analysisOptions.analyzeFunctionBodies
; |
| 7429 compilationUnit = parser.parseCompilationUnit(token[0]); | 7435 _unit = parser.parseCompilationUnit(token[0]); |
| 7430 errors = errorListener.getErrors2(source); | 7436 _errors = errorListener.getErrors2(source); |
| 7431 for (Directive directive in compilationUnit.directives) { | 7437 for (Directive directive in _unit.directives) { |
| 7432 if (directive is ExportDirective) { | 7438 if (directive is ExportDirective) { |
| 7433 Source exportSource = resolveSource(source, directive as ExportDirecti
ve); | 7439 Source exportSource = resolveSource(source, directive as ExportDirecti
ve); |
| 7434 if (exportSource != null) { | 7440 if (exportSource != null) { |
| 7435 _exportedSources.add(exportSource); | 7441 _exportedSources.add(exportSource); |
| 7436 } | 7442 } |
| 7437 } else if (directive is ImportDirective) { | 7443 } else if (directive is ImportDirective) { |
| 7438 Source importSource = resolveSource(source, directive as ImportDirecti
ve); | 7444 Source importSource = resolveSource(source, directive as ImportDirecti
ve); |
| 7439 if (importSource != null) { | 7445 if (importSource != null) { |
| 7440 _importedSources.add(importSource); | 7446 _importedSources.add(importSource); |
| 7441 } | 7447 } |
| 7442 } else if (directive is LibraryDirective) { | 7448 } else if (directive is LibraryDirective) { |
| 7443 _hasLibraryDirective2 = true; | 7449 _hasLibraryDirective2 = true; |
| 7444 } else if (directive is PartDirective) { | 7450 } else if (directive is PartDirective) { |
| 7445 Source partSource = resolveSource(source, directive as PartDirective); | 7451 Source partSource = resolveSource(source, directive as PartDirective); |
| 7446 if (partSource != null) { | 7452 if (partSource != null) { |
| 7447 _includedSources.add(partSource); | 7453 _includedSources.add(partSource); |
| 7448 } | 7454 } |
| 7449 } else if (directive is PartOfDirective) { | 7455 } else if (directive is PartOfDirective) { |
| 7450 _hasPartOfDirective2 = true; | 7456 _hasPartOfDirective2 = true; |
| 7451 } | 7457 } |
| 7452 } | 7458 } |
| 7453 compilationUnit.lineInfo = lineInfo; | 7459 _unit.lineInfo = _lineInfo; |
| 7454 } finally { | 7460 } finally { |
| 7455 timeCounterParse.stop(); | 7461 timeCounterParse.stop(); |
| 7456 } | 7462 } |
| 7457 } | 7463 } |
| 7458 | 7464 |
| 7459 /** | 7465 /** |
| 7460 * Return the result of resolving the URI of the given URI-based directive aga
inst the URI of the | 7466 * Return the result of resolving the URI of the given URI-based directive aga
inst the URI of the |
| 7461 * given library, or `null` if the URI is not valid. | 7467 * given library, or `null` if the URI is not valid. |
| 7462 * | 7468 * |
| 7463 * @param librarySource the source representing the library containing the dir
ective | 7469 * @param librarySource the source representing the library containing the dir
ective |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7508 | 7514 |
| 7509 void accept(CharBuffer contents, int modificationTime) { | 7515 void accept(CharBuffer contents, int modificationTime) { |
| 7510 doScan(contents, modificationTime); | 7516 doScan(contents, modificationTime); |
| 7511 } | 7517 } |
| 7512 | 7518 |
| 7513 void accept2(String contents, int modificationTime) { | 7519 void accept2(String contents, int modificationTime) { |
| 7514 doScan(new CharSequence(contents), modificationTime); | 7520 doScan(new CharSequence(contents), modificationTime); |
| 7515 } | 7521 } |
| 7516 | 7522 |
| 7517 void doScan(CharSequence contents, int modificationTime) { | 7523 void doScan(CharSequence contents, int modificationTime) { |
| 7518 ParseDartTask_this.modificationTime = modificationTime; | 7524 ParseDartTask_this._modificationTime = modificationTime; |
| 7519 Scanner scanner = new Scanner(ParseDartTask_this.source, new CharSequenceRea
der(contents), errorListener); | 7525 Scanner scanner = new Scanner(ParseDartTask_this.source, new CharSequenceRea
der(contents), errorListener); |
| 7520 scanner.preserveComments = ParseDartTask_this.context.analysisOptions.preser
veComments; | 7526 scanner.preserveComments = ParseDartTask_this.context.analysisOptions.preser
veComments; |
| 7521 token[0] = scanner.tokenize(); | 7527 token[0] = scanner.tokenize(); |
| 7522 ParseDartTask_this.lineInfo = new LineInfo(scanner.lineStarts); | 7528 ParseDartTask_this._lineInfo = new LineInfo(scanner.lineStarts); |
| 7523 } | 7529 } |
| 7524 } | 7530 } |
| 7525 | 7531 |
| 7526 /** | 7532 /** |
| 7527 * Instances of the class `ParseHtmlTask` parse a specific source as an HTML fil
e. | 7533 * Instances of the class `ParseHtmlTask` parse a specific source as an HTML fil
e. |
| 7528 */ | 7534 */ |
| 7529 class ParseHtmlTask extends AnalysisTask { | 7535 class ParseHtmlTask extends AnalysisTask { |
| 7530 /** | 7536 /** |
| 7531 * The source to be parsed. | 7537 * The source to be parsed. |
| 7532 */ | 7538 */ |
| 7533 Source source; | 7539 final Source source; |
| 7534 | 7540 |
| 7535 /** | 7541 /** |
| 7536 * The time at which the contents of the source were last modified. | 7542 * The time at which the contents of the source were last modified. |
| 7537 */ | 7543 */ |
| 7538 int modificationTime = -1; | 7544 int _modificationTime = -1; |
| 7539 | 7545 |
| 7540 /** | 7546 /** |
| 7541 * The line information that was produced. | 7547 * The line information that was produced. |
| 7542 */ | 7548 */ |
| 7543 LineInfo lineInfo; | 7549 LineInfo _lineInfo; |
| 7544 | 7550 |
| 7545 /** | 7551 /** |
| 7546 * The HTML unit that was produced by parsing the source. | 7552 * The HTML unit that was produced by parsing the source. |
| 7547 */ | 7553 */ |
| 7548 HtmlUnit htmlUnit; | 7554 HtmlUnit _unit; |
| 7549 | 7555 |
| 7550 /** | 7556 /** |
| 7551 * The errors that were produced by scanning and parsing the source. | 7557 * The errors that were produced by scanning and parsing the source. |
| 7552 */ | 7558 */ |
| 7553 List<AnalysisError> errors = AnalysisError.NO_ERRORS; | 7559 List<AnalysisError> _errors = AnalysisError.NO_ERRORS; |
| 7554 | 7560 |
| 7555 /** | 7561 /** |
| 7556 * An array containing the sources of the libraries that are referenced within
the HTML. | 7562 * An array containing the sources of the libraries that are referenced within
the HTML. |
| 7557 */ | 7563 */ |
| 7558 List<Source> referencedLibraries = Source.EMPTY_ARRAY; | 7564 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; |
| 7559 | 7565 |
| 7560 /** | 7566 /** |
| 7561 * The name of the 'src' attribute in a HTML tag. | 7567 * The name of the 'src' attribute in a HTML tag. |
| 7562 */ | 7568 */ |
| 7563 static String _ATTRIBUTE_SRC = "src"; | 7569 static String _ATTRIBUTE_SRC = "src"; |
| 7564 | 7570 |
| 7565 /** | 7571 /** |
| 7566 * The name of the 'type' attribute in a HTML tag. | 7572 * The name of the 'type' attribute in a HTML tag. |
| 7567 */ | 7573 */ |
| 7568 static String _ATTRIBUTE_TYPE = "type"; | 7574 static String _ATTRIBUTE_TYPE = "type"; |
| 7569 | 7575 |
| 7570 /** | 7576 /** |
| 7571 * The name of the 'script' tag in an HTML file. | 7577 * The name of the 'script' tag in an HTML file. |
| 7572 */ | 7578 */ |
| 7573 static String _TAG_SCRIPT = "script"; | 7579 static String _TAG_SCRIPT = "script"; |
| 7574 | 7580 |
| 7575 /** | 7581 /** |
| 7576 * The value of the 'type' attribute of a 'script' tag that indicates that the
script is written | 7582 * The value of the 'type' attribute of a 'script' tag that indicates that the
script is written |
| 7577 * in Dart. | 7583 * in Dart. |
| 7578 */ | 7584 */ |
| 7579 static String _TYPE_DART = "application/dart"; | 7585 static String _TYPE_DART = "application/dart"; |
| 7580 | 7586 |
| 7581 /** | 7587 /** |
| 7582 * Initialize a newly created task to perform analysis within the given contex
t. | 7588 * Initialize a newly created task to perform analysis within the given contex
t. |
| 7583 * | 7589 * |
| 7584 * @param context the context in which the task is to be performed | 7590 * @param context the context in which the task is to be performed |
| 7585 * @param source the source to be parsed | 7591 * @param source the source to be parsed |
| 7586 */ | 7592 */ |
| 7587 ParseHtmlTask(InternalAnalysisContext context, Source source) : super(context)
{ | 7593 ParseHtmlTask(InternalAnalysisContext context, this.source) : super(context); |
| 7588 this.source = source; | |
| 7589 } | |
| 7590 | 7594 |
| 7591 accept(AnalysisTaskVisitor visitor) => visitor.visitParseHtmlTask(this); | 7595 accept(AnalysisTaskVisitor visitor) => visitor.visitParseHtmlTask(this); |
| 7592 | 7596 |
| 7597 /** |
| 7598 * Return the errors that were produced by scanning and parsing the source, or
`null` if the |
| 7599 * task has not yet been performed or if an exception occurred. |
| 7600 * |
| 7601 * @return the errors that were produced by scanning and parsing the source |
| 7602 */ |
| 7603 List<AnalysisError> get errors => _errors; |
| 7604 |
| 7605 /** |
| 7606 * Return the HTML unit that was produced by parsing the source. |
| 7607 * |
| 7608 * @return the HTML unit that was produced by parsing the source |
| 7609 */ |
| 7610 HtmlUnit get htmlUnit => _unit; |
| 7611 |
| 7612 /** |
| 7613 * Return the line information that was produced, or `null` if the task has no
t yet been |
| 7614 * performed or if an exception occurred. |
| 7615 * |
| 7616 * @return the line information that was produced |
| 7617 */ |
| 7618 LineInfo get lineInfo => _lineInfo; |
| 7619 |
| 7620 /** |
| 7621 * Return the time at which the contents of the source that was parsed were la
st modified, or a |
| 7622 * negative value if the task has not yet been performed or if an exception oc
curred. |
| 7623 * |
| 7624 * @return the time at which the contents of the source that was parsed were l
ast modified |
| 7625 */ |
| 7626 int get modificationTime => _modificationTime; |
| 7627 |
| 7628 /** |
| 7629 * Return an array containing the sources of the libraries that are referenced
within the HTML. |
| 7630 * |
| 7631 * @return the sources of the libraries that are referenced within the HTML |
| 7632 */ |
| 7633 List<Source> get referencedLibraries => _referencedLibraries; |
| 7634 |
| 7593 String get taskDescription { | 7635 String get taskDescription { |
| 7594 if (source == null) { | 7636 if (source == null) { |
| 7595 return "parse as html null source"; | 7637 return "parse as html null source"; |
| 7596 } | 7638 } |
| 7597 return "parse as html ${source.fullName}"; | 7639 return "parse as html ${source.fullName}"; |
| 7598 } | 7640 } |
| 7599 | 7641 |
| 7600 void internalPerform() { | 7642 void internalPerform() { |
| 7601 HtmlScanner scanner = new HtmlScanner(source); | 7643 HtmlScanner scanner = new HtmlScanner(source); |
| 7602 try { | 7644 try { |
| 7603 source.getContents(scanner); | 7645 source.getContents(scanner); |
| 7604 } on JavaException catch (exception) { | 7646 } on JavaException catch (exception) { |
| 7605 throw new AnalysisException.con3(exception); | 7647 throw new AnalysisException.con3(exception); |
| 7606 } | 7648 } |
| 7607 HtmlScanResult scannerResult = scanner.result; | 7649 HtmlScanResult scannerResult = scanner.result; |
| 7608 modificationTime = scannerResult.modificationTime; | 7650 _modificationTime = scannerResult.modificationTime; |
| 7609 lineInfo = new LineInfo(scannerResult.lineStarts); | 7651 _lineInfo = new LineInfo(scannerResult.lineStarts); |
| 7610 RecordingErrorListener errorListener = new RecordingErrorListener(); | 7652 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 7611 HtmlParseResult result = new HtmlParser(source, errorListener).parse(scanner
Result); | 7653 HtmlParseResult result = new HtmlParser(source, errorListener).parse(scanner
Result); |
| 7612 htmlUnit = result.htmlUnit; | 7654 _unit = result.htmlUnit; |
| 7613 errors = errorListener.getErrors2(source); | 7655 _errors = errorListener.getErrors2(source); |
| 7614 referencedLibraries = librarySources; | 7656 _referencedLibraries = librarySources; |
| 7615 } | 7657 } |
| 7616 | 7658 |
| 7617 /** | 7659 /** |
| 7618 * Return the sources of libraries that are referenced in the specified HTML f
ile. | 7660 * Return the sources of libraries that are referenced in the specified HTML f
ile. |
| 7619 * | 7661 * |
| 7620 * @return the sources of libraries that are referenced in the HTML file | 7662 * @return the sources of libraries that are referenced in the HTML file |
| 7621 */ | 7663 */ |
| 7622 List<Source> get librarySources { | 7664 List<Source> get librarySources { |
| 7623 List<Source> libraries = new List<Source>(); | 7665 List<Source> libraries = new List<Source>(); |
| 7624 htmlUnit.accept(new RecursiveXmlVisitor_12(this, libraries)); | 7666 _unit.accept(new RecursiveXmlVisitor_12(this, libraries)); |
| 7625 if (libraries.isEmpty) { | 7667 if (libraries.isEmpty) { |
| 7626 return Source.EMPTY_ARRAY; | 7668 return Source.EMPTY_ARRAY; |
| 7627 } | 7669 } |
| 7628 return new List.from(libraries); | 7670 return new List.from(libraries); |
| 7629 } | 7671 } |
| 7630 } | 7672 } |
| 7631 | 7673 |
| 7632 class RecursiveXmlVisitor_12 extends RecursiveXmlVisitor<Object> { | 7674 class RecursiveXmlVisitor_12 extends RecursiveXmlVisitor<Object> { |
| 7633 final ParseHtmlTask ParseHtmlTask_this; | 7675 final ParseHtmlTask ParseHtmlTask_this; |
| 7634 | 7676 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 7658 } | 7700 } |
| 7659 } | 7701 } |
| 7660 | 7702 |
| 7661 /** | 7703 /** |
| 7662 * Instances of the class `ResolveDartLibraryTask` parse a specific Dart library
. | 7704 * Instances of the class `ResolveDartLibraryTask` parse a specific Dart library
. |
| 7663 */ | 7705 */ |
| 7664 class ResolveDartLibraryTask extends AnalysisTask { | 7706 class ResolveDartLibraryTask extends AnalysisTask { |
| 7665 /** | 7707 /** |
| 7666 * The source representing the file whose compilation unit is to be returned. | 7708 * The source representing the file whose compilation unit is to be returned. |
| 7667 */ | 7709 */ |
| 7668 Source unitSource; | 7710 final Source unitSource; |
| 7669 | 7711 |
| 7670 /** | 7712 /** |
| 7671 * The source representing the library to be resolved. | 7713 * The source representing the library to be resolved. |
| 7672 */ | 7714 */ |
| 7673 Source librarySource; | 7715 final Source librarySource; |
| 7674 | 7716 |
| 7675 /** | 7717 /** |
| 7676 * The library resolver holding information about the libraries that were reso
lved. | 7718 * The library resolver holding information about the libraries that were reso
lved. |
| 7677 */ | 7719 */ |
| 7678 LibraryResolver libraryResolver; | 7720 LibraryResolver _resolver; |
| 7679 | 7721 |
| 7680 /** | 7722 /** |
| 7681 * Initialize a newly created task to perform analysis within the given contex
t. | 7723 * Initialize a newly created task to perform analysis within the given contex
t. |
| 7682 * | 7724 * |
| 7683 * @param context the context in which the task is to be performed | 7725 * @param context the context in which the task is to be performed |
| 7684 * @param unitSource the source representing the file whose compilation unit i
s to be returned | 7726 * @param unitSource the source representing the file whose compilation unit i
s to be returned |
| 7685 * @param librarySource the source representing the library to be resolved | 7727 * @param librarySource the source representing the library to be resolved |
| 7686 */ | 7728 */ |
| 7687 ResolveDartLibraryTask(InternalAnalysisContext context, Source unitSource, Sou
rce librarySource) : super(context) { | 7729 ResolveDartLibraryTask(InternalAnalysisContext context, this.unitSource, this.
librarySource) : super(context); |
| 7688 this.unitSource = unitSource; | |
| 7689 this.librarySource = librarySource; | |
| 7690 } | |
| 7691 | 7730 |
| 7692 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartLibraryTask(thi
s); | 7731 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartLibraryTask(thi
s); |
| 7693 | 7732 |
| 7733 /** |
| 7734 * Return the library resolver holding information about the libraries that we
re resolved. |
| 7735 * |
| 7736 * @return the library resolver holding information about the libraries that w
ere resolved |
| 7737 */ |
| 7738 LibraryResolver get libraryResolver => _resolver; |
| 7739 |
| 7694 String get taskDescription { | 7740 String get taskDescription { |
| 7695 if (librarySource == null) { | 7741 if (librarySource == null) { |
| 7696 return "resolve library null source"; | 7742 return "resolve library null source"; |
| 7697 } | 7743 } |
| 7698 return "resolve library ${librarySource.fullName}"; | 7744 return "resolve library ${librarySource.fullName}"; |
| 7699 } | 7745 } |
| 7700 | 7746 |
| 7701 void internalPerform() { | 7747 void internalPerform() { |
| 7702 libraryResolver = new LibraryResolver(context); | 7748 _resolver = new LibraryResolver(context); |
| 7703 libraryResolver.resolveLibrary(librarySource, true); | 7749 _resolver.resolveLibrary(librarySource, true); |
| 7704 } | 7750 } |
| 7705 } | 7751 } |
| 7706 | 7752 |
| 7707 /** | 7753 /** |
| 7708 * Instances of the class `ResolveDartUnitTask` resolve a single Dart file based
on a existing | 7754 * Instances of the class `ResolveDartUnitTask` resolve a single Dart file based
on a existing |
| 7709 * element model. | 7755 * element model. |
| 7710 */ | 7756 */ |
| 7711 class ResolveDartUnitTask extends AnalysisTask { | 7757 class ResolveDartUnitTask extends AnalysisTask { |
| 7712 /** | 7758 /** |
| 7713 * The source that is to be resolved. | 7759 * The source that is to be resolved. |
| 7714 */ | 7760 */ |
| 7715 Source source; | 7761 final Source source; |
| 7716 | 7762 |
| 7717 /** | 7763 /** |
| 7718 * The element model for the library containing the source. | 7764 * The element model for the library containing the source. |
| 7719 */ | 7765 */ |
| 7720 LibraryElement _libraryElement; | 7766 LibraryElement _libraryElement; |
| 7721 | 7767 |
| 7722 /** | 7768 /** |
| 7723 * The time at which the contents of the source were last modified. | 7769 * The time at which the contents of the source were last modified. |
| 7724 */ | 7770 */ |
| 7725 int modificationTime = -1; | 7771 int _modificationTime = -1; |
| 7726 | 7772 |
| 7727 /** | 7773 /** |
| 7728 * The compilation unit that was resolved by this task. | 7774 * The compilation unit that was resolved by this task. |
| 7729 */ | 7775 */ |
| 7730 CompilationUnit resolvedUnit; | 7776 CompilationUnit _resolvedUnit; |
| 7731 | 7777 |
| 7732 /** | 7778 /** |
| 7733 * Initialize a newly created task to perform analysis within the given contex
t. | 7779 * Initialize a newly created task to perform analysis within the given contex
t. |
| 7734 * | 7780 * |
| 7735 * @param context the context in which the task is to be performed | 7781 * @param context the context in which the task is to be performed |
| 7736 * @param source the source to be parsed | 7782 * @param source the source to be parsed |
| 7737 * @param libraryElement the element model for the library containing the sour
ce | 7783 * @param libraryElement the element model for the library containing the sour
ce |
| 7738 */ | 7784 */ |
| 7739 ResolveDartUnitTask(InternalAnalysisContext context, Source source, LibraryEle
ment libraryElement) : super(context) { | 7785 ResolveDartUnitTask(InternalAnalysisContext context, this.source, LibraryEleme
nt libraryElement) : super(context) { |
| 7740 this.source = source; | |
| 7741 this._libraryElement = libraryElement; | 7786 this._libraryElement = libraryElement; |
| 7742 } | 7787 } |
| 7743 | 7788 |
| 7744 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartUnitTask(this); | 7789 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartUnitTask(this); |
| 7745 | 7790 |
| 7746 /** | 7791 /** |
| 7747 * Return the source for the library containing the source that is to be resol
ved. | 7792 * Return the source for the library containing the source that is to be resol
ved. |
| 7748 * | 7793 * |
| 7749 * @return the source for the library containing the source that is to be reso
lved | 7794 * @return the source for the library containing the source that is to be reso
lved |
| 7750 */ | 7795 */ |
| 7751 Source get librarySource => _libraryElement.source; | 7796 Source get librarySource => _libraryElement.source; |
| 7752 | 7797 |
| 7798 /** |
| 7799 * Return the time at which the contents of the source that was parsed were la
st modified, or a |
| 7800 * negative value if the task has not yet been performed or if an exception oc
curred. |
| 7801 * |
| 7802 * @return the time at which the contents of the source that was parsed were l
ast modified |
| 7803 */ |
| 7804 int get modificationTime => _modificationTime; |
| 7805 |
| 7806 /** |
| 7807 * Return the compilation unit that was resolved by this task. |
| 7808 * |
| 7809 * @return the compilation unit that was resolved by this task |
| 7810 */ |
| 7811 CompilationUnit get resolvedUnit => _resolvedUnit; |
| 7812 |
| 7753 String get taskDescription { | 7813 String get taskDescription { |
| 7754 Source librarySource = _libraryElement.source; | 7814 Source librarySource = _libraryElement.source; |
| 7755 if (librarySource == null) { | 7815 if (librarySource == null) { |
| 7756 return "resolve unit null source"; | 7816 return "resolve unit null source"; |
| 7757 } | 7817 } |
| 7758 return "resolve unit ${librarySource.fullName}"; | 7818 return "resolve unit ${librarySource.fullName}"; |
| 7759 } | 7819 } |
| 7760 | 7820 |
| 7761 void internalPerform() { | 7821 void internalPerform() { |
| 7762 Source coreLibrarySource = _libraryElement.context.sourceFactory.forUri(Dart
Sdk.DART_CORE); | 7822 TypeProvider typeProvider = (_libraryElement.context as InternalAnalysisCont
ext).typeProvider; |
| 7763 LibraryElement coreElement = context.computeLibraryElement(coreLibrarySource
); | |
| 7764 TypeProvider typeProvider = new TypeProviderImpl(coreElement); | |
| 7765 ResolvableCompilationUnit resolvableUnit = context.computeResolvableCompilat
ionUnit(source); | 7823 ResolvableCompilationUnit resolvableUnit = context.computeResolvableCompilat
ionUnit(source); |
| 7766 modificationTime = resolvableUnit.modificationTime; | 7824 _modificationTime = resolvableUnit.modificationTime; |
| 7767 CompilationUnit unit = resolvableUnit.compilationUnit; | 7825 CompilationUnit unit = resolvableUnit.compilationUnit; |
| 7768 if (unit == null) { | 7826 if (unit == null) { |
| 7769 throw new AnalysisException.con1("Internal error: computeResolvableCompila
tionUnit returned a value without a parsed Dart unit"); | 7827 throw new AnalysisException.con1("Internal error: computeResolvableCompila
tionUnit returned a value without a parsed Dart unit"); |
| 7770 } | 7828 } |
| 7771 new DeclarationResolver().resolve(unit, find(_libraryElement, source)); | 7829 new DeclarationResolver().resolve(unit, find(_libraryElement, source)); |
| 7772 RecordingErrorListener errorListener = new RecordingErrorListener(); | 7830 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 7773 TypeResolverVisitor typeResolverVisitor = new TypeResolverVisitor.con2(_libr
aryElement, source, typeProvider, errorListener); | 7831 TypeResolverVisitor typeResolverVisitor = new TypeResolverVisitor.con2(_libr
aryElement, source, typeProvider, errorListener); |
| 7774 unit.accept(typeResolverVisitor); | 7832 unit.accept(typeResolverVisitor); |
| 7775 InheritanceManager inheritanceManager = new InheritanceManager(_libraryEleme
nt); | 7833 InheritanceManager inheritanceManager = new InheritanceManager(_libraryEleme
nt); |
| 7776 ResolverVisitor resolverVisitor = new ResolverVisitor.con2(_libraryElement,
source, typeProvider, inheritanceManager, errorListener); | 7834 ResolverVisitor resolverVisitor = new ResolverVisitor.con2(_libraryElement,
source, typeProvider, inheritanceManager, errorListener); |
| 7777 unit.accept(resolverVisitor); | 7835 unit.accept(resolverVisitor); |
| 7778 for (ProxyConditionalAnalysisError conditionalCode in resolverVisitor.proxyC
onditionalAnalysisErrors) { | 7836 for (ProxyConditionalAnalysisError conditionalCode in resolverVisitor.proxyC
onditionalAnalysisErrors) { |
| 7779 if (conditionalCode.shouldIncludeErrorCode()) { | 7837 if (conditionalCode.shouldIncludeErrorCode()) { |
| 7780 resolverVisitor.reportError(conditionalCode.analysisError); | 7838 resolverVisitor.reportError(conditionalCode.analysisError); |
| 7781 } | 7839 } |
| 7782 } | 7840 } |
| 7783 TimeCounter_TimeCounterHandle counterHandleErrors = PerformanceStatistics.er
rors.start(); | 7841 TimeCounter_TimeCounterHandle counterHandleErrors = PerformanceStatistics.er
rors.start(); |
| 7784 try { | 7842 try { |
| 7785 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); | 7843 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); |
| 7786 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, _libraryEle
ment, typeProvider, inheritanceManager); | 7844 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, _libraryEle
ment, typeProvider, inheritanceManager); |
| 7787 unit.accept(errorVerifier); | 7845 unit.accept(errorVerifier); |
| 7788 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, ty
peProvider); | 7846 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, ty
peProvider); |
| 7789 unit.accept(constantVerifier); | 7847 unit.accept(constantVerifier); |
| 7790 } finally { | 7848 } finally { |
| 7791 counterHandleErrors.stop(); | 7849 counterHandleErrors.stop(); |
| 7792 } | 7850 } |
| 7793 resolvedUnit = unit; | 7851 _resolvedUnit = unit; |
| 7794 } | 7852 } |
| 7795 | 7853 |
| 7796 /** | 7854 /** |
| 7797 * Search the compilation units that are part of the given library and return
the element | 7855 * Search the compilation units that are part of the given library and return
the element |
| 7798 * representing the compilation unit with the given source. Return `null` if t
here is no | 7856 * representing the compilation unit with the given source. Return `null` if t
here is no |
| 7799 * such compilation unit. | 7857 * such compilation unit. |
| 7800 * | 7858 * |
| 7801 * @param libraryElement the element representing the library being searched t
hrough | 7859 * @param libraryElement the element representing the library being searched t
hrough |
| 7802 * @param unitSource the source for the compilation unit whose element is to b
e returned | 7860 * @param unitSource the source for the compilation unit whose element is to b
e returned |
| 7803 * @return the element representing the compilation unit | 7861 * @return the element representing the compilation unit |
| (...skipping 12 matching lines...) Expand all Loading... |
| 7816 } | 7874 } |
| 7817 } | 7875 } |
| 7818 | 7876 |
| 7819 /** | 7877 /** |
| 7820 * Instances of the class `ResolveHtmlTask` resolve a specific source as an HTML
file. | 7878 * Instances of the class `ResolveHtmlTask` resolve a specific source as an HTML
file. |
| 7821 */ | 7879 */ |
| 7822 class ResolveHtmlTask extends AnalysisTask { | 7880 class ResolveHtmlTask extends AnalysisTask { |
| 7823 /** | 7881 /** |
| 7824 * The source to be resolved. | 7882 * The source to be resolved. |
| 7825 */ | 7883 */ |
| 7826 Source source; | 7884 final Source source; |
| 7827 | 7885 |
| 7828 /** | 7886 /** |
| 7829 * The time at which the contents of the source were last modified. | 7887 * The time at which the contents of the source were last modified. |
| 7830 */ | 7888 */ |
| 7831 int modificationTime = -1; | 7889 int _modificationTime = -1; |
| 7832 | 7890 |
| 7833 /** | 7891 /** |
| 7834 * The element produced by resolving the source. | 7892 * The element produced by resolving the source. |
| 7835 */ | 7893 */ |
| 7836 HtmlElement element = null; | 7894 HtmlElement _element = null; |
| 7837 | 7895 |
| 7838 /** | 7896 /** |
| 7839 * The resolution errors that were discovered while resolving the source. | 7897 * The resolution errors that were discovered while resolving the source. |
| 7840 */ | 7898 */ |
| 7841 List<AnalysisError> resolutionErrors = AnalysisError.NO_ERRORS; | 7899 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
| 7842 | 7900 |
| 7843 /** | 7901 /** |
| 7844 * Initialize a newly created task to perform analysis within the given contex
t. | 7902 * Initialize a newly created task to perform analysis within the given contex
t. |
| 7845 * | 7903 * |
| 7846 * @param context the context in which the task is to be performed | 7904 * @param context the context in which the task is to be performed |
| 7847 * @param source the source to be resolved | 7905 * @param source the source to be resolved |
| 7848 */ | 7906 */ |
| 7849 ResolveHtmlTask(InternalAnalysisContext context, Source source) : super(contex
t) { | 7907 ResolveHtmlTask(InternalAnalysisContext context, this.source) : super(context)
; |
| 7850 this.source = source; | |
| 7851 } | |
| 7852 | 7908 |
| 7853 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveHtmlTask(this); | 7909 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveHtmlTask(this); |
| 7854 | 7910 |
| 7911 HtmlElement get element => _element; |
| 7912 |
| 7913 /** |
| 7914 * Return the time at which the contents of the source that was parsed were la
st modified, or a |
| 7915 * negative value if the task has not yet been performed or if an exception oc
curred. |
| 7916 * |
| 7917 * @return the time at which the contents of the source that was parsed were l
ast modified |
| 7918 */ |
| 7919 int get modificationTime => _modificationTime; |
| 7920 |
| 7921 List<AnalysisError> get resolutionErrors => _resolutionErrors; |
| 7922 |
| 7855 String get taskDescription { | 7923 String get taskDescription { |
| 7856 if (source == null) { | 7924 if (source == null) { |
| 7857 return "resolve as html null source"; | 7925 return "resolve as html null source"; |
| 7858 } | 7926 } |
| 7859 return "resolve as html ${source.fullName}"; | 7927 return "resolve as html ${source.fullName}"; |
| 7860 } | 7928 } |
| 7861 | 7929 |
| 7862 void internalPerform() { | 7930 void internalPerform() { |
| 7863 ResolvableHtmlUnit resolvableHtmlUnit = context.computeResolvableHtmlUnit(so
urce); | 7931 ResolvableHtmlUnit resolvableHtmlUnit = context.computeResolvableHtmlUnit(so
urce); |
| 7864 HtmlUnit unit = resolvableHtmlUnit.compilationUnit; | 7932 HtmlUnit unit = resolvableHtmlUnit.compilationUnit; |
| 7865 if (unit == null) { | 7933 if (unit == null) { |
| 7866 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni
t returned a value without a parsed HTML unit"); | 7934 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni
t returned a value without a parsed HTML unit"); |
| 7867 } | 7935 } |
| 7868 modificationTime = resolvableHtmlUnit.modificationTime; | 7936 _modificationTime = resolvableHtmlUnit.modificationTime; |
| 7869 HtmlUnitBuilder builder = new HtmlUnitBuilder(context); | 7937 HtmlUnitBuilder builder = new HtmlUnitBuilder(context); |
| 7870 element = builder.buildHtmlElement2(source, modificationTime, unit); | 7938 _element = builder.buildHtmlElement2(source, _modificationTime, unit); |
| 7871 resolutionErrors = builder.errorListener.getErrors2(source); | 7939 _resolutionErrors = builder.errorListener.getErrors2(source); |
| 7872 } | 7940 } |
| 7873 } | 7941 } |
| 7874 | 7942 |
| 7875 /** | 7943 /** |
| 7876 * The interface `Logger` defines the behavior of objects that can be used to re
ceive | 7944 * The interface `Logger` defines the behavior of objects that can be used to re
ceive |
| 7877 * information about errors within the analysis engine. Implementations usually
write this | 7945 * information about errors within the analysis engine. Implementations usually
write this |
| 7878 * information to a file, but can also record the information for later use (suc
h as during testing) | 7946 * information to a file, but can also record the information for later use (suc
h as during testing) |
| 7879 * or even ignore the information. | 7947 * or even ignore the information. |
| 7880 * | 7948 * |
| 7881 * @coverage dart.engine.utilities | 7949 * @coverage dart.engine.utilities |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7934 | 8002 |
| 7935 void logError3(Exception exception) { | 8003 void logError3(Exception exception) { |
| 7936 } | 8004 } |
| 7937 | 8005 |
| 7938 void logInformation(String message) { | 8006 void logInformation(String message) { |
| 7939 } | 8007 } |
| 7940 | 8008 |
| 7941 void logInformation2(String message, Exception exception) { | 8009 void logInformation2(String message, Exception exception) { |
| 7942 } | 8010 } |
| 7943 } | 8011 } |
| OLD | NEW |