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

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

Issue 1076773002: do not suggest local functions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 8 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/test/mock_sdk.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 9 import 'package:analysis_server/src/protocol.dart' as protocol
10 show Element, ElementKind; 10 show Element, ElementKind;
(...skipping 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 assertNotSuggested('=='); 1204 assertNotSuggested('==');
1205 }); 1205 });
1206 } 1206 }
1207 1207
1208 test_Block() { 1208 test_Block() {
1209 // Block BlockFunctionBody MethodDeclaration 1209 // Block BlockFunctionBody MethodDeclaration
1210 addSource('/testAB.dart', ''' 1210 addSource('/testAB.dart', '''
1211 export "dart:math" hide max; 1211 export "dart:math" hide max;
1212 class A {int x;} 1212 class A {int x;}
1213 @deprecated D1() {int x;} 1213 @deprecated D1() {int x;}
1214 class _B { }'''); 1214 class _B {boo() { partBoo() {}} }''');
1215 addSource('/testCD.dart', ''' 1215 addSource('/testCD.dart', '''
1216 String T1; 1216 String T1;
1217 var _T2; 1217 var _T2;
1218 class C { } 1218 class C { }
1219 class D { }'''); 1219 class D { }''');
1220 addSource('/testEEF.dart', ''' 1220 addSource('/testEEF.dart', '''
1221 class EE { } 1221 class EE { }
1222 class F { }'''); 1222 class F { }''');
1223 addSource('/testG.dart', 'class G { }'); 1223 addSource('/testG.dart', 'class G { }');
1224 addSource('/testH.dart', ''' 1224 addSource('/testH.dart', '''
1225 class H { } 1225 class H { }
1226 int T3; 1226 int T3;
1227 var _T4;'''); // not imported 1227 var _T4;'''); // not imported
1228 addTestSource(''' 1228 addTestSource('''
1229 import "/testAB.dart"; 1229 import "/testAB.dart";
1230 import "/testCD.dart" hide D; 1230 import "/testCD.dart" hide D;
1231 import "/testEEF.dart" show EE; 1231 import "/testEEF.dart" show EE;
1232 import "/testG.dart" as g; 1232 import "/testG.dart" as g;
1233 int T5; 1233 int T5;
1234 var _T6; 1234 var _T6;
1235 String get T7 => 'hello'; 1235 String get T7 => 'hello';
1236 set T8(int value) { } 1236 set T8(int value) { partT8() {} }
1237 Z D2() {int x;} 1237 Z D2() {int x;}
1238 class X { 1238 class X {
1239 int get clog => 8; 1239 int get clog => 8;
1240 set blog(value) { } 1240 set blog(value) { }
1241 a() { 1241 a() {
1242 var f; 1242 var f;
1243 localF(int arg1) { } 1243 localF(int arg1) { }
1244 {var x;} 1244 {var x;}
1245 ^ var r; 1245 ^ var r;
1246 } 1246 }
1247 void b() { }} 1247 void b() { }}
1248 class Z { }'''); 1248 class Z { }''');
1249 computeFast(); 1249 computeFast();
1250 return computeFull((bool result) { 1250 return computeFull((bool result) {
1251 expect(request.replacementOffset, completionOffset); 1251 expect(request.replacementOffset, completionOffset);
1252 expect(request.replacementLength, 0); 1252 expect(request.replacementLength, 0);
1253 1253
1254 assertSuggestLocalClass('X'); 1254 assertSuggestLocalClass('X');
1255 assertSuggestLocalClass('Z'); 1255 assertSuggestLocalClass('Z');
1256 assertSuggestLocalMethod('a', 'X', null); 1256 assertSuggestLocalMethod('a', 'X', null);
1257 assertSuggestLocalMethod('b', 'X', 'void'); 1257 assertSuggestLocalMethod('b', 'X', 'void');
1258 assertSuggestLocalFunction('localF', null); 1258 assertSuggestLocalFunction('localF', null);
1259 assertSuggestLocalVariable('f', null); 1259 assertSuggestLocalVariable('f', null);
1260 // Don't suggest locals out of scope 1260 // Don't suggest locals out of scope
1261 assertNotSuggested('r'); 1261 assertNotSuggested('r');
1262 assertNotSuggested('x'); 1262 assertNotSuggested('x');
1263 assertNotSuggested('partT8');
1263 1264
1264 assertSuggestImportedClass('A'); 1265 assertSuggestImportedClass('A');
1265 assertNotSuggested('_B'); 1266 assertNotSuggested('_B');
1266 assertSuggestImportedClass('C'); 1267 assertSuggestImportedClass('C');
1268 assertNotSuggested('partBoo');
1267 // hidden element suggested as low relevance 1269 // hidden element suggested as low relevance
1268 // but imported results are partially filtered 1270 // but imported results are partially filtered
1269 //assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW); 1271 //assertSuggestImportedClass('D', COMPLETION_RELEVANCE_LOW);
1270 //assertSuggestImportedFunction( 1272 //assertSuggestImportedFunction(
1271 // 'D1', null, true, COMPLETION_RELEVANCE_LOW); 1273 // 'D1', null, true, COMPLETION_RELEVANCE_LOW);
1272 assertSuggestLocalFunction('D2', 'Z'); 1274 assertSuggestLocalFunction('D2', 'Z');
1273 assertSuggestImportedClass('EE'); 1275 assertSuggestImportedClass('EE');
1274 // hidden element suggested as low relevance 1276 // hidden element suggested as low relevance
1275 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW); 1277 //assertSuggestImportedClass('F', COMPLETION_RELEVANCE_LOW);
1276 assertSuggestLibraryPrefix('g'); 1278 assertSuggestLibraryPrefix('g');
(...skipping 15 matching lines...) Expand all
1292 assertNotSuggested('_T4'); 1294 assertNotSuggested('_T4');
1293 assertSuggestLocalTopLevelVar('T5', 'int'); 1295 assertSuggestLocalTopLevelVar('T5', 'int');
1294 assertSuggestLocalTopLevelVar('_T6', null); 1296 assertSuggestLocalTopLevelVar('_T6', null);
1295 assertNotSuggested('=='); 1297 assertNotSuggested('==');
1296 assertSuggestLocalGetter('T7', 'String'); 1298 assertSuggestLocalGetter('T7', 'String');
1297 assertSuggestLocalSetter('T8'); 1299 assertSuggestLocalSetter('T8');
1298 assertSuggestLocalGetter('clog', 'int'); 1300 assertSuggestLocalGetter('clog', 'int');
1299 assertSuggestLocalSetter('blog'); 1301 assertSuggestLocalSetter('blog');
1300 // TODO (danrubel) suggest HtmlElement as low relevance 1302 // TODO (danrubel) suggest HtmlElement as low relevance
1301 assertNotSuggested('HtmlElement'); 1303 assertNotSuggested('HtmlElement');
1304 assertSuggestImportedClass('Uri');
1305 assertNotSuggested('parseIPv6Address');
1306 assertNotSuggested('parseHex');
1302 }); 1307 });
1303 } 1308 }
1304 1309
1305 test_Block_identifier_partial() { 1310 test_Block_identifier_partial() {
1306 addSource('/testAB.dart', ''' 1311 addSource('/testAB.dart', '''
1307 export "dart:math" hide max; 1312 export "dart:math" hide max;
1308 class A {int x;} 1313 class A {int x;}
1309 @deprecated D1() {int x;} 1314 @deprecated D1() {int x;}
1310 class _B { }'''); 1315 class _B { }''');
1311 addSource('/testCD.dart', ''' 1316 addSource('/testCD.dart', '''
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 assertSuggestLocalField('m1', null); 1437 assertSuggestLocalField('m1', null);
1433 assertSuggestLocalGetter('f3', null); 1438 assertSuggestLocalGetter('f3', null);
1434 assertSuggestLocalSetter('f4'); 1439 assertSuggestLocalSetter('f4');
1435 assertSuggestLocalMethod('e2', 'E', null); 1440 assertSuggestLocalMethod('e2', 'E', null);
1436 assertSuggestLocalMethod('f2', 'F', null); 1441 assertSuggestLocalMethod('f2', 'F', null);
1437 assertSuggestLocalMethod('i2', 'I', null); 1442 assertSuggestLocalMethod('i2', 'I', null);
1438 assertSuggestLocalMethod('m2', 'M', 'int'); 1443 assertSuggestLocalMethod('m2', 'M', 'int');
1439 }); 1444 });
1440 } 1445 }
1441 1446
1447 test_Block_local_function() {
1448 addSource('/testAB.dart', '''
1449 export "dart:math" hide max;
1450 class A {int x;}
1451 @deprecated D1() {int x;}
1452 class _B {boo() { partBoo() {}} }''');
1453 addSource('/testCD.dart', '''
1454 String T1;
1455 var _T2;
1456 class C { }
1457 class D { }''');
1458 addSource('/testEEF.dart', '''
1459 class EE { }
1460 class F { }''');
1461 addSource('/testG.dart', 'class G { }');
1462 addSource('/testH.dart', '''
1463 class H { }
1464 int T3;
1465 var _T4;'''); // not imported
1466 addTestSource('''
1467 import "/testAB.dart";
1468 import "/testCD.dart" hide D;
1469 import "/testEEF.dart" show EE;
1470 import "/testG.dart" as g;
1471 int T5;
1472 var _T6;
1473 String get T7 => 'hello';
1474 set T8(int value) { partT8() {} }
1475 Z D2() {int x;}
1476 class X {
1477 int get clog => 8;
1478 set blog(value) { }
1479 a() {
1480 var f;
1481 localF(int arg1) { }
1482 {var x;}
1483 p^ var r;
1484 }
1485 void b() { }}
1486 class Z { }''');
1487 computeFast();
1488 return computeFull((bool result) {
1489 expect(request.replacementOffset, completionOffset - 1);
1490 expect(request.replacementLength, 1);
1491
1492 assertNotSuggested('partT8');
1493 assertNotSuggested('partBoo');
1494 assertNotSuggested('parseIPv6Address');
1495 assertNotSuggested('parseHex');
1496 });
1497 }
1498
1442 test_Block_unimported() { 1499 test_Block_unimported() {
1443 addSource('/testAB.dart', 'class Foo { }'); 1500 addSource('/testAB.dart', 'class Foo { }');
1444 addTestSource('class C {foo(){F^}}'); 1501 addTestSource('class C {foo(){F^}}');
1445 computeFast(); 1502 computeFast();
1446 return computeFull((bool result) { 1503 return computeFull((bool result) {
1447 expect(request.replacementOffset, completionOffset - 1); 1504 expect(request.replacementOffset, completionOffset - 1);
1448 expect(request.replacementLength, 1); 1505 expect(request.replacementLength, 1);
1449 assertSuggestImportedClass('Foo', relevance: DART_RELEVANCE_LOW); 1506 assertSuggestImportedClass('Foo', relevance: DART_RELEVANCE_LOW);
1450 assertSuggestImportedClass('Future', relevance: DART_RELEVANCE_LOW); 1507 assertSuggestImportedClass('Future', relevance: DART_RELEVANCE_LOW);
1451 }); 1508 });
(...skipping 2305 matching lines...) Expand 10 before | Expand all | Expand 10 after
3757 assertNotSuggested('bar2'); 3814 assertNotSuggested('bar2');
3758 assertNotSuggested('_B'); 3815 assertNotSuggested('_B');
3759 assertSuggestLocalClass('Y'); 3816 assertSuggestLocalClass('Y');
3760 assertSuggestLocalClass('C'); 3817 assertSuggestLocalClass('C');
3761 assertSuggestLocalVariable('f', null); 3818 assertSuggestLocalVariable('f', null);
3762 assertNotSuggested('x'); 3819 assertNotSuggested('x');
3763 assertNotSuggested('e'); 3820 assertNotSuggested('e');
3764 }); 3821 });
3765 } 3822 }
3766 } 3823 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/mock_sdk.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698