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

Side by Side Diff: pkg/analysis_server/test/services/completion/local_computer_test.dart

Issue 558893002: add code completion declared and return types (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge and remove reference to analysis engine Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/test/services/completion/invocation_computer_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.services.completion.dart.local; 5 library test.services.completion.dart.local;
6 6
7 import 'package:analysis_server/src/services/completion/local_computer.dart'; 7 import 'package:analysis_server/src/services/completion/local_computer.dart';
8 import '../../reflective_tests.dart'; 8 import '../../reflective_tests.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
11 import 'completion_test_util.dart'; 11 import 'completion_test_util.dart';
12 12
13 main() { 13 main() {
14 groupSep = ' | '; 14 groupSep = ' | ';
15 runReflectiveTests(LocalComputerTest); 15 runReflectiveTests(LocalComputerTest);
16 } 16 }
17 17
18 @ReflectiveTestCase() 18 @ReflectiveTestCase()
19 class LocalComputerTest extends AbstractCompletionTest { 19 class LocalComputerTest extends AbstractCompletionTest {
20 20
21 @override 21 @override
22 void setUp() { 22 void setUp() {
23 super.setUp(); 23 super.setUp();
24 computer = new LocalComputer(); 24 computer = new LocalComputer();
25 } 25 }
26 26
27 test_block() { 27 test_block() {
28 addTestSource('class A {a() {var f; {var x;} ^ var g;}}'); 28 addTestSource('class A {a() {var f; {var x;} ^ var g;}}');
29 expect(computeFast(), isTrue); 29 expect(computeFast(), isTrue);
30 assertSuggestLocalVariable('f'); 30 assertSuggestLocalVariable('f', null);
31 assertNotSuggested('g'); 31 assertNotSuggested('g');
32 assertNotSuggested('x'); 32 assertNotSuggested('x');
33 } 33 }
34 34
35 test_catch() { 35 test_catch() {
36 addTestSource('class A {a() {try{} catch (e) {^}}}'); 36 addTestSource('class A {a() {try{} on E catch (e) {^}}}');
37 expect(computeFast(), isTrue); 37 expect(computeFast(), isTrue);
38 assertSuggestParameter('e'); 38 assertSuggestParameter('e', 'E');
39 } 39 }
40 40
41 test_catch2() { 41 test_catch2() {
42 addTestSource('class A {a() {try{} catch (e, s) {^}}}'); 42 addTestSource('class A {a() {try{} catch (e, s) {^}}}');
43 expect(computeFast(), isTrue); 43 expect(computeFast(), isTrue);
44 assertSuggestParameter('e'); 44 assertSuggestParameter('e', null);
45 assertSuggestParameter('s'); 45 assertSuggestParameter('s', null);
46 } 46 }
47 47
48 test_compilationUnit_declarations() { 48 test_compilationUnit_declarations() {
49 addTestSource('class A {^} class B {} var T;'); 49 addTestSource('class A {^} class B {} A T;');
50 expect(computeFast(), isTrue); 50 expect(computeFast(), isTrue);
51 assertSuggestClass('A'); 51 assertSuggestClass('A');
52 assertSuggestClass('B'); 52 assertSuggestClass('B');
53 assertSuggestTopLevelVar('T'); 53 assertSuggestTopLevelVar('T', 'A');
54 } 54 }
55 55
56 test_compilationUnit_directives() { 56 test_compilationUnit_directives() {
57 addTestSource('import "boo.dart" as x; class A {^}'); 57 addTestSource('import "boo.dart" as x; class A {^}');
58 expect(computeFast(), isTrue); 58 expect(computeFast(), isTrue);
59 assertSuggestLibraryPrefix('x'); 59 assertSuggestLibraryPrefix('x');
60 } 60 }
61 61
62 test_field_name() { 62 test_field_name() {
63 addTestSource('class A {B ^}}'); 63 addTestSource('class A {B ^}}');
64 expect(computeFast(), isTrue); 64 expect(computeFast(), isTrue);
65 assertNotSuggested('A'); 65 assertNotSuggested('A');
66 } 66 }
67 67
68 test_field_name2() { 68 test_field_name2() {
69 addTestSource('class A {var ^}}'); 69 addTestSource('class A {var ^}}');
70 expect(computeFast(), isTrue); 70 expect(computeFast(), isTrue);
71 assertNotSuggested('A'); 71 assertNotSuggested('A');
72 } 72 }
73 73
74 test_for() { 74 test_for() {
75 addTestSource('main(args) {for (int i; i < 10; ++i) {^}}'); 75 addTestSource('main(args) {for (int i; i < 10; ++i) {^}}');
76 expect(computeFast(), isTrue); 76 expect(computeFast(), isTrue);
77 assertSuggestLocalVariable('i'); 77 assertSuggestLocalVariable('i', 'int');
78 } 78 }
79 79
80 test_forEach() { 80 test_forEach() {
81 addTestSource('main(args) {for (foo in bar) {^}}'); 81 addTestSource('main(args) {for (foo in bar) {^}}');
82 expect(computeFast(), isTrue); 82 expect(computeFast(), isTrue);
83 assertSuggestLocalVariable('foo'); 83 assertSuggestLocalVariable('foo', null);
84 } 84 }
85 85
86 test_function() { 86 test_function() {
87 addTestSource('main(args) {x.then((b) {^});}'); 87 addTestSource('String foo(List args) {x.then((R b) {^});}');
88 expect(computeFast(), isTrue); 88 expect(computeFast(), isTrue);
89 assertSuggestFunction('main'); 89 assertSuggestFunction('foo', 'String');
90 assertSuggestParameter('args'); 90 assertSuggestParameter('args', 'List');
91 assertSuggestParameter('b'); 91 assertSuggestParameter('b', 'R');
92 } 92 }
93 93
94 test_local_name() { 94 test_local_name() {
95 addTestSource('class A {a() {var f; A ^}}'); 95 addTestSource('class A {a() {var f; A ^}}');
96 expect(computeFast(), isTrue); 96 expect(computeFast(), isTrue);
97 //TODO (danrubel) should not be suggested 97 assertNotSuggested('A');
98 // but A ^ in this test 98 assertNotSuggested('a');
99 // parses differently than var ^ in test below 99 assertNotSuggested('f');
100 assertSuggestClass('A');
101 assertSuggestMethodName('a');
102 assertSuggestLocalVariable('f');
103 } 100 }
104 101
105 test_local_name2() { 102 test_local_name2() {
106 addTestSource('class A {a() {var f; var ^}}'); 103 addTestSource('class A {a() {var f; var ^}}');
107 expect(computeFast(), isTrue); 104 expect(computeFast(), isTrue);
108 assertNotSuggested('A'); 105 assertNotSuggested('A');
109 assertNotSuggested('a'); 106 assertNotSuggested('a');
110 assertNotSuggested('f'); 107 assertNotSuggested('f');
111 } 108 }
112 109
113 test_members() { 110 test_members() {
114 addTestSource('class A {var f; a() {^} var g;}'); 111 addTestSource('class A {X f; Z a() {^} var g;}');
115 expect(computeFast(), isTrue); 112 expect(computeFast(), isTrue);
116 assertSuggestMethodName('a'); 113 assertSuggestMethodName('a', 'A', 'Z');
117 assertSuggestField('f'); 114 assertSuggestField('f', 'A', 'X');
118 assertSuggestField('g'); 115 assertSuggestField('g', 'A', null);
119 } 116 }
120 117
121 test_methodParam_named() { 118 test_methodParam_named() {
122 addTestSource('class A {a(x, {y: boo}) {^}}'); 119 addTestSource('class A {Z a(X x, {y: boo}) {^}}');
123 expect(computeFast(), isTrue); 120 expect(computeFast(), isTrue);
124 assertSuggestMethodName('a'); 121 assertSuggestMethodName('a', 'A', 'Z');
125 assertSuggestParameter('x'); 122 assertSuggestParameter('x', 'X');
126 assertSuggestParameter('y'); 123 assertSuggestParameter('y', 'boo');
127 } 124 }
128 125
129 test_methodParam_positional() { 126 test_methodParam_positional() {
130 addTestSource('class A {a(x, [y=1]) {^}}'); 127 addTestSource('class A {Z a(X x, [int y=1]) {^}}');
131 expect(computeFast(), isTrue); 128 expect(computeFast(), isTrue);
132 assertSuggestMethodName('a'); 129 assertSuggestMethodName('a', 'A', 'Z');
133 assertSuggestParameter('x'); 130 assertSuggestParameter('x', 'X');
134 assertSuggestParameter('y'); 131 assertSuggestParameter('y', 'int');
135 } 132 }
136 133
137 test_topLevelVar_name() { 134 test_topLevelVar_name() {
138 addTestSource('class A {} B ^'); 135 addTestSource('class A {} B ^');
139 expect(computeFast(), isTrue); 136 expect(computeFast(), isTrue);
140 assertNotSuggested('A'); 137 assertNotSuggested('A');
141 } 138 }
142 139
143 test_topLevelVar_name2() { 140 test_topLevelVar_name2() {
144 addTestSource('class A {} var ^'); 141 addTestSource('class A {} var ^');
145 expect(computeFast(), isTrue); 142 expect(computeFast(), isTrue);
146 assertNotSuggested('A'); 143 assertNotSuggested('A');
147 } 144 }
148 145
149 test_variableDeclaration() { 146 test_variableDeclaration() {
150 addTestSource('main() {int a = 1, b = 2 + ^;}'); 147 addTestSource('main() {int a = 1, b = 2 + ^;}');
151 expect(computeFast(), isTrue); 148 expect(computeFast(), isTrue);
152 assertSuggestLocalVariable('a'); 149 assertSuggestLocalVariable('a', 'int');
153 assertNotSuggested('b'); 150 assertNotSuggested('b');
154 } 151 }
155 } 152 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/services/completion/invocation_computer_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698