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

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

Issue 2656233004: Use AnalysisDriver.getErrors() to get cached errors for already analyzed files. (Closed)
Patch Set: Created 3 years, 11 months 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') | pkg/analyzer_cli/lib/src/analyzer_impl.dart » ('j') | 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 1602d1edaf1e5cf6bc51c808d8d42734d5ce71f6..682adeacf0338acd963da732aead5ec1b2037093 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -694,6 +694,17 @@ bbb() {}
expect(driver.knownFiles, isNot(contains(templatePath)));
}
+ test_getErrors() async {
+ String content = 'int f() => 42 + bar();';
+ addTestFile(content, priority: true);
+
+ ErrorsResult result = await driver.getErrors(testFile);
+ expect(result.path, testFile);
+ expect(result.uri.toString(), 'package:test/test.dart');
+ expect(result.contentHash, _md5(content));
+ expect(result.errors, hasLength(1));
+ }
+
test_getFilesReferencingName() async {
var a = _p('/test/bin/a.dart');
var b = _p('/test/bin/b.dart');
@@ -1365,6 +1376,80 @@ import 'b.dart';
expect(clazz.name.name, 'A2');
}
+ test_part_getErrors_afterLibrary() async {
+ var a = _p('/test/lib/a.dart');
+ var b = _p('/test/lib/b.dart');
+ var c = _p('/test/lib/c.dart');
+ provider.newFile(
+ a,
+ r'''
+library a;
+import 'b.dart';
+part 'c.dart';
+class A {}
+var c = new C();
+''');
+ provider.newFile(b, 'class B {}');
+ provider.newFile(
+ c,
+ r'''
+part of a;
+class C {}
+var a = new A();
+var b = new B();
+''');
+
+ driver.addFile(a);
+ driver.addFile(b);
+ driver.addFile(c);
+
+ // Process a.dart so that we know that it's a library for c.dart later.
+ {
+ ErrorsResult result = await driver.getErrors(a);
+ expect(result.errors, isEmpty);
+ }
+
+ // c.dart does not have errors in the context of a.dart
+ {
+ ErrorsResult result = await driver.getErrors(c);
+ expect(result.errors, isEmpty);
+ }
+ }
+
+ test_part_getErrors_beforeLibrary() async {
+ var a = _p('/test/lib/a.dart');
+ var b = _p('/test/lib/b.dart');
+ var c = _p('/test/lib/c.dart');
+ provider.newFile(
+ a,
+ r'''
+library a;
+import 'b.dart';
+part 'c.dart';
+class A {}
+var c = new C();
+''');
+ provider.newFile(b, 'class B {}');
+ provider.newFile(
+ c,
+ r'''
+part of a;
+class C {}
+var a = new A();
+var b = new B();
+''');
+
+ driver.addFile(a);
+ driver.addFile(b);
+ driver.addFile(c);
+
+ // c.dart is resolve in the context of a.dart, so have no errors
+ {
+ ErrorsResult result = await driver.getErrors(c);
+ expect(result.errors, isEmpty);
+ }
+ }
+
test_part_getResult_afterLibrary() 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') | pkg/analyzer_cli/lib/src/analyzer_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698