Skip to content

Commit 1aa6fa4

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Refactor Cider FileState.
The general direction is to make pieces of data that are produced together to be stored together, and so be available together. _FileStateLocation is created before FileState, so it is separated. Any FileState has some unlinked state, so we pass _FileStateUnlinked into the constructor. In Cider we don't refresh files, we discard them and recreate. So, '_unlinked' is a final field. Practically FileState works as a wrapper around _FileStateUnlinked. It could probably have been inlined into FileState. My excuse for not doing this is that in DAS, at least at the moment, we keep FileState instances and refresh them with replacing their unlinked states. So, they should be separate objects. Change-Id: I9439a4021e6efa9e4375eceb5eecf534eabda168 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217860 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Keerti Parthasarathy <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 9eddeae commit 1aa6fa4

File tree

4 files changed

+819
-693
lines changed

4 files changed

+819
-693
lines changed

pkg/analyzer/lib/src/dart/micro/library_analyzer.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class LibraryAnalyzer {
110110

111111
// Parse all files.
112112
performance.run('parse', (performance) {
113-
for (FileState file in _library.libraryFiles) {
113+
for (FileState file in _library.files().ofLibrary) {
114114
if (completionPath == null || file.path == completionPath) {
115115
units[file] = _parse(
116116
file: file,
@@ -231,19 +231,19 @@ class LibraryAnalyzer {
231231

232232
if (_analysisOptions.lint) {
233233
performance.run('computeLints', (performance) {
234-
var allUnits = _library.libraryFiles.map((file) {
234+
var allUnits = _library.files().ofLibrary.map((file) {
235235
var content = getFileContent(file);
236236
return LinterContextUnit(content, units[file]!);
237237
}).toList();
238238
for (int i = 0; i < allUnits.length; i++) {
239-
_computeLints(_library.libraryFiles[i], allUnits[i], allUnits);
239+
_computeLints(_library.files().ofLibrary[i], allUnits[i], allUnits);
240240
}
241241
});
242242
}
243243

244244
// This must happen after all other diagnostics have been computed but
245245
// before the list of diagnostics has been filtered.
246-
for (var file in _library.libraryFiles) {
246+
for (var file in _library.files().ofLibrary) {
247247
IgnoreValidator(
248248
_getErrorReporter(file),
249249
_getErrorListener(file).errors,
@@ -472,7 +472,7 @@ class LibraryAnalyzer {
472472
}
473473

474474
bool _isExistingSource(Source source) {
475-
for (var file in _library.directReferencedFiles) {
475+
for (var file in _library.files().directReferencedFiles) {
476476
if (file.uri == source.uri) {
477477
return file.exists;
478478
}
@@ -595,7 +595,7 @@ class LibraryAnalyzer {
595595
} else if (directive is PartDirectiveImpl) {
596596
StringLiteral partUri = directive.uri;
597597

598-
FileState partFile = _library.partedFiles[partIndex];
598+
FileState partFile = _library.files().parted[partIndex];
599599
var partUnit = units[partFile]!;
600600
CompilationUnitElement partElement = _libraryElement.parts[partIndex];
601601
partUnit.element = partElement;

0 commit comments

Comments
 (0)