@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.mjs
CHANGED
|
@@ -1298,6 +1298,42 @@ var StyleSheetService = {
|
|
|
1298
1298
|
break;
|
|
1299
1299
|
}
|
|
1300
1300
|
},
|
|
1301
|
+
async findReferences(doc, params) {
|
|
1302
|
+
const infoByExt = getStyleSheetInfo(doc);
|
|
1303
|
+
const sourceOffset = doc.offsetAt(params.position);
|
|
1304
|
+
for (const ext in infoByExt) {
|
|
1305
|
+
const info = infoByExt[ext];
|
|
1306
|
+
const generatedOffset = info.generatedOffsetAt(sourceOffset);
|
|
1307
|
+
if (generatedOffset === void 0)
|
|
1308
|
+
continue;
|
|
1309
|
+
const { service: service2, virtualDoc } = info;
|
|
1310
|
+
const result = [];
|
|
1311
|
+
for (const location of service2.findReferences(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed)) {
|
|
1312
|
+
if (updateRange(doc, info, location.range)) {
|
|
1313
|
+
result.push(location);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
return result.length ? result : void 0;
|
|
1317
|
+
}
|
|
1318
|
+
},
|
|
1319
|
+
async findDocumentHighlights(doc, params) {
|
|
1320
|
+
const infoByExt = getStyleSheetInfo(doc);
|
|
1321
|
+
const sourceOffset = doc.offsetAt(params.position);
|
|
1322
|
+
for (const ext in infoByExt) {
|
|
1323
|
+
const info = infoByExt[ext];
|
|
1324
|
+
const generatedOffset = info.generatedOffsetAt(sourceOffset);
|
|
1325
|
+
if (generatedOffset === void 0)
|
|
1326
|
+
continue;
|
|
1327
|
+
const { service: service2, virtualDoc } = info;
|
|
1328
|
+
const result = [];
|
|
1329
|
+
for (const highlight of service2.findDocumentHighlights(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed)) {
|
|
1330
|
+
if (updateRange(doc, info, highlight.range)) {
|
|
1331
|
+
result.push(highlight);
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
return result.length ? result : void 0;
|
|
1335
|
+
}
|
|
1336
|
+
},
|
|
1301
1337
|
async findDocumentColors(doc) {
|
|
1302
1338
|
const infoByExt = getStyleSheetInfo(doc);
|
|
1303
1339
|
const result = [];
|
|
@@ -1532,6 +1568,54 @@ var service = {
|
|
|
1532
1568
|
}
|
|
1533
1569
|
return result;
|
|
1534
1570
|
},
|
|
1571
|
+
async findReferences(doc, params, cancel) {
|
|
1572
|
+
let result;
|
|
1573
|
+
try {
|
|
1574
|
+
const requests = plugins.map((plugin) => {
|
|
1575
|
+
var _a;
|
|
1576
|
+
return (_a = plugin.findReferences) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1577
|
+
});
|
|
1578
|
+
for (const pending of requests) {
|
|
1579
|
+
const cur = await pending;
|
|
1580
|
+
if (cancel.isCancellationRequested)
|
|
1581
|
+
return;
|
|
1582
|
+
if (cur) {
|
|
1583
|
+
if (result) {
|
|
1584
|
+
result.push(...cur);
|
|
1585
|
+
} else {
|
|
1586
|
+
result = cur;
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
} catch (err) {
|
|
1591
|
+
displayError(err);
|
|
1592
|
+
}
|
|
1593
|
+
return result;
|
|
1594
|
+
},
|
|
1595
|
+
async findDocumentHighlights(doc, params, cancel) {
|
|
1596
|
+
let result;
|
|
1597
|
+
try {
|
|
1598
|
+
const requests = plugins.map((plugin) => {
|
|
1599
|
+
var _a;
|
|
1600
|
+
return (_a = plugin.findDocumentHighlights) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1601
|
+
});
|
|
1602
|
+
for (const pending of requests) {
|
|
1603
|
+
const cur = await pending;
|
|
1604
|
+
if (cancel.isCancellationRequested)
|
|
1605
|
+
return;
|
|
1606
|
+
if (cur) {
|
|
1607
|
+
if (result) {
|
|
1608
|
+
result.push(...cur);
|
|
1609
|
+
} else {
|
|
1610
|
+
result = cur;
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
} catch (err) {
|
|
1615
|
+
displayError(err);
|
|
1616
|
+
}
|
|
1617
|
+
return result;
|
|
1618
|
+
},
|
|
1535
1619
|
async findDocumentColors(doc, params, cancel) {
|
|
1536
1620
|
let result;
|
|
1537
1621
|
try {
|
|
@@ -1715,7 +1799,9 @@ connection2.onInitialize(() => {
|
|
|
1715
1799
|
hoverProvider: true,
|
|
1716
1800
|
renameProvider: true,
|
|
1717
1801
|
codeActionProvider: true,
|
|
1802
|
+
referencesProvider: true,
|
|
1718
1803
|
colorProvider: true,
|
|
1804
|
+
documentHighlightProvider: true,
|
|
1719
1805
|
completionProvider: {
|
|
1720
1806
|
triggerCharacters: [
|
|
1721
1807
|
".",
|
|
@@ -1755,6 +1841,12 @@ connection2.onCompletion(async (params, cancel) => {
|
|
|
1755
1841
|
connection2.onDefinition(async (params, cancel) => {
|
|
1756
1842
|
return await service.findDefinition(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1757
1843
|
});
|
|
1844
|
+
connection2.onReferences(async (params, cancel) => {
|
|
1845
|
+
return await service.findReferences(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1846
|
+
});
|
|
1847
|
+
connection2.onDocumentHighlight(async (params, cancel) => {
|
|
1848
|
+
return await service.findDocumentHighlights(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1849
|
+
});
|
|
1758
1850
|
connection2.onDocumentColor(async (params, cancel) => {
|
|
1759
1851
|
return await service.findDocumentColors(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1760
1852
|
});
|