mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Revert "Do nothing if [changeFile] reported, but the file content is the same."
This reverts commit 1ffda5601b
.
There is a bug with reporting changeFile() twice, first time the change
be noticed and the file content hash updated. But the second time the
content hash is the same, and we unschedule the file from analysis :-(
R=brianwilkerson@google.com, paulberry@google.com
BUG=
Review URL: https://codereview.chromium.org/2462743003 .
This commit is contained in:
parent
1ffda5601b
commit
1bdee25bdf
2 changed files with 8 additions and 42 deletions
|
@ -208,6 +208,12 @@ class AnalysisDriver {
|
||||||
* "analyzing" and an analysis result is produced for every added file prior
|
* "analyzing" and an analysis result is produced for every added file prior
|
||||||
* to the next time the analysis state transitions to "idle".
|
* to the next time the analysis state transitions to "idle".
|
||||||
*
|
*
|
||||||
|
* At least one analysis result is produced for every file passed to
|
||||||
|
* [addFile] or [changeFile] prior to the next time the analysis state
|
||||||
|
* transitions to "idle", unless the file is later removed from analysis
|
||||||
|
* using [removeFile]. Analysis results for other files are produced only if
|
||||||
|
* the changes affect analysis results of other files.
|
||||||
|
*
|
||||||
* More than one result might be produced for the same file, even if the
|
* More than one result might be produced for the same file, even if the
|
||||||
* client does not change the state of the files.
|
* client does not change the state of the files.
|
||||||
*
|
*
|
||||||
|
@ -299,11 +305,6 @@ class AnalysisDriver {
|
||||||
* The [path] must be absolute and normalized.
|
* The [path] must be absolute and normalized.
|
||||||
*
|
*
|
||||||
* The results of analysis are eventually produced by the [results] stream.
|
* The results of analysis are eventually produced by the [results] stream.
|
||||||
*
|
|
||||||
* Causes the analysis state to transition to "analyzing" (if it is not in
|
|
||||||
* that state already). At least one analysis result will be produced the
|
|
||||||
* file prior to the next time the analysis state transitions to "idle",
|
|
||||||
* unless the file is later removed from analysis using [removeFile].
|
|
||||||
*/
|
*/
|
||||||
void addFile(String path) {
|
void addFile(String path) {
|
||||||
_explicitFiles.add(path);
|
_explicitFiles.add(path);
|
||||||
|
@ -325,11 +326,6 @@ class AnalysisDriver {
|
||||||
* into the current file state prior to the next time the analysis state
|
* into the current file state prior to the next time the analysis state
|
||||||
* transitions to "idle".
|
* transitions to "idle".
|
||||||
*
|
*
|
||||||
* If the file content is the same, no new results will be produced because
|
|
||||||
* of this notification, including no result for the file itself. Otherwise,
|
|
||||||
* one or more results will be produced - for the file itself and other
|
|
||||||
* files that that change in the file might affect.
|
|
||||||
*
|
|
||||||
* Invocation of this method will not prevent a [Future] returned from
|
* Invocation of this method will not prevent a [Future] returned from
|
||||||
* [getResult] from completing with a result, but the result is not
|
* [getResult] from completing with a result, but the result is not
|
||||||
* guaranteed to be consistent with the new current file state after this
|
* guaranteed to be consistent with the new current file state after this
|
||||||
|
@ -685,22 +681,16 @@ class AnalysisDriver {
|
||||||
*/
|
*/
|
||||||
void _verifyApiSignatureOfChangedFile(String path) {
|
void _verifyApiSignatureOfChangedFile(String path) {
|
||||||
_logger.run('Verify API signature of $path', () {
|
_logger.run('Verify API signature of $path', () {
|
||||||
String oldContentHash = _fileContentHashMap[path];
|
|
||||||
String oldSignature = _fileApiSignatureMap[path];
|
String oldSignature = _fileApiSignatureMap[path];
|
||||||
// Compute the new API signature.
|
// Compute the new API signature.
|
||||||
// _File.forResolution() also updates the content hash in the cache.
|
// _File.forResolution() also updates the content hash in the cache.
|
||||||
Source source = _sourceForPath(path);
|
Source source = _sourceForPath(path);
|
||||||
_File newFile = new _File.forResolution(this, source);
|
_File newFile = new _File.forResolution(this, source);
|
||||||
// If the file content hash is the same, we don't need analyzing it.
|
String newSignature = newFile.unlinked.apiSignature;
|
||||||
if (newFile.contentHash == oldContentHash) {
|
|
||||||
_filesToAnalyze.remove(path);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// If the old API signature is not null, then the file was used to
|
// If the old API signature is not null, then the file was used to
|
||||||
// compute at least one dependency signature. If the new API signature
|
// compute at least one dependency signature. If the new API signature
|
||||||
// is different, then potentially all dependency signatures and
|
// is different, then potentially all dependency signatures and
|
||||||
// resolution results are invalid.
|
// resolution results are invalid.
|
||||||
String newSignature = newFile.unlinked.apiSignature;
|
|
||||||
if (oldSignature != null && oldSignature != newSignature) {
|
if (oldSignature != null && oldSignature != newSignature) {
|
||||||
_logger.writeln('API signatures mismatch found for $newFile');
|
_logger.writeln('API signatures mismatch found for $newFile');
|
||||||
_dependencySignatureMap.clear();
|
_dependencySignatureMap.clear();
|
||||||
|
|
|
@ -77,7 +77,7 @@ class DriverTest {
|
||||||
})
|
})
|
||||||
], null, provider),
|
], null, provider),
|
||||||
new AnalysisOptionsImpl()..strongMode = true);
|
new AnalysisOptionsImpl()..strongMode = true);
|
||||||
driver.status.listen((status) {
|
driver.status.lastWhere((status) {
|
||||||
allStatuses.add(status);
|
allStatuses.add(status);
|
||||||
if (status.isIdle) {
|
if (status.isIdle) {
|
||||||
idleStatusMonitor.notify();
|
idleStatusMonitor.notify();
|
||||||
|
@ -141,30 +141,6 @@ var A = B;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
test_changeFile_noContentChange_noNewResult() async {
|
|
||||||
_addTestFile('main() {}', priority: true);
|
|
||||||
|
|
||||||
// Initial analysis.
|
|
||||||
await _waitForIdle();
|
|
||||||
expect(allResults, hasLength(1));
|
|
||||||
|
|
||||||
// Update the file, but don't notify the driver.
|
|
||||||
// Don't update the file in the file system.
|
|
||||||
// But tell the driver the the file was changed.
|
|
||||||
// The driver should eventually check the file and ignore.
|
|
||||||
allStatuses.clear();
|
|
||||||
allResults.clear();
|
|
||||||
driver.changeFile(testFile);
|
|
||||||
|
|
||||||
// The driver switched to analysis and back to idle.
|
|
||||||
await _waitForIdle();
|
|
||||||
expect(allStatuses, hasLength(2));
|
|
||||||
expect(allStatuses.map((status) => status.isAnalyzing), [true, false]);
|
|
||||||
|
|
||||||
// No new results.
|
|
||||||
expect(allResults, isEmpty);
|
|
||||||
}
|
|
||||||
|
|
||||||
test_changeFile_selfConsistent() async {
|
test_changeFile_selfConsistent() async {
|
||||||
var a = _p('/test/lib/a.dart');
|
var a = _p('/test/lib/a.dart');
|
||||||
var b = _p('/test/lib/b.dart');
|
var b = _p('/test/lib/b.dart');
|
||||||
|
|
Loading…
Reference in a new issue