| OLD | NEW |
| 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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 CompletionSuggestion assertSuggestLocalTopLevelVar(String name, | 545 CompletionSuggestion assertSuggestLocalTopLevelVar(String name, |
| 546 String returnType, [CompletionRelevance relevance = | 546 String returnType, [CompletionRelevance relevance = |
| 547 CompletionRelevance.DEFAULT]) { | 547 CompletionRelevance.DEFAULT]) { |
| 548 if (computer is LocalComputer) { | 548 if (computer is LocalComputer) { |
| 549 return assertSuggestTopLevelVar(name, returnType, relevance); | 549 return assertSuggestTopLevelVar(name, returnType, relevance); |
| 550 } else { | 550 } else { |
| 551 return assertNotSuggested(name); | 551 return assertNotSuggested(name); |
| 552 } | 552 } |
| 553 } | 553 } |
| 554 | 554 |
| 555 test_ArgumentList() { |
| 556 // ArgumentList MethodInvocation ExpressionStatement Block |
| 557 addSource('/libA.dart', ''' |
| 558 library A; |
| 559 bool hasLength(int expected) { }'''); |
| 560 addTestSource(''' |
| 561 import '/libA.dart' |
| 562 main() {expect(^)}'''); |
| 563 computeFast(); |
| 564 return computeFull(true).then((_) { |
| 565 assertSuggestLocalFunction('main', null); |
| 566 assertSuggestImportedFunction('hasLength', 'bool'); |
| 567 }); |
| 568 } |
| 569 |
| 555 test_AssignmentExpression_name() { | 570 test_AssignmentExpression_name() { |
| 556 // SimpleIdentifier VariableDeclaration VariableDeclarationList | 571 // SimpleIdentifier VariableDeclaration VariableDeclarationList |
| 557 // VariableDeclarationStatement Block | 572 // VariableDeclarationStatement Block |
| 558 addTestSource('class A {} main() {int a; int ^b = 1;}'); | 573 addTestSource('class A {} main() {int a; int ^b = 1;}'); |
| 559 computeFast(); | 574 computeFast(); |
| 560 return computeFull(true).then((_) { | 575 return computeFull(true).then((_) { |
| 561 assertNoSuggestions(); | 576 assertNoSuggestions(); |
| 562 }); | 577 }); |
| 563 } | 578 } |
| 564 | 579 |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1392 assertNotSuggested('m'); | 1407 assertNotSuggested('m'); |
| 1393 assertNotSuggested('_n'); | 1408 assertNotSuggested('_n'); |
| 1394 assertNotSuggested('a'); | 1409 assertNotSuggested('a'); |
| 1395 assertNotSuggested('A'); | 1410 assertNotSuggested('A'); |
| 1396 assertNotSuggested('X'); | 1411 assertNotSuggested('X'); |
| 1397 assertNotSuggested('Object'); | 1412 assertNotSuggested('Object'); |
| 1398 assertNotSuggested('=='); | 1413 assertNotSuggested('=='); |
| 1399 }); | 1414 }); |
| 1400 } | 1415 } |
| 1401 | 1416 |
| 1402 test_PrefixedIdentifier_propertyAccess() { | |
| 1403 // PrefixedIdentifier ExpressionStatement Block BlockFunctionBody | |
| 1404 addTestSource('class A {String x; int get foo {x.^}'); | |
| 1405 computeFast(); | |
| 1406 return computeFull(true).then((_) { | |
| 1407 assertSuggestInvocationGetter('isEmpty', 'bool'); | |
| 1408 assertSuggestInvocationMethod('compareTo', 'Comparable', 'int'); | |
| 1409 }); | |
| 1410 } | |
| 1411 | |
| 1412 test_PrefixedIdentifier_class_imported() { | 1417 test_PrefixedIdentifier_class_imported() { |
| 1413 // SimpleIdentifier PrefixedIdentifier ExpressionStatement | 1418 // SimpleIdentifier PrefixedIdentifier ExpressionStatement |
| 1414 addSource('/testB.dart', ''' | 1419 addSource('/testB.dart', ''' |
| 1415 lib B; | 1420 lib B; |
| 1416 class I {X get f => new A();get _g => new A();} | 1421 class I {X get f => new A();get _g => new A();} |
| 1417 class A implements I { | 1422 class A implements I { |
| 1418 var b; X _c; | 1423 var b; X _c; |
| 1419 X get d => new A();get _e => new A(); | 1424 X get d => new A();get _e => new A(); |
| 1420 set s1(I x) {} set _s2(I x) {} | 1425 set s1(I x) {} set _s2(I x) {} |
| 1421 m(X x) {} I _n(X x) {}} | 1426 m(X x) {} I _n(X x) {}} |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 computeFast(); | 1533 computeFast(); |
| 1529 return computeFull(true).then((_) { | 1534 return computeFull(true).then((_) { |
| 1530 assertSuggestImportedClass('A'); | 1535 assertSuggestImportedClass('A'); |
| 1531 assertSuggestLocalClass('X'); | 1536 assertSuggestLocalClass('X'); |
| 1532 assertSuggestLocalMethod('foo', 'X', null); | 1537 assertSuggestLocalMethod('foo', 'X', null); |
| 1533 assertNotSuggested('bar'); | 1538 assertNotSuggested('bar'); |
| 1534 assertNotSuggested('_B'); | 1539 assertNotSuggested('_B'); |
| 1535 }); | 1540 }); |
| 1536 } | 1541 } |
| 1537 | 1542 |
| 1543 test_PrefixedIdentifier_propertyAccess() { |
| 1544 // PrefixedIdentifier ExpressionStatement Block BlockFunctionBody |
| 1545 addTestSource('class A {String x; int get foo {x.^}'); |
| 1546 computeFast(); |
| 1547 return computeFull(true).then((_) { |
| 1548 assertSuggestInvocationGetter('isEmpty', 'bool'); |
| 1549 assertSuggestInvocationMethod('compareTo', 'Comparable', 'int'); |
| 1550 }); |
| 1551 } |
| 1552 |
| 1538 test_PropertyAccess_expression() { | 1553 test_PropertyAccess_expression() { |
| 1539 // SimpleIdentifier MethodInvocation PropertyAccess ExpressionStatement | 1554 // SimpleIdentifier MethodInvocation PropertyAccess ExpressionStatement |
| 1540 addTestSource('class A {a() {"hello".to^String().length}}'); | 1555 addTestSource('class A {a() {"hello".to^String().length}}'); |
| 1541 computeFast(); | 1556 computeFast(); |
| 1542 return computeFull(true).then((_) { | 1557 return computeFull(true).then((_) { |
| 1543 assertSuggestInvocationGetter('length', 'int'); | 1558 assertSuggestInvocationGetter('length', 'int'); |
| 1544 assertNotSuggested('A'); | 1559 assertNotSuggested('A'); |
| 1545 assertNotSuggested('a'); | 1560 assertNotSuggested('a'); |
| 1546 assertNotSuggested('Object'); | 1561 assertNotSuggested('Object'); |
| 1547 assertNotSuggested('=='); | 1562 assertNotSuggested('=='); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1647 assertNotSuggested('bar2'); | 1662 assertNotSuggested('bar2'); |
| 1648 assertNotSuggested('_B'); | 1663 assertNotSuggested('_B'); |
| 1649 assertSuggestLocalClass('Y'); | 1664 assertSuggestLocalClass('Y'); |
| 1650 assertSuggestLocalClass('C'); | 1665 assertSuggestLocalClass('C'); |
| 1651 assertSuggestLocalVariable('f', null); | 1666 assertSuggestLocalVariable('f', null); |
| 1652 assertNotSuggested('x'); | 1667 assertNotSuggested('x'); |
| 1653 assertNotSuggested('e'); | 1668 assertNotSuggested('e'); |
| 1654 }); | 1669 }); |
| 1655 } | 1670 } |
| 1656 } | 1671 } |
| OLD | NEW |