@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.mjs
CHANGED
|
@@ -1038,14 +1038,11 @@ var findDefinition = async (doc, params) => {
|
|
|
1038
1038
|
};
|
|
1039
1039
|
|
|
1040
1040
|
// src/service/marko/format.ts
|
|
1041
|
-
import {
|
|
1041
|
+
import { Range as Range6, TextEdit as TextEdit4 } from "vscode-languageserver";
|
|
1042
1042
|
import { URI as URI6 } from "vscode-uri";
|
|
1043
1043
|
import * as prettier from "prettier";
|
|
1044
1044
|
import * as markoPrettier from "prettier-plugin-marko";
|
|
1045
|
-
var
|
|
1046
|
-
TextEdit4.replace(Range6.create(Position2.create(0, 0), Position2.create(0, 0)), "")
|
|
1047
|
-
];
|
|
1048
|
-
var format2 = async (doc, params, token) => {
|
|
1045
|
+
var format2 = async (doc, params, cancel) => {
|
|
1049
1046
|
try {
|
|
1050
1047
|
const { fsPath, scheme } = URI6.parse(doc.uri);
|
|
1051
1048
|
const text = doc.getText();
|
|
@@ -1059,15 +1056,14 @@ var format2 = async (doc, params, token) => {
|
|
|
1059
1056
|
editorconfig: true
|
|
1060
1057
|
}).catch(() => null) : null
|
|
1061
1058
|
};
|
|
1062
|
-
if (
|
|
1063
|
-
return
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1059
|
+
if (cancel.isCancellationRequested)
|
|
1060
|
+
return;
|
|
1061
|
+
return [
|
|
1062
|
+
TextEdit4.replace(Range6.create(doc.positionAt(0), doc.positionAt(text.length)), prettier.format(text, options))
|
|
1063
|
+
];
|
|
1067
1064
|
} catch (e) {
|
|
1068
1065
|
displayError(e);
|
|
1069
1066
|
}
|
|
1070
|
-
return NO_EDIT;
|
|
1071
1067
|
};
|
|
1072
1068
|
|
|
1073
1069
|
// src/service/marko/index.ts
|
|
@@ -1080,7 +1076,9 @@ var marko_default = {
|
|
|
1080
1076
|
|
|
1081
1077
|
// src/service/stylesheet/index.ts
|
|
1082
1078
|
import {
|
|
1083
|
-
CompletionList as CompletionList2
|
|
1079
|
+
CompletionList as CompletionList2,
|
|
1080
|
+
Range as Range8,
|
|
1081
|
+
TextDocumentEdit
|
|
1084
1082
|
} from "vscode-languageserver";
|
|
1085
1083
|
import {
|
|
1086
1084
|
getCSSLanguageService,
|
|
@@ -1149,7 +1147,7 @@ function createExtractor(code) {
|
|
|
1149
1147
|
const generatedStart = generatedMap[key];
|
|
1150
1148
|
const sourceStart = generatedMap[key + 1];
|
|
1151
1149
|
const sourceEnd = generatedMap[key + 2];
|
|
1152
|
-
return sourceEnd - sourceStart
|
|
1150
|
+
return sourceEnd - sourceStart < generatedOffset - generatedStart ? void 0 : sourceStart + (generatedOffset - generatedStart);
|
|
1153
1151
|
},
|
|
1154
1152
|
generatedOffsetAt(sourceOffset) {
|
|
1155
1153
|
let max = sourceMap.length / 3;
|
|
@@ -1189,10 +1187,20 @@ function extractStyleSheets(code, program, lookup) {
|
|
|
1189
1187
|
}).replace(/^.*\./, "") : "css";
|
|
1190
1188
|
};
|
|
1191
1189
|
const visit = (node) => {
|
|
1192
|
-
var _a, _b
|
|
1190
|
+
var _a, _b;
|
|
1193
1191
|
switch (node.type) {
|
|
1194
1192
|
case 1 /* Tag */:
|
|
1195
|
-
if (
|
|
1193
|
+
if (node.nameText === "style" && node.concise && node.attrs) {
|
|
1194
|
+
const block = node.attrs.at(-1);
|
|
1195
|
+
if (block.type === 8 /* AttrNamed */ && code[block.start] === "{") {
|
|
1196
|
+
getExtractor(getFileExtFromTag(node)).write`${{
|
|
1197
|
+
start: block.start + 1,
|
|
1198
|
+
end: block.end - 1
|
|
1199
|
+
}}`;
|
|
1200
|
+
break;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
if (node.body) {
|
|
1196
1204
|
if (node.nameText === "style") {
|
|
1197
1205
|
const ext = getFileExtFromTag(node);
|
|
1198
1206
|
for (const child of node.body) {
|
|
@@ -1206,30 +1214,22 @@ function extractStyleSheets(code, program, lookup) {
|
|
|
1206
1214
|
}
|
|
1207
1215
|
}
|
|
1208
1216
|
} else {
|
|
1209
|
-
if (node.attrs) {
|
|
1210
|
-
for (const attr of node.attrs) {
|
|
1211
|
-
if (attr.type === 8 /* AttrNamed */ && ((_b = attr.value) == null ? void 0 : _b.type) === 11 /* AttrValue */ && /^['"]$/.test(code[attr.value.value.start])) {
|
|
1212
|
-
const name = read(attr.name);
|
|
1213
|
-
if (name === "#style" || name === "style" && lookup && node.nameText && name === "style" && ((_c = lookup.getTag(node.nameText)) == null ? void 0 : _c.html)) {
|
|
1214
|
-
getExtractor("css").write`:root{${{
|
|
1215
|
-
start: attr.value.value.start + 1,
|
|
1216
|
-
end: attr.value.value.end - 1
|
|
1217
|
-
}}}`;
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
1217
|
for (const child of node.body) {
|
|
1223
1218
|
visit(child);
|
|
1224
1219
|
}
|
|
1225
1220
|
}
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1221
|
+
}
|
|
1222
|
+
if (node.attrs) {
|
|
1223
|
+
for (const attr of node.attrs) {
|
|
1224
|
+
if (attr.type === 8 /* AttrNamed */ && ((_a = attr.value) == null ? void 0 : _a.type) === 11 /* AttrValue */ && /^['"]$/.test(code[attr.value.value.start])) {
|
|
1225
|
+
const name = read(attr.name);
|
|
1226
|
+
if (name === "#style" || name === "style" && lookup && node.nameText && name === "style" && ((_b = lookup.getTag(node.nameText)) == null ? void 0 : _b.html)) {
|
|
1227
|
+
getExtractor("css").write`:root{${{
|
|
1228
|
+
start: attr.value.value.start + 1,
|
|
1229
|
+
end: attr.value.value.end - 1
|
|
1230
|
+
}}}`;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
1233
|
}
|
|
1234
1234
|
}
|
|
1235
1235
|
break;
|
|
@@ -1251,7 +1251,7 @@ var services = {
|
|
|
1251
1251
|
less: getLESSLanguageService,
|
|
1252
1252
|
scss: getSCSSLanguageService
|
|
1253
1253
|
};
|
|
1254
|
-
var
|
|
1254
|
+
var StyleSheetService = {
|
|
1255
1255
|
async doComplete(doc, params) {
|
|
1256
1256
|
const infoByExt = getStyleSheetInfo(doc);
|
|
1257
1257
|
const sourceOffset = doc.offsetAt(params.position);
|
|
@@ -1264,26 +1264,17 @@ var stylesheet_default = {
|
|
|
1264
1264
|
const result = service2.doComplete(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed);
|
|
1265
1265
|
for (const item of result.items) {
|
|
1266
1266
|
if (item.additionalTextEdits) {
|
|
1267
|
-
for (const
|
|
1268
|
-
|
|
1269
|
-
edit.newText = "";
|
|
1270
|
-
edit.range = START_OF_FILE;
|
|
1271
|
-
}
|
|
1267
|
+
for (const textEdit2 of item.additionalTextEdits) {
|
|
1268
|
+
updateTextEdit(doc, info, textEdit2);
|
|
1272
1269
|
}
|
|
1273
1270
|
}
|
|
1274
1271
|
const { textEdit } = item;
|
|
1275
1272
|
if (textEdit) {
|
|
1276
1273
|
if (textEdit.range) {
|
|
1277
|
-
|
|
1278
|
-
textEdit.newText = "";
|
|
1279
|
-
textEdit.range = START_OF_FILE;
|
|
1280
|
-
}
|
|
1274
|
+
updateTextEdit(doc, info, textEdit);
|
|
1281
1275
|
}
|
|
1282
1276
|
if (textEdit.insert) {
|
|
1283
|
-
|
|
1284
|
-
textEdit.newText = "";
|
|
1285
|
-
textEdit.insert = START_OF_FILE;
|
|
1286
|
-
}
|
|
1277
|
+
updateInsertReplaceEdit(doc, info, textEdit);
|
|
1287
1278
|
}
|
|
1288
1279
|
}
|
|
1289
1280
|
}
|
|
@@ -1307,6 +1298,48 @@ var stylesheet_default = {
|
|
|
1307
1298
|
break;
|
|
1308
1299
|
}
|
|
1309
1300
|
},
|
|
1301
|
+
async findDocumentColors(doc) {
|
|
1302
|
+
const infoByExt = getStyleSheetInfo(doc);
|
|
1303
|
+
const result = [];
|
|
1304
|
+
for (const ext in infoByExt) {
|
|
1305
|
+
const info = infoByExt[ext];
|
|
1306
|
+
const { service: service2, virtualDoc } = info;
|
|
1307
|
+
for (const colorInfo of service2.findDocumentColors(virtualDoc, info.parsed)) {
|
|
1308
|
+
if (updateRange(doc, info, colorInfo.range)) {
|
|
1309
|
+
result.push(colorInfo);
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
if (result.length) {
|
|
1314
|
+
return result;
|
|
1315
|
+
}
|
|
1316
|
+
},
|
|
1317
|
+
async getColorPresentations(doc, params) {
|
|
1318
|
+
const infoByExt = getStyleSheetInfo(doc);
|
|
1319
|
+
const sourceOffset = doc.offsetAt(params.range.start);
|
|
1320
|
+
for (const ext in infoByExt) {
|
|
1321
|
+
const info = infoByExt[ext];
|
|
1322
|
+
const generatedOffsetStart = info.generatedOffsetAt(sourceOffset);
|
|
1323
|
+
if (generatedOffsetStart === void 0)
|
|
1324
|
+
continue;
|
|
1325
|
+
const generatedOffsetEnd = info.generatedOffsetAt(doc.offsetAt(params.range.end));
|
|
1326
|
+
if (generatedOffsetEnd === void 0)
|
|
1327
|
+
continue;
|
|
1328
|
+
const { service: service2, virtualDoc } = info;
|
|
1329
|
+
const result = service2.getColorPresentations(virtualDoc, info.parsed, params.color, Range8.create(virtualDoc.positionAt(generatedOffsetStart), virtualDoc.positionAt(generatedOffsetEnd)));
|
|
1330
|
+
for (const colorPresentation of result) {
|
|
1331
|
+
if (colorPresentation.textEdit) {
|
|
1332
|
+
updateTextEdit(doc, info, colorPresentation.textEdit);
|
|
1333
|
+
}
|
|
1334
|
+
if (colorPresentation.additionalTextEdits) {
|
|
1335
|
+
for (const textEdit of colorPresentation.additionalTextEdits) {
|
|
1336
|
+
updateTextEdit(doc, info, textEdit);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
return result;
|
|
1341
|
+
}
|
|
1342
|
+
},
|
|
1310
1343
|
async doHover(doc, params) {
|
|
1311
1344
|
const infoByExt = getStyleSheetInfo(doc);
|
|
1312
1345
|
const sourceOffset = doc.offsetAt(params.position);
|
|
@@ -1316,12 +1349,72 @@ var stylesheet_default = {
|
|
|
1316
1349
|
if (generatedOffset === void 0)
|
|
1317
1350
|
continue;
|
|
1318
1351
|
const { service: service2, virtualDoc } = info;
|
|
1319
|
-
const result = service2.doHover(virtualDoc, virtualDoc.positionAt(generatedOffset),
|
|
1352
|
+
const result = service2.doHover(virtualDoc, virtualDoc.positionAt(generatedOffset), info.parsed);
|
|
1320
1353
|
if (result && (!result.range || updateRange(doc, info, result.range))) {
|
|
1321
1354
|
return result;
|
|
1322
1355
|
}
|
|
1323
1356
|
}
|
|
1324
1357
|
},
|
|
1358
|
+
async doRename(doc, params) {
|
|
1359
|
+
const infoByExt = getStyleSheetInfo(doc);
|
|
1360
|
+
const sourceOffset = doc.offsetAt(params.position);
|
|
1361
|
+
for (const ext in infoByExt) {
|
|
1362
|
+
const info = infoByExt[ext];
|
|
1363
|
+
const generatedOffset = info.generatedOffsetAt(sourceOffset);
|
|
1364
|
+
if (generatedOffset === void 0)
|
|
1365
|
+
continue;
|
|
1366
|
+
const { service: service2, virtualDoc } = info;
|
|
1367
|
+
const result = service2.doRename(virtualDoc, virtualDoc.positionAt(generatedOffset), params.newName, info.parsed);
|
|
1368
|
+
if (result.changes) {
|
|
1369
|
+
for (const uri in result.changes) {
|
|
1370
|
+
if (uri === doc.uri) {
|
|
1371
|
+
for (const textEdit of result.changes[uri]) {
|
|
1372
|
+
updateTextEdit(doc, info, textEdit);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
if (result.documentChanges) {
|
|
1378
|
+
for (const change of result.documentChanges) {
|
|
1379
|
+
if (TextDocumentEdit.is(change)) {
|
|
1380
|
+
if (change.textDocument.uri === doc.uri) {
|
|
1381
|
+
for (const textEdit of change.edits) {
|
|
1382
|
+
updateTextEdit(doc, info, textEdit);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
return result;
|
|
1389
|
+
}
|
|
1390
|
+
},
|
|
1391
|
+
async doCodeActions(doc, params) {
|
|
1392
|
+
var _a;
|
|
1393
|
+
const infoByExt = getStyleSheetInfo(doc);
|
|
1394
|
+
const sourceOffset = doc.offsetAt(params.range.start);
|
|
1395
|
+
for (const ext in infoByExt) {
|
|
1396
|
+
const info = infoByExt[ext];
|
|
1397
|
+
const generatedOffsetStart = info.generatedOffsetAt(sourceOffset);
|
|
1398
|
+
if (generatedOffsetStart === void 0)
|
|
1399
|
+
continue;
|
|
1400
|
+
const generatedOffsetEnd = info.generatedOffsetAt(doc.offsetAt(params.range.end));
|
|
1401
|
+
if (generatedOffsetEnd === void 0)
|
|
1402
|
+
continue;
|
|
1403
|
+
const { service: service2, virtualDoc } = info;
|
|
1404
|
+
const result = service2.doCodeActions(virtualDoc, Range8.create(virtualDoc.positionAt(generatedOffsetStart), virtualDoc.positionAt(generatedOffsetEnd)), params.context, info.parsed);
|
|
1405
|
+
if (result) {
|
|
1406
|
+
for (const command of result) {
|
|
1407
|
+
const edits = (_a = command.arguments) == null ? void 0 : _a[2];
|
|
1408
|
+
if (edits) {
|
|
1409
|
+
for (const textEdit of edits) {
|
|
1410
|
+
updateTextEdit(doc, info, textEdit);
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
return result;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
},
|
|
1325
1418
|
async doValidate(doc) {
|
|
1326
1419
|
const infoByExt = getStyleSheetInfo(doc);
|
|
1327
1420
|
const result = [];
|
|
@@ -1336,6 +1429,18 @@ var stylesheet_default = {
|
|
|
1336
1429
|
return result;
|
|
1337
1430
|
}
|
|
1338
1431
|
};
|
|
1432
|
+
function updateTextEdit(doc, info, textEdit) {
|
|
1433
|
+
if (!updateRange(doc, info, textEdit.range)) {
|
|
1434
|
+
textEdit.newText = "";
|
|
1435
|
+
textEdit.range = START_OF_FILE;
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
function updateInsertReplaceEdit(doc, info, insertReplaceEdit) {
|
|
1439
|
+
if (!updateRange(doc, info, insertReplaceEdit.insert)) {
|
|
1440
|
+
insertReplaceEdit.newText = "";
|
|
1441
|
+
insertReplaceEdit.insert = START_OF_FILE;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1339
1444
|
function updateRange(doc, info, range) {
|
|
1340
1445
|
const start = info.sourceOffsetAt(info.virtualDoc.offsetAt(range.start));
|
|
1341
1446
|
const end = info.sourceOffsetAt(info.virtualDoc.offsetAt(range.end));
|
|
@@ -1373,7 +1478,7 @@ function getStyleSheetInfo(doc) {
|
|
|
1373
1478
|
}
|
|
1374
1479
|
|
|
1375
1480
|
// src/service/index.ts
|
|
1376
|
-
var plugins = [marko_default,
|
|
1481
|
+
var plugins = [marko_default, StyleSheetService];
|
|
1377
1482
|
var service = {
|
|
1378
1483
|
async doComplete(doc, params, cancel) {
|
|
1379
1484
|
const result = CompletionList3.create([], false);
|
|
@@ -1385,7 +1490,7 @@ var service = {
|
|
|
1385
1490
|
for (const pending of requests) {
|
|
1386
1491
|
const cur = await pending;
|
|
1387
1492
|
if (cancel.isCancellationRequested)
|
|
1388
|
-
|
|
1493
|
+
return;
|
|
1389
1494
|
if (cur) {
|
|
1390
1495
|
let items;
|
|
1391
1496
|
if (Array.isArray(cur)) {
|
|
@@ -1413,7 +1518,7 @@ var service = {
|
|
|
1413
1518
|
for (const pending of requests) {
|
|
1414
1519
|
const cur = await pending;
|
|
1415
1520
|
if (cancel.isCancellationRequested)
|
|
1416
|
-
|
|
1521
|
+
return;
|
|
1417
1522
|
if (cur) {
|
|
1418
1523
|
if (Array.isArray(cur)) {
|
|
1419
1524
|
result.push(...cur);
|
|
@@ -1427,6 +1532,54 @@ var service = {
|
|
|
1427
1532
|
}
|
|
1428
1533
|
return result;
|
|
1429
1534
|
},
|
|
1535
|
+
async findDocumentColors(doc, params, cancel) {
|
|
1536
|
+
let result;
|
|
1537
|
+
try {
|
|
1538
|
+
const requests = plugins.map((plugin) => {
|
|
1539
|
+
var _a;
|
|
1540
|
+
return (_a = plugin.findDocumentColors) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1541
|
+
});
|
|
1542
|
+
for (const pending of requests) {
|
|
1543
|
+
const cur = await pending;
|
|
1544
|
+
if (cancel.isCancellationRequested)
|
|
1545
|
+
return;
|
|
1546
|
+
if (cur) {
|
|
1547
|
+
if (result) {
|
|
1548
|
+
result.push(...cur);
|
|
1549
|
+
} else {
|
|
1550
|
+
result = cur;
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
} catch (err) {
|
|
1555
|
+
displayError(err);
|
|
1556
|
+
}
|
|
1557
|
+
return result;
|
|
1558
|
+
},
|
|
1559
|
+
async getColorPresentations(doc, params, cancel) {
|
|
1560
|
+
let result;
|
|
1561
|
+
try {
|
|
1562
|
+
const requests = plugins.map((plugin) => {
|
|
1563
|
+
var _a;
|
|
1564
|
+
return (_a = plugin.getColorPresentations) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1565
|
+
});
|
|
1566
|
+
for (const pending of requests) {
|
|
1567
|
+
const cur = await pending;
|
|
1568
|
+
if (cancel.isCancellationRequested)
|
|
1569
|
+
return;
|
|
1570
|
+
if (cur) {
|
|
1571
|
+
if (result) {
|
|
1572
|
+
result.push(...cur);
|
|
1573
|
+
} else {
|
|
1574
|
+
result = cur;
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
} catch (err) {
|
|
1579
|
+
displayError(err);
|
|
1580
|
+
}
|
|
1581
|
+
return result;
|
|
1582
|
+
},
|
|
1430
1583
|
async doHover(doc, params, cancel) {
|
|
1431
1584
|
var _a;
|
|
1432
1585
|
try {
|
|
@@ -1441,6 +1594,80 @@ var service = {
|
|
|
1441
1594
|
displayError(err);
|
|
1442
1595
|
}
|
|
1443
1596
|
},
|
|
1597
|
+
async doRename(doc, params, cancel) {
|
|
1598
|
+
let changes;
|
|
1599
|
+
let changeAnnotations;
|
|
1600
|
+
let documentChanges;
|
|
1601
|
+
try {
|
|
1602
|
+
const requests = plugins.map((plugin) => {
|
|
1603
|
+
var _a;
|
|
1604
|
+
return (_a = plugin.doRename) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1605
|
+
});
|
|
1606
|
+
for (const pending of requests) {
|
|
1607
|
+
const cur = await pending;
|
|
1608
|
+
if (cancel.isCancellationRequested)
|
|
1609
|
+
return;
|
|
1610
|
+
if (cur) {
|
|
1611
|
+
if (cur.changes) {
|
|
1612
|
+
if (changes) {
|
|
1613
|
+
for (const uri in cur.changes) {
|
|
1614
|
+
if (changes[uri]) {
|
|
1615
|
+
changes[uri].push(...cur.changes[uri]);
|
|
1616
|
+
} else {
|
|
1617
|
+
changes[uri] = cur.changes[uri];
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
} else {
|
|
1621
|
+
changes = cur.changes;
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
if (cur.changeAnnotations) {
|
|
1625
|
+
if (changeAnnotations) {
|
|
1626
|
+
Object.assign(changeAnnotations, cur.changeAnnotations);
|
|
1627
|
+
} else {
|
|
1628
|
+
changeAnnotations = cur.changeAnnotations;
|
|
1629
|
+
}
|
|
1630
|
+
}
|
|
1631
|
+
if (cur.documentChanges) {
|
|
1632
|
+
if (documentChanges) {
|
|
1633
|
+
documentChanges.push(...cur.documentChanges);
|
|
1634
|
+
} else {
|
|
1635
|
+
documentChanges = cur.documentChanges;
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
} catch (err) {
|
|
1641
|
+
displayError(err);
|
|
1642
|
+
}
|
|
1643
|
+
if (changes || changeAnnotations || documentChanges) {
|
|
1644
|
+
return {
|
|
1645
|
+
changes,
|
|
1646
|
+
changeAnnotations,
|
|
1647
|
+
documentChanges
|
|
1648
|
+
};
|
|
1649
|
+
}
|
|
1650
|
+
},
|
|
1651
|
+
async doCodeActions(doc, params, cancel) {
|
|
1652
|
+
const result = [];
|
|
1653
|
+
try {
|
|
1654
|
+
const requests = plugins.map((plugin) => {
|
|
1655
|
+
var _a;
|
|
1656
|
+
return (_a = plugin.doCodeActions) == null ? void 0 : _a.call(plugin, doc, params, cancel);
|
|
1657
|
+
});
|
|
1658
|
+
for (const pending of requests) {
|
|
1659
|
+
const cur = await pending;
|
|
1660
|
+
if (cancel.isCancellationRequested)
|
|
1661
|
+
return;
|
|
1662
|
+
if (cur) {
|
|
1663
|
+
result.push(...cur);
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
} catch (err) {
|
|
1667
|
+
displayError(err);
|
|
1668
|
+
}
|
|
1669
|
+
return result;
|
|
1670
|
+
},
|
|
1444
1671
|
async doValidate(doc) {
|
|
1445
1672
|
const result = [];
|
|
1446
1673
|
try {
|
|
@@ -1486,6 +1713,9 @@ connection2.onInitialize(() => {
|
|
|
1486
1713
|
documentFormattingProvider: true,
|
|
1487
1714
|
definitionProvider: true,
|
|
1488
1715
|
hoverProvider: true,
|
|
1716
|
+
renameProvider: true,
|
|
1717
|
+
codeActionProvider: true,
|
|
1718
|
+
colorProvider: true,
|
|
1489
1719
|
completionProvider: {
|
|
1490
1720
|
triggerCharacters: [
|
|
1491
1721
|
".",
|
|
@@ -1525,9 +1755,21 @@ connection2.onCompletion(async (params, cancel) => {
|
|
|
1525
1755
|
connection2.onDefinition(async (params, cancel) => {
|
|
1526
1756
|
return await service.findDefinition(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1527
1757
|
});
|
|
1758
|
+
connection2.onDocumentColor(async (params, cancel) => {
|
|
1759
|
+
return await service.findDocumentColors(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1760
|
+
});
|
|
1761
|
+
connection2.onColorPresentation(async (params, cancel) => {
|
|
1762
|
+
return await service.getColorPresentations(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1763
|
+
});
|
|
1528
1764
|
connection2.onHover(async (params, cancel) => {
|
|
1529
1765
|
return await service.doHover(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1530
1766
|
});
|
|
1767
|
+
connection2.onRenameRequest(async (params, cancel) => {
|
|
1768
|
+
return await service.doRename(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1769
|
+
});
|
|
1770
|
+
connection2.onCodeAction(async (params, cancel) => {
|
|
1771
|
+
return await service.doCodeActions(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1772
|
+
});
|
|
1531
1773
|
connection2.onDocumentFormatting(async (params, cancel) => {
|
|
1532
1774
|
return await service.format(documents.get(params.textDocument.uri), params, cancel) || null;
|
|
1533
1775
|
});
|