@marko/language-server 0.12.7 → 0.12.8
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 +291 -51
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +295 -53
- package/dist/index.mjs.map +2 -2
- package/dist/service/stylesheet/index.d.ts +2 -2
- package/dist/service/types.d.ts +5 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1028,10 +1028,7 @@ var import_vscode_languageserver9 = require("vscode-languageserver");
|
|
|
1028
1028
|
var import_vscode_uri6 = require("vscode-uri");
|
|
1029
1029
|
var prettier = __toESM(require("prettier"));
|
|
1030
1030
|
var markoPrettier = __toESM(require("prettier-plugin-marko"));
|
|
1031
|
-
var
|
|
1032
|
-
import_vscode_languageserver9.TextEdit.replace(import_vscode_languageserver9.Range.create(import_vscode_languageserver9.Position.create(0, 0), import_vscode_languageserver9.Position.create(0, 0)), "")
|
|
1033
|
-
];
|
|
1034
|
-
var format2 = async (doc, params, token) => {
|
|
1031
|
+
var format2 = async (doc, params, cancel) => {
|
|
1035
1032
|
try {
|
|
1036
1033
|
const { fsPath, scheme } = import_vscode_uri6.URI.parse(doc.uri);
|
|
1037
1034
|
const text = doc.getText();
|
|
@@ -1045,15 +1042,14 @@ var format2 = async (doc, params, token) => {
|
|
|
1045
1042
|
editorconfig: true
|
|
1046
1043
|
}).catch(() => null) : null
|
|
1047
1044
|
};
|
|
1048
|
-
if (
|
|
1049
|
-
return
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1045
|
+
if (cancel.isCancellationRequested)
|
|
1046
|
+
return;
|
|
1047
|
+
return [
|
|
1048
|
+
import_vscode_languageserver9.TextEdit.replace(import_vscode_languageserver9.Range.create(doc.positionAt(0), doc.positionAt(text.length)), prettier.format(text, options))
|
|
1049
|
+
];
|
|
1053
1050
|
} catch (e) {
|
|
1054
1051
|
displayError(e);
|
|
1055
1052
|
}
|
|
1056
|
-
return NO_EDIT;
|
|
1057
1053
|
};
|
|
1058
1054
|
|
|
1059
1055
|
// src/service/marko/index.ts
|
|
@@ -1129,7 +1125,7 @@ function createExtractor(code) {
|
|
|
1129
1125
|
const generatedStart = generatedMap[key];
|
|
1130
1126
|
const sourceStart = generatedMap[key + 1];
|
|
1131
1127
|
const sourceEnd = generatedMap[key + 2];
|
|
1132
|
-
return sourceEnd - sourceStart
|
|
1128
|
+
return sourceEnd - sourceStart < generatedOffset - generatedStart ? void 0 : sourceStart + (generatedOffset - generatedStart);
|
|
1133
1129
|
},
|
|
1134
1130
|
generatedOffsetAt(sourceOffset) {
|
|
1135
1131
|
let max = sourceMap.length / 3;
|
|
@@ -1169,10 +1165,20 @@ function extractStyleSheets(code, program, lookup) {
|
|
|
1169
1165
|
}).replace(/^.*\./, "") : "css";
|
|
1170
1166
|
};
|
|
1171
1167
|
const visit = (node) => {
|
|
1172
|
-
var _a, _b
|
|
1168
|
+
var _a, _b;
|
|
1173
1169
|
switch (node.type) {
|
|
1174
1170
|
case 1 /* Tag */:
|
|
1175
|
-
if (
|
|
1171
|
+
if (node.nameText === "style" && node.concise && node.attrs) {
|
|
1172
|
+
const block = node.attrs.at(-1);
|
|
1173
|
+
if (block.type === 8 /* AttrNamed */ && code[block.start] === "{") {
|
|
1174
|
+
getExtractor(getFileExtFromTag(node)).write`${{
|
|
1175
|
+
start: block.start + 1,
|
|
1176
|
+
end: block.end - 1
|
|
1177
|
+
}}`;
|
|
1178
|
+
break;
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
if (node.body) {
|
|
1176
1182
|
if (node.nameText === "style") {
|
|
1177
1183
|
const ext = getFileExtFromTag(node);
|
|
1178
1184
|
for (const child of node.body) {
|
|
@@ -1186,30 +1192,22 @@ function extractStyleSheets(code, program, lookup) {
|
|
|
1186
1192
|
}
|
|
1187
1193
|
}
|
|
1188
1194
|
} else {
|
|
1189
|
-
if (node.attrs) {
|
|
1190
|
-
for (const attr of node.attrs) {
|
|
1191
|
-
if (attr.type === 8 /* AttrNamed */ && ((_b = attr.value) == null ? void 0 : _b.type) === 11 /* AttrValue */ && /^['"]$/.test(code[attr.value.value.start])) {
|
|
1192
|
-
const name = read(attr.name);
|
|
1193
|
-
if (name === "#style" || name === "style" && lookup && node.nameText && name === "style" && ((_c = lookup.getTag(node.nameText)) == null ? void 0 : _c.html)) {
|
|
1194
|
-
getExtractor("css").write`:root{${{
|
|
1195
|
-
start: attr.value.value.start + 1,
|
|
1196
|
-
end: attr.value.value.end - 1
|
|
1197
|
-
}}}`;
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
1195
|
for (const child of node.body) {
|
|
1203
1196
|
visit(child);
|
|
1204
1197
|
}
|
|
1205
1198
|
}
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1199
|
+
}
|
|
1200
|
+
if (node.attrs) {
|
|
1201
|
+
for (const attr of node.attrs) {
|
|
1202
|
+
if (attr.type === 8 /* AttrNamed */ && ((_a = attr.value) == null ? void 0 : _a.type) === 11 /* AttrValue */ && /^['"]$/.test(code[attr.value.value.start])) {
|
|
1203
|
+
const name = read(attr.name);
|
|
1204
|
+
if (name === "#style" || name === "style" && lookup && node.nameText && name === "style" && ((_b = lookup.getTag(node.nameText)) == null ? void 0 : _b.html)) {
|
|
1205
|
+
getExtractor("css").write`:root{${{
|
|
1206
|
+
start: attr.value.value.start + 1,
|
|
1207
|
+
end: attr.value.value.end - 1
|
|
1208
|
+
}}}`;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1213
1211
|
}
|
|
1214
1212
|
}
|
|
1215
1213
|
break;
|
|
@@ -1231,7 +1229,7 @@ var services = {
|
|
|
1231
1229
|
less: import_vscode_css_languageservice.getLESSLanguageService,
|
|
1232
1230
|
scss: import_vscode_css_languageservice.getSCSSLanguageService
|
|
1233
1231
|
};
|
|
1234
|
-
var
|
|
1232
|
+
var StyleSheetService = {
|
|
1235
1233
|
async doComplete(doc, params) {
|
|
1236
1234
|
const infoByExt = getStyleSheetInfo(doc);
|
|
1237
1235
|
const sourceOffset = doc.offsetAt(params.position);
|
|
@@ -1244,26 +1242,17 @@ var stylesheet_default = {
|
|
|
1244
1242
|
const result = service2.doComplete(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed);
|
|
1245
1243
|
for (const item of result.items) {
|
|
1246
1244
|
if (item.additionalTextEdits) {
|
|
1247
|
-
for (const
|
|
1248
|
-
|
|
1249
|
-
edit.newText = "";
|
|
1250
|
-
edit.range = START_OF_FILE;
|
|
1251
|
-
}
|
|
1245
|
+
for (const textEdit2 of item.additionalTextEdits) {
|
|
1246
|
+
updateTextEdit(doc, info, textEdit2);
|
|
1252
1247
|
}
|
|
1253
1248
|
}
|
|
1254
1249
|
const { textEdit } = item;
|
|
1255
1250
|
if (textEdit) {
|
|
1256
1251
|
if (textEdit.range) {
|
|
1257
|
-
|
|
1258
|
-
textEdit.newText = "";
|
|
1259
|
-
textEdit.range = START_OF_FILE;
|
|
1260
|
-
}
|
|
1252
|
+
updateTextEdit(doc, info, textEdit);
|
|
1261
1253
|
}
|
|
1262
1254
|
if (textEdit.insert) {
|
|
1263
|
-
|
|
1264
|
-
textEdit.newText = "";
|
|
1265
|
-
textEdit.insert = START_OF_FILE;
|
|
1266
|
-
}
|
|
1255
|
+
updateInsertReplaceEdit(doc, info, textEdit);
|
|
1267
1256
|
}
|
|
1268
1257
|
}
|
|
1269
1258
|
}
|
|
@@ -1287,6 +1276,48 @@ var stylesheet_default = {
|
|
|
1287
1276
|
break;
|
|
1288
1277
|
}
|
|
1289
1278
|
},
|
|
1279
|
+
async findDocumentColors(doc) {
|
|
1280
|
+
const infoByExt = getStyleSheetInfo(doc);
|
|
1281
|
+
const result = [];
|
|
1282
|
+
for (const ext in infoByExt) {
|
|
1283
|
+
const info = infoByExt[ext];
|
|
1284
|
+
const { service: service2, virtualDoc } = info;
|
|
1285
|
+
for (const colorInfo of service2.findDocumentColors(virtualDoc, info.parsed)) {
|
|
1286
|
+
if (updateRange(doc, info, colorInfo.range)) {
|
|
1287
|
+
result.push(colorInfo);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
if (result.length) {
|
|
1292
|
+
return result;
|
|
1293
|
+
}
|
|
1294
|
+
},
|
|
1295
|
+
async getColorPresentations(doc, params) {
|
|
1296
|
+
const infoByExt = getStyleSheetInfo(doc);
|
|
1297
|
+
const sourceOffset = doc.offsetAt(params.range.start);
|
|
1298
|
+
for (const ext in infoByExt) {
|
|
1299
|
+
const info = infoByExt[ext];
|
|
1300
|
+
const generatedOffsetStart = info.generatedOffsetAt(sourceOffset);
|
|
1301
|
+
if (generatedOffsetStart === void 0)
|
|
1302
|
+
continue;
|
|
1303
|
+
const generatedOffsetEnd = info.generatedOffsetAt(doc.offsetAt(params.range.end));
|
|
1304
|
+
if (generatedOffsetEnd === void 0)
|
|
1305
|
+
continue;
|
|
1306
|
+
const { service: service2, virtualDoc } = info;
|
|
1307
|
+
const result = service2.getColorPresentations(virtualDoc, info.parsed, params.color, import_vscode_languageserver10.Range.create(virtualDoc.positionAt(generatedOffsetStart), virtualDoc.positionAt(generatedOffsetEnd)));
|
|
1308
|
+
for (const colorPresentation of result) {
|
|
1309
|
+
if (colorPresentation.textEdit) {
|
|
1310
|
+
updateTextEdit(doc, info, colorPresentation.textEdit);
|
|
1311
|
+
}
|
|
1312
|
+
if (colorPresentation.additionalTextEdits) {
|
|
1313
|
+
for (const textEdit of colorPresentation.additionalTextEdits) {
|
|
1314
|
+
updateTextEdit(doc, info, textEdit);
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
return result;
|
|
1319
|
+
}
|
|
1320
|
+
},
|
|
1290
1321
|
async doHover(doc, params) {
|
|
1291
1322
|
const infoByExt = getStyleSheetInfo(doc);
|
|
1292
1323
|
const sourceOffset = doc.offsetAt(params.position);
|
|
@@ -1296,12 +1327,72 @@ var stylesheet_default = {
|
|
|
1296
1327
|
if (generatedOffset === void 0)
|
|
1297
1328
|
continue;
|
|
1298
1329
|
const { service: service2, virtualDoc } = info;
|
|
1299
|
-
const result = service2.doHover(virtualDoc, virtualDoc.positionAt(generatedOffset),
|
|
1330
|
+
const result = service2.doHover(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed);
|
|
1300
1331
|
if (result && (!result.range || updateRange(doc, info, result.range))) {
|
|
1301
1332
|
return result;
|
|
1302
1333
|
}
|
|
1303
1334
|
}
|
|
1304
1335
|
},
|
|
1336
|
+
async doRename(doc, params) {
|
|
1337
|
+
const infoByExt = getStyleSheetInfo(doc);
|
|
1338
|
+
const sourceOffset = doc.offsetAt(params.position);
|
|
1339
|
+
for (const ext in infoByExt) {
|
|
1340
|
+
const info = infoByExt[ext];
|
|
1341
|
+
const generatedOffset = info.generatedOffsetAt(sourceOffset);
|
|
1342
|
+
if (generatedOffset === void 0)
|
|
1343
|
+
continue;
|
|
1344
|
+
const { service: service2, virtualDoc } = info;
|
|
1345
|
+
const result = service2.doRename(virtualDoc, virtualDoc.positionAt(generatedOffset), params.newName, info.parsed);
|
|
1346
|
+
if (result.changes) {
|
|
1347
|
+
for (const uri in result.changes) {
|
|
1348
|
+
if (uri === doc.uri) {
|
|
1349
|
+
for (const textEdit of result.changes[uri]) {
|
|
1350
|
+
updateTextEdit(doc, info, textEdit);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
if (result.documentChanges) {
|
|
1356
|
+
for (const change of result.documentChanges) {
|
|
1357
|
+
if (import_vscode_languageserver10.TextDocumentEdit.is(change)) {
|
|
1358
|
+
if (change.textDocument.uri === doc.uri) {
|
|
1359
|
+
for (const textEdit of change.edits) {
|
|
1360
|
+
updateTextEdit(doc, info, textEdit);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
return result;
|
|
1367
|
+
}
|
|
1368
|
+
},
|
|
1369
|
+
async doCodeActions(doc, params) {
|
|
1370
|
+
var _a;
|
|
1371
|
+
const infoByExt = getStyleSheetInfo(doc);
|
|
1372
|
+
const sourceOffset = doc.offsetAt(params.range.start);
|
|
1373
|
+
for (const ext in infoByExt) {
|
|
1374
|
+
const info = infoByExt[ext];
|
|
1375
|
+
const generatedOffsetStart = info.generatedOffsetAt(sourceOffset);
|
|
1376
|
+
if (generatedOffsetStart === void 0)
|
|
1377
|
+
continue;
|
|
1378
|
+
const generatedOffsetEnd = info.generatedOffsetAt(doc.offsetAt(params.range.end));
|
|
1379
|
+
if (generatedOffsetEnd === void 0)
|
|
1380
|
+
continue;
|
|
1381
|
+
const { service: service2, virtualDoc } = info;
|
|
1382
|
+
const result = service2.doCodeActions(virtualDoc, import_vscode_languageserver10.Range.create(virtualDoc.positionAt(generatedOffsetStart), virtualDoc.positionAt(generatedOffsetEnd)), params.context, info.parsed);
|
|
1383
|
+
if (result) {
|
|
1384
|
+
for (const command of result) {
|
|
1385
|
+
const edits = (_a = command.arguments) == null ? void 0 : _a[2];
|
|
1386
|
+
if (edits) {
|
|
1387
|
+
for (const textEdit of edits) {
|
|
1388
|
+
updateTextEdit(doc, info, textEdit);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
return result;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
},
|
|
1305
1396
|
async doValidate(doc) {
|
|
1306
1397
|
const infoByExt = getStyleSheetInfo(doc);
|
|
1307
1398
|
const result = [];
|
|
@@ -1316,6 +1407,18 @@ var stylesheet_default = {
|
|
|
1316
1407
|
return result;
|
|
1317
1408
|
}
|
|
1318
1409
|
};
|
|
1410
|
+
function updateTextEdit(doc, info, textEdit) {
|
|
1411
|
+
if (!updateRange(doc, info, textEdit.range)) {
|
|
1412
|
+
textEdit.newText = "";
|
|
1413
|
+
textEdit.range = START_OF_FILE;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
function updateInsertReplaceEdit(doc, info, insertReplaceEdit) {
|
|
1417
|
+
if (!updateRange(doc, info, insertReplaceEdit.insert)) {
|
|
1418
|
+
insertReplaceEdit.newText = "";
|
|
1419
|
+
insertReplaceEdit.insert = START_OF_FILE;
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1319
1422
|
function updateRange(doc, info, range) {
|
|
1320
1423
|
const start = info.sourceOffsetAt(info.virtualDoc.offsetAt(range.start));
|
|
1321
1424
|
const end = info.sourceOffsetAt(info.virtualDoc.offsetAt(range.end));
|
|
@@ -1353,7 +1456,7 @@ function getStyleSheetInfo(doc) {
|
|
|
1353
1456
|
}
|
|
1354
1457
|
|
|
1355
1458
|
// src/service/index.ts
|
|
1356
|
-
var plugins = [marko_default,
|
|
1459
|
+
var plugins = [marko_default, StyleSheetService];
|
|
1357
1460
|
var service = {
|
|
1358
1461
|
async doComplete(doc, params, cancel) {
|
|
1359
1462
|
const result = import_vscode_languageserver11.CompletionList.create([], false);
|
|
@@ -1365,7 +1468,7 @@ var service = {
|
|
|
1365
1468
|
for (const pending of requests) {
|
|
1366
1469
|
const cur = await pending;
|
|
1367
1470
|
if (cancel.isCancellationRequested)
|
|
1368
|
-
|
|
1471
|
+
return;
|
|
1369
1472
|
if (cur) {
|
|
1370
1473
|
let items;
|
|
1371
1474
|
if (Array.isArray(cur)) {
|
|
@@ -1393,7 +1496,7 @@ var service = {
|
|
|
1393
1496
|
for (const pending of requests) {
|
|
1394
1497
|
const cur = await pending;
|
|
1395
1498
|
if (cancel.isCancellationRequested)
|
|
1396
|
-
|
|
1499
|
+
return;
|
|
1397
1500
|
if (cur) {
|
|
1398
1501
|
if (Array.isArray(cur)) {
|
|
1399
1502
|
result.push(...cur);
|
|
@@ -1407,6 +1510,54 @@ var service = {
|
|
|
1407
1510
|
}
|
|
1408
1511
|
return result;
|
|
1409
1512
|
},
|
|
1513
|
+
async findDocumentColors(doc, params, cancel) {
|
|
1514
|
+
let result;
|
|
1515
|
+
try {
|
|
1516
|
+
const requests = plugins.map((plugin) => {
|
|
1517
|
+
var _a;
|
|
1518
|
+
return (_a = plugin.findDocumentColors) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1519
|
+
});
|
|
1520
|
+
for (const pending of requests) {
|
|
1521
|
+
const cur = await pending;
|
|
1522
|
+
if (cancel.isCancellationRequested)
|
|
1523
|
+
return;
|
|
1524
|
+
if (cur) {
|
|
1525
|
+
if (result) {
|
|
1526
|
+
result.push(...cur);
|
|
1527
|
+
} else {
|
|
1528
|
+
result = cur;
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
} catch (err) {
|
|
1533
|
+
displayError(err);
|
|
1534
|
+
}
|
|
1535
|
+
return result;
|
|
1536
|
+
},
|
|
1537
|
+
async getColorPresentations(doc, params, cancel) {
|
|
1538
|
+
let result;
|
|
1539
|
+
try {
|
|
1540
|
+
const requests = plugins.map((plugin) => {
|
|
1541
|
+
var _a;
|
|
1542
|
+
return (_a = plugin.getColorPresentations) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1543
|
+
});
|
|
1544
|
+
for (const pending of requests) {
|
|
1545
|
+
const cur = await pending;
|
|
1546
|
+
if (cancel.isCancellationRequested)
|
|
1547
|
+
return;
|
|
1548
|
+
if (cur) {
|
|
1549
|
+
if (result) {
|
|
1550
|
+
result.push(...cur);
|
|
1551
|
+
} else {
|
|
1552
|
+
result = cur;
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
} catch (err) {
|
|
1557
|
+
displayError(err);
|
|
1558
|
+
}
|
|
1559
|
+
return result;
|
|
1560
|
+
},
|
|
1410
1561
|
async doHover(doc, params, cancel) {
|
|
1411
1562
|
var _a;
|
|
1412
1563
|
try {
|
|
@@ -1421,6 +1572,80 @@ var service = {
|
|
|
1421
1572
|
displayError(err);
|
|
1422
1573
|
}
|
|
1423
1574
|
},
|
|
1575
|
+
async doRename(doc, params, cancel) {
|
|
1576
|
+
let changes;
|
|
1577
|
+
let changeAnnotations;
|
|
1578
|
+
let documentChanges;
|
|
1579
|
+
try {
|
|
1580
|
+
const requests = plugins.map((plugin) => {
|
|
1581
|
+
var _a;
|
|
1582
|
+
return (_a = plugin.doRename) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1583
|
+
});
|
|
1584
|
+
for (const pending of requests) {
|
|
1585
|
+
const cur = await pending;
|
|
1586
|
+
if (cancel.isCancellationRequested)
|
|
1587
|
+
return;
|
|
1588
|
+
if (cur) {
|
|
1589
|
+
if (cur.changes) {
|
|
1590
|
+
if (changes) {
|
|
1591
|
+
for (const uri in cur.changes) {
|
|
1592
|
+
if (changes[uri]) {
|
|
1593
|
+
changes[uri].push(...cur.changes[uri]);
|
|
1594
|
+
} else {
|
|
1595
|
+
changes[uri] = cur.changes[uri];
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
} else {
|
|
1599
|
+
changes = cur.changes;
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
if (cur.changeAnnotations) {
|
|
1603
|
+
if (changeAnnotations) {
|
|
1604
|
+
Object.assign(changeAnnotations, cur.changeAnnotations);
|
|
1605
|
+
} else {
|
|
1606
|
+
changeAnnotations = cur.changeAnnotations;
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
if (cur.documentChanges) {
|
|
1610
|
+
if (documentChanges) {
|
|
1611
|
+
documentChanges.push(...cur.documentChanges);
|
|
1612
|
+
} else {
|
|
1613
|
+
documentChanges = cur.documentChanges;
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
} catch (err) {
|
|
1619
|
+
displayError(err);
|
|
1620
|
+
}
|
|
1621
|
+
if (changes || changeAnnotations || documentChanges) {
|
|
1622
|
+
return {
|
|
1623
|
+
changes,
|
|
1624
|
+
changeAnnotations,
|
|
1625
|
+
documentChanges
|
|
1626
|
+
};
|
|
1627
|
+
}
|
|
1628
|
+
},
|
|
1629
|
+
async doCodeActions(doc, params, cancel) {
|
|
1630
|
+
const result = [];
|
|
1631
|
+
try {
|
|
1632
|
+
const requests = plugins.map((plugin) => {
|
|
1633
|
+
var _a;
|
|
1634
|
+
return (_a = plugin.doCodeActions) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1635
|
+
});
|
|
1636
|
+
for (const pending of requests) {
|
|
1637
|
+
const cur = await pending;
|
|
1638
|
+
if (cancel.isCancellationRequested)
|
|
1639
|
+
return;
|
|
1640
|
+
if (cur) {
|
|
1641
|
+
result.push(...cur);
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
} catch (err) {
|
|
1645
|
+
displayError(err);
|
|
1646
|
+
}
|
|
1647
|
+
return result;
|
|
1648
|
+
},
|
|
1424
1649
|
async doValidate(doc) {
|
|
1425
1650
|
const result = [];
|
|
1426
1651
|
try {
|
|
@@ -1466,6 +1691,9 @@ connection2.onInitialize(() => {
|
|
|
1466
1691
|
documentFormattingProvider: true,
|
|
1467
1692
|
definitionProvider: true,
|
|
1468
1693
|
hoverProvider: true,
|
|
1694
|
+
renameProvider: true,
|
|
1695
|
+
codeActionProvider: true,
|
|
1696
|
+
colorProvider: true,
|
|
1469
1697
|
completionProvider: {
|
|
1470
1698
|
triggerCharacters: [
|
|
1471
1699
|
".",
|
|
@@ -1505,9 +1733,21 @@ connection2.onCompletion(async (params, cancel) => {
|
|
|
1505
1733
|
connection2.onDefinition(async (params, cancel) => {
|
|
1506
1734
|
return await service.findDefinition(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1507
1735
|
});
|
|
1736
|
+
connection2.onDocumentColor(async (params, cancel) => {
|
|
1737
|
+
return await service.findDocumentColors(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1738
|
+
});
|
|
1739
|
+
connection2.onColorPresentation(async (params, cancel) => {
|
|
1740
|
+
return await service.getColorPresentations(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1741
|
+
});
|
|
1508
1742
|
connection2.onHover(async (params, cancel) => {
|
|
1509
1743
|
return await service.doHover(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1510
1744
|
});
|
|
1745
|
+
connection2.onRenameRequest(async (params, cancel) => {
|
|
1746
|
+
return await service.doRename(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1747
|
+
});
|
|
1748
|
+
connection2.onCodeAction(async (params, cancel) => {
|
|
1749
|
+
return await service.doCodeActions(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1750
|
+
});
|
|
1511
1751
|
connection2.onDocumentFormatting(async (params, cancel) => {
|
|
1512
1752
|
return await service.format(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1513
1753
|
});
|