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

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

Issue 897483003: fix named param default value code completion (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 10 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.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 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 addTestSource(''' 1525 addTestSource('''
1526 import "/testAB.dart" show ^; 1526 import "/testAB.dart" show ^;
1527 import "/testCD.dart"; 1527 import "/testCD.dart";
1528 class X {}'''); 1528 class X {}''');
1529 computeFast(); 1529 computeFast();
1530 return computeFull((bool result) { 1530 return computeFull((bool result) {
1531 assertNoSuggestions(); 1531 assertNoSuggestions();
1532 }); 1532 });
1533 } 1533 }
1534 1534
1535 test_ConditionalExpression_partial_thenExpression() { 1535 test_ConditionalExpression_elseExpression() {
1536 // SimpleIdentifier ConditionalExpression ReturnStatement 1536 // SimpleIdentifier ConditionalExpression ReturnStatement
1537 addSource('/testA.dart', ''' 1537 addSource('/testA.dart', '''
1538 int T1; 1538 int T1;
1539 F1() { } 1539 F1() { }
1540 class A {int x;}'''); 1540 class A {int x;}''');
1541 addTestSource(''' 1541 addTestSource('''
1542 import "/testA.dart"; 1542 import "/testA.dart";
1543 int T2; 1543 int T2;
1544 F2() { } 1544 F2() { }
1545 class B {int x;} 1545 class B {int x;}
1546 class C {foo(){var f; {var x;} return a ? T^}}'''); 1546 class C {foo(){var f; {var x;} return a ? T1 : T^}}''');
1547 computeFast(); 1547 computeFast();
1548 return computeFull((bool result) { 1548 return computeFull((bool result) {
1549 // top level results are partially filtered based on first char 1549 // top level results are partially filtered based on first char
1550 assertSuggestLocalTopLevelVar('T2', 'int'); 1550 assertSuggestLocalTopLevelVar('T2', 'int');
1551 // TODO (danrubel) getter is being suggested instead of top level var 1551 // TODO (danrubel) getter is being suggested instead of top level var
1552 //assertSuggestImportedTopLevelVar('T1', 'int'); 1552 //assertSuggestImportedTopLevelVar('T1', 'int');
1553 }); 1553 });
1554 } 1554 }
1555 1555
1556 test_ConditionalExpression_partial_thenExpression_empty() { 1556 test_ConditionalExpression_elseExpression_empty() {
1557 // SimpleIdentifier ConditionalExpression ReturnStatement 1557 // SimpleIdentifier ConditionalExpression ReturnStatement
1558 addSource('/testA.dart', ''' 1558 addSource('/testA.dart', '''
1559 int T1; 1559 int T1;
1560 F1() { } 1560 F1() { }
1561 class A {int x;}'''); 1561 class A {int x;}''');
1562 addTestSource(''' 1562 addTestSource('''
1563 import "/testA.dart"; 1563 import "/testA.dart";
1564 int T2; 1564 int T2;
1565 F2() { } 1565 F2() { }
1566 class B {int x;} 1566 class B {int x;}
1567 class C {foo(){var f; {var x;} return a ? ^}}'''); 1567 class C {foo(){var f; {var x;} return a ? T1 : ^}}''');
1568 computeFast(); 1568 computeFast();
1569 return computeFull((bool result) { 1569 return computeFull((bool result) {
1570 assertNotSuggested('x'); 1570 assertNotSuggested('x');
1571 assertSuggestLocalVariable('f', null); 1571 assertSuggestLocalVariable('f', null);
1572 assertSuggestLocalMethod('foo', 'C', null); 1572 assertSuggestLocalMethod('foo', 'C', null);
1573 assertSuggestLocalClass('C'); 1573 assertSuggestLocalClass('C');
1574 assertSuggestLocalFunction('F2', null); 1574 assertSuggestLocalFunction('F2', null);
1575 assertSuggestLocalTopLevelVar('T2', 'int'); 1575 assertSuggestLocalTopLevelVar('T2', 'int');
1576 assertSuggestImportedClass('A'); 1576 assertSuggestImportedClass('A');
1577 assertSuggestImportedFunction('F1', null); 1577 assertSuggestImportedFunction('F1', null);
1578 // TODO (danrubel) getter is being suggested instead of top level var 1578 // TODO (danrubel) getter is being suggested instead of top level var
1579 //assertSuggestImportedTopLevelVar('T1', 'int'); 1579 //assertSuggestImportedTopLevelVar('T1', 'int');
1580 }); 1580 });
1581 } 1581 }
1582 1582
1583 test_ConditionalExpression_elseExpression() { 1583 test_ConditionalExpression_partial_thenExpression() {
1584 // SimpleIdentifier ConditionalExpression ReturnStatement 1584 // SimpleIdentifier ConditionalExpression ReturnStatement
1585 addSource('/testA.dart', ''' 1585 addSource('/testA.dart', '''
1586 int T1; 1586 int T1;
1587 F1() { } 1587 F1() { }
1588 class A {int x;}'''); 1588 class A {int x;}''');
1589 addTestSource(''' 1589 addTestSource('''
1590 import "/testA.dart"; 1590 import "/testA.dart";
1591 int T2; 1591 int T2;
1592 F2() { } 1592 F2() { }
1593 class B {int x;} 1593 class B {int x;}
1594 class C {foo(){var f; {var x;} return a ? T1 : T^}}'''); 1594 class C {foo(){var f; {var x;} return a ? T^}}''');
1595 computeFast(); 1595 computeFast();
1596 return computeFull((bool result) { 1596 return computeFull((bool result) {
1597 // top level results are partially filtered based on first char 1597 // top level results are partially filtered based on first char
1598 assertSuggestLocalTopLevelVar('T2', 'int'); 1598 assertSuggestLocalTopLevelVar('T2', 'int');
1599 // TODO (danrubel) getter is being suggested instead of top level var 1599 // TODO (danrubel) getter is being suggested instead of top level var
1600 //assertSuggestImportedTopLevelVar('T1', 'int'); 1600 //assertSuggestImportedTopLevelVar('T1', 'int');
1601 }); 1601 });
1602 } 1602 }
1603 1603
1604 test_ConditionalExpression_elseExpression_empty() { 1604 test_ConditionalExpression_partial_thenExpression_empty() {
1605 // SimpleIdentifier ConditionalExpression ReturnStatement 1605 // SimpleIdentifier ConditionalExpression ReturnStatement
1606 addSource('/testA.dart', ''' 1606 addSource('/testA.dart', '''
1607 int T1; 1607 int T1;
1608 F1() { } 1608 F1() { }
1609 class A {int x;}'''); 1609 class A {int x;}''');
1610 addTestSource(''' 1610 addTestSource('''
1611 import "/testA.dart"; 1611 import "/testA.dart";
1612 int T2; 1612 int T2;
1613 F2() { } 1613 F2() { }
1614 class B {int x;} 1614 class B {int x;}
1615 class C {foo(){var f; {var x;} return a ? T1 : ^}}'''); 1615 class C {foo(){var f; {var x;} return a ? ^}}''');
1616 computeFast(); 1616 computeFast();
1617 return computeFull((bool result) { 1617 return computeFull((bool result) {
1618 assertNotSuggested('x'); 1618 assertNotSuggested('x');
1619 assertSuggestLocalVariable('f', null); 1619 assertSuggestLocalVariable('f', null);
1620 assertSuggestLocalMethod('foo', 'C', null); 1620 assertSuggestLocalMethod('foo', 'C', null);
1621 assertSuggestLocalClass('C'); 1621 assertSuggestLocalClass('C');
1622 assertSuggestLocalFunction('F2', null); 1622 assertSuggestLocalFunction('F2', null);
1623 assertSuggestLocalTopLevelVar('T2', 'int'); 1623 assertSuggestLocalTopLevelVar('T2', 'int');
1624 assertSuggestImportedClass('A'); 1624 assertSuggestImportedClass('A');
1625 assertSuggestImportedFunction('F1', null); 1625 assertSuggestImportedFunction('F1', null);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 expect(request.replacementLength, 0); 1752 expect(request.replacementLength, 0);
1753 assertSuggestNamedConstructor('c', 'X'); 1753 assertSuggestNamedConstructor('c', 'X');
1754 assertSuggestNamedConstructor('_d', 'X'); 1754 assertSuggestNamedConstructor('_d', 'X');
1755 assertNotSuggested('F1'); 1755 assertNotSuggested('F1');
1756 assertNotSuggested('T1'); 1756 assertNotSuggested('T1');
1757 assertNotSuggested('z'); 1757 assertNotSuggested('z');
1758 assertNotSuggested('m'); 1758 assertNotSuggested('m');
1759 }); 1759 });
1760 } 1760 }
1761 1761
1762 test_DefaultFormalParameter_named_expression() {
1763 // DefaultFormalParameter FormalParameterList MethodDeclaration
1764 addTestSource('''
1765 foo() { }
1766 void bar() { }
1767 class A {a(blat: ^) { }}''');
1768 computeFast();
1769 return computeFull((bool result) {
1770 expect(request.replacementOffset, completionOffset);
1771 expect(request.replacementLength, 0);
1772 assertSuggestLocalFunction('foo', null);
1773 assertSuggestLocalMethod('a', 'A', null);
1774 assertSuggestLocalClass('A');
1775 assertSuggestImportedClass('String');
1776 assertSuggestImportedFunction('identical', 'bool');
1777 assertNotSuggested('bar');
1778 });
1779 }
1780
1762 test_ExpressionStatement_identifier() { 1781 test_ExpressionStatement_identifier() {
1763 // SimpleIdentifier ExpressionStatement Block 1782 // SimpleIdentifier ExpressionStatement Block
1764 addSource('/testA.dart', ''' 1783 addSource('/testA.dart', '''
1765 _B F1() { } 1784 _B F1() { }
1766 class A {int x;} 1785 class A {int x;}
1767 class _B { }'''); 1786 class _B { }''');
1768 addTestSource(''' 1787 addTestSource('''
1769 import "/testA.dart"; 1788 import "/testA.dart";
1770 typedef int F2(int blat); 1789 typedef int F2(int blat);
1771 class Clz = Object with Object; 1790 class Clz = Object with Object;
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2876 assertNotSuggested('bar2'); 2895 assertNotSuggested('bar2');
2877 assertNotSuggested('_B'); 2896 assertNotSuggested('_B');
2878 assertSuggestLocalClass('Y'); 2897 assertSuggestLocalClass('Y');
2879 assertSuggestLocalClass('C'); 2898 assertSuggestLocalClass('C');
2880 assertSuggestLocalVariable('f', null); 2899 assertSuggestLocalVariable('f', null);
2881 assertNotSuggested('x'); 2900 assertNotSuggested('x');
2882 assertNotSuggested('e'); 2901 assertNotSuggested('e');
2883 }); 2902 });
2884 } 2903 }
2885 } 2904 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698