Log digests on digest mismatch state error
Also reformat to satisfy a presubmit check.
Bug: 418755091
Change-Id: I5d7b85749a254ecd1b40de67ee62a2ce0e2e1f8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441300
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
index 11b009d..2511f41 100644
--- a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
+++ b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
@@ -60,7 +60,11 @@
var contentWithDigest = _getContent();
if (contentWithDigest.digestStr != digestStr) {
- throw StateError('File was changed, but not invalidated: $path');
+ throw StateError(
+ 'File was changed, but not invalidated: $path. '
+ 'Expected digest: $digestStr.'
+ 'Actual digest: ${contentWithDigest.digestStr}',
+ );
}
return contentWithDigest.content;
@@ -330,10 +334,9 @@
var bytes = _errorResultsCache.get(errorsKey);
if (bytes != null) {
var data = CiderUnitErrors.fromBuffer(bytes);
- diagnostics =
- data.errors.map((error) {
- return ErrorEncoding.decode(file.source, error)!;
- }).toList();
+ diagnostics = data.errors.map((error) {
+ return ErrorEncoding.decode(file.source, error)!;
+ }).toList();
} else {
var unitResult = await resolve(path: path, performance: performance);
diagnostics = unitResult.diagnostics;
@@ -652,16 +655,15 @@
});
});
- var resolvedUnits =
- results.map((fileResult) {
- var file = fileResult.file;
- return ResolvedUnitResultImpl(
- session: contextObjects!.analysisSession,
- fileState: file,
- unit: fileResult.unit,
- diagnostics: fileResult.diagnostics,
- );
- }).toList();
+ var resolvedUnits = results.map((fileResult) {
+ var file = fileResult.file;
+ return ResolvedUnitResultImpl(
+ session: contextObjects!.analysisSession,
+ fileState: file,
+ unit: fileResult.unit,
+ diagnostics: fileResult.diagnostics,
+ );
+ }).toList();
var libraryUnit = resolvedUnits.first;
var result = ResolvedLibraryResultImpl(
@@ -694,13 +696,12 @@
return;
}
- var analysisOptions =
- (AnalysisOptionsBuilder()
- ..strictInference = fileAnalysisOptions.strictInference
- ..contextFeatures =
- FeatureSet.latestLanguageVersion() as ExperimentStatus
- ..nonPackageFeatureSet = FeatureSet.latestLanguageVersion())
- .build();
+ var analysisOptions = (AnalysisOptionsBuilder()
+ ..strictInference = fileAnalysisOptions.strictInference
+ ..contextFeatures =
+ FeatureSet.latestLanguageVersion() as ExperimentStatus
+ ..nonPackageFeatureSet = FeatureSet.latestLanguageVersion())
+ .build();
if (fsState == null) {
var featureSetProvider = FeatureSetProvider.build(
@@ -782,8 +783,8 @@
YamlMap? optionMap;
var separator = resourceProvider.pathContext.separator;
- var isThirdParty =
- path.contains('${separator}third_party${separator}dart$separator') ||
+ var isThirdParty = path
+ .contains('${separator}third_party${separator}dart$separator') ||
path.contains('${separator}third_party${separator}dart_lang$separator');
File? optionsFile;
@@ -881,16 +882,15 @@
);
unitResult.unit.accept(visitor);
var lineInfo = unitResult.lineInfo;
- var infos =
- visitor.results
- .map(
- (searchResult) => CiderSearchInfo(
- lineInfo.getLocation(searchResult.offset),
- searchResult.length,
- MatchKind.REFERENCE,
- ),
- )
- .toList();
+ var infos = visitor.results
+ .map(
+ (searchResult) => CiderSearchInfo(
+ lineInfo.getLocation(searchResult.offset),
+ searchResult.length,
+ MatchKind.REFERENCE,
+ ),
+ )
+ .toList();
results.add(CiderSearchMatch(unitPath, infos));
}
return results;