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

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

Issue 135653008: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine; 8 library engine;
9 9
10 import 'java_core.dart'; 10 import 'java_core.dart';
(...skipping 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 } else if (identical(descriptor, DartEntry.HINTS)) { 1732 } else if (identical(descriptor, DartEntry.HINTS)) {
1733 return identical(state._hintsState, CacheState.INVALID); 1733 return identical(state._hintsState, CacheState.INVALID);
1734 } 1734 }
1735 } 1735 }
1736 return false; 1736 return false;
1737 } else { 1737 } else {
1738 return identical(super.getState(descriptor), CacheState.INVALID); 1738 return identical(super.getState(descriptor), CacheState.INVALID);
1739 } 1739 }
1740 } 1740 }
1741 1741
1742 /**
1743 * Invalidate all of the information associated with the compilation unit.
1744 */
1745 void invalidateAllInformation() { 1742 void invalidateAllInformation() {
1746 setState(SourceEntry.LINE_INFO, CacheState.INVALID); 1743 super.invalidateAllInformation();
1747 _sourceKind = SourceKind.UNKNOWN; 1744 _sourceKind = SourceKind.UNKNOWN;
1748 _sourceKindState = CacheState.INVALID; 1745 _sourceKindState = CacheState.INVALID;
1749 _parseErrors = AnalysisError.NO_ERRORS; 1746 _parseErrors = AnalysisError.NO_ERRORS;
1750 _parseErrorsState = CacheState.INVALID; 1747 _parseErrorsState = CacheState.INVALID;
1751 _parsedUnit = null; 1748 _parsedUnit = null;
1752 _parsedUnitAccessed = false; 1749 _parsedUnitAccessed = false;
1753 _parsedUnitState = CacheState.INVALID; 1750 _parsedUnitState = CacheState.INVALID;
1754 discardCachedResolutionInformation(); 1751 discardCachedResolutionInformation();
1755 } 1752 }
1756 1753
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
2572 } 2569 }
2573 return super.getValue(descriptor); 2570 return super.getValue(descriptor);
2574 } 2571 }
2575 2572
2576 HtmlEntryImpl get writableCopy { 2573 HtmlEntryImpl get writableCopy {
2577 HtmlEntryImpl copy = new HtmlEntryImpl(); 2574 HtmlEntryImpl copy = new HtmlEntryImpl();
2578 copy.copyFrom(this); 2575 copy.copyFrom(this);
2579 return copy; 2576 return copy;
2580 } 2577 }
2581 2578
2582 /**
2583 * Invalidate all of the information associated with the HTML file.
2584 */
2585 void invalidateAllInformation() { 2579 void invalidateAllInformation() {
2586 setState(SourceEntry.LINE_INFO, CacheState.INVALID); 2580 super.invalidateAllInformation();
2587 _parseErrors = AnalysisError.NO_ERRORS; 2581 _parseErrors = AnalysisError.NO_ERRORS;
2588 _parseErrorsState = CacheState.INVALID; 2582 _parseErrorsState = CacheState.INVALID;
2589 _parsedUnit = null; 2583 _parsedUnit = null;
2590 _parsedUnitState = CacheState.INVALID; 2584 _parsedUnitState = CacheState.INVALID;
2591 _referencedLibraries = Source.EMPTY_ARRAY; 2585 _referencedLibraries = Source.EMPTY_ARRAY;
2592 _referencedLibrariesState = CacheState.INVALID; 2586 _referencedLibrariesState = CacheState.INVALID;
2593 invalidateAllResolutionInformation(); 2587 invalidateAllResolutionInformation();
2594 } 2588 }
2595 2589
2596 /** 2590 /**
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2842 2836
2843 Object getValue(DataDescriptor descriptor) { 2837 Object getValue(DataDescriptor descriptor) {
2844 if (identical(descriptor, SourceEntry.LINE_INFO)) { 2838 if (identical(descriptor, SourceEntry.LINE_INFO)) {
2845 return _lineInfo; 2839 return _lineInfo;
2846 } else { 2840 } else {
2847 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); 2841 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}");
2848 } 2842 }
2849 } 2843 }
2850 2844
2851 /** 2845 /**
2846 * Invalidate all of the information associated with this source.
2847 */
2848 void invalidateAllInformation() {
2849 _lineInfo = null;
2850 _lineInfoState = CacheState.INVALID;
2851 }
2852
2853 /**
2852 * Set the most recent time at which the state of the source matched the state represented by this 2854 * Set the most recent time at which the state of the source matched the state represented by this
2853 * entry to the given time. 2855 * entry to the given time.
2854 * 2856 *
2855 * @param time the new modification time of this entry 2857 * @param time the new modification time of this entry
2856 */ 2858 */
2857 void set modificationTime(int time) { 2859 void set modificationTime(int time) {
2858 _modificationTime = time; 2860 _modificationTime = time;
2859 } 2861 }
2860 2862
2861 /** 2863 /**
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
3062 */ 3064 */
3063 List<Source> _priorityOrder = Source.EMPTY_ARRAY; 3065 List<Source> _priorityOrder = Source.EMPTY_ARRAY;
3064 3066
3065 /** 3067 /**
3066 * A table mapping sources to the change notices that are waiting to be return ed related to that 3068 * A table mapping sources to the change notices that are waiting to be return ed related to that
3067 * source. 3069 * source.
3068 */ 3070 */
3069 Map<Source, ChangeNoticeImpl> _pendingNotices = new Map<Source, ChangeNoticeIm pl>(); 3071 Map<Source, ChangeNoticeImpl> _pendingNotices = new Map<Source, ChangeNoticeIm pl>();
3070 3072
3071 /** 3073 /**
3074 * A set containing information about the tasks that have been performed since the last change
3075 * notification. Used to detect infinite loops in [performAnalysisTask].
3076 */
3077 Set<String> _recentTasks = new Set<String>();
3078
3079 /**
3072 * The object used to synchronize access to all of the caches. The rules relat ed to the use of 3080 * The object used to synchronize access to all of the caches. The rules relat ed to the use of
3073 * this lock object are 3081 * this lock object are
3074 * 3082 *
3075 * * no analysis work is done while holding the lock, and 3083 * * no analysis work is done while holding the lock, and
3076 * * no analysis results can be recorded unless we have obtained the lock and validated that the 3084 * * no analysis results can be recorded unless we have obtained the lock and validated that the
3077 * results are for the same version (modification time) of the source as our c urrent cache 3085 * results are for the same version (modification time) of the source as our c urrent cache
3078 * content. 3086 * content.
3079 * 3087 *
3080 */ 3088 */
3081 Object _cacheLock = new Object(); 3089 Object _cacheLock = new Object();
(...skipping 21 matching lines...) Expand all
3103 // This implementation assumes that the access to the cache does not need to be synchronized 3111 // This implementation assumes that the access to the cache does not need to be synchronized
3104 // because no other object can have access to this context while this method is being invoked. 3112 // because no other object can have access to this context while this method is being invoked.
3105 _cache.put(source, info); 3113 _cache.put(source, info);
3106 } 3114 }
3107 3115
3108 void applyChanges(ChangeSet changeSet) { 3116 void applyChanges(ChangeSet changeSet) {
3109 if (changeSet.isEmpty) { 3117 if (changeSet.isEmpty) {
3110 return; 3118 return;
3111 } 3119 }
3112 { 3120 {
3121 _recentTasks.clear();
3113 // 3122 //
3114 // First, compute the list of sources that have been removed. 3123 // First, compute the list of sources that have been removed.
3115 // 3124 //
3116 List<Source> removedSources = new List<Source>.from(changeSet.removed3); 3125 List<Source> removedSources = new List<Source>.from(changeSet.removed3);
3117 for (SourceContainer container in changeSet.removedContainers) { 3126 for (SourceContainer container in changeSet.removedContainers) {
3118 addSourcesInContainer(removedSources, container); 3127 addSourcesInContainer(removedSources, container);
3119 } 3128 }
3120 // 3129 //
3121 // Then determine which cached results are no longer valid. 3130 // Then determine which cached results are no longer valid.
3122 // 3131 //
3123 bool addedDartSource = false; 3132 bool addedDartSource = false;
3124 for (Source source in changeSet.added3) { 3133 for (Source source in changeSet.added3) {
3125 if (sourceAvailable(source)) { 3134 if (sourceAvailable(source)) {
3126 addedDartSource = true; 3135 addedDartSource = true;
3127 } 3136 }
3128 } 3137 }
3129 for (Source source in changeSet.changed3) { 3138 for (Source source in changeSet.changed3) {
3130 sourceChanged(source); 3139 sourceChanged(source);
3131 } 3140 }
3132 for (Source source in removedSources) { 3141 for (Source source in removedSources) {
3133 sourceRemoved(source); 3142 sourceRemoved(source);
3134 } 3143 }
3135 if (addedDartSource) { 3144 if (addedDartSource) {
3136 // TODO(brianwilkerson) This is hugely inefficient, but we need to re-an alyze any libraries 3145 // TODO(brianwilkerson) This is hugely inefficient, but we need to re-an alyze any libraries
3137 // that might have been referencing the not-yet-existing source that was just added. Longer 3146 // that might have been referencing the not-yet-existing source that was just added. Longer
3138 // term we need to keep track of which libraries are referencing non-exi sting sources and 3147 // term we need to keep track of which libraries are referencing non-exi sting sources and
3139 // only re-analyze those libraries. 3148 // only re-analyze those libraries.
3149 logInformation("Added Dart sources, invalidating all resolution informat ion");
3140 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { 3150 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) {
3141 SourceEntry sourceEntry = mapEntry.getValue(); 3151 SourceEntry sourceEntry = mapEntry.getValue();
3142 if (!mapEntry.getKey().isInSystemLibrary && sourceEntry is DartEntry) { 3152 if (!mapEntry.getKey().isInSystemLibrary && sourceEntry is DartEntry) {
3143 DartEntryImpl dartCopy = sourceEntry.writableCopy; 3153 DartEntryImpl dartCopy = sourceEntry.writableCopy;
3144 dartCopy.invalidateAllResolutionInformation(); 3154 dartCopy.invalidateAllResolutionInformation();
3145 mapEntry.setValue(dartCopy); 3155 mapEntry.setValue(dartCopy);
3146 } 3156 }
3147 } 3157 }
3148 } 3158 }
3149 } 3159 }
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
3707 } 3717 }
3708 3718
3709 CompilationUnit parseCompilationUnit(Source source) => getDartParseData2(sourc e, DartEntry.PARSED_UNIT, null); 3719 CompilationUnit parseCompilationUnit(Source source) => getDartParseData2(sourc e, DartEntry.PARSED_UNIT, null);
3710 3720
3711 HtmlUnit parseHtmlUnit(Source source) => getHtmlParseData(source, HtmlEntry.PA RSED_UNIT, null); 3721 HtmlUnit parseHtmlUnit(Source source) => getHtmlParseData(source, HtmlEntry.PA RSED_UNIT, null);
3712 3722
3713 AnalysisResult performAnalysisTask() { 3723 AnalysisResult performAnalysisTask() {
3714 int getStart = JavaSystem.currentTimeMillis(); 3724 int getStart = JavaSystem.currentTimeMillis();
3715 AnalysisTask task = nextTaskAnalysisTask; 3725 AnalysisTask task = nextTaskAnalysisTask;
3716 int getEnd = JavaSystem.currentTimeMillis(); 3726 int getEnd = JavaSystem.currentTimeMillis();
3727 if (task == null && validateCacheConsistency()) {
3728 task = nextTaskAnalysisTask;
3729 }
3717 if (task == null) { 3730 if (task == null) {
3718 return new AnalysisResult(getChangeNotices(true), getEnd - getStart, null, -1); 3731 return new AnalysisResult(getChangeNotices(true), getEnd - getStart, null, -1);
3719 } 3732 }
3720 //System.out.println(task); 3733 String taskDescriptor = task.toString();
3734 if (_recentTasks.add(taskDescriptor)) {
3735 logInformation("Performing task: ${taskDescriptor}");
3736 } else {
3737 logInformation("*** Performing repeated task: ${taskDescriptor}");
3738 }
3721 int performStart = JavaSystem.currentTimeMillis(); 3739 int performStart = JavaSystem.currentTimeMillis();
3722 try { 3740 try {
3723 task.perform(_resultRecorder); 3741 task.perform(_resultRecorder);
3724 } on AnalysisException catch (exception) { 3742 } on AnalysisException catch (exception) {
3725 if (exception.cause is! JavaIOException) { 3743 if (exception.cause is! JavaIOException) {
3726 AnalysisEngine.instance.logger.logError2("Internal error while performin g the task: ${task}", exception); 3744 AnalysisEngine.instance.logger.logError2("Internal error while performin g the task: ${task}", exception);
3727 } 3745 }
3728 } 3746 }
3729 int performEnd = JavaSystem.currentTimeMillis(); 3747 int performEnd = JavaSystem.currentTimeMillis();
3730 return new AnalysisResult(getChangeNotices(false), getEnd - getStart, task.r untimeType.toString(), performEnd - performStart); 3748 return new AnalysisResult(getChangeNotices(false), getEnd - getStart, task.r untimeType.toString(), performEnd - performStart);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
3812 _priorityOrder = new List<Source>(count); 3830 _priorityOrder = new List<Source>(count);
3813 for (int i = 0; i < count; i++) { 3831 for (int i = 0; i < count; i++) {
3814 _priorityOrder[i] = sources[i]; 3832 _priorityOrder[i] = sources[i];
3815 } 3833 }
3816 } 3834 }
3817 } 3835 }
3818 } 3836 }
3819 3837
3820 void setChangedContents(Source source, String contents, int offset, int oldLen gth, int newLength) { 3838 void setChangedContents(Source source, String contents, int offset, int oldLen gth, int newLength) {
3821 { 3839 {
3840 _recentTasks.clear();
3822 String originalContents = _sourceFactory.setContents(source, contents); 3841 String originalContents = _sourceFactory.setContents(source, contents);
3823 if (contents != null) { 3842 if (contents != null) {
3824 if (contents != originalContents) { 3843 if (contents != originalContents) {
3825 if (_options.incremental) { 3844 if (_options.incremental) {
3826 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increme ntalAnalysisCache, source, originalContents, contents, offset, oldLength, newLen gth, getReadableSourceEntry(source)); 3845 _incrementalAnalysisCache = IncrementalAnalysisCache.update(_increme ntalAnalysisCache, source, originalContents, contents, offset, oldLength, newLen gth, getReadableSourceEntry(source));
3827 } 3846 }
3828 sourceChanged(source); 3847 sourceChanged(source);
3829 } 3848 }
3830 } else if (originalContents != null) { 3849 } else if (originalContents != null) {
3831 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA nalysisCache, source); 3850 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA nalysisCache, source);
3832 sourceChanged(source); 3851 sourceChanged(source);
3833 } 3852 }
3834 } 3853 }
3835 } 3854 }
3836 3855
3837 void setContents(Source source, String contents) { 3856 void setContents(Source source, String contents) {
3838 { 3857 {
3858 _recentTasks.clear();
3839 String originalContents = _sourceFactory.setContents(source, contents); 3859 String originalContents = _sourceFactory.setContents(source, contents);
3840 if (contents != null) { 3860 if (contents != null) {
3841 if (contents != originalContents) { 3861 if (contents != originalContents) {
3842 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementa lAnalysisCache, source); 3862 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementa lAnalysisCache, source);
3843 sourceChanged(source); 3863 sourceChanged(source);
3844 } 3864 }
3845 } else if (originalContents != null) { 3865 } else if (originalContents != null) {
3846 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA nalysisCache, source); 3866 _incrementalAnalysisCache = IncrementalAnalysisCache.clear(_incrementalA nalysisCache, source);
3847 sourceChanged(source); 3867 sourceChanged(source);
3848 } 3868 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
3947 _cache.put(source, dartCopy); 3967 _cache.put(source, dartCopy);
3948 if (source == unitSource) { 3968 if (source == unitSource) {
3949 unitEntry = dartCopy; 3969 unitEntry = dartCopy;
3950 } 3970 }
3951 ChangeNoticeImpl notice = getNotice(source); 3971 ChangeNoticeImpl notice = getNotice(source);
3952 notice.compilationUnit = unit; 3972 notice.compilationUnit = unit;
3953 notice.setErrors(dartCopy.allErrors, lineInfo); 3973 notice.setErrors(dartCopy.allErrors, lineInfo);
3954 } 3974 }
3955 } 3975 }
3956 } else { 3976 } else {
3977 PrintStringWriter writer = new PrintStringWriter();
3978 writer.println("Library resolution results discarded for");
3957 for (Library library in resolvedLibraries) { 3979 for (Library library in resolvedLibraries) {
3958 for (Source source in library.compilationUnitSources) { 3980 for (Source source in library.compilationUnitSources) {
3959 DartEntry dartEntry = getReadableDartEntry(source); 3981 DartEntry dartEntry = getReadableDartEntry(source);
3960 if (dartEntry != null) { 3982 if (dartEntry != null) {
3961 int resultTime = library.getModificationTime(source); 3983 int resultTime = library.getModificationTime(source);
3984 writer.println(" ${debuggingString(source)}; sourceTime = ${sou rce.modificationStamp}, resultTime = ${resultTime}, cacheTime = ${dartEntry.modi ficationTime}");
3962 DartEntryImpl dartCopy = dartEntry.writableCopy; 3985 DartEntryImpl dartCopy = dartEntry.writableCopy;
3963 if (thrownException == null || resultTime >= 0) { 3986 if (thrownException == null || resultTime >= 0) {
3964 // 3987 //
3965 // The analysis was performed on out-of-date sources. Mark the cache so that the 3988 // The analysis was performed on out-of-date sources. Mark the cache so that the
3966 // sources will be re-analyzed using the up-to-date sources. 3989 // sources will be re-analyzed using the up-to-date sources.
3967 // 3990 //
3968 dartCopy.recordResolutionNotInProcess(); 3991 dartCopy.recordResolutionNotInProcess();
3969 } else { 3992 } else {
3970 // 3993 //
3971 // We could not determine whether the sources were up-to-date or out-of-date. Mark 3994 // We could not determine whether the sources were up-to-date or out-of-date. Mark
3972 // the cache so that we won't attempt to re-analyze the source s until there's a 3995 // the cache so that we won't attempt to re-analyze the source s until there's a
3973 // good chance that we'll be able to do so without error. 3996 // good chance that we'll be able to do so without error.
3974 // 3997 //
3975 dartCopy.recordResolutionError(); 3998 dartCopy.recordResolutionError();
3976 } 3999 }
3977 dartCopy.exception = thrownException; 4000 dartCopy.exception = thrownException;
3978 _cache.put(source, dartCopy); 4001 _cache.put(source, dartCopy);
3979 if (source == unitSource) { 4002 if (source == unitSource) {
3980 unitEntry = dartCopy; 4003 unitEntry = dartCopy;
3981 } 4004 }
4005 } else {
4006 writer.println(" ${debuggingString(source)}; sourceTime = ${sou rce.modificationStamp}, no entry");
3982 } 4007 }
3983 } 4008 }
3984 } 4009 }
4010 logInformation(writer.toString());
3985 } 4011 }
3986 } 4012 }
3987 } 4013 }
3988 if (thrownException != null) { 4014 if (thrownException != null) {
3989 throw thrownException; 4015 throw thrownException;
3990 } 4016 }
3991 if (unitEntry == null) { 4017 if (unitEntry == null) {
3992 unitEntry = getReadableDartEntry(unitSource); 4018 unitEntry = getReadableDartEntry(unitSource);
3993 if (unitEntry == null) { 4019 if (unitEntry == null) {
3994 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${ unitSource.fullName}"); 4020 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${ unitSource.fullName}");
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
4282 return htmlEntry; 4308 return htmlEntry;
4283 } else { 4309 } else {
4284 DartEntryImpl dartEntry = new DartEntryImpl(); 4310 DartEntryImpl dartEntry = new DartEntryImpl();
4285 dartEntry.modificationTime = source.modificationStamp; 4311 dartEntry.modificationTime = source.modificationStamp;
4286 _cache.put(source, dartEntry); 4312 _cache.put(source, dartEntry);
4287 return dartEntry; 4313 return dartEntry;
4288 } 4314 }
4289 } 4315 }
4290 4316
4291 /** 4317 /**
4318 * Return a string with debugging information about the given source (the full name and
4319 * modification stamp of the source).
4320 *
4321 * @param source the source for which a debugging string is to be produced
4322 * @return debugging information about the given source
4323 */
4324 String debuggingString(Source source) => "'${source.fullName}' [${source.modif icationStamp}]";
4325
4326 /**
4292 * Return an array containing all of the change notices that are waiting to be returned. If there 4327 * Return an array containing all of the change notices that are waiting to be returned. If there
4293 * are no notices, then return either `null` or an empty array, depending on t he value of 4328 * are no notices, then return either `null` or an empty array, depending on t he value of
4294 * the argument. 4329 * the argument.
4295 * 4330 *
4296 * @param nullIfEmpty `true` if `null` should be returned when there are no no tices 4331 * @param nullIfEmpty `true` if `null` should be returned when there are no no tices
4297 * @return the change notices that are waiting to be returned 4332 * @return the change notices that are waiting to be returned
4298 */ 4333 */
4299 List<ChangeNotice> getChangeNotices(bool nullIfEmpty) { 4334 List<ChangeNotice> getChangeNotices(bool nullIfEmpty) {
4300 { 4335 {
4301 if (_pendingNotices.isEmpty) { 4336 if (_pendingNotices.isEmpty) {
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
4838 } 4873 }
4839 } 4874 }
4840 4875
4841 /** 4876 /**
4842 * In response to a change to at least one of the compilation units in the giv en library, 4877 * In response to a change to at least one of the compilation units in the giv en library,
4843 * invalidate any results that are dependent on the result of resolving that l ibrary. 4878 * invalidate any results that are dependent on the result of resolving that l ibrary.
4844 * 4879 *
4845 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 4880 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
4846 * 4881 *
4847 * @param librarySource the source of the library being invalidated 4882 * @param librarySource the source of the library being invalidated
4883 * @param writer the writer to which debugging information should be written
4848 */ 4884 */
4849 void invalidateLibraryResolution(Source librarySource) { 4885 void invalidateLibraryResolution(Source librarySource, PrintStringWriter write r) {
4850 // TODO(brianwilkerson) This could be optimized. There's no need to flush al l of these caches if 4886 // TODO(brianwilkerson) This could be optimized. There's no need to flush al l of these caches if
4851 // the public namespace hasn't changed, which will be a fairly common case. The question is 4887 // the public namespace hasn't changed, which will be a fairly common case. The question is
4852 // whether we can afford the time to compute the namespace to look for diffe rences. 4888 // whether we can afford the time to compute the namespace to look for diffe rences.
4853 DartEntry libraryEntry = getReadableDartEntry(librarySource); 4889 DartEntry libraryEntry = getReadableDartEntry(librarySource);
4854 if (libraryEntry != null) { 4890 if (libraryEntry != null) {
4855 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART S); 4891 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART S);
4856 DartEntryImpl libraryCopy = libraryEntry.writableCopy; 4892 DartEntryImpl libraryCopy = libraryEntry.writableCopy;
4893 int oldTime = libraryCopy.modificationTime;
4857 libraryCopy.invalidateAllResolutionInformation(); 4894 libraryCopy.invalidateAllResolutionInformation();
4858 libraryCopy.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID); 4895 libraryCopy.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID);
4859 _cache.put(librarySource, libraryCopy); 4896 _cache.put(librarySource, libraryCopy);
4897 if (writer != null) {
4898 writer.println(" Invalidated library source: ${debuggingString(libraryS ource)} (previously modified at ${oldTime})");
4899 }
4860 for (Source partSource in includedParts) { 4900 for (Source partSource in includedParts) {
4861 SourceEntry partEntry = _cache.get(partSource); 4901 SourceEntry partEntry = _cache.get(partSource);
4862 if (partEntry is DartEntry) { 4902 if (partEntry is DartEntry) {
4863 DartEntryImpl partCopy = partEntry.writableCopy; 4903 DartEntryImpl partCopy = partEntry.writableCopy;
4904 oldTime = partCopy.modificationTime;
4864 partCopy.invalidateAllResolutionInformation(); 4905 partCopy.invalidateAllResolutionInformation();
4865 _cache.put(partSource, partCopy); 4906 _cache.put(partSource, partCopy);
4907 if (writer != null) {
4908 writer.println(" Invalidated part source: ${debuggingString(partSou rce)} (previously modified at ${oldTime})");
4909 }
4866 } 4910 }
4867 } 4911 }
4868 } 4912 }
4869 } 4913 }
4870 4914
4871 /** 4915 /**
4872 * Return `true` if this library is, or depends on, dart:html. 4916 * Return `true` if this library is, or depends on, dart:html.
4873 * 4917 *
4874 * @param library the library being tested 4918 * @param library the library being tested
4875 * @param visitedLibraries a collection of the libraries that have been visite d, used to prevent 4919 * @param visitedLibraries a collection of the libraries that have been visite d, used to prevent
(...skipping 15 matching lines...) Expand all
4891 } 4935 }
4892 for (LibraryElement exported in library.exportedLibraries) { 4936 for (LibraryElement exported in library.exportedLibraries) {
4893 if (isClient(exported, htmlSource, visitedLibraries)) { 4937 if (isClient(exported, htmlSource, visitedLibraries)) {
4894 return true; 4938 return true;
4895 } 4939 }
4896 } 4940 }
4897 return false; 4941 return false;
4898 } 4942 }
4899 4943
4900 /** 4944 /**
4945 * Log the given debugging information.
4946 *
4947 * @param message the message to be added to the log
4948 */
4949 void logInformation(String message) {
4950 AnalysisEngine.instance.logger.logInformation(message);
4951 }
4952
4953 /**
4954 * Log the given debugging information.
4955 *
4956 * @param message the message to be added to the log
4957 * @param exception the exception to be included in the log entry
4958 */
4959 void logInformation2(String message, Exception exception) {
4960 if (exception == null) {
4961 AnalysisEngine.instance.logger.logInformation(message);
4962 } else {
4963 AnalysisEngine.instance.logger.logInformation3(message, exception);
4964 }
4965 }
4966
4967 /**
4901 * Given a cache entry and a library element, record the library element and o ther information 4968 * Given a cache entry and a library element, record the library element and o ther information
4902 * gleaned from the element in the cache entry. 4969 * gleaned from the element in the cache entry.
4903 * 4970 *
4904 * @param dartCopy the cache entry in which data is to be recorded 4971 * @param dartCopy the cache entry in which data is to be recorded
4905 * @param library the library element used to record information 4972 * @param library the library element used to record information
4906 * @param htmlSource the source for the HTML library 4973 * @param htmlSource the source for the HTML library
4907 */ 4974 */
4908 void recordElementData(DartEntryImpl dartCopy, LibraryElement library, Source htmlSource) { 4975 void recordElementData(DartEntryImpl dartCopy, LibraryElement library, Source htmlSource) {
4909 dartCopy.setValue(DartEntry.ELEMENT, library); 4976 dartCopy.setValue(DartEntry.ELEMENT, library);
4910 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); 4977 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4956 dartCopy.setValue2(DartEntry.VERIFICATION_ERRORS, librarySource, task. errors); 5023 dartCopy.setValue2(DartEntry.VERIFICATION_ERRORS, librarySource, task. errors);
4957 ChangeNoticeImpl notice = getNotice(source); 5024 ChangeNoticeImpl notice = getNotice(source);
4958 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LIN E_INFO)); 5025 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LIN E_INFO));
4959 } else { 5026 } else {
4960 dartCopy.setState2(DartEntry.VERIFICATION_ERRORS, librarySource, Cache State.ERROR); 5027 dartCopy.setState2(DartEntry.VERIFICATION_ERRORS, librarySource, Cache State.ERROR);
4961 } 5028 }
4962 dartCopy.exception = thrownException; 5029 dartCopy.exception = thrownException;
4963 _cache.put(source, dartCopy); 5030 _cache.put(source, dartCopy);
4964 dartEntry = dartCopy; 5031 dartEntry = dartCopy;
4965 } else { 5032 } else {
5033 logInformation2("Generated errors discarded for ${debuggingString(source )}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEn try.modificationTime}", thrownException);
4966 DartEntryImpl dartCopy = dartEntry.writableCopy; 5034 DartEntryImpl dartCopy = dartEntry.writableCopy;
4967 if (thrownException == null || resultTime >= 0) { 5035 if (thrownException == null || resultTime >= 0) {
4968 // 5036 //
4969 // The analysis was performed on out-of-date sources. Mark the cache s o that the source 5037 // The analysis was performed on out-of-date sources. Mark the cache s o that the source
4970 // will be re-verified using the up-to-date sources. 5038 // will be re-verified using the up-to-date sources.
4971 // 5039 //
4972 dartCopy.setState2(DartEntry.VERIFICATION_ERRORS, librarySource, Cache State.INVALID); 5040 dartCopy.setState2(DartEntry.VERIFICATION_ERRORS, librarySource, Cache State.INVALID);
4973 } else { 5041 } else {
4974 // 5042 //
4975 // We could not determine whether the sources were up-to-date or out-o f-date. Mark the 5043 // We could not determine whether the sources were up-to-date or out-o f-date. Mark the
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
5053 dartCopy.setValue2(DartEntry.HINTS, librarySource, results.data); 5121 dartCopy.setValue2(DartEntry.HINTS, librarySource, results.data);
5054 ChangeNoticeImpl notice = getNotice(unitSource); 5122 ChangeNoticeImpl notice = getNotice(unitSource);
5055 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.L INE_INFO)); 5123 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.L INE_INFO));
5056 } else { 5124 } else {
5057 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.ERROR) ; 5125 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.ERROR) ;
5058 } 5126 }
5059 dartCopy.exception = thrownException; 5127 dartCopy.exception = thrownException;
5060 _cache.put(unitSource, dartCopy); 5128 _cache.put(unitSource, dartCopy);
5061 dartEntry = dartCopy; 5129 dartEntry = dartCopy;
5062 } else { 5130 } else {
5131 logInformation2("Generated hints discarded for ${debuggingString(unitS ource)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${d artEntry.modificationTime}", thrownException);
5063 if (identical(dartEntry.getState2(DartEntry.HINTS, librarySource), Cac heState.IN_PROCESS)) { 5132 if (identical(dartEntry.getState2(DartEntry.HINTS, librarySource), Cac heState.IN_PROCESS)) {
5064 DartEntryImpl dartCopy = dartEntry.writableCopy; 5133 DartEntryImpl dartCopy = dartEntry.writableCopy;
5065 if (thrownException == null || resultTime >= 0) { 5134 if (thrownException == null || resultTime >= 0) {
5066 // 5135 //
5067 // The analysis was performed on out-of-date sources. Mark the cac he so that the sources 5136 // The analysis was performed on out-of-date sources. Mark the cac he so that the sources
5068 // will be re-analyzed using the up-to-date sources. 5137 // will be re-analyzed using the up-to-date sources.
5069 // 5138 //
5070 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.INVA LID); 5139 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.INVA LID);
5071 } else { 5140 } else {
5072 // 5141 //
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
5159 // Verify that the incrementally parsed and resolved unit in the incre mental cache 5228 // Verify that the incrementally parsed and resolved unit in the incre mental cache
5160 // is structurally equivalent to the fully parsed unit 5229 // is structurally equivalent to the fully parsed unit
5161 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_ incrementalAnalysisCache, source, task.compilationUnit); 5230 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_ incrementalAnalysisCache, source, task.compilationUnit);
5162 } else { 5231 } else {
5163 dartCopy.recordParseError(); 5232 dartCopy.recordParseError();
5164 } 5233 }
5165 dartCopy.exception = thrownException; 5234 dartCopy.exception = thrownException;
5166 _cache.put(source, dartCopy); 5235 _cache.put(source, dartCopy);
5167 dartEntry = dartCopy; 5236 dartEntry = dartCopy;
5168 } else { 5237 } else {
5238 logInformation2("Parse results discarded for ${debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry .modificationTime}", thrownException);
5169 DartEntryImpl dartCopy = dartEntry.writableCopy; 5239 DartEntryImpl dartCopy = dartEntry.writableCopy;
5170 if (thrownException == null || resultTime >= 0) { 5240 if (thrownException == null || resultTime >= 0) {
5171 // 5241 //
5172 // The analysis was performed on out-of-date sources. Mark the cache s o that the sources 5242 // The analysis was performed on out-of-date sources. Mark the cache s o that the sources
5173 // will be re-analyzed using the up-to-date sources. 5243 // will be re-analyzed using the up-to-date sources.
5174 // 5244 //
5175 dartCopy.recordParseNotInProcess(); 5245 dartCopy.recordParseNotInProcess();
5176 } else { 5246 } else {
5177 // 5247 //
5178 // We could not determine whether the sources were up-to-date or out-o f-date. Mark the 5248 // We could not determine whether the sources were up-to-date or out-o f-date. Mark the
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5234 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibra ries); 5304 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibra ries);
5235 ChangeNoticeImpl notice = getNotice(source); 5305 ChangeNoticeImpl notice = getNotice(source);
5236 notice.setErrors(htmlEntry.allErrors, lineInfo); 5306 notice.setErrors(htmlEntry.allErrors, lineInfo);
5237 } else { 5307 } else {
5238 htmlCopy.recordParseError(); 5308 htmlCopy.recordParseError();
5239 } 5309 }
5240 htmlCopy.exception = thrownException; 5310 htmlCopy.exception = thrownException;
5241 _cache.put(source, htmlCopy); 5311 _cache.put(source, htmlCopy);
5242 htmlEntry = htmlCopy; 5312 htmlEntry = htmlCopy;
5243 } else { 5313 } else {
5314 logInformation2("Parse results discarded for ${debuggingString(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry .modificationTime}", thrownException);
5244 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; 5315 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy;
5245 if (thrownException == null || resultTime >= 0) { 5316 if (thrownException == null || resultTime >= 0) {
5246 // 5317 //
5247 // The analysis was performed on out-of-date sources. Mark the cache s o that the sources 5318 // The analysis was performed on out-of-date sources. Mark the cache s o that the sources
5248 // will be re-analyzed using the up-to-date sources. 5319 // will be re-analyzed using the up-to-date sources.
5249 // 5320 //
5250 if (identical(htmlCopy.getState(SourceEntry.LINE_INFO), CacheState.IN_ PROCESS)) { 5321 if (identical(htmlCopy.getState(SourceEntry.LINE_INFO), CacheState.IN_ PROCESS)) {
5251 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID); 5322 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVALID);
5252 } 5323 }
5253 if (identical(htmlCopy.getState(HtmlEntry.PARSED_UNIT), CacheState.IN_ PROCESS)) { 5324 if (identical(htmlCopy.getState(HtmlEntry.PARSED_UNIT), CacheState.IN_ PROCESS)) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
5313 DartEntryImpl dartCopy = dartEntry.writableCopy; 5384 DartEntryImpl dartCopy = dartEntry.writableCopy;
5314 if (thrownException == null) { 5385 if (thrownException == null) {
5315 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, task.resolv edUnit); 5386 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, task.resolv edUnit);
5316 } else { 5387 } else {
5317 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState. ERROR); 5388 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState. ERROR);
5318 } 5389 }
5319 dartCopy.exception = thrownException; 5390 dartCopy.exception = thrownException;
5320 _cache.put(unitSource, dartCopy); 5391 _cache.put(unitSource, dartCopy);
5321 dartEntry = dartCopy; 5392 dartEntry = dartCopy;
5322 } else { 5393 } else {
5394 logInformation2("Resolution results discarded for ${debuggingString(unit Source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${ dartEntry.modificationTime}", thrownException);
5323 DartEntryImpl dartCopy = dartEntry.writableCopy; 5395 DartEntryImpl dartCopy = dartEntry.writableCopy;
5324 if (thrownException == null || resultTime >= 0) { 5396 if (thrownException == null || resultTime >= 0) {
5325 // 5397 //
5326 // The analysis was performed on out-of-date sources. Mark the cache s o that the sources 5398 // The analysis was performed on out-of-date sources. Mark the cache s o that the sources
5327 // will be re-analyzed using the up-to-date sources. 5399 // will be re-analyzed using the up-to-date sources.
5328 // 5400 //
5329 if (identical(dartCopy.getState(DartEntry.RESOLVED_UNIT), CacheState.I N_PROCESS)) { 5401 if (identical(dartCopy.getState(DartEntry.RESOLVED_UNIT), CacheState.I N_PROCESS)) {
5330 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheStat e.INVALID); 5402 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheStat e.INVALID);
5331 } 5403 }
5332 } else { 5404 } else {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
5387 ChangeNoticeImpl notice = getNotice(source); 5459 ChangeNoticeImpl notice = getNotice(source);
5388 notice.htmlUnit = task.resolvedUnit; 5460 notice.htmlUnit = task.resolvedUnit;
5389 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN E_INFO)); 5461 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN E_INFO));
5390 } else { 5462 } else {
5391 htmlCopy.recordResolutionError(); 5463 htmlCopy.recordResolutionError();
5392 } 5464 }
5393 htmlCopy.exception = thrownException; 5465 htmlCopy.exception = thrownException;
5394 _cache.put(source, htmlCopy); 5466 _cache.put(source, htmlCopy);
5395 htmlEntry = htmlCopy; 5467 htmlEntry = htmlCopy;
5396 } else { 5468 } else {
5469 logInformation2("Resolution results discarded for ${debuggingString(sour ce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${html Entry.modificationTime}", thrownException);
5397 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; 5470 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy;
5398 if (thrownException == null || resultTime >= 0) { 5471 if (thrownException == null || resultTime >= 0) {
5399 // 5472 //
5400 // The analysis was performed on out-of-date sources. Mark the cache s o that the sources 5473 // The analysis was performed on out-of-date sources. Mark the cache s o that the sources
5401 // will be re-analyzed using the up-to-date sources. 5474 // will be re-analyzed using the up-to-date sources.
5402 // 5475 //
5403 if (identical(htmlCopy.getState(HtmlEntry.ELEMENT), CacheState.IN_PROC ESS)) { 5476 if (identical(htmlCopy.getState(HtmlEntry.ELEMENT), CacheState.IN_PROC ESS)) {
5404 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID); 5477 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID);
5405 } 5478 }
5406 if (identical(htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS), CacheSta te.IN_PROCESS)) { 5479 if (identical(htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS), CacheSta te.IN_PROCESS)) {
(...skipping 24 matching lines...) Expand all
5431 * 5504 *
5432 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 5505 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
5433 * 5506 *
5434 * @param source the source that has been added 5507 * @param source the source that has been added
5435 * @return `true` if the new source is a Dart file 5508 * @return `true` if the new source is a Dart file
5436 */ 5509 */
5437 bool sourceAvailable(Source source) { 5510 bool sourceAvailable(Source source) {
5438 SourceEntry sourceEntry = _cache.get(source); 5511 SourceEntry sourceEntry = _cache.get(source);
5439 if (sourceEntry == null) { 5512 if (sourceEntry == null) {
5440 sourceEntry = createSourceEntry(source); 5513 sourceEntry = createSourceEntry(source);
5514 logInformation("Added new source: ${debuggingString(source)}");
5441 } else { 5515 } else {
5442 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; 5516 SourceEntryImpl sourceCopy = sourceEntry.writableCopy;
5517 int oldTime = sourceCopy.modificationTime;
5443 sourceCopy.modificationTime = source.modificationStamp; 5518 sourceCopy.modificationTime = source.modificationStamp;
5519 // TODO(brianwilkerson) Understand why we're not invalidating the cache.
5444 _cache.put(source, sourceCopy); 5520 _cache.put(source, sourceCopy);
5521 logInformation("Added new source: ${debuggingString(source)} (previously m odified at ${oldTime})");
5445 } 5522 }
5446 return sourceEntry is DartEntry; 5523 return sourceEntry is DartEntry;
5447 } 5524 }
5448 5525
5449 /** 5526 /**
5450 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 5527 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
5451 * 5528 *
5452 * @param source the source that has been changed 5529 * @param source the source that has been changed
5453 */ 5530 */
5454 void sourceChanged(Source source) { 5531 void sourceChanged(Source source) {
5455 SourceEntry sourceEntry = _cache.get(source); 5532 SourceEntry sourceEntry = _cache.get(source);
5456 if (sourceEntry == null || sourceEntry.modificationTime == source.modificati onStamp) { 5533 if (sourceEntry == null || sourceEntry.modificationTime == source.modificati onStamp) {
5457 // Either we have removed this source, in which case we don't care that it is changed, or we 5534 // Either we have removed this source, in which case we don't care that it is changed, or we
5458 // have already invalidated the cache and don't need to invalidate it agai n. 5535 // have already invalidated the cache and don't need to invalidate it agai n.
5536 if (sourceEntry == null) {
5537 logInformation("Modified source, but there is no entry: ${debuggingStrin g(source)}");
5538 } else {
5539 logInformation("Modified source, but modification time matches: ${debugg ingString(source)}");
5540 }
5459 return; 5541 return;
5460 } 5542 }
5461 if (sourceEntry is HtmlEntry) { 5543 if (sourceEntry is HtmlEntry) {
5462 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; 5544 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy;
5545 int oldTime = htmlCopy.modificationTime;
5463 htmlCopy.modificationTime = source.modificationStamp; 5546 htmlCopy.modificationTime = source.modificationStamp;
5464 htmlCopy.invalidateAllInformation(); 5547 htmlCopy.invalidateAllInformation();
5465 _cache.put(source, htmlCopy); 5548 _cache.put(source, htmlCopy);
5549 logInformation("Modified HTML source: ${debuggingString(source)} (previous ly modified at ${oldTime})");
5466 } else if (sourceEntry is DartEntry) { 5550 } else if (sourceEntry is DartEntry) {
5467 List<Source> containingLibraries = getLibrariesContaining(source); 5551 List<Source> containingLibraries = getLibrariesContaining(source);
5468 Set<Source> librariesToInvalidate = new Set<Source>(); 5552 Set<Source> librariesToInvalidate = new Set<Source>();
5469 for (Source containingLibrary in containingLibraries) { 5553 for (Source containingLibrary in containingLibraries) {
5470 librariesToInvalidate.add(containingLibrary); 5554 librariesToInvalidate.add(containingLibrary);
5471 for (Source dependentLibrary in getLibrariesDependingOn(containingLibrar y)) { 5555 for (Source dependentLibrary in getLibrariesDependingOn(containingLibrar y)) {
5472 librariesToInvalidate.add(dependentLibrary); 5556 librariesToInvalidate.add(dependentLibrary);
5473 } 5557 }
5474 } 5558 }
5559 PrintStringWriter writer = new PrintStringWriter();
5560 int oldTime = sourceEntry.modificationTime;
5561 writer.println("Modified Dart source: ${debuggingString(source)} (previous ly modified at ${oldTime})");
5475 for (Source library in librariesToInvalidate) { 5562 for (Source library in librariesToInvalidate) {
5476 // for (Source library : containingLibraries) { 5563 // for (Source library : containingLibraries) {
5477 invalidateLibraryResolution(library); 5564 invalidateLibraryResolution(library, writer);
5478 } 5565 }
5479 DartEntryImpl dartCopy = sourceEntry.writableCopy; 5566 DartEntryImpl dartCopy = sourceEntry.writableCopy;
5480 dartCopy.modificationTime = source.modificationStamp; 5567 dartCopy.modificationTime = source.modificationStamp;
5481 dartCopy.invalidateAllInformation(); 5568 dartCopy.invalidateAllInformation();
5482 _cache.put(source, dartCopy); 5569 _cache.put(source, dartCopy);
5570 logInformation(writer.toString());
5483 } 5571 }
5484 } 5572 }
5485 5573
5486 /** 5574 /**
5487 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock]. 5575 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
5488 * 5576 *
5489 * @param source the source that has been deleted 5577 * @param source the source that has been deleted
5490 */ 5578 */
5491 void sourceRemoved(Source source) { 5579 void sourceRemoved(Source source) {
5580 PrintStringWriter writer = new PrintStringWriter();
5581 writer.println("Removed source: ${debuggingString(source)}");
5492 SourceEntry sourceEntry = _cache.get(source); 5582 SourceEntry sourceEntry = _cache.get(source);
5493 if (sourceEntry is DartEntry) { 5583 if (sourceEntry is DartEntry) {
5494 Set<Source> libraries = new Set<Source>(); 5584 Set<Source> libraries = new Set<Source>();
5495 for (Source librarySource in getLibrariesContaining(source)) { 5585 for (Source librarySource in getLibrariesContaining(source)) {
5496 libraries.add(librarySource); 5586 libraries.add(librarySource);
5497 for (Source dependentLibrary in getLibrariesDependingOn(librarySource)) { 5587 for (Source dependentLibrary in getLibrariesDependingOn(librarySource)) {
5498 libraries.add(dependentLibrary); 5588 libraries.add(dependentLibrary);
5499 } 5589 }
5500 } 5590 }
5501 for (Source librarySource in libraries) { 5591 for (Source librarySource in libraries) {
5502 invalidateLibraryResolution(librarySource); 5592 invalidateLibraryResolution(librarySource, writer);
5503 } 5593 }
5504 } 5594 }
5505 _cache.remove(source); 5595 _cache.remove(source);
5596 logInformation(writer.toString());
5597 }
5598
5599 /**
5600 * Check the cache for any invalid entries (entries whose modification time do es not match the
5601 * modification time of the source associated with the entry). Invalid entries will be marked as
5602 * invalid so that the source will be re-analyzed.
5603 *
5604 * <b>Note:</b> This method must only be invoked while we are synchronized on [cacheLock].
5605 *
5606 * @return `true` if at least one entry was invalid
5607 */
5608 bool validateCacheConsistency() {
5609 int consistencyCheckStart = JavaSystem.nanoTime();
5610 int inconsistentCount = 0;
5611 {
5612 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) {
5613 Source source = entry.getKey();
5614 SourceEntry sourceEntry = entry.getValue();
5615 int sourceTime = source.modificationStamp;
5616 if (sourceTime != sourceEntry.modificationTime) {
5617 sourceChanged(source);
5618 inconsistentCount++;
5619 }
5620 }
5621 }
5622 int consistencyCheckEnd = JavaSystem.nanoTime();
5623 logInformation("Consistency check found ${inconsistentCount} inconsistent en tries in ${((consistencyCheckEnd - consistencyCheckStart) / 1000000.0)} ms");
5624 return inconsistentCount > 0;
5506 } 5625 }
5507 } 5626 }
5508 5627
5509 /** 5628 /**
5510 * Instances of the class `AnalysisTaskResultRecorder` are used by an analysis c ontext to 5629 * Instances of the class `AnalysisTaskResultRecorder` are used by an analysis c ontext to
5511 * record the results of a task. 5630 * record the results of a task.
5512 */ 5631 */
5513 class AnalysisContextImpl_AnalysisTaskResultRecorder implements AnalysisTaskVisi tor<SourceEntry> { 5632 class AnalysisContextImpl_AnalysisTaskResultRecorder implements AnalysisTaskVisi tor<SourceEntry> {
5514 final AnalysisContextImpl AnalysisContextImpl_this; 5633 final AnalysisContextImpl AnalysisContextImpl_this;
5515 5634
(...skipping 1662 matching lines...) Expand 10 before | Expand all | Expand 10 after
7178 * 7297 *
7179 * @param visitor the visitor used to visit this task after it has completed 7298 * @param visitor the visitor used to visit this task after it has completed
7180 * @return the value returned by the visitor 7299 * @return the value returned by the visitor
7181 * @throws AnalysisException if the visitor throws the exception 7300 * @throws AnalysisException if the visitor throws the exception
7182 */ 7301 */
7183 Object perform(AnalysisTaskVisitor visitor) { 7302 Object perform(AnalysisTaskVisitor visitor) {
7184 try { 7303 try {
7185 safelyPerform(); 7304 safelyPerform();
7186 } on AnalysisException catch (exception) { 7305 } on AnalysisException catch (exception) {
7187 _thrownException = exception; 7306 _thrownException = exception;
7188 AnalysisEngine.instance.logger.logInformation2("Task failed: ${taskDescrip tion}", exception); 7307 AnalysisEngine.instance.logger.logInformation3("Task failed: ${taskDescrip tion}", exception);
7189 } 7308 }
7190 return accept(visitor); 7309 return accept(visitor);
7191 } 7310 }
7192 7311
7193 String toString() => taskDescription; 7312 String toString() => taskDescription;
7194 7313
7195 /** 7314 /**
7196 * Return a textual description of this task. 7315 * Return a textual description of this task.
7197 * 7316 *
7198 * @return a textual description of this task 7317 * @return a textual description of this task
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
8323 * @param exception the exception being logged 8442 * @param exception the exception being logged
8324 */ 8443 */
8325 void logInformation(String message); 8444 void logInformation(String message);
8326 8445
8327 /** 8446 /**
8328 * Log the given exception as one representing an informational message. 8447 * Log the given exception as one representing an informational message.
8329 * 8448 *
8330 * @param message an explanation of why the error occurred or what it means 8449 * @param message an explanation of why the error occurred or what it means
8331 * @param exception the exception being logged 8450 * @param exception the exception being logged
8332 */ 8451 */
8333 void logInformation2(String message, Exception exception); 8452 void logInformation3(String message, Exception exception);
8334 } 8453 }
8335 8454
8336 /** 8455 /**
8337 * Implementation of [Logger] that does nothing. 8456 * Implementation of [Logger] that does nothing.
8338 */ 8457 */
8339 class Logger_NullLogger implements Logger { 8458 class Logger_NullLogger implements Logger {
8340 void logError(String message) { 8459 void logError(String message) {
8341 } 8460 }
8342 8461
8343 void logError2(String message, Exception exception) { 8462 void logError2(String message, Exception exception) {
8344 } 8463 }
8345 8464
8346 void logError3(Exception exception) { 8465 void logError3(Exception exception) {
8347 } 8466 }
8348 8467
8349 void logInformation(String message) { 8468 void logInformation(String message) {
8350 } 8469 }
8351 8470
8352 void logInformation2(String message, Exception exception) { 8471 void logInformation3(String message, Exception exception) {
8353 } 8472 }
8354 } 8473 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698