Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
| 8 | 8 |
| 9 import 'package:analyzer/context/declared_variables.dart'; | 9 import 'package:analyzer/context/declared_variables.dart'; |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 * The set of part files that are currently scheduled for analysis. | 202 * The set of part files that are currently scheduled for analysis. |
| 203 */ | 203 */ |
| 204 final _partsToAnalyze = new LinkedHashSet<String>(); | 204 final _partsToAnalyze = new LinkedHashSet<String>(); |
| 205 | 205 |
| 206 /** | 206 /** |
| 207 * The controller for the [results] stream. | 207 * The controller for the [results] stream. |
| 208 */ | 208 */ |
| 209 final _resultController = new StreamController<AnalysisResult>(); | 209 final _resultController = new StreamController<AnalysisResult>(); |
| 210 | 210 |
| 211 /** | 211 /** |
| 212 * Resolution signatures of the most recently produced results for files. | |
| 213 */ | |
| 214 final Map<String, String> _lastProducedSignatures = {}; | |
| 215 | |
| 216 /** | |
| 212 * Cached results for [_priorityFiles]. | 217 * Cached results for [_priorityFiles]. |
| 213 */ | 218 */ |
| 214 final Map<String, AnalysisResult> _priorityResults = {}; | 219 final Map<String, AnalysisResult> _priorityResults = {}; |
| 215 | 220 |
| 216 /** | 221 /** |
| 217 * The controller for the [exceptions] stream. | 222 * The controller for the [exceptions] stream. |
| 218 */ | 223 */ |
| 219 final StreamController<ExceptionResult> _exceptionController = | 224 final StreamController<ExceptionResult> _exceptionController = |
| 220 new StreamController<ExceptionResult>(); | 225 new StreamController<ExceptionResult>(); |
| 221 | 226 |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 690 * given [path]. | 695 * given [path]. |
| 691 * | 696 * |
| 692 * The result will have the fully resolved unit and will always be newly | 697 * The result will have the fully resolved unit and will always be newly |
| 693 * compute only if [withUnit] is `true`. | 698 * compute only if [withUnit] is `true`. |
| 694 * | 699 * |
| 695 * Return `null` if the file is a part of an unknown library, so cannot be | 700 * Return `null` if the file is a part of an unknown library, so cannot be |
| 696 * analyzed yet. But [asIsIfPartWithoutLibrary] is `true`, then the file is | 701 * analyzed yet. But [asIsIfPartWithoutLibrary] is `true`, then the file is |
| 697 * analyzed anyway, even without a library. | 702 * analyzed anyway, even without a library. |
| 698 */ | 703 */ |
| 699 AnalysisResult _computeAnalysisResult(String path, | 704 AnalysisResult _computeAnalysisResult(String path, |
| 700 {bool withUnit: false, bool asIsIfPartWithoutLibrary: false}) { | 705 {bool withUnit: false, |
| 706 bool asIsIfPartWithoutLibrary: false, | |
| 707 bool skipIfSameSignature: false}) { | |
|
Brian Wilkerson
2017/02/18 17:40:03
Document what "skipIfSameSignature" does.
scheglov
2017/02/18 20:15:45
Done.
| |
| 701 FileState file = _fileTracker.fsState.getFileForPath(path); | 708 FileState file = _fileTracker.fsState.getFileForPath(path); |
| 702 | 709 |
| 703 // Prepare the library - the file itself, or the known library. | 710 // Prepare the library - the file itself, or the known library. |
| 704 FileState library = file.isPart ? file.library : file; | 711 FileState library = file.isPart ? file.library : file; |
| 705 if (library == null) { | 712 if (library == null) { |
| 706 if (asIsIfPartWithoutLibrary) { | 713 if (asIsIfPartWithoutLibrary) { |
| 707 library = file; | 714 library = file; |
| 708 } else { | 715 } else { |
| 709 return null; | 716 return null; |
| 710 } | 717 } |
| 711 } | 718 } |
| 712 | 719 |
| 720 // Prepare the signature and key. | |
| 721 String signature = _getResolvedUnitSignature(library, file); | |
| 722 String key = _getResolvedUnitKey(signature); | |
| 723 | |
| 724 // Skip reading if the signature, so errors, are the same as the last time. | |
| 725 if (skipIfSameSignature) { | |
| 726 assert(!withUnit); | |
| 727 if (_lastProducedSignatures[path] == signature) { | |
| 728 return AnalysisResult._SAME_ERRORS; | |
| 729 } | |
| 730 } | |
| 731 | |
| 713 // If we don't need the fully resolved unit, check for the cached result. | 732 // If we don't need the fully resolved unit, check for the cached result. |
| 714 if (!withUnit) { | 733 if (!withUnit) { |
| 715 String key = _getResolvedUnitKey(library, file); | |
| 716 List<int> bytes = _byteStore.get(key); | 734 List<int> bytes = _byteStore.get(key); |
| 717 if (bytes != null) { | 735 if (bytes != null) { |
| 718 return _getAnalysisResultFromBytes(file, bytes); | 736 return _getAnalysisResultFromBytes(file, signature, bytes); |
| 719 } | 737 } |
| 720 } | 738 } |
| 721 | 739 |
| 722 // We need the fully resolved unit, or the result is not cached. | 740 // We need the fully resolved unit, or the result is not cached. |
| 723 return _logger.run('Compute analysis result for $path', () { | 741 return _logger.run('Compute analysis result for $path', () { |
| 724 try { | 742 try { |
| 725 LibraryContext libraryContext = _createLibraryContext(library); | 743 LibraryContext libraryContext = _createLibraryContext(library); |
| 726 try { | 744 try { |
| 727 CompilationUnit resolvedUnit; | 745 CompilationUnit resolvedUnit; |
| 728 List<int> bytes; | 746 List<int> bytes; |
| 729 if (analyzeWithoutTasks) { | 747 if (analyzeWithoutTasks) { |
| 730 LibraryAnalyzer analyzer = new LibraryAnalyzer( | 748 LibraryAnalyzer analyzer = new LibraryAnalyzer( |
| 731 analysisOptions, | 749 analysisOptions, |
| 732 declaredVariables, | 750 declaredVariables, |
| 733 sourceFactory, | 751 sourceFactory, |
| 734 _fileTracker.fsState, | 752 _fileTracker.fsState, |
| 735 libraryContext.store, | 753 libraryContext.store, |
| 736 library); | 754 library); |
| 737 Map<FileState, UnitAnalysisResult> results = analyzer.analyze(); | 755 Map<FileState, UnitAnalysisResult> results = analyzer.analyze(); |
| 738 for (FileState unitFile in results.keys) { | 756 for (FileState unitFile in results.keys) { |
| 739 UnitAnalysisResult unitResult = results[unitFile]; | 757 UnitAnalysisResult unitResult = results[unitFile]; |
| 740 List<int> unitBytes = _storeResolvedUnit( | 758 List<int> unitBytes = |
| 741 library, unitFile, unitResult.unit, unitResult.errors); | 759 _serializeResolvedUnit(unitResult.unit, unitResult.errors); |
| 760 String unitSignature = | |
| 761 _getResolvedUnitSignature(library, unitFile); | |
| 762 String unitKey = _getResolvedUnitKey(unitSignature); | |
| 763 _byteStore.put(unitKey, unitBytes); | |
| 742 if (unitFile == file) { | 764 if (unitFile == file) { |
| 743 bytes = unitBytes; | 765 bytes = unitBytes; |
| 744 resolvedUnit = unitResult.unit; | 766 resolvedUnit = unitResult.unit; |
| 745 } | 767 } |
| 746 } | 768 } |
| 747 } else { | 769 } else { |
| 748 ResolutionResult resolutionResult = | 770 ResolutionResult resolutionResult = |
| 749 libraryContext.resolveUnit(library.source, file.source); | 771 libraryContext.resolveUnit(library.source, file.source); |
| 750 resolvedUnit = resolutionResult.resolvedUnit; | 772 resolvedUnit = resolutionResult.resolvedUnit; |
| 751 List<AnalysisError> errors = resolutionResult.errors; | 773 List<AnalysisError> errors = resolutionResult.errors; |
| 752 | 774 |
| 753 // Store the result into the cache. | 775 // Store the result into the cache. |
| 754 bytes = _storeResolvedUnit(library, file, resolvedUnit, errors); | 776 bytes = _serializeResolvedUnit(resolvedUnit, errors); |
| 777 _byteStore.put(key, bytes); | |
| 755 } | 778 } |
| 756 | 779 |
| 757 // Return the result, full or partial. | 780 // Return the result, full or partial. |
| 758 _logger.writeln('Computed new analysis result.'); | 781 _logger.writeln('Computed new analysis result.'); |
| 759 AnalysisResult result = _getAnalysisResultFromBytes(file, bytes, | 782 AnalysisResult result = _getAnalysisResultFromBytes( |
| 783 file, signature, bytes, | |
| 760 content: withUnit ? file.content : null, | 784 content: withUnit ? file.content : null, |
| 761 withErrors: _fileTracker.addedFiles.contains(path), | 785 withErrors: _fileTracker.addedFiles.contains(path), |
| 762 resolvedUnit: withUnit ? resolvedUnit : null); | 786 resolvedUnit: withUnit ? resolvedUnit : null); |
| 763 if (withUnit && _priorityFiles.contains(path)) { | 787 if (withUnit && _priorityFiles.contains(path)) { |
| 764 _priorityResults[path] = result; | 788 _priorityResults[path] = result; |
| 765 } | 789 } |
| 766 return result; | 790 return result; |
| 767 } finally { | 791 } finally { |
| 768 libraryContext.dispose(); | 792 libraryContext.dispose(); |
| 769 } | 793 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 840 assert(crossContextOptions.length == AnalysisOptions.signatureLength); | 864 assert(crossContextOptions.length == AnalysisOptions.signatureLength); |
| 841 for (int i = 0; i < crossContextOptions.length; i++) { | 865 for (int i = 0; i < crossContextOptions.length; i++) { |
| 842 _salt[i + 1] = crossContextOptions[i]; | 866 _salt[i + 1] = crossContextOptions[i]; |
| 843 } | 867 } |
| 844 } | 868 } |
| 845 | 869 |
| 846 /** | 870 /** |
| 847 * Load the [AnalysisResult] for the given [file] from the [bytes]. Set | 871 * Load the [AnalysisResult] for the given [file] from the [bytes]. Set |
| 848 * optional [content] and [resolvedUnit]. | 872 * optional [content] and [resolvedUnit]. |
| 849 */ | 873 */ |
| 850 AnalysisResult _getAnalysisResultFromBytes(FileState file, List<int> bytes, | 874 AnalysisResult _getAnalysisResultFromBytes( |
| 875 FileState file, String signature, List<int> bytes, | |
| 851 {String content, bool withErrors: true, CompilationUnit resolvedUnit}) { | 876 {String content, bool withErrors: true, CompilationUnit resolvedUnit}) { |
| 852 var unit = new AnalysisDriverResolvedUnit.fromBuffer(bytes); | 877 var unit = new AnalysisDriverResolvedUnit.fromBuffer(bytes); |
| 853 List<AnalysisError> errors = withErrors | 878 List<AnalysisError> errors = withErrors |
| 854 ? _getErrorsFromSerialized(file, unit.errors) | 879 ? _getErrorsFromSerialized(file, unit.errors) |
| 855 : const <AnalysisError>[]; | 880 : const <AnalysisError>[]; |
| 856 return new AnalysisResult( | 881 return new AnalysisResult( |
| 857 this, | 882 this, |
| 858 _sourceFactory, | 883 _sourceFactory, |
| 859 file.path, | 884 file.path, |
| 860 file.uri, | 885 file.uri, |
| 861 file.exists, | 886 file.exists, |
| 862 content, | 887 content, |
| 863 file.contentHash, | 888 file.contentHash, |
| 864 file.lineInfo, | 889 file.lineInfo, |
| 890 signature, | |
| 865 resolvedUnit, | 891 resolvedUnit, |
| 866 errors, | 892 errors, |
| 867 unit.index); | 893 unit.index); |
| 868 } | 894 } |
| 869 | 895 |
| 870 /** | 896 /** |
| 871 * Return [AnalysisError]s for the given [serialized] errors. | 897 * Return [AnalysisError]s for the given [serialized] errors. |
| 872 */ | 898 */ |
| 873 List<AnalysisError> _getErrorsFromSerialized( | 899 List<AnalysisError> _getErrorsFromSerialized( |
| 874 FileState file, List<AnalysisDriverUnitError> serialized) { | 900 FileState file, List<AnalysisDriverUnitError> serialized) { |
| 875 return serialized.map((error) { | 901 return serialized.map((error) { |
| 876 String errorName = error.uniqueName; | 902 String errorName = error.uniqueName; |
| 877 ErrorCode errorCode = | 903 ErrorCode errorCode = |
| 878 errorCodeByUniqueName(errorName) ?? _lintCodeByUniqueName(errorName); | 904 errorCodeByUniqueName(errorName) ?? _lintCodeByUniqueName(errorName); |
| 879 if (errorCode == null) { | 905 if (errorCode == null) { |
| 880 // This could fail because the error code is no longer defined, or, in | 906 // This could fail because the error code is no longer defined, or, in |
| 881 // the case of a lint rule, if the lint rule has been disabled since the | 907 // the case of a lint rule, if the lint rule has been disabled since the |
| 882 // errors were written. | 908 // errors were written. |
| 883 throw new StateError('No ErrorCode for $errorName in $file'); | 909 throw new StateError('No ErrorCode for $errorName in $file'); |
| 884 } | 910 } |
| 885 return new AnalysisError.forValues(file.source, error.offset, | 911 return new AnalysisError.forValues(file.source, error.offset, |
| 886 error.length, errorCode, error.message, error.correction); | 912 error.length, errorCode, error.message, error.correction); |
| 887 }).toList(); | 913 }).toList(); |
| 888 } | 914 } |
| 889 | 915 |
| 890 /** | 916 /** |
| 891 * Return the key to store fully resolved results for the [file] in the | 917 * Return the key to store fully resolved results for the [signature]. |
| 892 * [library] into the cache. | |
| 893 */ | 918 */ |
| 894 String _getResolvedUnitKey(FileState library, FileState file) { | 919 String _getResolvedUnitKey(String signature) { |
| 895 String signature = _getResolvedUnitSignature(library, file); | |
| 896 return '$signature.resolved'; | 920 return '$signature.resolved'; |
| 897 } | 921 } |
| 898 | 922 |
| 899 /** | 923 /** |
| 900 * Return the signature that identifies fully resolved results for the [file] | 924 * Return the signature that identifies fully resolved results for the [file] |
| 901 * in the [library], e.g. element model, errors, index, etc. | 925 * in the [library], e.g. element model, errors, index, etc. |
| 902 */ | 926 */ |
| 903 String _getResolvedUnitSignature(FileState library, FileState file) { | 927 String _getResolvedUnitSignature(FileState library, FileState file) { |
| 904 ApiSignature signature = new ApiSignature(); | 928 ApiSignature signature = new ApiSignature(); |
| 905 signature.addUint32List(_salt); | 929 signature.addUint32List(_salt); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1038 } catch (exception, stackTrace) { | 1062 } catch (exception, stackTrace) { |
| 1039 _reportException(path, exception, stackTrace); | 1063 _reportException(path, exception, stackTrace); |
| 1040 } finally { | 1064 } finally { |
| 1041 _fileTracker.fileWasAnalyzed(path); | 1065 _fileTracker.fileWasAnalyzed(path); |
| 1042 } | 1066 } |
| 1043 return; | 1067 return; |
| 1044 } | 1068 } |
| 1045 } | 1069 } |
| 1046 } | 1070 } |
| 1047 | 1071 |
| 1072 // Analyze a general file. | |
| 1048 if (_fileTracker.hasPendingFiles) { | 1073 if (_fileTracker.hasPendingFiles) { |
| 1049 // Analyze a general file. | |
| 1050 String path = _fileTracker.anyPendingFile; | 1074 String path = _fileTracker.anyPendingFile; |
| 1051 try { | 1075 try { |
| 1052 AnalysisResult result = _computeAnalysisResult(path, withUnit: false); | 1076 AnalysisResult result = _computeAnalysisResult(path, |
| 1077 withUnit: false, skipIfSameSignature: true); | |
| 1053 if (result == null) { | 1078 if (result == null) { |
| 1054 _partsToAnalyze.add(path); | 1079 _partsToAnalyze.add(path); |
| 1080 } else if (result == AnalysisResult._SAME_ERRORS) { | |
| 1081 // We found that the set of errors is the same as we produced the | |
| 1082 // last time, so we don't need to produce it again now. | |
| 1055 } else { | 1083 } else { |
| 1056 _resultController.add(result); | 1084 _resultController.add(result); |
| 1085 _lastProducedSignatures[result.path] = result.signature; | |
| 1057 } | 1086 } |
| 1058 } catch (exception, stackTrace) { | 1087 } catch (exception, stackTrace) { |
| 1059 _reportException(path, exception, stackTrace); | 1088 _reportException(path, exception, stackTrace); |
| 1060 } finally { | 1089 } finally { |
| 1061 _fileTracker.fileWasAnalyzed(path); | 1090 _fileTracker.fileWasAnalyzed(path); |
| 1062 } | 1091 } |
| 1063 return; | 1092 return; |
| 1064 } | 1093 } |
| 1065 | 1094 |
| 1066 // Analyze a requested part file. | 1095 // Analyze a requested part file. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1106 if (exception is _ExceptionState) { | 1135 if (exception is _ExceptionState) { |
| 1107 var state = exception as _ExceptionState; | 1136 var state = exception as _ExceptionState; |
| 1108 exception = state.exception; | 1137 exception = state.exception; |
| 1109 stackTrace = state.stackTrace; | 1138 stackTrace = state.stackTrace; |
| 1110 contextKey = state.contextKey; | 1139 contextKey = state.contextKey; |
| 1111 } | 1140 } |
| 1112 CaughtException caught = new CaughtException(exception, stackTrace); | 1141 CaughtException caught = new CaughtException(exception, stackTrace); |
| 1113 _exceptionController.add(new ExceptionResult(path, caught, contextKey)); | 1142 _exceptionController.add(new ExceptionResult(path, caught, contextKey)); |
| 1114 } | 1143 } |
| 1115 | 1144 |
| 1145 /** | |
| 1146 * Serialize the given [resolvedUnit] errors and index into bytes. | |
| 1147 */ | |
| 1148 List<int> _serializeResolvedUnit( | |
| 1149 CompilationUnit resolvedUnit, List<AnalysisError> errors) { | |
| 1150 AnalysisDriverUnitIndexBuilder index = indexUnit(resolvedUnit); | |
| 1151 return new AnalysisDriverResolvedUnitBuilder( | |
| 1152 errors: errors | |
| 1153 .map((error) => new AnalysisDriverUnitErrorBuilder( | |
| 1154 offset: error.offset, | |
| 1155 length: error.length, | |
| 1156 uniqueName: error.errorCode.uniqueName, | |
| 1157 message: error.message, | |
| 1158 correction: error.correction)) | |
| 1159 .toList(), | |
| 1160 index: index) | |
| 1161 .toBuffer(); | |
| 1162 } | |
| 1163 | |
| 1116 String _storeExceptionContext( | 1164 String _storeExceptionContext( |
| 1117 String path, FileState libraryFile, exception, StackTrace stackTrace) { | 1165 String path, FileState libraryFile, exception, StackTrace stackTrace) { |
| 1118 if (allowedNumberOfContextsToWrite <= 0) { | 1166 if (allowedNumberOfContextsToWrite <= 0) { |
| 1119 return null; | 1167 return null; |
| 1120 } else { | 1168 } else { |
| 1121 allowedNumberOfContextsToWrite--; | 1169 allowedNumberOfContextsToWrite--; |
| 1122 } | 1170 } |
| 1123 try { | 1171 try { |
| 1124 List<AnalysisDriverExceptionFileBuilder> contextFiles = libraryFile | 1172 List<AnalysisDriverExceptionFileBuilder> contextFiles = libraryFile |
| 1125 .transitiveFiles | 1173 .transitiveFiles |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1154 String sec = _twoDigits(time.second); | 1202 String sec = _twoDigits(time.second); |
| 1155 String ms = _threeDigits(time.millisecond); | 1203 String ms = _threeDigits(time.millisecond); |
| 1156 String key = 'exception_${time.year}$m$d' '_$h$min$sec' + '_$ms'; | 1204 String key = 'exception_${time.year}$m$d' '_$h$min$sec' + '_$ms'; |
| 1157 | 1205 |
| 1158 _byteStore.put(key, bytes); | 1206 _byteStore.put(key, bytes); |
| 1159 return key; | 1207 return key; |
| 1160 } catch (_) { | 1208 } catch (_) { |
| 1161 return null; | 1209 return null; |
| 1162 } | 1210 } |
| 1163 } | 1211 } |
| 1164 | |
| 1165 /** | |
| 1166 * Store the fully resolved results for the [file] in the [library] into the | |
| 1167 * cache and return the stored bytes. | |
| 1168 */ | |
| 1169 List<int> _storeResolvedUnit(FileState library, FileState file, | |
| 1170 CompilationUnit resolvedUnit, List<AnalysisError> errors) { | |
| 1171 AnalysisDriverUnitIndexBuilder index = indexUnit(resolvedUnit); | |
| 1172 | |
| 1173 String key = _getResolvedUnitKey(library, file); | |
| 1174 List<int> bytes = new AnalysisDriverResolvedUnitBuilder( | |
| 1175 errors: errors | |
| 1176 .map((error) => new AnalysisDriverUnitErrorBuilder( | |
| 1177 offset: error.offset, | |
| 1178 length: error.length, | |
| 1179 uniqueName: error.errorCode.uniqueName, | |
| 1180 message: error.message, | |
| 1181 correction: error.correction)) | |
| 1182 .toList(), | |
| 1183 index: index) | |
| 1184 .toBuffer(); | |
| 1185 _byteStore.put(key, bytes); | |
| 1186 return bytes; | |
| 1187 } | |
| 1188 } | 1212 } |
| 1189 | 1213 |
| 1190 /** | 1214 /** |
| 1191 * Priorities of [AnalysisDriver] work. The farther a priority to the beginning | 1215 * Priorities of [AnalysisDriver] work. The farther a priority to the beginning |
| 1192 * of the list, the earlier the corresponding [AnalysisDriver] should be asked | 1216 * of the list, the earlier the corresponding [AnalysisDriver] should be asked |
| 1193 * to perform work. | 1217 * to perform work. |
| 1194 */ | 1218 */ |
| 1195 enum AnalysisDriverPriority { nothing, general, priority, interactive } | 1219 enum AnalysisDriverPriority { nothing, general, priority, interactive } |
| 1196 | 1220 |
| 1197 /** | 1221 /** |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1378 * | 1402 * |
| 1379 * These results are self-consistent, i.e. [content], [contentHash], the | 1403 * These results are self-consistent, i.e. [content], [contentHash], the |
| 1380 * resolved [unit] correspond to each other. All referenced elements, even | 1404 * resolved [unit] correspond to each other. All referenced elements, even |
| 1381 * external ones, are also self-consistent. But none of the results is | 1405 * external ones, are also self-consistent. But none of the results is |
| 1382 * guaranteed to be consistent with the state of the files. | 1406 * guaranteed to be consistent with the state of the files. |
| 1383 * | 1407 * |
| 1384 * Every result is independent, and is not guaranteed to be consistent with | 1408 * Every result is independent, and is not guaranteed to be consistent with |
| 1385 * any previously returned result, even inside of the same library. | 1409 * any previously returned result, even inside of the same library. |
| 1386 */ | 1410 */ |
| 1387 class AnalysisResult { | 1411 class AnalysisResult { |
| 1412 static final _SAME_ERRORS = new AnalysisResult( | |
| 1413 null, null, null, null, null, null, null, null, null, null, null, null); | |
|
Brian Wilkerson
2017/02/18 17:40:03
As I understand it, the effect of this CL is to ma
scheglov
2017/02/18 20:15:45
Done.
| |
| 1414 | |
| 1388 /** | 1415 /** |
| 1389 * The [AnalysisDriver] that produced this result. | 1416 * The [AnalysisDriver] that produced this result. |
| 1390 */ | 1417 */ |
| 1391 final AnalysisDriver driver; | 1418 final AnalysisDriver driver; |
| 1392 | 1419 |
| 1393 /** | 1420 /** |
| 1394 * The [SourceFactory] with which the file was analyzed. | 1421 * The [SourceFactory] with which the file was analyzed. |
| 1395 */ | 1422 */ |
| 1396 final SourceFactory sourceFactory; | 1423 final SourceFactory sourceFactory; |
| 1397 | 1424 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1421 * The MD5 hash of the [content]. | 1448 * The MD5 hash of the [content]. |
| 1422 */ | 1449 */ |
| 1423 final String contentHash; | 1450 final String contentHash; |
| 1424 | 1451 |
| 1425 /** | 1452 /** |
| 1426 * Information about lines in the [content]. | 1453 * Information about lines in the [content]. |
| 1427 */ | 1454 */ |
| 1428 final LineInfo lineInfo; | 1455 final LineInfo lineInfo; |
| 1429 | 1456 |
| 1430 /** | 1457 /** |
| 1458 * The signature of the result based on the content of the file, and the | |
| 1459 * transitive closure of files imported and exported by the the library of | |
| 1460 * the requested file. | |
| 1461 */ | |
| 1462 final String signature; | |
| 1463 | |
| 1464 /** | |
| 1431 * The fully resolved compilation unit for the [content]. | 1465 * The fully resolved compilation unit for the [content]. |
| 1432 */ | 1466 */ |
| 1433 final CompilationUnit unit; | 1467 final CompilationUnit unit; |
| 1434 | 1468 |
| 1435 /** | 1469 /** |
| 1436 * The full list of computed analysis errors, both syntactic and semantic. | 1470 * The full list of computed analysis errors, both syntactic and semantic. |
| 1437 */ | 1471 */ |
| 1438 final List<AnalysisError> errors; | 1472 final List<AnalysisError> errors; |
| 1439 | 1473 |
| 1440 /** | 1474 /** |
| 1441 * The index of the unit. | 1475 * The index of the unit. |
| 1442 */ | 1476 */ |
| 1443 final AnalysisDriverUnitIndex _index; | 1477 final AnalysisDriverUnitIndex _index; |
| 1444 | 1478 |
| 1445 AnalysisResult( | 1479 AnalysisResult( |
| 1446 this.driver, | 1480 this.driver, |
| 1447 this.sourceFactory, | 1481 this.sourceFactory, |
| 1448 this.path, | 1482 this.path, |
| 1449 this.uri, | 1483 this.uri, |
| 1450 this.exists, | 1484 this.exists, |
| 1451 this.content, | 1485 this.content, |
| 1452 this.contentHash, | 1486 this.contentHash, |
| 1453 this.lineInfo, | 1487 this.lineInfo, |
| 1488 this.signature, | |
| 1454 this.unit, | 1489 this.unit, |
| 1455 this.errors, | 1490 this.errors, |
| 1456 this._index); | 1491 this._index); |
| 1457 } | 1492 } |
| 1458 | 1493 |
| 1459 /** | 1494 /** |
| 1460 * The errors in a single file. | 1495 * The errors in a single file. |
| 1461 * | 1496 * |
| 1462 * These results are self-consistent, i.e. [content], [contentHash], [errors] | 1497 * These results are self-consistent, i.e. [content], [contentHash], [errors] |
| 1463 * correspond to each other. But none of the results is guaranteed to be | 1498 * correspond to each other. But none of the results is guaranteed to be |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1865 libraryDeclarations.add(new TopLevelDeclarationInSource( | 1900 libraryDeclarations.add(new TopLevelDeclarationInSource( |
| 1866 file.source, declaration, isExported)); | 1901 file.source, declaration, isExported)); |
| 1867 } | 1902 } |
| 1868 } | 1903 } |
| 1869 } | 1904 } |
| 1870 | 1905 |
| 1871 // We're not done yet. | 1906 // We're not done yet. |
| 1872 return false; | 1907 return false; |
| 1873 } | 1908 } |
| 1874 } | 1909 } |
| OLD | NEW |