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

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

Issue 651443006: filter invalid method invocation suggestions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 2 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/lib/src/services/completion/local_computer.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.util; 5 library test.services.completion.util;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element,
10 ElementKind; 10 ElementKind;
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 if (getterG != null) { 1305 if (getterG != null) {
1306 expect(getterG.element.isDeprecated, isFalse); 1306 expect(getterG.element.isDeprecated, isFalse);
1307 expect(getterG.element.isPrivate, isTrue); 1307 expect(getterG.element.isPrivate, isTrue);
1308 } 1308 }
1309 assertSuggestImportedClass('bool'); 1309 assertSuggestImportedClass('bool');
1310 }); 1310 });
1311 } 1311 }
1312 1312
1313 test_MethodDeclaration_parameters_named() { 1313 test_MethodDeclaration_parameters_named() {
1314 // Block BlockFunctionBody MethodDeclaration 1314 // Block BlockFunctionBody MethodDeclaration
1315 addTestSource('class A {@deprecated Z a(X x, {y: boo}) {^}}'); 1315 addTestSource('class A {@deprecated Z a(X x, _, b, {y: boo}) {^}}');
1316 computeFast(); 1316 computeFast();
1317 return computeFull(true).then((_) { 1317 return computeFull(true).then((_) {
1318 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z'); 1318 CompletionSuggestion methodA = assertSuggestLocalMethod('a', 'A', 'Z');
1319 if (methodA != null) { 1319 if (methodA != null) {
1320 expect(methodA.element.isDeprecated, isTrue); 1320 expect(methodA.element.isDeprecated, isTrue);
1321 expect(methodA.element.isPrivate, isFalse); 1321 expect(methodA.element.isPrivate, isFalse);
1322 } 1322 }
1323 assertSuggestParameter('x', 'X'); 1323 assertSuggestParameter('x', 'X');
1324 assertSuggestParameter('y', null); 1324 assertSuggestParameter('y', null);
1325 assertSuggestParameter('b', null);
1325 assertSuggestImportedClass('int'); 1326 assertSuggestImportedClass('int');
1327 assertNotSuggested('_');
1326 }); 1328 });
1327 } 1329 }
1328 1330
1329 test_MethodDeclaration_parameters_positional() { 1331 test_MethodDeclaration_parameters_positional() {
1330 // Block BlockFunctionBody MethodDeclaration 1332 // Block BlockFunctionBody MethodDeclaration
1331 addTestSource(''' 1333 addTestSource('''
1332 foo() { } 1334 foo() { }
1333 void bar() { } 1335 void bar() { }
1334 class A {Z a(X x, [int y=1]) {^}}'''); 1336 class A {Z a(X x, [int y=1]) {^}}''');
1335 computeFast(); 1337 computeFast();
1336 return computeFull(true).then((_) { 1338 return computeFull(true).then((_) {
1337 assertSuggestLocalFunction('foo', null); 1339 assertSuggestLocalFunction('foo', null);
1338 assertSuggestLocalFunction('bar', 'void'); 1340 assertSuggestLocalFunction('bar', 'void');
1339 assertSuggestLocalMethod('a', 'A', 'Z'); 1341 assertSuggestLocalMethod('a', 'A', 'Z');
1340 assertSuggestParameter('x', 'X'); 1342 assertSuggestParameter('x', 'X');
1341 assertSuggestParameter('y', 'int'); 1343 assertSuggestParameter('y', 'int');
1342 assertSuggestImportedClass('String'); 1344 assertSuggestImportedClass('String');
1343 }); 1345 });
1344 } 1346 }
1345 1347
1348 test_MethodInvocation_no_semicolon() {
1349 // MethodInvocation ExpressionStatement Block
1350 addTestSource('''
1351 main() { }
1352 class I {X get f => new A();get _g => new A();}
1353 class A implements I {
1354 var b; X _c;
1355 X get d => new A();get _e => new A();
1356 // no semicolon between completion point and next statement
1357 set s1(I x) {} set _s2(I x) {x.^ m(null);}
1358 m(X x) {} I _n(X x) {}}
1359 class X{}''');
1360 computeFast();
1361 return computeFull(true).then((_) {
1362 assertSuggestInvocationGetter('f', 'X');
1363 assertSuggestInvocationGetter('_g', null);
1364 assertNotSuggested('b');
1365 assertNotSuggested('_c');
1366 assertNotSuggested('d');
1367 assertNotSuggested('_e');
1368 assertNotSuggested('s1');
1369 assertNotSuggested('_s2');
1370 assertNotSuggested('m');
1371 assertNotSuggested('_n');
1372 assertNotSuggested('a');
1373 assertNotSuggested('A');
1374 assertNotSuggested('X');
1375 assertNotSuggested('Object');
1376 assertNotSuggested('==');
1377 });
1378 }
1379
1346 test_PrefixedIdentifier_class_imported() { 1380 test_PrefixedIdentifier_class_imported() {
1347 // SimpleIdentifier PrefixedIdentifier ExpressionStatement 1381 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
1348 addSource('/testB.dart', ''' 1382 addSource('/testB.dart', '''
1349 lib B; 1383 lib B;
1350 class I {X get f => new A();get _g => new A();} 1384 class I {X get f => new A();get _g => new A();}
1351 class A implements I { 1385 class A implements I {
1352 var b; X _c; 1386 var b; X _c;
1353 X get d => new A();get _e => new A(); 1387 X get d => new A();get _e => new A();
1354 set s1(I x) {} set _s2(I x) {} 1388 set s1(I x) {} set _s2(I x) {}
1355 m(X x) {} I _n(X x) {}} 1389 m(X x) {} I _n(X x) {}}
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 assertNotSuggested('bar2'); 1615 assertNotSuggested('bar2');
1582 assertNotSuggested('_B'); 1616 assertNotSuggested('_B');
1583 assertSuggestLocalClass('Y'); 1617 assertSuggestLocalClass('Y');
1584 assertSuggestLocalClass('C'); 1618 assertSuggestLocalClass('C');
1585 assertSuggestLocalVariable('f', null); 1619 assertSuggestLocalVariable('f', null);
1586 assertNotSuggested('x'); 1620 assertNotSuggested('x');
1587 assertNotSuggested('e'); 1621 assertNotSuggested('e');
1588 }); 1622 });
1589 } 1623 }
1590 } 1624 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/local_computer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698