Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: pkg/analyzer/test/src/dart/analysis/driver_test.dart

Issue 2569553002: addFile() must refresh the file. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/driver.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/dart/analysis/driver_test.dart
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index 860d6de731646a45e94f8055967b9a929e01ddfd..1d28fd00060edddafa408ea50aa3bca32c943e7d 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -265,6 +265,57 @@ class AnalysisDriverTest extends BaseAnalysisDriverTest {
expect(driver.addedFiles, isNot(contains(b)));
}
+ test_addFile_shouldRefresh() async {
+ var a = _p('/test/lib/a.dart');
+ var b = _p('/test/lib/b.dart');
+
+ provider.newFile(a, 'class A {}');
+ provider.newFile(
+ b,
+ r'''
+import 'a.dart';
+''');
+
+ driver.addFile(a);
+ driver.addFile(b);
+
+ void assertNumberOfErrorsInB(int n) {
+ var bResult = allResults.singleWhere((r) => r.path == b);
+ expect(bResult.errors, hasLength(n));
+ allResults.clear();
+ }
+
+ // Initial analysis, 'b' does not use 'a', so there is a hint.
+ await _waitForIdle();
+ assertNumberOfErrorsInB(1);
+
+ // Update 'b' to use 'a', no more hints.
+ provider.newFile(
+ b,
+ r'''
+import 'a.dart';
+main() {
+ print(A);
+}
+''');
+ driver.changeFile(b);
+ await _waitForIdle();
+ assertNumberOfErrorsInB(0);
+
+ // Change 'b' t have a hint again.
+ // Add and remove 'b'.
+ // The file must be refreshed, and the hint must be reported.
+ provider.newFile(
+ b,
+ r'''
+import 'a.dart';
+''');
+ driver.removeFile(b);
+ driver.addFile(b);
+ await _waitForIdle();
+ assertNumberOfErrorsInB(1);
+ }
+
test_addFile_thenRemove() async {
var a = _p('/test/lib/a.dart');
var b = _p('/test/lib/b.dart');
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/driver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698