@marko/language-server 0.12.8 → 0.12.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +92 -0
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +92 -0
- package/dist/index.mjs.map +2 -2
- package/dist/service/types.d.ts +3 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1276,6 +1276,42 @@ var StyleSheetService = {
|
|
|
1276
1276
|
break;
|
|
1277
1277
|
}
|
|
1278
1278
|
},
|
|
1279
|
+
async findReferences(doc, params) {
|
|
1280
|
+
const infoByExt = getStyleSheetInfo(doc);
|
|
1281
|
+
const sourceOffset = doc.offsetAt(params.position);
|
|
1282
|
+
for (const ext in infoByExt) {
|
|
1283
|
+
const info = infoByExt[ext];
|
|
1284
|
+
const generatedOffset = info.generatedOffsetAt(sourceOffset);
|
|
1285
|
+
if (generatedOffset === void 0)
|
|
1286
|
+
continue;
|
|
1287
|
+
const { service: service2, virtualDoc } = info;
|
|
1288
|
+
const result = [];
|
|
1289
|
+
for (const location of service2.findReferences(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed)) {
|
|
1290
|
+
if (updateRange(doc, info, location.range)) {
|
|
1291
|
+
result.push(location);
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
return result.length ? result : void 0;
|
|
1295
|
+
}
|
|
1296
|
+
},
|
|
1297
|
+
async findDocumentHighlights(doc, params) {
|
|
1298
|
+
const infoByExt = getStyleSheetInfo(doc);
|
|
1299
|
+
const sourceOffset = doc.offsetAt(params.position);
|
|
1300
|
+
for (const ext in infoByExt) {
|
|
1301
|
+
const info = infoByExt[ext];
|
|
1302
|
+
const generatedOffset = info.generatedOffsetAt(sourceOffset);
|
|
1303
|
+
if (generatedOffset === void 0)
|
|
1304
|
+
continue;
|
|
1305
|
+
const { service: service2, virtualDoc } = info;
|
|
1306
|
+
const result = [];
|
|
1307
|
+
for (const highlight of service2.findDocumentHighlights(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed)) {
|
|
1308
|
+
if (updateRange(doc, info, highlight.range)) {
|
|
1309
|
+
result.push(highlight);
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
return result.length ? result : void 0;
|
|
1313
|
+
}
|
|
1314
|
+
},
|
|
1279
1315
|
async findDocumentColors(doc) {
|
|
1280
1316
|
const infoByExt = getStyleSheetInfo(doc);
|
|
1281
1317
|
const result = [];
|
|
@@ -1510,6 +1546,54 @@ var service = {
|
|
|
1510
1546
|
}
|
|
1511
1547
|
return result;
|
|
1512
1548
|
},
|
|
1549
|
+
async findReferences(doc, params, cancel) {
|
|
1550
|
+
let result;
|
|
1551
|
+
try {
|
|
1552
|
+
const requests = plugins.map((plugin) => {
|
|
1553
|
+
var _a;
|
|
1554
|
+
return (_a = plugin.findReferences) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1555
|
+
});
|
|
1556
|
+
for (const pending of requests) {
|
|
1557
|
+
const cur = await pending;
|
|
1558
|
+
if (cancel.isCancellationRequested)
|
|
1559
|
+
return;
|
|
1560
|
+
if (cur) {
|
|
1561
|
+
if (result) {
|
|
1562
|
+
result.push(...cur);
|
|
1563
|
+
} else {
|
|
1564
|
+
result = cur;
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
} catch (err) {
|
|
1569
|
+
displayError(err);
|
|
1570
|
+
}
|
|
1571
|
+
return result;
|
|
1572
|
+
},
|
|
1573
|
+
async findDocumentHighlights(doc, params, cancel) {
|
|
1574
|
+
let result;
|
|
1575
|
+
try {
|
|
1576
|
+
const requests = plugins.map((plugin) => {
|
|
1577
|
+
var _a;
|
|
1578
|
+
return (_a = plugin.findDocumentHighlights) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1579
|
+
});
|
|
1580
|
+
for (const pending of requests) {
|
|
1581
|
+
const cur = await pending;
|
|
1582
|
+
if (cancel.isCancellationRequested)
|
|
1583
|
+
return;
|
|
1584
|
+
if (cur) {
|
|
1585
|
+
if (result) {
|
|
1586
|
+
result.push(...cur);
|
|
1587
|
+
} else {
|
|
1588
|
+
result = cur;
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
} catch (err) {
|
|
1593
|
+
displayError(err);
|
|
1594
|
+
}
|
|
1595
|
+
return result;
|
|
1596
|
+
},
|
|
1513
1597
|
async findDocumentColors(doc, params, cancel) {
|
|
1514
1598
|
let result;
|
|
1515
1599
|
try {
|
|
@@ -1693,7 +1777,9 @@ connection2.onInitialize(() => {
|
|
|
1693
1777
|
hoverProvider: true,
|
|
1694
1778
|
renameProvider: true,
|
|
1695
1779
|
codeActionProvider: true,
|
|
1780
|
+
referencesProvider: true,
|
|
1696
1781
|
colorProvider: true,
|
|
1782
|
+
documentHighlightProvider: true,
|
|
1697
1783
|
completionProvider: {
|
|
1698
1784
|
triggerCharacters: [
|
|
1699
1785
|
".",
|
|
@@ -1733,6 +1819,12 @@ connection2.onCompletion(async (params, cancel) => {
|
|
|
1733
1819
|
connection2.onDefinition(async (params, cancel) => {
|
|
1734
1820
|
return await service.findDefinition(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1735
1821
|
});
|
|
1822
|
+
connection2.onReferences(async (params, cancel) => {
|
|
1823
|
+
return await service.findReferences(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1824
|
+
});
|
|
1825
|
+
connection2.onDocumentHighlight(async (params, cancel) => {
|
|
1826
|
+
return await service.findDocumentHighlights(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1827
|
+
});
|
|
1736
1828
|
connection2.onDocumentColor(async (params, cancel) => {
|
|
1737
1829
|
return await service.findDocumentColors(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1738
1830
|
});
|