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