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

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

Issue 999923002: completions for function return type (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 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 unified diff | Download patch | Annotate | Revision Log
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.target; 5 library test.services.completion.target;
6 6
7 import 'package:analysis_server/src/services/completion/completion_target.dart'; 7 import 'package:analysis_server/src/services/completion/completion_target.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 addTestSource('class A {var b; X _c; foo() {var a; (a as ^String).foo();}'); 130 addTestSource('class A {var b; X _c; foo() {var a; (a as ^String).foo();}');
131 assertTarget('String', 'a as String'); 131 assertTarget('String', 'a as String');
132 } 132 }
133 133
134 test_Block() { 134 test_Block() {
135 // Block 135 // Block
136 addTestSource('main() {^}'); 136 addTestSource('main() {^}');
137 assertTarget('}', '{}'); 137 assertTarget('}', '{}');
138 } 138 }
139 139
140 test_FunctionDeclaration_inLineComment() {
141 // Comment CompilationUnit
142 addTestSource('''
143 // normal comment ^
144 zoo(z) { } String name;''');
145 assertTarget('// normal comment ', 'zoo(z) {} String name;');
146 }
147
148 test_FunctionDeclaration_inLineComment2() {
149 // Comment CompilationUnit
150 addTestSource('''
151 // normal ^comment
152 zoo(z) { } String name;''');
153 assertTarget('// normal comment', 'zoo(z) {} String name;');
154 }
155
156 test_FunctionDeclaration_inLineComment3() {
157 // Comment CompilationUnit
158 addTestSource('''
159 // normal comment ^
160 // normal comment 2
161 zoo(z) { } String name;''');
162 assertTarget('// normal comment ', 'zoo(z) {} String name;');
163 }
164
165 test_FunctionDeclaration_inLineComment4() {
166 // Comment CompilationUnit
167 addTestSource('''
168 // normal comment
169 // normal comment 2^
170 zoo(z) { } String name;''');
171 assertTarget('// normal comment 2', 'zoo(z) {} String name;');
172 }
173
174 test_FunctionDeclaration_inLineDocComment() {
175 // Comment FunctionDeclaration CompilationUnit
176 addTestSource('''
177 /// some dartdoc ^
178 zoo(z) { } String name;''');
179 assertTarget('/// some dartdoc ', '');
180 expect(target.containingNode is Comment, isTrue);
181 expect(target.containingNode.parent.toSource(), 'zoo(z) {}');
182 }
183
184 test_FunctionDeclaration_inLineDocComment2() {
185 // Comment FunctionDeclaration CompilationUnit
186 addTestSource('''
187 /// some ^dartdoc
188 zoo(z) { } String name;''');
189 assertTarget('/// some dartdoc', '');
190 expect(target.containingNode is Comment, isTrue);
191 expect(target.containingNode.parent.toSource(), 'zoo(z) {}');
192 }
193
194 test_FunctionDeclaration_inStarComment() {
195 // Comment CompilationUnit
196 addTestSource('/* ^ */ zoo(z) {} String name;');
197 assertTarget('/* */', 'zoo(z) {} String name;');
198 }
199
200 test_FunctionDeclaration_inStarComment2() {
201 // Comment CompilationUnit
202 addTestSource('/* *^/ zoo(z) {} String name;');
203 assertTarget('/* */', 'zoo(z) {} String name;');
204 }
205
206 test_FunctionDeclaration_inStarDocComment() {
207 // Comment FunctionDeclaration CompilationUnit
208 addTestSource('/** ^ */ zoo(z) { } String name;');
209 assertTarget('/** */', '');
210 expect(target.containingNode is Comment, isTrue);
211 expect(target.containingNode.parent.toSource(), 'zoo(z) {}');
212 }
213
214 test_FunctionDeclaration_inStarDocComment2() {
215 // Comment FunctionDeclaration CompilationUnit
216 addTestSource('/** *^/ zoo(z) { } String name;');
217 assertTarget('/** */', '');
218 expect(target.containingNode is Comment, isTrue);
219 expect(target.containingNode.parent.toSource(), 'zoo(z) {}');
220 }
221
222 test_FunctionDeclaration_returnType() {
223 // CompilationUnit
224 addTestSource('^ zoo(z) { } String name;');
225 assertTarget('zoo(z) {}', 'zoo(z) {} String name;');
226 }
227
228 test_FunctionDeclaration_returnType_afterLineComment() {
229 // FunctionDeclaration CompilationUnit
230 addTestSource('''
231 // normal comment
232 ^ zoo(z) {} String name;''');
233 assertTarget('zoo(z) {}', 'zoo(z) {} String name;');
234 }
235
236 test_FunctionDeclaration_returnType_afterLineComment2() {
237 // FunctionDeclaration CompilationUnit
238 // TOD(danrubel) left align all test source
239 addTestSource('''
240 // normal comment
241 ^ zoo(z) {} String name;''');
242 assertTarget('zoo(z) {}', 'zoo(z) {} String name;');
243 }
244
245 test_FunctionDeclaration_returnType_afterLineDocComment() {
246 // SimpleIdentifier FunctionDeclaration CompilationUnit
247 addTestSource('''
248 /// some dartdoc
249 ^ zoo(z) { } String name; ''');
250 assertTarget('zoo', 'zoo(z) {}');
251 }
252
253 test_FunctionDeclaration_returnType_afterLineDocComment2() {
254 // SimpleIdentifier FunctionDeclaration CompilationUnit
255 addTestSource('''
256 /// some dartdoc
257 ^ zoo(z) { } String name;''');
258 assertTarget('zoo', 'zoo(z) {}');
259 }
260
261 test_FunctionDeclaration_returnType_afterStarComment() {
262 // CompilationUnit
263 addTestSource('/* */ ^ zoo(z) { } String name;');
264 assertTarget('zoo(z) {}', 'zoo(z) {} String name;');
265 }
266
267 test_FunctionDeclaration_returnType_afterStarComment2() {
268 // CompilationUnit
269 addTestSource('/* */^ zoo(z) { } String name;');
270 assertTarget('zoo(z) {}', 'zoo(z) {} String name;');
271 }
272
273 test_FunctionDeclaration_returnType_afterStarDocComment() {
274 // FunctionDeclaration CompilationUnit
275 addTestSource('/** */ ^ zoo(z) { } String name;');
276 assertTarget('zoo', 'zoo(z) {}');
277 }
278
279 test_FunctionDeclaration_returnType_afterStarDocComment2() {
280 // FunctionDeclaration CompilationUnit
281 addTestSource('/** */^ zoo(z) { } String name;');
282 assertTarget('zoo', 'zoo(z) {}');
283 }
284
140 test_InstanceCreationExpression_identifier() { 285 test_InstanceCreationExpression_identifier() {
141 // InstanceCreationExpression ExpressionStatement Block 286 // InstanceCreationExpression ExpressionStatement Block
142 addTestSource('class C {foo(){var f; {var x;} new ^C();}}'); 287 addTestSource('class C {foo(){var f; {var x;} new ^C();}}');
143 assertTarget('C', 'new C()'); 288 assertTarget('C', 'new C()');
144 } 289 }
145 290
146 test_InstanceCreationExpression_keyword() { 291 test_InstanceCreationExpression_keyword() {
147 // InstanceCreationExpression ExpressionStatement Block 292 // InstanceCreationExpression ExpressionStatement Block
148 addTestSource('class C {foo(){var f; {var x;} new^ }}'); 293 addTestSource('class C {foo(){var f; {var x;} new^ }}');
149 assertTarget('new ();', '{var f; {var x;} new ();}'); 294 assertTarget('new ();', '{var f; {var x;} new ();}');
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 addTestSource('main() {int b^ = 1;}'); 460 addTestSource('main() {int b^ = 1;}');
316 assertTarget('b = 1', 'int b = 1'); 461 assertTarget('b = 1', 'int b = 1');
317 } 462 }
318 463
319 test_VariableDeclaration_lhs_identifier_before() { 464 test_VariableDeclaration_lhs_identifier_before() {
320 // VariableDeclaration VariableDeclarationList 465 // VariableDeclaration VariableDeclarationList
321 addTestSource('main() {int ^b = 1;}'); 466 addTestSource('main() {int ^b = 1;}');
322 assertTarget('b = 1', 'int b = 1'); 467 assertTarget('b = 1', 'int b = 1');
323 } 468 }
324 } 469 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698