Call changeFile() for ChangeType.ADD

AnalysisDriver.addFile() means: analyze this file when anything about
its dependenciea changes, e.g. it is a part of an open directory. But
generated files are not, we don't want to analyze *them* per se. But
they might affect added files, so we should call changeFile() instead.

Change-Id: I729119b3be077cbc99480ca66698d6b67425c79f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215380
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Michal Terepeta <michalt@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2021-10-04 16:20:48 +00:00 committed by commit-bot@chromium.org
parent d3b03b128d
commit f7a0e16bf6

View file

@ -547,15 +547,13 @@ class ContextManagerImpl implements ContextManager {
for (var driver in driverMap.values) {
var needsUriReset = false;
for (var event in fileEvents) {
if (event.type == ChangeType.ADD) {
driver.addFile(event.path);
driver.changeFile(event.path);
if (event.type == ChangeType.ADD || event.type == ChangeType.REMOVE) {
needsUriReset = true;
}
if (event.type == ChangeType.MODIFY) driver.changeFile(event.path);
if (event.type == ChangeType.REMOVE) driver.removeFile(event.path);
}
// Since the file has been created after we've searched for it, the
// URI resolution is likely wrong, so we need to reset it.
// If a file was created or removed, the URI resolution is likely wrong,
// so we need to reset it.
if (needsUriReset) driver.resetUriResolution();
}
}