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

Unified Diff: pkg/analysis_server/test/analysis/notification_navigation_test.dart

Issue 2769813005: Allow navigation from var when there is an inferred type (issue 29091) (Closed)
Patch Set: Created 3 years, 9 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
Index: pkg/analysis_server/test/analysis/notification_navigation_test.dart
diff --git a/pkg/analysis_server/test/analysis/notification_navigation_test.dart b/pkg/analysis_server/test/analysis/notification_navigation_test.dart
index 49b55ae704c8e94ccee84bcefde3133553533029..e8ab91da7fcfc7fd7dc893676d3cb91ddc1cd185 100644
--- a/pkg/analysis_server/test/analysis/notification_navigation_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_navigation_test.dart
@@ -933,4 +933,100 @@ void main() {
await prepareNavigation();
assertNoRegionAt('void');
}
+
+ test_var_declaredVariable() async {
+ addTestFile('''
+class C {}
+f(List<C> items) {
+ for (var item in items) {}
+}
+''');
+ await prepareNavigation();
+ assertHasRegionTarget('var', 'C {}');
+ expect(testTarget.kind, ElementKind.CLASS);
+ }
+
+ test_var_localVariable_multiple_inferred_different() async {
+ addTestFile('''
+class A {}
+class B {}
+void f() {
+ var a = new A(), b = new B();
+}
+''');
+ await prepareNavigation();
+ assertNoRegionAt('var');
+ }
+
+ test_var_localVariable_multiple_inferred_same() async {
+ addTestFile('''
+class C {}
+void f() {
+ var a = new C(), b = new C();
+}
+''');
+ await prepareNavigation();
+ assertHasRegionTarget('var', 'C {}');
+ expect(testTarget.kind, ElementKind.CLASS);
+ }
+
+ test_var_localVariable_single_inferred() async {
+ addTestFile('''
+class C {}
+f() {
+ var c = new C();
+}
+''');
+ await prepareNavigation();
+ assertHasRegionTarget('var', 'C {}');
+ expect(testTarget.kind, ElementKind.CLASS);
+ }
+
+ test_var_localVariable_single_notInferred() async {
+ addTestFile('''
+f() {
+ var x;
+}
+''');
+ await prepareNavigation();
+ assertNoRegionAt('var');
+ }
+
+ test_var_topLevelVariable_multiple_inferred_different() async {
+ addTestFile('''
+class A {}
+class B {}
+var a = new A(), b = new B();
+''');
+ await prepareNavigation();
+ assertNoRegionAt('var');
+ }
+
+ test_var_topLevelVariable_multiple_inferred_same() async {
+ addTestFile('''
+class C {}
+var a = new C(), b = new C();
+''');
+ await prepareNavigation();
+ assertHasRegionTarget('var', 'C {}');
+ expect(testTarget.kind, ElementKind.CLASS);
+ }
+
+ test_var_topLevelVariable_single_inferred() async {
+ addTestFile('''
+class C {}
+var c = new C();
+''');
+ await prepareNavigation();
+ assertHasRegionTarget('var', 'C {}');
+ expect(testTarget.kind, ElementKind.CLASS);
+ }
+
+ test_var_topLevelVariable_single_notInferred() async {
+ addTestFile('''
+var x;
+''');
+ await prepareNavigation();
+ assertNoRegionAt('var');
+ }
}

Powered by Google App Engine
This is Rietveld 408576698