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

Side by Side Diff: pkg/analysis_server/test/completion_test.dart

Issue 1838933003: Format code in analysis_server (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 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
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.completion.support; 5 library test.completion.support;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 <String>["1+json"]); 358 <String>["1+json"]);
359 359
360 buildTests( 360 buildTests(
361 'testCommentSnippets049', 361 'testCommentSnippets049',
362 ''' 362 '''
363 import 'dart:convert' as json; 363 import 'dart:convert' as json;
364 import 'dart:convert' as jxx; 364 import 'dart:convert' as jxx;
365 class JsonDecoderX{} 365 class JsonDecoderX{}
366 f1() {var x=new !2j!1s!3}''', 366 f1() {var x=new !2j!1s!3}''',
367 <String>[ 367 <String>[
368 "1+json", 368 "1+json",
369 "1+jxx", 369 "1+jxx",
370 "2+json", 370 "2+json",
371 "2+jxx", 371 "2+jxx",
372 "2-JsonDecoder", 372 "2-JsonDecoder",
373 "3+json", 373 "3+json",
374 "3-jxx" 374 "3-jxx"
375 ]); 375 ]);
376 376
377 buildTests( 377 buildTests(
378 'testCommentSnippets050', 378 'testCommentSnippets050',
379 ''' 379 '''
380 class xdr { 380 class xdr {
381 xdr(); 381 xdr();
382 const xdr.a(a,b,c); 382 const xdr.a(a,b,c);
383 xdr.b(); 383 xdr.b();
384 f() => 3; 384 f() => 3;
385 } 385 }
386 class xa{} 386 class xa{}
387 k() { 387 k() {
388 new x!1dr().f(); 388 new x!1dr().f();
389 const x!2dr.!3a(1, 2, 3); 389 const x!2dr.!3a(1, 2, 3);
390 }''', 390 }''',
391 <String>[ 391 <String>[
392 "1+xdr", 392 "1+xdr",
393 "1+xa", 393 "1+xa",
394 "1+xdr.a", 394 "1+xdr.a",
395 "1+xdr.b", 395 "1+xdr.b",
396 "2+xa", // suggest default constructor 396 "2+xa", // suggest default constructor
397 "2+xdr", // suggest normal constructor 397 "2+xdr", // suggest normal constructor
398 "2+xdr.a", 398 "2+xdr.a",
399 "2+xdr.b", // suggest named constructor 399 "2+xdr.b", // suggest named constructor
400 "3+b", // suggest named constructor 400 "3+b", // suggest named constructor
401 "3+a" 401 "3+a"
402 ]); 402 ]);
403 403
404 // Type propagation. 404 // Type propagation.
405 buildTests( 405 buildTests(
406 'testCommentSnippets051', 406 'testCommentSnippets051',
407 ''' 407 '''
408 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}} 408 class String{int length(){} String toUpperCase(){} bool isEmpty(){}}class Map{ge tKeys(){}}
409 void r() { 409 void r() {
410 var v; 410 var v;
411 if (v is String) { 411 if (v is String) {
412 v.!1length; 412 v.!1length;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 class Line { 562 class Line {
563 Spline j; 563 Spline j;
564 Line g() { 564 Line g() {
565 return this; 565 return this;
566 } 566 }
567 Spline h() { 567 Spline h() {
568 return null; 568 return null;
569 } 569 }
570 }''', 570 }''',
571 <String>[ 571 <String>[
572 "1+a", 572 "1+a",
573 "2+b", 573 "2+b",
574 "1-g", 574 "1-g",
575 "2-h", 575 "2-h",
576 "3+b", 576 "3+b",
577 "4+c", 577 "4+c",
578 "5+a", 578 "5+a",
579 "6+c", 579 "6+c",
580 "7+g", 580 "7+g",
581 "8+j", 581 "8+j",
582 "9+h" 582 "9+h"
583 ]); 583 ]);
584 584
585 buildTests( 585 buildTests(
586 'testCommentSnippets065', 586 'testCommentSnippets065',
587 ''' 587 '''
588 class Spline { 588 class Spline {
589 Line c; 589 Line c;
590 Spline a() { 590 Spline a() {
591 return this; 591 return this;
592 } 592 }
593 Line b() { 593 Line b() {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 factory FileMode._internal1(int this._mode); 811 factory FileMode._internal1(int this._mode);
812 factory FileMode(_mode); 812 factory FileMode(_mode);
813 final int _mode; 813 final int _mode;
814 } 814 }
815 class File { 815 class File {
816 factory File(String path) => null; 816 factory File(String path) => null;
817 factory File.fromPath(Path path) => null; 817 factory File.fromPath(Path path) => null;
818 } 818 }
819 f() => new Fil!1''', 819 f() => new Fil!1''',
820 <String>[ 820 <String>[
821 "1+File", 821 "1+File",
822 "1+File.fromPath", 822 "1+File.fromPath",
823 "1+FileMode", 823 "1+FileMode",
824 "1+FileMode._internal1", 824 "1+FileMode._internal1",
825 "1+FileMode._internal" 825 "1+FileMode._internal"
826 ]); 826 ]);
827 827
828 buildTests( 828 buildTests(
829 'testCommentSnippets078', 829 'testCommentSnippets078',
830 ''' 830 '''
831 class Map{static from()=>null;clear(){}}void main() { Map.!1 }''', 831 class Map{static from()=>null;clear(){}}void main() { Map.!1 }''',
832 <String>["1+from", "1-clear"]); // static method, instance method 832 <String>["1+from", "1-clear"]); // static method, instance method
833 833
834 buildTests( 834 buildTests(
835 'testCommentSnippets079', 835 'testCommentSnippets079',
836 ''' 836 '''
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 class A { 1258 class A {
1259 /** 1259 /**
1260 * [aa!1] 1260 * [aa!1]
1261 * [int!2] 1261 * [int!2]
1262 * [method!3] 1262 * [method!3]
1263 */ 1263 */
1264 methodA(aaa, bbb) {} 1264 methodA(aaa, bbb) {}
1265 methodB() {} 1265 methodB() {}
1266 }''', 1266 }''',
1267 <String>[ 1267 <String>[
1268 "1+aaa", 1268 "1+aaa",
1269 "1-bbb", 1269 "1-bbb",
1270 "2+int", 1270 "2+int",
1271 "2-double", 1271 "2-double",
1272 "3+methodA", 1272 "3+methodA",
1273 "3+methodB", 1273 "3+methodB",
1274 "3-int" 1274 "3-int"
1275 ]); 1275 ]);
1276 1276
1277 buildTests( 1277 buildTests(
1278 'testCompletion_dartDoc_reference_incomplete', 1278 'testCompletion_dartDoc_reference_incomplete',
1279 ''' 1279 '''
1280 /** 1280 /**
1281 * [doubl!1 some text 1281 * [doubl!1 some text
1282 * other text 1282 * other text
1283 */ 1283 */
1284 class A {} 1284 class A {}
1285 /** 1285 /**
1286 * [!2 some text 1286 * [!2 some text
1287 * other text 1287 * other text
1288 */ 1288 */
1289 class B {} 1289 class B {}
1290 /** 1290 /**
1291 * [!3] some text 1291 * [!3] some text
1292 */ 1292 */
1293 class C {}''', 1293 class C {}''',
1294 <String>[ 1294 <String>[
1295 "1+double", 1295 "1+double",
1296 "1-int", 1296 "1-int",
1297 "2+int", 1297 "2+int",
1298 "2+String", 1298 "2+String",
1299 "3+int", 1299 "3+int",
1300 "3+String" 1300 "3+String"
1301 ]); 1301 ]);
1302 1302
1303 buildTests( 1303 buildTests(
1304 'testCompletion_double_inFractionPart', 1304 'testCompletion_double_inFractionPart',
1305 ''' 1305 '''
1306 main() { 1306 main() {
1307 1.0!1 1307 1.0!1
1308 }''', 1308 }''',
1309 <String>["1-abs", "1-main"]); 1309 <String>["1-abs", "1-main"]);
1310 1310
1311 buildTests( 1311 buildTests(
1312 'testCompletion_enum', 1312 'testCompletion_enum',
1313 ''' 1313 '''
1314 enum MyEnum {A, B, C} 1314 enum MyEnum {A, B, C}
1315 main() { 1315 main() {
1316 MyEnum.!1; 1316 MyEnum.!1;
1317 }''', 1317 }''',
1318 <String>["1+values", "1+A", "1+B", "1+C"]); 1318 <String>["1+values", "1+A", "1+B", "1+C"]);
1319 1319
1320 buildTests( 1320 buildTests(
1321 'testCompletion_exactPrefix_hasHigherRelevance', 1321 'testCompletion_exactPrefix_hasHigherRelevance',
1322 ''' 1322 '''
1323 var STR; 1323 var STR;
1324 main(p) { 1324 main(p) {
1325 var str; 1325 var str;
1326 str!1; 1326 str!1;
1327 STR!2; 1327 STR!2;
1328 Str!3; 1328 Str!3;
1329 }''', 1329 }''',
1330 <String>[ 1330 <String>[
1331 "1+str" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 1)*/, 1331 "1+str" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 1)*/,
1332 "1+STR" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 0)*/, 1332 "1+STR" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 0)*/,
1333 "2+STR" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 1)*/, 1333 "2+STR" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 1)*/,
1334 "2+str" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 0)*/, 1334 "2+str" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 0)*/,
1335 "3+String" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 1)*/, 1335 "3+String" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 1)*/,
1336 "3+STR" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 0)*/, 1336 "3+STR" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 0)*/,
1337 "3+str" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 0)*/ 1337 "3+str" /*",rel=" + (CompletionProposal.RELEVANCE_DEFAULT + 0)*/
1338 ]); 1338 ]);
1339 1339
1340 buildTests( 1340 buildTests(
1341 'testCompletion_export_dart', 1341 'testCompletion_export_dart',
1342 ''' 1342 '''
1343 import 'dart:math 1343 import 'dart:math
1344 import 'dart:_chrome 1344 import 'dart:_chrome
1345 import 'dart:_collection.dev 1345 import 'dart:_collection.dev
1346 export 'dart:!1''', 1346 export 'dart:!1''',
1347 <String>[ 1347 <String>[
1348 "1+dart:core", 1348 "1+dart:core",
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 ''' 1587 '''
1588 class MyClass {} 1588 class MyClass {}
1589 main(p) { 1589 main(p) {
1590 var isVariable; 1590 var isVariable;
1591 if (p is MyCla!1) {} 1591 if (p is MyCla!1) {}
1592 var v1 = p is MyCla!2; 1592 var v1 = p is MyCla!2;
1593 var v2 = p is !3; 1593 var v2 = p is !3;
1594 var v2 = p is!4; 1594 var v2 = p is!4;
1595 }''', 1595 }''',
1596 <String>[ 1596 <String>[
1597 "1+MyClass", 1597 "1+MyClass",
1598 "2+MyClass", 1598 "2+MyClass",
1599 "3+MyClass", 1599 "3+MyClass",
1600 "3-v1", 1600 "3-v1",
1601 "4+is", 1601 "4+is",
1602 "4-isVariable" 1602 "4-isVariable"
1603 ]); 1603 ]);
1604 1604
1605 buildTests( 1605 buildTests(
1606 'testCompletion_is_asIdentifierStart', 1606 'testCompletion_is_asIdentifierStart',
1607 ''' 1607 '''
1608 main(p) { 1608 main(p) {
1609 var isVisible; 1609 var isVisible;
1610 var v1 = is!1; 1610 var v1 = is!1;
1611 var v2 = is!2 1611 var v2 = is!2
1612 }''', 1612 }''',
1613 <String>["1+isVisible", "2+isVisible"]); 1613 <String>["1+isVisible", "2+isVisible"]);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 'testCompletion_methodRef_asArg_ofFunctionType', 1712 'testCompletion_methodRef_asArg_ofFunctionType',
1713 ''' 1713 '''
1714 foo( f(int p) ) {} 1714 foo( f(int p) ) {}
1715 class Functions { 1715 class Functions {
1716 static int myFunc(int p) {} 1716 static int myFunc(int p) {}
1717 } 1717 }
1718 main(p) { 1718 main(p) {
1719 foo(Functions.!1); 1719 foo(Functions.!1);
1720 }''', 1720 }''',
1721 <String>[ 1721 <String>[
1722 "1+myFunc" /*":" + ProposalKind.METHOD*/, 1722 "1+myFunc" /*":" + ProposalKind.METHOD*/,
1723 "1+myFunc" /*":" + ProposalKind.METHOD_NAME*/ 1723 "1+myFunc" /*":" + ProposalKind.METHOD_NAME*/
1724 ]); 1724 ]);
1725 1725
1726 buildTests( 1726 buildTests(
1727 'testCompletion_namedArgument_alreadyUsed', 1727 'testCompletion_namedArgument_alreadyUsed',
1728 ''' 1728 '''
1729 func({foo}) {} main() { func(foo: 0, fo!1); }''', 1729 func({foo}) {} main() { func(foo: 0, fo!1); }''',
1730 <String>["1-foo"]); 1730 <String>["1-foo"]);
1731 1731
1732 buildTests( 1732 buildTests(
1733 'testCompletion_namedArgument_constructor', 1733 'testCompletion_namedArgument_constructor',
1734 ''' 1734 '''
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 buildTests( 2202 buildTests(
2203 'testLibrary004', 2203 'testLibrary004',
2204 ''' 2204 '''
2205 library foo; 2205 library foo;
2206 import 'dart:convert' as json; 2206 import 'dart:convert' as json;
2207 class JsonDecoderX{} 2207 class JsonDecoderX{}
2208 f1() {var x=new json.!1} 2208 f1() {var x=new json.!1}
2209 f2() {var x=new json.JsonDe!2} 2209 f2() {var x=new json.JsonDe!2}
2210 f3() {var x=new json.JsonDecoder!3}''', 2210 f3() {var x=new json.JsonDecoder!3}''',
2211 <String>[ 2211 <String>[
2212 "1+JsonDecoder", 2212 "1+JsonDecoder",
2213 "1-JsonDecoderX", 2213 "1-JsonDecoderX",
2214 "2+JsonDecoder", 2214 "2+JsonDecoder",
2215 "2-JsonDecoderX", 2215 "2-JsonDecoderX",
2216 "3+JsonDecoder", 2216 "3+JsonDecoder",
2217 "3-JsonDecoderX" 2217 "3-JsonDecoderX"
2218 ]); 2218 ]);
2219 2219
2220 // TODO Enable after type propagation is implemented. Not yet. 2220 // TODO Enable after type propagation is implemented. Not yet.
2221 // TODO Include corelib analysis 2221 // TODO Include corelib analysis
2222 buildTests('testLibrary005', 2222 buildTests('testLibrary005',
2223 '''var PHI;main(){PHI=5.3;PHI.abs().!1 Object x;}''', <String>["1+abs"], 2223 '''var PHI;main(){PHI=5.3;PHI.abs().!1 Object x;}''', <String>["1+abs"],
2224 failingTests: '1'); 2224 failingTests: '1');
2225 2225
2226 // Exercise import and export handling. 2226 // Exercise import and export handling.
2227 // Libraries are defined in partial order of increasing dependency. 2227 // Libraries are defined in partial order of increasing dependency.
2228 sources.clear(); 2228 sources.clear();
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2350 } 2350 }
2351 2351
2352 void buildNumberedTests() { 2352 void buildNumberedTests() {
2353 buildTests( 2353 buildTests(
2354 'test001', 2354 'test001',
2355 ''' 2355 '''
2356 void r1(var v) { 2356 void r1(var v) {
2357 v.!1toString!2().!3hash!4Code 2357 v.!1toString!2().!3hash!4Code
2358 }''', 2358 }''',
2359 <String>[ 2359 <String>[
2360 "1+toString", 2360 "1+toString",
2361 "1-==", 2361 "1-==",
2362 "2+toString", 2362 "2+toString",
2363 "3+hashCode", 2363 "3+hashCode",
2364 "3+toString", 2364 "3+toString",
2365 "4+hashCode", 2365 "4+hashCode",
2366 "4-toString" 2366 "4-toString"
2367 ]); 2367 ]);
2368 2368
2369 buildTests( 2369 buildTests(
2370 'test002', 2370 'test002',
2371 ''' 2371 '''
2372 void r2(var vim) { 2372 void r2(var vim) {
2373 v!1.toString() 2373 v!1.toString()
2374 }''', 2374 }''',
2375 <String>["1+vim"]); 2375 <String>["1+vim"]);
2376 2376
2377 buildTests( 2377 buildTests(
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
2741 var g = R.!Bm; 2741 var g = R.!Bm;
2742 var h = R.!Cg(); 2742 var h = R.!Cg();
2743 } 2743 }
2744 h() { 2744 h() {
2745 var q = R._!Dm; 2745 var q = R._!Dm;
2746 var g = R.!Em; 2746 var g = R.!Em;
2747 var h = R.!Fg(); 2747 var h = R.!Fg();
2748 } 2748 }
2749 }''', 2749 }''',
2750 <String>[ 2750 <String>[
2751 "1+m", 2751 "1+m",
2752 "2+_m", 2752 "2+_m",
2753 "3+g", 2753 "3+g",
2754 "4+m", 2754 "4+m",
2755 "5+_m", 2755 "5+_m",
2756 "6+g", 2756 "6+g",
2757 "7-g", 2757 "7-g",
2758 "8-m", 2758 "8-m",
2759 "9-_m", 2759 "9-_m",
2760 "A+_m", 2760 "A+_m",
2761 "B+m", 2761 "B+m",
2762 "C+g", 2762 "C+g",
2763 "D+_m", 2763 "D+_m",
2764 "E+m", 2764 "E+m",
2765 "F+g" 2765 "F+g"
2766 ]); 2766 ]);
2767 2767
2768 buildTests('test026', '''var aBcD; var x=ab!1''', <String>["1+aBcD"]); 2768 buildTests('test026', '''var aBcD; var x=ab!1''', <String>["1+aBcD"]);
2769 2769
2770 buildTests( 2770 buildTests(
2771 'test027', '''m(){try{}catch(eeee,ssss){s!1}''', <String>["1+ssss"]); 2771 'test027', '''m(){try{}catch(eeee,ssss){s!1}''', <String>["1+ssss"]);
2772 2772
2773 buildTests('test028', '''m(){var isX=3;if(is!1)''', <String>["1+isX"]); 2773 buildTests('test028', '''m(){var isX=3;if(is!1)''', <String>["1+isX"]);
2774 2774
2775 buildTests('test029', '''m(){[1].forEach((x)=>!1x);}''', <String>["1+x"]); 2775 buildTests('test029', '''m(){[1].forEach((x)=>!1x);}''', <String>["1+x"]);
2776 2776
(...skipping 15 matching lines...) Expand all
2792 int x; 2792 int x;
2793 switch (x) { 2793 switch (x) {
2794 case !3ICHI: 2794 case !3ICHI:
2795 case UKSI: 2795 case UKSI:
2796 case EIN!2: 2796 case EIN!2:
2797 case ONE!1: return; 2797 case ONE!1: return;
2798 default: return; 2798 default: return;
2799 } 2799 }
2800 }''', 2800 }''',
2801 <String>[ 2801 <String>[
2802 "1+ONE", 2802 "1+ONE",
2803 "1-UKSI", 2803 "1-UKSI",
2804 "2+EIN", 2804 "2+EIN",
2805 "2-ICHI", 2805 "2-ICHI",
2806 "3+ICHI", 2806 "3+ICHI",
2807 "3+UKSI", 2807 "3+UKSI",
2808 "3+EIN", 2808 "3+EIN",
2809 "3+ONE" 2809 "3+ONE"
2810 ]); 2810 ]);
2811 2811
2812 buildTests( 2812 buildTests(
2813 'test033', 2813 'test033',
2814 '''class A{}class B extends A{b(){}}class C implements A {c(){}}class X{ x(){A f;f.!1}}''', 2814 '''class A{}class B extends A{b(){}}class C implements A {c(){}}class X{ x(){A f;f.!1}}''',
2815 <String>["1+b", "1-c"], 2815 <String>["1+b", "1-c"],
2816 failingTests: '1'); 2816 failingTests: '1');
2817 2817
2818 // TODO(scheglov) decide what to do with Type for untyped field (not 2818 // TODO(scheglov) decide what to do with Type for untyped field (not
2819 // supported by the new store) 2819 // supported by the new store)
2820 // test analysis of untyped fields and top-level vars 2820 // test analysis of untyped fields and top-level vars
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2990 } else { 2990 } else {
2991 ++expectedPassCount; 2991 ++expectedPassCount;
2992 tester(testName, () { 2992 tester(testName, () {
2993 CompletionTestCase test = new CompletionTestCase(); 2993 CompletionTestCase test = new CompletionTestCase();
2994 return test.runTest(spec, extraFiles); 2994 return test.runTest(spec, extraFiles);
2995 }); 2995 });
2996 } 2996 }
2997 } 2997 }
2998 } 2998 }
2999 } 2999 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698