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

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

Issue 658053002: filter void methods when suggesting expression (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 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 } 955 }
956 956
957 test_ExpressionStatement_identifier() { 957 test_ExpressionStatement_identifier() {
958 // SimpleIdentifier ExpressionStatement Block 958 // SimpleIdentifier ExpressionStatement Block
959 addSource('/testA.dart', ''' 959 addSource('/testA.dart', '''
960 _B F1() { } 960 _B F1() { }
961 class A {int x;} 961 class A {int x;}
962 class _B { }'''); 962 class _B { }''');
963 addTestSource(''' 963 addTestSource('''
964 import "/testA.dart"; 964 import "/testA.dart";
965 class C {foo(){O^}}'''); 965 class C {foo(){O^} void bar() {}}''');
966 computeFast(); 966 computeFast();
967 return computeFull(true).then((_) { 967 return computeFull(true).then((_) {
968 assertSuggestImportedClass('A'); 968 assertSuggestImportedClass('A');
969 assertSuggestImportedFunction('F1', '_B', false); 969 assertSuggestImportedFunction('F1', '_B', false);
970 assertSuggestLocalClass('C'); 970 assertSuggestLocalClass('C');
971 assertSuggestLocalMethod('foo', 'C', null);
972 assertSuggestLocalMethod('bar', 'C', 'void');
973 assertSuggestLocalClass('C');
971 assertNotSuggested('x'); 974 assertNotSuggested('x');
972 assertNotSuggested('_B'); 975 assertNotSuggested('_B');
973 }); 976 });
974 } 977 }
975 978
976 test_ExpressionStatement_name() { 979 test_ExpressionStatement_name() {
977 // ExpressionStatement Block BlockFunctionBody MethodDeclaration 980 // ExpressionStatement Block BlockFunctionBody MethodDeclaration
978 addSource('/testA.dart', ''' 981 addSource('/testA.dart', '''
979 B T1; 982 B T1;
980 class B{}'''); 983 class B{}''');
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 // SimpleIdentifier ForStatement 1070 // SimpleIdentifier ForStatement
1068 addTestSource('main() {for (int index = 0; index < 10; i^)}'); 1071 addTestSource('main() {for (int index = 0; index < 10; i^)}');
1069 computeFast(); 1072 computeFast();
1070 return computeFull(true).then((_) { 1073 return computeFull(true).then((_) {
1071 assertSuggestLocalVariable('index', 'int'); 1074 assertSuggestLocalVariable('index', 'int');
1072 }); 1075 });
1073 } 1076 }
1074 1077
1075 test_ForStatement_updaters_prefix_expression() { 1078 test_ForStatement_updaters_prefix_expression() {
1076 // SimpleIdentifier PrefixExpression ForStatement 1079 // SimpleIdentifier PrefixExpression ForStatement
1077 addTestSource('main() {for (int index = 0; index < 10; ++i^)}'); 1080 addTestSource('''
1081 void bar() { }
1082 main() {for (int index = 0; index < 10; ++i^)}''');
1078 computeFast(); 1083 computeFast();
1079 return computeFull(true).then((_) { 1084 return computeFull(true).then((_) {
1080 assertSuggestLocalVariable('index', 'int'); 1085 assertSuggestLocalVariable('index', 'int');
1086 assertSuggestLocalFunction('main', null);
1087 assertNotSuggested('bar');
1081 }); 1088 });
1082 } 1089 }
1083 1090
1084 test_FunctionExpression_body_function() { 1091 test_FunctionExpression_body_function() {
1085 // Block BlockFunctionBody FunctionExpression 1092 // Block BlockFunctionBody FunctionExpression
1086 addTestSource('String foo(List args) {x.then((R b) {^});}'); 1093 addTestSource('''
1094 void bar() { }
1095 String foo(List args) {x.then((R b) {^});}''');
1087 computeFast(); 1096 computeFast();
1088 return computeFull(true).then((_) { 1097 return computeFull(true).then((_) {
1089 var f = assertSuggestLocalFunction('foo', 'String', false); 1098 var f = assertSuggestLocalFunction('foo', 'String', false);
1090 if (f != null) { 1099 if (f != null) {
1091 expect(f.element.isPrivate, isFalse); 1100 expect(f.element.isPrivate, isFalse);
1092 } 1101 }
1102 assertSuggestLocalFunction('bar', 'void');
1093 assertSuggestParameter('args', 'List'); 1103 assertSuggestParameter('args', 'List');
1094 assertSuggestParameter('b', 'R'); 1104 assertSuggestParameter('b', 'R');
1095 assertSuggestImportedClass('Object'); 1105 assertSuggestImportedClass('Object');
1096 }); 1106 });
1097 } 1107 }
1098 1108
1099 test_IfStatement_condition() { 1109 test_IfStatement_condition() {
1100 // SimpleIdentifier IfStatement Block BlockFunctionBody 1110 // SimpleIdentifier IfStatement Block BlockFunctionBody
1101 addTestSource(''' 1111 addTestSource('''
1102 class A {int x; int y() => 0;} 1112 class A {int x; int y() => 0;}
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 assertSuggestLocalClass('Y'); 1218 assertSuggestLocalClass('Y');
1209 assertNotSuggested('x'); 1219 assertNotSuggested('x');
1210 assertNotSuggested('main'); 1220 assertNotSuggested('main');
1211 assertNotSuggested('foo'); 1221 assertNotSuggested('foo');
1212 }); 1222 });
1213 } 1223 }
1214 1224
1215 test_IsExpression_target() { 1225 test_IsExpression_target() {
1216 // IfStatement Block BlockFunctionBody 1226 // IfStatement Block BlockFunctionBody
1217 addTestSource(''' 1227 addTestSource('''
1228 foo() { }
1229 void bar() { }
1218 class A {int x; int y() => 0;} 1230 class A {int x; int y() => 0;}
1219 main(){var a; if (^ is A)}'''); 1231 main(){var a; if (^ is A)}''');
1220 computeFast(); 1232 computeFast();
1221 return computeFull(true).then((_) { 1233 return computeFull(true).then((_) {
1222 assertSuggestLocalVariable('a', null); 1234 assertSuggestLocalVariable('a', null);
1223 assertSuggestLocalFunction('main', null); 1235 assertSuggestLocalFunction('main', null);
1236 assertSuggestLocalFunction('foo', null);
1237 assertNotSuggested('bar');
1224 assertSuggestLocalClass('A'); 1238 assertSuggestLocalClass('A');
1225 assertSuggestImportedClass('Object'); 1239 assertSuggestImportedClass('Object');
1226 }); 1240 });
1227 } 1241 }
1228 1242
1229 test_IsExpression_type() { 1243 test_IsExpression_type() {
1230 // SimpleIdentifier TypeName IsExpression IfStatement 1244 // SimpleIdentifier TypeName IsExpression IfStatement
1231 addTestSource(''' 1245 addTestSource('''
1232 class A {int x; int y() => 0;} 1246 class A {int x; int y() => 0;}
1233 main(){var a; if (a is ^)}'''); 1247 main(){var a; if (a is ^)}''');
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 expect(methodA.element.isPrivate, isFalse); 1321 expect(methodA.element.isPrivate, isFalse);
1308 } 1322 }
1309 assertSuggestParameter('x', 'X'); 1323 assertSuggestParameter('x', 'X');
1310 assertSuggestParameter('y', null); 1324 assertSuggestParameter('y', null);
1311 assertSuggestImportedClass('int'); 1325 assertSuggestImportedClass('int');
1312 }); 1326 });
1313 } 1327 }
1314 1328
1315 test_MethodDeclaration_parameters_positional() { 1329 test_MethodDeclaration_parameters_positional() {
1316 // Block BlockFunctionBody MethodDeclaration 1330 // Block BlockFunctionBody MethodDeclaration
1317 addTestSource('class A {Z a(X x, [int y=1]) {^}}'); 1331 addTestSource('''
1332 foo() { }
1333 void bar() { }
1334 class A {Z a(X x, [int y=1]) {^}}''');
1318 computeFast(); 1335 computeFast();
1319 return computeFull(true).then((_) { 1336 return computeFull(true).then((_) {
1337 assertSuggestLocalFunction('foo', null);
1338 assertSuggestLocalFunction('bar', 'void');
1320 assertSuggestLocalMethod('a', 'A', 'Z'); 1339 assertSuggestLocalMethod('a', 'A', 'Z');
1321 assertSuggestParameter('x', 'X'); 1340 assertSuggestParameter('x', 'X');
1322 assertSuggestParameter('y', 'int'); 1341 assertSuggestParameter('y', 'int');
1323 assertSuggestImportedClass('String'); 1342 assertSuggestImportedClass('String');
1324 }); 1343 });
1325 } 1344 }
1326 1345
1327 test_PrefixedIdentifier_class_imported() { 1346 test_PrefixedIdentifier_class_imported() {
1328 // SimpleIdentifier PrefixedIdentifier ExpressionStatement 1347 // SimpleIdentifier PrefixedIdentifier ExpressionStatement
1329 addSource('/testB.dart', ''' 1348 addSource('/testB.dart', '''
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 assertNotSuggested('_B'); 1468 assertNotSuggested('_B');
1450 }); 1469 });
1451 } 1470 }
1452 1471
1453 test_PropertyAccess_expression() { 1472 test_PropertyAccess_expression() {
1454 // SimpleIdentifier MethodInvocation PropertyAccess ExpressionStatement 1473 // SimpleIdentifier MethodInvocation PropertyAccess ExpressionStatement
1455 addTestSource('class A {a() {"hello".to^String().length}}'); 1474 addTestSource('class A {a() {"hello".to^String().length}}');
1456 computeFast(); 1475 computeFast();
1457 return computeFull(true).then((_) { 1476 return computeFull(true).then((_) {
1458 assertSuggestInvocationGetter('length', 'int'); 1477 assertSuggestInvocationGetter('length', 'int');
1459 assertNotSuggested('==');
1460 assertNotSuggested('A'); 1478 assertNotSuggested('A');
1461 assertNotSuggested('a'); 1479 assertNotSuggested('a');
1462 assertNotSuggested('Object'); 1480 assertNotSuggested('Object');
1463 assertNotSuggested('=='); 1481 assertNotSuggested('==');
1464 }); 1482 });
1465 } 1483 }
1466 1484
1467 test_PropertyAccess_selector() { 1485 test_PropertyAccess_selector() {
1468 // SimpleIdentifier PropertyAccess ExpressionStatement Block 1486 // SimpleIdentifier PropertyAccess ExpressionStatement Block
1469 addTestSource('class A {a() {"hello".length.^}}'); 1487 addTestSource('class A {a() {"hello".length.^}}');
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 assertNotSuggested('x'); 1555 assertNotSuggested('x');
1538 assertNotSuggested('e'); 1556 assertNotSuggested('e');
1539 }); 1557 });
1540 } 1558 }
1541 1559
1542 test_VariableDeclarationStatement_RHS_missing_semicolon() { 1560 test_VariableDeclarationStatement_RHS_missing_semicolon() {
1543 // VariableDeclaration VariableDeclarationList 1561 // VariableDeclaration VariableDeclarationList
1544 // VariableDeclarationStatement 1562 // VariableDeclarationStatement
1545 addSource('/testB.dart', ''' 1563 addSource('/testB.dart', '''
1546 lib B; 1564 lib B;
1547 foo() { } 1565 foo1() { }
1566 void bar1() { }
1548 class _B { } 1567 class _B { }
1549 class X {X.c(); X._d(); z() {}}'''); 1568 class X {X.c(); X._d(); z() {}}''');
1550 addTestSource(''' 1569 addTestSource('''
1551 import "/testB.dart"; 1570 import "/testB.dart";
1571 foo2() { }
1572 void bar2() { }
1552 class Y {Y.c(); Y._d(); z() {}} 1573 class Y {Y.c(); Y._d(); z() {}}
1553 class C {bar(){var f; {var x;} var e = ^ var g}}'''); 1574 class C {bar(){var f; {var x;} var e = ^ var g}}''');
1554 computeFast(); 1575 computeFast();
1555 return computeFull(true).then((_) { 1576 return computeFull(true).then((_) {
1556 assertSuggestImportedClass('X'); 1577 assertSuggestImportedClass('X');
1578 assertSuggestImportedFunction('foo1', null);
1579 assertNotSuggested('bar1');
1580 assertSuggestLocalFunction('foo2', null);
1581 assertNotSuggested('bar2');
1557 assertNotSuggested('_B'); 1582 assertNotSuggested('_B');
1558 assertSuggestLocalClass('Y'); 1583 assertSuggestLocalClass('Y');
1559 assertSuggestLocalClass('C'); 1584 assertSuggestLocalClass('C');
1560 assertSuggestLocalVariable('f', null); 1585 assertSuggestLocalVariable('f', null);
1561 assertNotSuggested('x'); 1586 assertNotSuggested('x');
1562 assertNotSuggested('e'); 1587 assertNotSuggested('e');
1563 }); 1588 });
1564 } 1589 }
1565 } 1590 }
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