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

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

Issue 914283002: Add SourceEntry.CONTENT_ERRORS data descriptor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine; 8 library engine;
9 9
10 import "dart:math" as math; 10 import "dart:math" as math;
(...skipping 4666 matching lines...) Expand 10 before | Expand all | Expand 10 after
4677 */ 4677 */
4678 SourceEntry _recordGetContentsTask(GetContentTask task) { 4678 SourceEntry _recordGetContentsTask(GetContentTask task) {
4679 if (!task.isComplete) { 4679 if (!task.isComplete) {
4680 return null; 4680 return null;
4681 } 4681 }
4682 Source source = task.source; 4682 Source source = task.source;
4683 SourceEntry sourceEntry = _cache.get(source); 4683 SourceEntry sourceEntry = _cache.get(source);
4684 CaughtException thrownException = task.exception; 4684 CaughtException thrownException = task.exception;
4685 if (thrownException != null) { 4685 if (thrownException != null) {
4686 sourceEntry.recordContentError(thrownException); 4686 sourceEntry.recordContentError(thrownException);
4687 // TODO(scheglov) should we add separate ContentErrorCode and 4687 {
4688 // SourceEntry.CONTENT_ERRORS entry? 4688 sourceEntry.setValue(SourceEntry.CONTENT_ERRORS, task.errors);
4689 if (sourceEntry is DartEntry) {
4690 sourceEntry.setValue(
4691 DartEntry.SCAN_ERRORS,
4692 <AnalysisError>[
4693 new AnalysisError.con1(
4694 source,
4695 ScannerErrorCode.UNABLE_GET_CONTENT,
4696 [thrownException.toString()])]);
4697 ChangeNoticeImpl notice = _getNotice(source); 4689 ChangeNoticeImpl notice = _getNotice(source);
4698 notice.setErrors(sourceEntry.allErrors, null); 4690 notice.setErrors(sourceEntry.allErrors, null);
4699 } 4691 }
4700 _workManager.remove(source); 4692 _workManager.remove(source);
4701 throw new AnalysisException('<rethrow>', thrownException); 4693 throw new AnalysisException('<rethrow>', thrownException);
4702 } 4694 }
4703 sourceEntry.modificationTime = task.modificationTime; 4695 sourceEntry.modificationTime = task.modificationTime;
4704 sourceEntry.setValue(SourceEntry.CONTENT, task.content); 4696 sourceEntry.setValue(SourceEntry.CONTENT, task.content);
4705 return sourceEntry; 4697 return sourceEntry;
4706 } 4698 }
(...skipping 3171 matching lines...) Expand 10 before | Expand all | Expand 10 after
7878 "DartEntry.RESOLUTION_ERRORS", 7870 "DartEntry.RESOLUTION_ERRORS",
7879 AnalysisError.NO_ERRORS); 7871 AnalysisError.NO_ERRORS);
7880 7872
7881 /** 7873 /**
7882 * The data descriptor representing the resolved AST structure. 7874 * The data descriptor representing the resolved AST structure.
7883 */ 7875 */
7884 static final DataDescriptor<CompilationUnit> RESOLVED_UNIT = 7876 static final DataDescriptor<CompilationUnit> RESOLVED_UNIT =
7885 new DataDescriptor<CompilationUnit>("DartEntry.RESOLVED_UNIT"); 7877 new DataDescriptor<CompilationUnit>("DartEntry.RESOLVED_UNIT");
7886 7878
7887 /** 7879 /**
7888 * The data descriptor representing the token stream. 7880 * The data descriptor representing the errors resulting from scanning the
7881 * source.
7889 */ 7882 */
7890 static final DataDescriptor<List<AnalysisError>> SCAN_ERRORS = 7883 static final DataDescriptor<List<AnalysisError>> SCAN_ERRORS =
7891 new DataDescriptor<List<AnalysisError>>( 7884 new DataDescriptor<List<AnalysisError>>(
7892 "DartEntry.SCAN_ERRORS", 7885 "DartEntry.SCAN_ERRORS",
7893 AnalysisError.NO_ERRORS); 7886 AnalysisError.NO_ERRORS);
7894 7887
7895 /** 7888 /**
7896 * The data descriptor representing the source kind. 7889 * The data descriptor representing the source kind.
7897 */ 7890 */
7898 static final DataDescriptor<SourceKind> SOURCE_KIND = 7891 static final DataDescriptor<SourceKind> SOURCE_KIND =
(...skipping 26 matching lines...) Expand all
7925 * `null`. 7918 * `null`.
7926 */ 7919 */
7927 ResolutionState _resolutionState = new ResolutionState(); 7920 ResolutionState _resolutionState = new ResolutionState();
7928 7921
7929 /** 7922 /**
7930 * Return all of the errors associated with the compilation unit that are 7923 * Return all of the errors associated with the compilation unit that are
7931 * currently cached. 7924 * currently cached.
7932 */ 7925 */
7933 List<AnalysisError> get allErrors { 7926 List<AnalysisError> get allErrors {
7934 List<AnalysisError> errors = new List<AnalysisError>(); 7927 List<AnalysisError> errors = new List<AnalysisError>();
7928 errors.addAll(super.allErrors);
7935 errors.addAll(getValue(SCAN_ERRORS)); 7929 errors.addAll(getValue(SCAN_ERRORS));
7936 errors.addAll(getValue(PARSE_ERRORS)); 7930 errors.addAll(getValue(PARSE_ERRORS));
7937 ResolutionState state = _resolutionState; 7931 ResolutionState state = _resolutionState;
7938 while (state != null) { 7932 while (state != null) {
7939 errors.addAll(state.getValue(RESOLUTION_ERRORS)); 7933 errors.addAll(state.getValue(RESOLUTION_ERRORS));
7940 errors.addAll(state.getValue(VERIFICATION_ERRORS)); 7934 errors.addAll(state.getValue(VERIFICATION_ERRORS));
7941 errors.addAll(state.getValue(HINTS)); 7935 errors.addAll(state.getValue(HINTS));
7942 errors.addAll(state.getValue(LINTS)); 7936 errors.addAll(state.getValue(LINTS));
7943 state = state._nextState; 7937 state = state._nextState;
7944 } 7938 }
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after
9039 * A flag indicating whether this task is complete. 9033 * A flag indicating whether this task is complete.
9040 */ 9034 */
9041 bool _complete = false; 9035 bool _complete = false;
9042 9036
9043 /** 9037 /**
9044 * The contents of the source. 9038 * The contents of the source.
9045 */ 9039 */
9046 String _content; 9040 String _content;
9047 9041
9048 /** 9042 /**
9043 * The errors that were produced by getting the source content.
9044 */
9045 final List<AnalysisError> errors = <AnalysisError>[];
9046
9047 /**
9049 * The time at which the contents of the source were last modified. 9048 * The time at which the contents of the source were last modified.
9050 */ 9049 */
9051 int _modificationTime = -1; 9050 int _modificationTime = -1;
9052 9051
9053 /** 9052 /**
9054 * Initialize a newly created task to perform analysis within the given contex t. 9053 * Initialize a newly created task to perform analysis within the given contex t.
9055 * 9054 *
9056 * @param context the context in which the task is to be performed 9055 * @param context the context in which the task is to be performed
9057 * @param source the source to be parsed 9056 * @param source the source to be parsed
9058 * @param contentData the time-stamped contents of the source 9057 * @param contentData the time-stamped contents of the source
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
9102 _complete = true; 9101 _complete = true;
9103 try { 9102 try {
9104 TimestampedData<String> data = context.getContents(source); 9103 TimestampedData<String> data = context.getContents(source);
9105 _content = data.data; 9104 _content = data.data;
9106 _modificationTime = data.modificationTime; 9105 _modificationTime = data.modificationTime;
9107 AnalysisEngine.instance.instrumentationService.logFileRead( 9106 AnalysisEngine.instance.instrumentationService.logFileRead(
9108 source.fullName, 9107 source.fullName,
9109 _modificationTime, 9108 _modificationTime,
9110 _content); 9109 _content);
9111 } catch (exception, stackTrace) { 9110 } catch (exception, stackTrace) {
9111 errors.add(
9112 new AnalysisError.con1(
9113 source,
9114 ScannerErrorCode.UNABLE_GET_CONTENT,
9115 [exception]));
9112 throw new AnalysisException( 9116 throw new AnalysisException(
9113 "Could not get contents of $source", 9117 "Could not get contents of $source",
9114 new CaughtException(exception, stackTrace)); 9118 new CaughtException(exception, stackTrace));
9115 } 9119 }
9116 } 9120 }
9117 } 9121 }
9118 9122
9119 /** 9123 /**
9120 * An `HtmlEntry` maintains the information cached by an analysis context about 9124 * An `HtmlEntry` maintains the information cached by an analysis context about
9121 * an individual HTML file. 9125 * an individual HTML file.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
9173 new DataDescriptor<List<AnalysisError>>( 9177 new DataDescriptor<List<AnalysisError>>(
9174 "HtmlEntry.RESOLUTION_ERRORS", 9178 "HtmlEntry.RESOLUTION_ERRORS",
9175 AnalysisError.NO_ERRORS); 9179 AnalysisError.NO_ERRORS);
9176 9180
9177 /** 9181 /**
9178 * Return all of the errors associated with the HTML file that are currently 9182 * Return all of the errors associated with the HTML file that are currently
9179 * cached. 9183 * cached.
9180 */ 9184 */
9181 List<AnalysisError> get allErrors { 9185 List<AnalysisError> get allErrors {
9182 List<AnalysisError> errors = new List<AnalysisError>(); 9186 List<AnalysisError> errors = new List<AnalysisError>();
9187 errors.addAll(super.allErrors);
9183 errors.addAll(getValue(PARSE_ERRORS)); 9188 errors.addAll(getValue(PARSE_ERRORS));
9184 errors.addAll(getValue(RESOLUTION_ERRORS)); 9189 errors.addAll(getValue(RESOLUTION_ERRORS));
9185 errors.addAll(getValue(HINTS)); 9190 errors.addAll(getValue(HINTS));
9186 if (errors.length == 0) { 9191 if (errors.length == 0) {
9187 return AnalysisError.NO_ERRORS; 9192 return AnalysisError.NO_ERRORS;
9188 } 9193 }
9189 return errors; 9194 return errors;
9190 } 9195 }
9191 9196
9192 /** 9197 /**
(...skipping 2411 matching lines...) Expand 10 before | Expand all | Expand 10 after
11604 * an individual source, no matter what kind of source it is. 11609 * an individual source, no matter what kind of source it is.
11605 */ 11610 */
11606 abstract class SourceEntry { 11611 abstract class SourceEntry {
11607 /** 11612 /**
11608 * The data descriptor representing the contents of the source. 11613 * The data descriptor representing the contents of the source.
11609 */ 11614 */
11610 static final DataDescriptor<String> CONTENT = 11615 static final DataDescriptor<String> CONTENT =
11611 new DataDescriptor<String>("SourceEntry.CONTENT"); 11616 new DataDescriptor<String>("SourceEntry.CONTENT");
11612 11617
11613 /** 11618 /**
11619 * The data descriptor representing the errors resulting from reading the
11620 * source content.
11621 */
11622 static final DataDescriptor<List<AnalysisError>> CONTENT_ERRORS =
11623 new DataDescriptor<List<AnalysisError>>(
11624 "SourceEntry.CONTENT_ERRORS",
11625 AnalysisError.NO_ERRORS);
11626
11627 /**
11614 * The data descriptor representing the line information. 11628 * The data descriptor representing the line information.
11615 */ 11629 */
11616 static final DataDescriptor<LineInfo> LINE_INFO = 11630 static final DataDescriptor<LineInfo> LINE_INFO =
11617 new DataDescriptor<LineInfo>("SourceEntry.LINE_INFO"); 11631 new DataDescriptor<LineInfo>("SourceEntry.LINE_INFO");
11618 11632
11619 /** 11633 /**
11620 * The index of the flag indicating whether the source was explicitly added to 11634 * The index of the flag indicating whether the source was explicitly added to
11621 * the context or whether the source was implicitly added because it was 11635 * the context or whether the source was implicitly added because it was
11622 * referenced by another source. 11636 * referenced by another source.
11623 */ 11637 */
(...skipping 24 matching lines...) Expand all
11648 int _flags = 0; 11662 int _flags = 0;
11649 11663
11650 /** 11664 /**
11651 * A table mapping data descriptors to the cached results for those 11665 * A table mapping data descriptors to the cached results for those
11652 * descriptors. 11666 * descriptors.
11653 */ 11667 */
11654 Map<DataDescriptor, CachedResult> resultMap = 11668 Map<DataDescriptor, CachedResult> resultMap =
11655 new HashMap<DataDescriptor, CachedResult>(); 11669 new HashMap<DataDescriptor, CachedResult>();
11656 11670
11657 /** 11671 /**
11672 * Return all of the errors associated with this entry.
11673 */
11674 List<AnalysisError> get allErrors {
11675 List<AnalysisError> errors = new List<AnalysisError>();
Brian Wilkerson 2015/02/11 20:49:23 Or just return getValue(CONTENT_ERRORS); at leas
11676 errors.addAll(getValue(CONTENT_ERRORS));
11677 return errors;
11678 }
11679
11680 /**
11658 * Get a list of all the library-independent descriptors for which values may 11681 * Get a list of all the library-independent descriptors for which values may
11659 * be stored in this SourceEntry. 11682 * be stored in this SourceEntry.
11660 */ 11683 */
11661 List<DataDescriptor> get descriptors { 11684 List<DataDescriptor> get descriptors {
11662 return <DataDescriptor>[SourceEntry.CONTENT, SourceEntry.LINE_INFO]; 11685 return <DataDescriptor>[CONTENT, CONTENT_ERRORS, LINE_INFO];
11663 } 11686 }
11664 11687
11665 /** 11688 /**
11666 * Return `true` if the source was explicitly added to the context or `false` 11689 * Return `true` if the source was explicitly added to the context or `false`
11667 * if the source was implicitly added because it was referenced by another 11690 * if the source was implicitly added because it was referenced by another
11668 * source. 11691 * source.
11669 */ 11692 */
11670 bool get explicitlyAdded => _getFlag(_EXPLICITLY_ADDED_FLAG); 11693 bool get explicitlyAdded => _getFlag(_EXPLICITLY_ADDED_FLAG);
11671 11694
11672 /** 11695 /**
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
11751 } 11774 }
11752 } 11775 }
11753 return false; 11776 return false;
11754 } 11777 }
11755 11778
11756 /** 11779 /**
11757 * Invalidate all of the information associated with this source. 11780 * Invalidate all of the information associated with this source.
11758 */ 11781 */
11759 void invalidateAllInformation() { 11782 void invalidateAllInformation() {
11760 setState(CONTENT, CacheState.INVALID); 11783 setState(CONTENT, CacheState.INVALID);
11784 setState(CONTENT_ERRORS, CacheState.INVALID);
11761 setState(LINE_INFO, CacheState.INVALID); 11785 setState(LINE_INFO, CacheState.INVALID);
11762 } 11786 }
11763 11787
11764 /** 11788 /**
11765 * Record that an [exception] occurred while attempting to get the contents of 11789 * Record that an [exception] occurred while attempting to get the contents of
11766 * the source represented by this entry. This will set the state of all 11790 * the source represented by this entry. This will set the state of all
11767 * information, including any resolution-based information, as being in error. 11791 * information, including any resolution-based information, as being in error.
11768 */ 11792 */
11769 void recordContentError(CaughtException exception) { 11793 void recordContentError(CaughtException exception) {
11770 setState(CONTENT, CacheState.ERROR); 11794 setState(CONTENT, CacheState.ERROR);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
11849 11873
11850 /** 11874 /**
11851 * Return the value of the flag with the given [index]. 11875 * Return the value of the flag with the given [index].
11852 */ 11876 */
11853 bool _getFlag(int index) => BooleanArray.get(_flags, index); 11877 bool _getFlag(int index) => BooleanArray.get(_flags, index);
11854 11878
11855 /** 11879 /**
11856 * Return `true` if the [descriptor] is valid for this entry. 11880 * Return `true` if the [descriptor] is valid for this entry.
11857 */ 11881 */
11858 bool _isValidDescriptor(DataDescriptor descriptor) { 11882 bool _isValidDescriptor(DataDescriptor descriptor) {
11859 return descriptor == CONTENT || descriptor == LINE_INFO; 11883 return descriptor == CONTENT ||
11884 descriptor == CONTENT_ERRORS ||
11885 descriptor == LINE_INFO;
11860 } 11886 }
11861 11887
11862 /** 11888 /**
11863 * Set the value of the flag with the given [index] to the given [value]. 11889 * Set the value of the flag with the given [index] to the given [value].
11864 */ 11890 */
11865 void _setFlag(int index, bool value) { 11891 void _setFlag(int index, bool value) {
11866 _flags = BooleanArray.set(_flags, index, value); 11892 _flags = BooleanArray.set(_flags, index, value);
11867 } 11893 }
11868 11894
11869 /** 11895 /**
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
11910 buffer.write("; "); 11936 buffer.write("; ");
11911 } 11937 }
11912 buffer.write("time = "); 11938 buffer.write("time = ");
11913 buffer.write(oldModificationTime); 11939 buffer.write(oldModificationTime);
11914 buffer.write(" -> "); 11940 buffer.write(" -> ");
11915 buffer.write(modificationTime); 11941 buffer.write(modificationTime);
11916 needsSeparator = true; 11942 needsSeparator = true;
11917 } 11943 }
11918 needsSeparator = 11944 needsSeparator =
11919 _writeStateDiffOn(buffer, needsSeparator, "content", CONTENT, oldEntry); 11945 _writeStateDiffOn(buffer, needsSeparator, "content", CONTENT, oldEntry);
11946 needsSeparator = _writeStateDiffOn(
11947 buffer,
11948 needsSeparator,
11949 "contentErrors",
11950 CONTENT_ERRORS,
11951 oldEntry);
11920 needsSeparator = 11952 needsSeparator =
11921 _writeStateDiffOn(buffer, needsSeparator, "lineInfo", LINE_INFO, oldEntr y); 11953 _writeStateDiffOn(buffer, needsSeparator, "lineInfo", LINE_INFO, oldEntr y);
11922 return needsSeparator; 11954 return needsSeparator;
11923 } 11955 }
11924 11956
11925 /** 11957 /**
11926 * Write a textual representation of this entry to the given [buffer]. The 11958 * Write a textual representation of this entry to the given [buffer]. The
11927 * result should only be used for debugging purposes. 11959 * result should only be used for debugging purposes.
11928 */ 11960 */
11929 void _writeOn(StringBuffer buffer) { 11961 void _writeOn(StringBuffer buffer) {
11930 buffer.write("time = "); 11962 buffer.write("time = ");
11931 buffer.write(modificationTime); 11963 buffer.write(modificationTime);
11932 _writeStateOn(buffer, "content", CONTENT); 11964 _writeStateOn(buffer, "content", CONTENT);
11965 _writeStateOn(buffer, "contentErrors", CONTENT_ERRORS);
11933 _writeStateOn(buffer, "lineInfo", LINE_INFO); 11966 _writeStateOn(buffer, "lineInfo", LINE_INFO);
11934 } 11967 }
11935 11968
11936 /** 11969 /**
11937 * Write a textual representation of the difference between the state of the 11970 * Write a textual representation of the difference between the state of the
11938 * value described by the given [descriptor] between the [oldEntry] and this 11971 * value described by the given [descriptor] between the [oldEntry] and this
11939 * entry to the given [buffer]. Return `true` if some difference was written. 11972 * entry to the given [buffer]. Return `true` if some difference was written.
11940 */ 11973 */
11941 bool _writeStateDiffOn(StringBuffer buffer, bool needsSeparator, String label, 11974 bool _writeStateDiffOn(StringBuffer buffer, bool needsSeparator, String label,
11942 DataDescriptor descriptor, SourceEntry oldEntry) { 11975 DataDescriptor descriptor, SourceEntry oldEntry) {
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
12398 if (element.id == _id) { 12431 if (element.id == _id) {
12399 result = element; 12432 result = element;
12400 throw new _ElementByIdFinderException(); 12433 throw new _ElementByIdFinderException();
12401 } 12434 }
12402 super.visitElement(element); 12435 super.visitElement(element);
12403 } 12436 }
12404 } 12437 }
12405 12438
12406 class _ElementByIdFinderException { 12439 class _ElementByIdFinderException {
12407 } 12440 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698