@@ -1230,6 +1230,496 @@ class Foo {
1230
1230
},
1231
1231
},
1232
1232
},
1233
+ {
1234
+ name : "basicClassMembers" ,
1235
+ files : map [string ]string {
1236
+ mainFileName : `
1237
+ class n {
1238
+ constructor (public x: number, public y: number, private z: string) { }
1239
+ }
1240
+ var t = new n(0, 1, '');t./*a*/` ,
1241
+ },
1242
+ expected : map [string ]* lsproto.CompletionList {
1243
+ "a" : {
1244
+ IsIncomplete : false ,
1245
+ ItemDefaults : itemDefaults ,
1246
+ Items : []* lsproto.CompletionItem {
1247
+ {
1248
+ Label : "x" ,
1249
+ Kind : fieldKind ,
1250
+ SortText : sortTextLocationPriority ,
1251
+ FilterText : ptrTo (".x" ),
1252
+ InsertTextFormat : insertTextFormatPlainText ,
1253
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1254
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1255
+ NewText : "x" ,
1256
+ Insert : lsproto.Range {
1257
+ Start : lsproto.Position {Line : 3 , Character : 26 },
1258
+ End : lsproto.Position {Line : 3 , Character : 26 },
1259
+ },
1260
+ Replace : lsproto.Range {
1261
+ Start : lsproto.Position {Line : 3 , Character : 26 },
1262
+ End : lsproto.Position {Line : 3 , Character : 26 },
1263
+ },
1264
+ },
1265
+ },
1266
+ },
1267
+ {
1268
+ Label : "y" ,
1269
+ Kind : fieldKind ,
1270
+ SortText : sortTextLocationPriority ,
1271
+ FilterText : ptrTo (".y" ),
1272
+ InsertTextFormat : insertTextFormatPlainText ,
1273
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1274
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1275
+ NewText : "y" ,
1276
+ Insert : lsproto.Range {
1277
+ Start : lsproto.Position {Line : 3 , Character : 26 },
1278
+ End : lsproto.Position {Line : 3 , Character : 26 },
1279
+ },
1280
+ Replace : lsproto.Range {
1281
+ Start : lsproto.Position {Line : 3 , Character : 26 },
1282
+ End : lsproto.Position {Line : 3 , Character : 26 },
1283
+ },
1284
+ },
1285
+ },
1286
+ },
1287
+ },
1288
+ },
1289
+ },
1290
+ },
1291
+ {
1292
+ name : "cloduleAsBaseClass" ,
1293
+ files : map [string ]string {
1294
+ mainFileName : `
1295
+ class A {
1296
+ constructor(x: number) { }
1297
+ foo() { }
1298
+ static bar() { }
1299
+ }
1300
+
1301
+ module A {
1302
+ export var x = 1;
1303
+ export function baz() { }
1304
+ }
1305
+
1306
+ class D extends A {
1307
+ constructor() {
1308
+ super(1);
1309
+ }
1310
+ foo2() { }
1311
+ static bar2() { }
1312
+ }
1313
+
1314
+ D./*a*/` ,
1315
+ },
1316
+ expected : map [string ]* lsproto.CompletionList {
1317
+ "a" : {
1318
+ IsIncomplete : false ,
1319
+ ItemDefaults : itemDefaults ,
1320
+ Items : []* lsproto.CompletionItem { // !!! `funcionMembersPlus`
1321
+ {
1322
+ Label : "bar" ,
1323
+ Kind : methodKind ,
1324
+ SortText : sortTextLocalDeclarationPriority ,
1325
+ FilterText : ptrTo (".bar" ),
1326
+ InsertTextFormat : insertTextFormatPlainText ,
1327
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1328
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1329
+ NewText : "bar" ,
1330
+ Insert : lsproto.Range {
1331
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1332
+ End : lsproto.Position {Line : 19 , Character : 2 },
1333
+ },
1334
+ Replace : lsproto.Range {
1335
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1336
+ End : lsproto.Position {Line : 19 , Character : 2 },
1337
+ },
1338
+ },
1339
+ },
1340
+ },
1341
+ {
1342
+ Label : "bar2" ,
1343
+ Kind : methodKind ,
1344
+ SortText : sortTextLocalDeclarationPriority ,
1345
+ FilterText : ptrTo (".bar2" ),
1346
+ InsertTextFormat : insertTextFormatPlainText ,
1347
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1348
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1349
+ NewText : "bar2" ,
1350
+ Insert : lsproto.Range {
1351
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1352
+ End : lsproto.Position {Line : 19 , Character : 2 },
1353
+ },
1354
+ Replace : lsproto.Range {
1355
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1356
+ End : lsproto.Position {Line : 19 , Character : 2 },
1357
+ },
1358
+ },
1359
+ },
1360
+ },
1361
+ {
1362
+ Label : "apply" ,
1363
+ Kind : methodKind ,
1364
+ SortText : sortTextLocationPriority ,
1365
+ FilterText : ptrTo (".apply" ),
1366
+ InsertTextFormat : insertTextFormatPlainText ,
1367
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1368
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1369
+ NewText : "apply" ,
1370
+ Insert : lsproto.Range {
1371
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1372
+ End : lsproto.Position {Line : 19 , Character : 2 },
1373
+ },
1374
+ Replace : lsproto.Range {
1375
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1376
+ End : lsproto.Position {Line : 19 , Character : 2 },
1377
+ },
1378
+ },
1379
+ },
1380
+ },
1381
+ {
1382
+ Label : "arguments" ,
1383
+ Kind : fieldKind ,
1384
+ SortText : sortTextLocationPriority ,
1385
+ FilterText : ptrTo (".arguments" ),
1386
+ InsertTextFormat : insertTextFormatPlainText ,
1387
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1388
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1389
+ NewText : "arguments" ,
1390
+ Insert : lsproto.Range {
1391
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1392
+ End : lsproto.Position {Line : 19 , Character : 2 },
1393
+ },
1394
+ Replace : lsproto.Range {
1395
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1396
+ End : lsproto.Position {Line : 19 , Character : 2 },
1397
+ },
1398
+ },
1399
+ },
1400
+ },
1401
+ {
1402
+ Label : "baz" ,
1403
+ Kind : functionKind ,
1404
+ SortText : sortTextLocationPriority ,
1405
+ FilterText : ptrTo (".baz" ),
1406
+ InsertTextFormat : insertTextFormatPlainText ,
1407
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1408
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1409
+ NewText : "baz" ,
1410
+ Insert : lsproto.Range {
1411
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1412
+ End : lsproto.Position {Line : 19 , Character : 2 },
1413
+ },
1414
+ Replace : lsproto.Range {
1415
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1416
+ End : lsproto.Position {Line : 19 , Character : 2 },
1417
+ },
1418
+ },
1419
+ },
1420
+ },
1421
+ {
1422
+ Label : "bind" ,
1423
+ Kind : methodKind ,
1424
+ SortText : sortTextLocationPriority ,
1425
+ FilterText : ptrTo (".bind" ),
1426
+ InsertTextFormat : insertTextFormatPlainText ,
1427
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1428
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1429
+ NewText : "bind" ,
1430
+ Insert : lsproto.Range {
1431
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1432
+ End : lsproto.Position {Line : 19 , Character : 2 },
1433
+ },
1434
+ Replace : lsproto.Range {
1435
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1436
+ End : lsproto.Position {Line : 19 , Character : 2 },
1437
+ },
1438
+ },
1439
+ },
1440
+ },
1441
+ {
1442
+ Label : "call" ,
1443
+ Kind : methodKind ,
1444
+ SortText : sortTextLocationPriority ,
1445
+ FilterText : ptrTo (".call" ),
1446
+ InsertTextFormat : insertTextFormatPlainText ,
1447
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1448
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1449
+ NewText : "call" ,
1450
+ Insert : lsproto.Range {
1451
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1452
+ End : lsproto.Position {Line : 19 , Character : 2 },
1453
+ },
1454
+ Replace : lsproto.Range {
1455
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1456
+ End : lsproto.Position {Line : 19 , Character : 2 },
1457
+ },
1458
+ },
1459
+ },
1460
+ },
1461
+ {
1462
+ Label : "caller" ,
1463
+ Kind : fieldKind ,
1464
+ SortText : sortTextLocationPriority ,
1465
+ FilterText : ptrTo (".caller" ),
1466
+ InsertTextFormat : insertTextFormatPlainText ,
1467
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1468
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1469
+ NewText : "caller" ,
1470
+ Insert : lsproto.Range {
1471
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1472
+ End : lsproto.Position {Line : 19 , Character : 2 },
1473
+ },
1474
+ Replace : lsproto.Range {
1475
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1476
+ End : lsproto.Position {Line : 19 , Character : 2 },
1477
+ },
1478
+ },
1479
+ },
1480
+ },
1481
+ {
1482
+ Label : "length" ,
1483
+ Kind : fieldKind ,
1484
+ SortText : sortTextLocationPriority ,
1485
+ FilterText : ptrTo (".length" ),
1486
+ InsertTextFormat : insertTextFormatPlainText ,
1487
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1488
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1489
+ NewText : "length" ,
1490
+ Insert : lsproto.Range {
1491
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1492
+ End : lsproto.Position {Line : 19 , Character : 2 },
1493
+ },
1494
+ Replace : lsproto.Range {
1495
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1496
+ End : lsproto.Position {Line : 19 , Character : 2 },
1497
+ },
1498
+ },
1499
+ },
1500
+ },
1501
+ {
1502
+ Label : "prototype" ,
1503
+ Kind : fieldKind ,
1504
+ SortText : sortTextLocationPriority ,
1505
+ FilterText : ptrTo (".prototype" ),
1506
+ InsertTextFormat : insertTextFormatPlainText ,
1507
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1508
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1509
+ NewText : "prototype" ,
1510
+ Insert : lsproto.Range {
1511
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1512
+ End : lsproto.Position {Line : 19 , Character : 2 },
1513
+ },
1514
+ Replace : lsproto.Range {
1515
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1516
+ End : lsproto.Position {Line : 19 , Character : 2 },
1517
+ },
1518
+ },
1519
+ },
1520
+ },
1521
+ {
1522
+ Label : "toString" ,
1523
+ Kind : methodKind ,
1524
+ SortText : sortTextLocationPriority ,
1525
+ FilterText : ptrTo (".toString" ),
1526
+ InsertTextFormat : insertTextFormatPlainText ,
1527
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1528
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1529
+ NewText : "toString" ,
1530
+ Insert : lsproto.Range {
1531
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1532
+ End : lsproto.Position {Line : 19 , Character : 2 },
1533
+ },
1534
+ Replace : lsproto.Range {
1535
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1536
+ End : lsproto.Position {Line : 19 , Character : 2 },
1537
+ },
1538
+ },
1539
+ },
1540
+ },
1541
+ {
1542
+ Label : "x" ,
1543
+ Kind : variableKind ,
1544
+ SortText : sortTextLocationPriority ,
1545
+ FilterText : ptrTo (".x" ),
1546
+ InsertTextFormat : insertTextFormatPlainText ,
1547
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1548
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1549
+ NewText : "x" ,
1550
+ Insert : lsproto.Range {
1551
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1552
+ End : lsproto.Position {Line : 19 , Character : 2 },
1553
+ },
1554
+ Replace : lsproto.Range {
1555
+ Start : lsproto.Position {Line : 19 , Character : 2 },
1556
+ End : lsproto.Position {Line : 19 , Character : 2 },
1557
+ },
1558
+ },
1559
+ },
1560
+ },
1561
+ },
1562
+ },
1563
+ },
1564
+ },
1565
+ {
1566
+ name : "lambdaThisMembers" ,
1567
+ files : map [string ]string {
1568
+ mainFileName : `class Foo {
1569
+ a: number;
1570
+ b() {
1571
+ var x = () => {
1572
+ this./**/;
1573
+ }
1574
+ }
1575
+ }` ,
1576
+ },
1577
+ expected : map [string ]* lsproto.CompletionList {
1578
+ "" : {
1579
+ IsIncomplete : false ,
1580
+ ItemDefaults : itemDefaults ,
1581
+ Items : []* lsproto.CompletionItem {
1582
+ {
1583
+ Label : "a" ,
1584
+ Kind : fieldKind ,
1585
+ SortText : sortTextLocationPriority ,
1586
+ FilterText : ptrTo (".a" ),
1587
+ InsertTextFormat : insertTextFormatPlainText ,
1588
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1589
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1590
+ NewText : "a" ,
1591
+ Insert : lsproto.Range {
1592
+ Start : lsproto.Position {Line : 4 , Character : 17 },
1593
+ End : lsproto.Position {Line : 4 , Character : 17 },
1594
+ },
1595
+ Replace : lsproto.Range {
1596
+ Start : lsproto.Position {Line : 4 , Character : 17 },
1597
+ End : lsproto.Position {Line : 4 , Character : 17 },
1598
+ },
1599
+ },
1600
+ },
1601
+ },
1602
+ {
1603
+ Label : "b" ,
1604
+ Kind : methodKind ,
1605
+ SortText : sortTextLocationPriority ,
1606
+ FilterText : ptrTo (".b" ),
1607
+ InsertTextFormat : insertTextFormatPlainText ,
1608
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1609
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1610
+ NewText : "b" ,
1611
+ Insert : lsproto.Range {
1612
+ Start : lsproto.Position {Line : 4 , Character : 17 },
1613
+ End : lsproto.Position {Line : 4 , Character : 17 },
1614
+ },
1615
+ Replace : lsproto.Range {
1616
+ Start : lsproto.Position {Line : 4 , Character : 17 },
1617
+ End : lsproto.Position {Line : 4 , Character : 17 },
1618
+ },
1619
+ },
1620
+ },
1621
+ },
1622
+ },
1623
+ },
1624
+ },
1625
+ },
1626
+ {
1627
+ name : "memberCompletionInForEach1" ,
1628
+ files : map [string ]string {
1629
+ mainFileName : `var x: string[] = [];
1630
+ x.forEach(function (y) { y./*1*/` ,
1631
+ },
1632
+ expected : map [string ]* lsproto.CompletionList {
1633
+ "1" : {
1634
+ IsIncomplete : false ,
1635
+ ItemDefaults : itemDefaults ,
1636
+ Items : core .Map (stringMembers , func (basicItem * lsproto.CompletionItem ) * lsproto.CompletionItem {
1637
+ item := * basicItem
1638
+ item .FilterText = ptrTo ("." + item .Label )
1639
+ item .TextEdit = & lsproto.TextEditOrInsertReplaceEdit {
1640
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1641
+ NewText : item .Label ,
1642
+ Insert : lsproto.Range {
1643
+ Start : lsproto.Position {Line : 1 , Character : 27 },
1644
+ End : lsproto.Position {Line : 1 , Character : 27 },
1645
+ },
1646
+ Replace : lsproto.Range {
1647
+ Start : lsproto.Position {Line : 1 , Character : 27 },
1648
+ End : lsproto.Position {Line : 1 , Character : 27 },
1649
+ },
1650
+ },
1651
+ }
1652
+ return & item
1653
+ }),
1654
+ },
1655
+ },
1656
+ },
1657
+ {
1658
+ name : "completionsTuple" ,
1659
+ files : map [string ]string {
1660
+ mainFileName : `declare const x: [number, number];
1661
+ x./**/;` ,
1662
+ },
1663
+ expected : map [string ]* lsproto.CompletionList {
1664
+ "" : {
1665
+ IsIncomplete : false ,
1666
+ ItemDefaults : itemDefaults ,
1667
+ Items : append ([]* lsproto.CompletionItem {
1668
+ {
1669
+ Label : "0" ,
1670
+ Kind : fieldKind ,
1671
+ SortText : sortTextLocationPriority ,
1672
+ InsertText : ptrTo ("[0]" ),
1673
+ InsertTextFormat : insertTextFormatPlainText ,
1674
+ FilterText : ptrTo (".[0]" ),
1675
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1676
+ TextEdit : & lsproto.TextEdit {
1677
+ NewText : "[0]" ,
1678
+ Range : lsproto.Range {
1679
+ Start : lsproto.Position {Line : 1 , Character : 1 },
1680
+ End : lsproto.Position {Line : 1 , Character : 2 },
1681
+ },
1682
+ },
1683
+ },
1684
+ },
1685
+ {
1686
+ Label : "1" ,
1687
+ Kind : fieldKind ,
1688
+ SortText : sortTextLocationPriority ,
1689
+ InsertText : ptrTo ("[1]" ),
1690
+ InsertTextFormat : insertTextFormatPlainText ,
1691
+ FilterText : ptrTo (".[1]" ),
1692
+ TextEdit : & lsproto.TextEditOrInsertReplaceEdit {
1693
+ TextEdit : & lsproto.TextEdit {
1694
+ NewText : "[1]" ,
1695
+ Range : lsproto.Range {
1696
+ Start : lsproto.Position {Line : 1 , Character : 1 },
1697
+ End : lsproto.Position {Line : 1 , Character : 2 },
1698
+ },
1699
+ },
1700
+ },
1701
+ },
1702
+ }, core .Map (arrayMembers , func (basicItem * lsproto.CompletionItem ) * lsproto.CompletionItem {
1703
+ item := * basicItem
1704
+ item .FilterText = ptrTo ("." + item .Label )
1705
+ item .TextEdit = & lsproto.TextEditOrInsertReplaceEdit {
1706
+ InsertReplaceEdit : & lsproto.InsertReplaceEdit {
1707
+ NewText : item .Label ,
1708
+ Insert : lsproto.Range {
1709
+ Start : lsproto.Position {Line : 1 , Character : 2 },
1710
+ End : lsproto.Position {Line : 1 , Character : 2 },
1711
+ },
1712
+ Replace : lsproto.Range {
1713
+ Start : lsproto.Position {Line : 1 , Character : 2 },
1714
+ End : lsproto.Position {Line : 1 , Character : 2 },
1715
+ },
1716
+ },
1717
+ }
1718
+ return & item
1719
+ })... ),
1720
+ },
1721
+ },
1722
+ },
1233
1723
}
1234
1724
for _ , testCase := range testCases {
1235
1725
t .Run (testCase .name , func (t * testing.T ) {
0 commit comments