Simplify handling of watch events for the new analysis driver.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/2463903002 .
This commit is contained in:
Konstantin Shcheglov 2016-10-31 11:00:22 -07:00
parent 6826e267b9
commit 0257eeb4f5

View file

@ -1379,11 +1379,15 @@ class ContextManagerImpl implements ContextManager {
if (resource is File) { if (resource is File) {
File file = resource; File file = resource;
if (_shouldFileBeAnalyzed(file)) { if (_shouldFileBeAnalyzed(file)) {
ChangeSet changeSet = new ChangeSet(); if (enableNewAnalysisDriver) {
Source source = createSourceInContext(info.context, file); info.analysisDriver.addFile(path);
changeSet.addedSource(source); } else {
callbacks.applyChangesToContext(info.folder, changeSet); ChangeSet changeSet = new ChangeSet();
info.sources[path] = source; Source source = createSourceInContext(info.context, file);
changeSet.addedSource(source);
callbacks.applyChangesToContext(info.folder, changeSet);
info.sources[path] = source;
}
} }
} }
break; break;
@ -1420,24 +1424,32 @@ class ContextManagerImpl implements ContextManager {
} }
} }
List<Source> sources = info.context.getSourcesWithFullName(path); if (enableNewAnalysisDriver) {
if (!sources.isEmpty) { info.analysisDriver.removeFile(path);
ChangeSet changeSet = new ChangeSet(); } else {
sources.forEach((Source source) { List<Source> sources = info.context.getSourcesWithFullName(path);
changeSet.removedSource(source); if (!sources.isEmpty) {
}); ChangeSet changeSet = new ChangeSet();
callbacks.applyChangesToContext(info.folder, changeSet); sources.forEach((Source source) {
info.sources.remove(path); changeSet.removedSource(source);
});
callbacks.applyChangesToContext(info.folder, changeSet);
info.sources.remove(path);
}
} }
break; break;
case ChangeType.MODIFY: case ChangeType.MODIFY:
List<Source> sources = info.context.getSourcesWithFullName(path); if (enableNewAnalysisDriver) {
if (!sources.isEmpty) { info.analysisDriver.changeFile(path);
ChangeSet changeSet = new ChangeSet(); } else {
sources.forEach((Source source) { List<Source> sources = info.context.getSourcesWithFullName(path);
changeSet.changedSource(source); if (!sources.isEmpty) {
}); ChangeSet changeSet = new ChangeSet();
callbacks.applyChangesToContext(info.folder, changeSet); sources.forEach((Source source) {
changeSet.changedSource(source);
});
callbacks.applyChangesToContext(info.folder, changeSet);
}
} }
break; break;
} }