mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
For for LateInitializationError in Cider topLevelDeclarations.
Change-Id: I1e52d251a8e63a05304da701d6157986d25d9f21 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216400 Reviewed-by: Keerti Parthasarathy <keertip@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
14428eda69
commit
baecc6fccc
|
@ -277,14 +277,6 @@ class FileState {
|
|||
var decoded = CiderUnlinkedUnit.fromBuffer(unlinkedBytes!);
|
||||
unlinked2 = decoded.unlinkedUnit!;
|
||||
|
||||
var unitDeclarations = decoded.topLevelDeclarations!;
|
||||
topLevelDeclarations = TopLevelDeclarations(
|
||||
extensionNames: unitDeclarations.extensionNames.toList(),
|
||||
functionNames: unitDeclarations.functionNames.toList(),
|
||||
typeNames: unitDeclarations.typeNames.toList(),
|
||||
variableNames: unitDeclarations.variableNames.toList(),
|
||||
);
|
||||
|
||||
performance.run('prefetch', (_) {
|
||||
_prefetchDirectReferences(unlinked2);
|
||||
});
|
||||
|
@ -295,9 +287,19 @@ class FileState {
|
|||
}
|
||||
|
||||
// Read the unlinked bundle.
|
||||
unlinked2 = CiderUnlinkedUnit.fromBuffer(unlinkedBytes!).unlinkedUnit!;
|
||||
var decoded = CiderUnlinkedUnit.fromBuffer(unlinkedBytes!);
|
||||
unlinked2 = decoded.unlinkedUnit!;
|
||||
_apiSignature = Uint8List.fromList(unlinked2.apiSignature);
|
||||
|
||||
// Copy information about top-level declarations.
|
||||
var unitDeclarations = decoded.topLevelDeclarations!;
|
||||
topLevelDeclarations = TopLevelDeclarations(
|
||||
extensionNames: unitDeclarations.extensionNames.toList(),
|
||||
functionNames: unitDeclarations.functionNames.toList(),
|
||||
typeNames: unitDeclarations.typeNames.toList(),
|
||||
variableNames: unitDeclarations.variableNames.toList(),
|
||||
);
|
||||
|
||||
// Build the graph.
|
||||
for (var directive in unlinked2.imports) {
|
||||
var file = _fileForRelativeUri(
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
import 'package:analyzer/src/dart/error/syntactic_errors.dart';
|
||||
import 'package:analyzer/src/dart/micro/cider_byte_store.dart';
|
||||
import 'package:analyzer/src/dart/micro/library_graph.dart';
|
||||
import 'package:analyzer/src/dart/micro/resolve_file.dart';
|
||||
import 'package:analyzer/src/error/codes.dart';
|
||||
import 'package:analyzer/src/lint/registry.dart';
|
||||
|
@ -743,6 +744,32 @@ var a = 4.2;
|
|||
expect(fileResolver.testView!.resolvedLibraries, <Object>[]);
|
||||
}
|
||||
|
||||
test_getFilesWithTopLevelDeclarations_cached() async {
|
||||
await assertNoErrorsInCode(r'''
|
||||
int a = 0;
|
||||
var b = 1 + 2;
|
||||
''');
|
||||
|
||||
void assertHasOneVariable() {
|
||||
var files = fileResolver.getFilesWithTopLevelDeclarations('a');
|
||||
expect(files, hasLength(1));
|
||||
var file = files.single;
|
||||
expect(file.file.path, result.path);
|
||||
expect(file.kind, FileTopLevelDeclarationKind.variable);
|
||||
}
|
||||
|
||||
// Ask to check that it works when parsed.
|
||||
assertHasOneVariable();
|
||||
|
||||
// Create a new resolved, but reuse the cache.
|
||||
createFileResolver();
|
||||
|
||||
await resolveTestFile();
|
||||
|
||||
// Ask again, when unlinked information is read from the cache.
|
||||
assertHasOneVariable();
|
||||
}
|
||||
|
||||
test_getLibraryByUri() {
|
||||
newFile('/workspace/dart/my/lib/a.dart', content: r'''
|
||||
class A {}
|
||||
|
|
Loading…
Reference in a new issue