Make 'hasFilesToAnalyze' private, remove tests.

It is used only internally by the scheduler, and we observe its effect
by seeing results and/or transitions to analyzing/idle.

Change-Id: If79f2e3e36b48f66c1f1fb5e94db46bad3bb815b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345340
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Konstantin Shcheglov 2024-01-08 19:26:49 +00:00 committed by Commit Queue
parent 50cb67023f
commit cee5fac576
2 changed files with 9 additions and 70 deletions

View file

@ -355,14 +355,6 @@ class AnalysisDriver {
/// The current file system state.
FileSystemState get fsState => _fsState;
/// Return `true` if the driver has a file to analyze.
bool get hasFilesToAnalyze {
return hasPendingFileChanges ||
_fileTracker.hasChangedFiles ||
_requestedFiles.isNotEmpty ||
_fileTracker.hasPendingFiles;
}
bool get hasPendingFileChanges => _pendingFileChanges.isNotEmpty;
/// Return the set of files that are known at this moment. This set does not
@ -525,6 +517,14 @@ class AnalysisDriver {
return AnalysisDriverPriority.nothing;
}
/// Whether the driver has a file to analyze.
bool get _hasFilesToAnalyze {
return hasPendingFileChanges ||
_fileTracker.hasChangedFiles ||
_requestedFiles.isNotEmpty ||
_fileTracker.hasPendingFiles;
}
/// Add the file with the given [path] to the set of files that are explicitly
/// being analyzed.
///
@ -2164,7 +2164,7 @@ class AnalysisDriverScheduler {
/// Return `true` if there is a driver with a file to analyze.
bool get _hasFilesToAnalyze {
for (final driver in _drivers) {
if (driver.hasFilesToAnalyze) {
if (driver._hasFilesToAnalyze) {
return true;
}
}

View file

@ -2440,67 +2440,6 @@ import 'package:test/b.dart';
expect(result, isA<InvalidPathResult>());
}
test_hasFilesToAnalyze_addFile() async {
final a = newFile('$testPackageLibPath/a.dart', '');
final driver = driverFor(testFile);
// No files yet, nothing to analyze.
expect(driver.hasFilesToAnalyze, isFalse);
// Add `a`, it should be analyzed.
driver.addFile2(a);
driver.priorityFiles2 = [a];
expect(driver.hasFilesToAnalyze, isTrue);
// Wait for idle, nothing to do.
await pumpEventQueue(times: 5000);
expect(driver.hasFilesToAnalyze, isFalse);
}
test_hasFilesToAnalyze_getFilesReferencingName() async {
final driver = driverFor(testFile);
// Request of referenced names is not analysis of a file.
unawaited(driver.getFilesReferencingName('X'));
expect(driver.hasFilesToAnalyze, isFalse);
}
test_hasFilesToAnalyze_getResolvedUnit() async {
final a = newFile('$testPackageLibPath/a.dart', '');
final driver = driverFor(testFile);
final collector = DriverEventCollector(driver);
// No files yet, nothing to analyze.
expect(driver.hasFilesToAnalyze, isFalse);
// Ask to analyze `a`, so there is a file to analyze.
final future = driver.getResolvedUnit2(a);
expect(driver.hasFilesToAnalyze, isTrue);
// Once analysis is done, there is nothing to analyze.
await future;
expect(driver.hasFilesToAnalyze, isFalse);
// Ignore results.
await pumpEventQueue(times: 5000);
collector.take();
// Change a file, even if not added, it still might affect analysis.
final b = getFile('$testPackageLibPath/b.dart');
driver.changeFile2(b);
expect(driver.hasFilesToAnalyze, isTrue);
// Once the pending changes processed, nothing to analyze.
await pumpEventQueue(times: 5000);
expect(driver.hasFilesToAnalyze, isFalse);
// No analysis done.
await assertEventsText(collector, r'''
''');
}
test_hermetic_modifyLibraryFile_resolvePart() async {
final a = newFile('$testPackageLibPath/a.dart', r'''
part 'b.dart';