@webgal/language-server 0.0.2-alpha.0 → 0.0.2-alpha.2
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/build/browser.cjs +21 -11
- package/build/browser.mjs +22 -12
- package/build/index.cjs +20 -10
- package/build/index.mjs +21 -11
- package/build/{onInitialize-Czud2_xG.cjs → onInitialize-7r14ko5I.cjs} +72 -77
- package/build/{onInitialize-B6oAsPYj.mjs → onInitialize-DLHBz6ds.mjs} +74 -79
- package/build/utils.cjs +272 -89
- package/build/utils.d.cts +29 -8
- package/build/utils.d.mts +30 -9
- package/build/utils.mjs +266 -89
- package/package.json +4 -4
package/build/browser.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
require('./providerState-B7hGbqQj.cjs');
|
|
3
3
|
const require_utils = require('./utils.cjs');
|
|
4
|
-
const require_onInitialize = require('./onInitialize-
|
|
4
|
+
const require_onInitialize = require('./onInitialize-7r14ko5I.cjs');
|
|
5
5
|
let _volar_language_server_browser = require("@volar/language-server/browser");
|
|
6
6
|
|
|
7
7
|
//#region src/browser.ts
|
|
@@ -11,16 +11,26 @@ function startServer(connection) {
|
|
|
11
11
|
const documents = server.documents;
|
|
12
12
|
require_utils.bindCoreFileAccessorToClientVfs(connection);
|
|
13
13
|
server.fileSystem.install("file", require_utils.createClientVfsFileSystem(connection));
|
|
14
|
-
const webgalLanguagePlugin = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
const webgalLanguagePlugin = {
|
|
15
|
+
getLanguageId(scriptId) {
|
|
16
|
+
const path = scriptId.path.toLowerCase();
|
|
17
|
+
if (scriptId.scheme !== "file") {
|
|
18
|
+
if (path.endsWith("/game/config.txt") || path.endsWith("config.txt")) return "webgal-config";
|
|
19
|
+
if (path.endsWith(".txt")) return "webgal";
|
|
20
|
+
return "webgal";
|
|
21
|
+
}
|
|
22
|
+
if (path.endsWith("/game/config.txt")) return "webgal-config";
|
|
23
|
+
if (path.endsWith(".txt") && path.includes("/game/scene/")) return "webgal";
|
|
24
|
+
},
|
|
25
|
+
createVirtualCode(scriptId, languageId, snapshot) {
|
|
26
|
+
if (languageId !== "webgal" && languageId !== "webgal-config") return;
|
|
27
|
+
return require_utils.createWebgalVirtualCode(scriptId, languageId, snapshot);
|
|
28
|
+
},
|
|
29
|
+
updateVirtualCode(_scriptId, virtualCode, newSnapshot) {
|
|
30
|
+
if (virtualCode.languageId !== "webgal" && virtualCode.languageId !== "webgal-config") return;
|
|
31
|
+
return require_utils.updateWebgalVirtualCode(virtualCode, newSnapshot);
|
|
20
32
|
}
|
|
21
|
-
|
|
22
|
-
if (path.endsWith(".txt") && path.includes("/game/scene/")) return "webgal";
|
|
23
|
-
} };
|
|
33
|
+
};
|
|
24
34
|
connection.onInitialize((params) => {
|
|
25
35
|
require_onInitialize.applyClientCapabilities(params);
|
|
26
36
|
const result = server.initialize(params, (0, _volar_language_server_browser.createSimpleProject)([webgalLanguagePlugin]), [require_onInitialize.createWebgalService(connection)]);
|
|
@@ -28,8 +38,8 @@ function startServer(connection) {
|
|
|
28
38
|
return result;
|
|
29
39
|
});
|
|
30
40
|
connection.onInitialized(() => {
|
|
31
|
-
require_onInitialize.registerConnectionHandlers(documents, connection);
|
|
32
41
|
server.initialized();
|
|
42
|
+
require_onInitialize.registerConnectionHandlers(documents, connection);
|
|
33
43
|
});
|
|
34
44
|
connection.onShutdown(server.shutdown);
|
|
35
45
|
connection.listen();
|
package/build/browser.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./providerState-CLCXHs37.mjs";
|
|
2
|
-
import { bindCoreFileAccessorToClientVfs, createClientVfsFileSystem } from "./utils.mjs";
|
|
3
|
-
import { i as registerConnectionHandlers, n as applyServerCapabilities, r as createWebgalService, t as applyClientCapabilities } from "./onInitialize-
|
|
2
|
+
import { bindCoreFileAccessorToClientVfs, createClientVfsFileSystem, createWebgalVirtualCode, updateWebgalVirtualCode } from "./utils.mjs";
|
|
3
|
+
import { i as registerConnectionHandlers, n as applyServerCapabilities, r as createWebgalService, t as applyClientCapabilities } from "./onInitialize-DLHBz6ds.mjs";
|
|
4
4
|
import { createConnection, createConnection as createConnection$1, createServer, createSimpleProject } from "@volar/language-server/browser";
|
|
5
5
|
|
|
6
6
|
//#region src/browser.ts
|
|
@@ -10,16 +10,26 @@ function startServer(connection) {
|
|
|
10
10
|
const documents = server.documents;
|
|
11
11
|
bindCoreFileAccessorToClientVfs(connection);
|
|
12
12
|
server.fileSystem.install("file", createClientVfsFileSystem(connection));
|
|
13
|
-
const webgalLanguagePlugin = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
const webgalLanguagePlugin = {
|
|
14
|
+
getLanguageId(scriptId) {
|
|
15
|
+
const path = scriptId.path.toLowerCase();
|
|
16
|
+
if (scriptId.scheme !== "file") {
|
|
17
|
+
if (path.endsWith("/game/config.txt") || path.endsWith("config.txt")) return "webgal-config";
|
|
18
|
+
if (path.endsWith(".txt")) return "webgal";
|
|
19
|
+
return "webgal";
|
|
20
|
+
}
|
|
21
|
+
if (path.endsWith("/game/config.txt")) return "webgal-config";
|
|
22
|
+
if (path.endsWith(".txt") && path.includes("/game/scene/")) return "webgal";
|
|
23
|
+
},
|
|
24
|
+
createVirtualCode(scriptId, languageId, snapshot) {
|
|
25
|
+
if (languageId !== "webgal" && languageId !== "webgal-config") return;
|
|
26
|
+
return createWebgalVirtualCode(scriptId, languageId, snapshot);
|
|
27
|
+
},
|
|
28
|
+
updateVirtualCode(_scriptId, virtualCode, newSnapshot) {
|
|
29
|
+
if (virtualCode.languageId !== "webgal" && virtualCode.languageId !== "webgal-config") return;
|
|
30
|
+
return updateWebgalVirtualCode(virtualCode, newSnapshot);
|
|
19
31
|
}
|
|
20
|
-
|
|
21
|
-
if (path.endsWith(".txt") && path.includes("/game/scene/")) return "webgal";
|
|
22
|
-
} };
|
|
32
|
+
};
|
|
23
33
|
connection.onInitialize((params) => {
|
|
24
34
|
applyClientCapabilities(params);
|
|
25
35
|
const result = server.initialize(params, createSimpleProject([webgalLanguagePlugin]), [createWebgalService(connection)]);
|
|
@@ -27,8 +37,8 @@ function startServer(connection) {
|
|
|
27
37
|
return result;
|
|
28
38
|
});
|
|
29
39
|
connection.onInitialized(() => {
|
|
30
|
-
registerConnectionHandlers(documents, connection);
|
|
31
40
|
server.initialized();
|
|
41
|
+
registerConnectionHandlers(documents, connection);
|
|
32
42
|
});
|
|
33
43
|
connection.onShutdown(server.shutdown);
|
|
34
44
|
connection.listen();
|
package/build/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require('./providerState-B7hGbqQj.cjs');
|
|
2
2
|
const require_utils = require('./utils.cjs');
|
|
3
|
-
const require_onInitialize = require('./onInitialize-
|
|
3
|
+
const require_onInitialize = require('./onInitialize-7r14ko5I.cjs');
|
|
4
4
|
let _volar_language_server_node = require("@volar/language-server/node");
|
|
5
5
|
let vscode_languageserver_node = require("vscode-languageserver/node");
|
|
6
6
|
|
|
@@ -47,16 +47,26 @@ function startServer(connection, useClientVfs) {
|
|
|
47
47
|
if (useClientVfs) server.fileSystem.install("file", require_utils.createClientVfsFileSystem(connection));
|
|
48
48
|
connection.onInitialize((params) => {
|
|
49
49
|
require_onInitialize.applyClientCapabilities(params);
|
|
50
|
-
const result = server.initialize(params, (0, _volar_language_server_node.createSimpleProject)([{
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
const result = server.initialize(params, (0, _volar_language_server_node.createSimpleProject)([{
|
|
51
|
+
getLanguageId(scriptId) {
|
|
52
|
+
const path = scriptId.path.toLowerCase();
|
|
53
|
+
if (scriptId.scheme !== "file") {
|
|
54
|
+
if (path.endsWith("/game/config.txt") || path.endsWith("config.txt")) return "webgal-config";
|
|
55
|
+
if (path.endsWith(".txt")) return "webgal";
|
|
56
|
+
return "webgal";
|
|
57
|
+
}
|
|
58
|
+
if (path.endsWith("/game/config.txt")) return "webgal-config";
|
|
59
|
+
if (path.endsWith(".txt") && path.includes("/game/scene/")) return "webgal";
|
|
60
|
+
},
|
|
61
|
+
createVirtualCode(scriptId, languageId, snapshot) {
|
|
62
|
+
if (languageId !== "webgal" && languageId !== "webgal-config") return;
|
|
63
|
+
return require_utils.createWebgalVirtualCode(scriptId, languageId, snapshot);
|
|
64
|
+
},
|
|
65
|
+
updateVirtualCode(_scriptId, virtualCode, newSnapshot) {
|
|
66
|
+
if (virtualCode.languageId !== "webgal" && virtualCode.languageId !== "webgal-config") return;
|
|
67
|
+
return require_utils.updateWebgalVirtualCode(virtualCode, newSnapshot);
|
|
56
68
|
}
|
|
57
|
-
|
|
58
|
-
if (path.endsWith(".txt") && path.includes("/game/scene/")) return "webgal";
|
|
59
|
-
} }]), [require_onInitialize.createWebgalService(connection)]);
|
|
69
|
+
}]), [require_onInitialize.createWebgalService(connection)]);
|
|
60
70
|
require_onInitialize.applyServerCapabilities(result);
|
|
61
71
|
return result;
|
|
62
72
|
});
|
package/build/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./providerState-CLCXHs37.mjs";
|
|
2
|
-
import { bindCoreFileAccessorToClientVfs, createClientVfsFileSystem } from "./utils.mjs";
|
|
3
|
-
import { i as registerConnectionHandlers, n as applyServerCapabilities, r as createWebgalService, t as applyClientCapabilities } from "./onInitialize-
|
|
2
|
+
import { bindCoreFileAccessorToClientVfs, createClientVfsFileSystem, createWebgalVirtualCode, updateWebgalVirtualCode } from "./utils.mjs";
|
|
3
|
+
import { i as registerConnectionHandlers, n as applyServerCapabilities, r as createWebgalService, t as applyClientCapabilities } from "./onInitialize-DLHBz6ds.mjs";
|
|
4
4
|
import { createConnection, createServer, createSimpleProject } from "@volar/language-server/node";
|
|
5
5
|
import { createConnection as createConnection$1 } from "vscode-languageserver/node";
|
|
6
6
|
|
|
@@ -47,16 +47,26 @@ function startServer(connection, useClientVfs) {
|
|
|
47
47
|
if (useClientVfs) server.fileSystem.install("file", createClientVfsFileSystem(connection));
|
|
48
48
|
connection.onInitialize((params) => {
|
|
49
49
|
applyClientCapabilities(params);
|
|
50
|
-
const result = server.initialize(params, createSimpleProject([{
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
const result = server.initialize(params, createSimpleProject([{
|
|
51
|
+
getLanguageId(scriptId) {
|
|
52
|
+
const path = scriptId.path.toLowerCase();
|
|
53
|
+
if (scriptId.scheme !== "file") {
|
|
54
|
+
if (path.endsWith("/game/config.txt") || path.endsWith("config.txt")) return "webgal-config";
|
|
55
|
+
if (path.endsWith(".txt")) return "webgal";
|
|
56
|
+
return "webgal";
|
|
57
|
+
}
|
|
58
|
+
if (path.endsWith("/game/config.txt")) return "webgal-config";
|
|
59
|
+
if (path.endsWith(".txt") && path.includes("/game/scene/")) return "webgal";
|
|
60
|
+
},
|
|
61
|
+
createVirtualCode(scriptId, languageId, snapshot) {
|
|
62
|
+
if (languageId !== "webgal" && languageId !== "webgal-config") return;
|
|
63
|
+
return createWebgalVirtualCode(scriptId, languageId, snapshot);
|
|
64
|
+
},
|
|
65
|
+
updateVirtualCode(_scriptId, virtualCode, newSnapshot) {
|
|
66
|
+
if (virtualCode.languageId !== "webgal" && virtualCode.languageId !== "webgal-config") return;
|
|
67
|
+
return updateWebgalVirtualCode(virtualCode, newSnapshot);
|
|
56
68
|
}
|
|
57
|
-
|
|
58
|
-
if (path.endsWith(".txt") && path.includes("/game/scene/")) return "webgal";
|
|
59
|
-
} }]), [createWebgalService(connection)]);
|
|
69
|
+
}]), [createWebgalService(connection)]);
|
|
60
70
|
applyServerCapabilities(result);
|
|
61
71
|
return result;
|
|
62
72
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_utils = require('./utils.cjs');
|
|
2
|
-
let _webgal_language_core = require("@webgal/language-core");
|
|
3
2
|
let _volar_language_server = require("@volar/language-server");
|
|
3
|
+
let vscode_uri = require("vscode-uri");
|
|
4
4
|
|
|
5
5
|
//#region src/events/onDid.ts
|
|
6
6
|
var onDid_default = function(documents, connection) {
|
|
@@ -12,6 +12,9 @@ var onDid_default = function(documents, connection) {
|
|
|
12
12
|
else require_utils.setGlobalSettings(change.settings.XRWebGalLanguageServer || require_utils.defaultSettings);
|
|
13
13
|
connection.languages.diagnostics.refresh();
|
|
14
14
|
});
|
|
15
|
+
connection.onNotification("webgal/vfsChanged", () => {
|
|
16
|
+
connection.sendRequest("workspace/documentLink/refresh");
|
|
17
|
+
});
|
|
15
18
|
};
|
|
16
19
|
|
|
17
20
|
//#endregion
|
|
@@ -1172,9 +1175,9 @@ function getTypeDirectory(command, fileName) {
|
|
|
1172
1175
|
|
|
1173
1176
|
//#endregion
|
|
1174
1177
|
//#region src/events/onCompletion.ts
|
|
1175
|
-
async function provideCompletionItems(document, position, connection) {
|
|
1176
|
-
const file_name =
|
|
1177
|
-
const documentTextArray =
|
|
1178
|
+
async function provideCompletionItems(document, position, connection, definitionMap, lines, lineCommandTypes, sourceUri) {
|
|
1179
|
+
const file_name = sourceUri;
|
|
1180
|
+
const documentTextArray = lines;
|
|
1178
1181
|
const { token } = require_utils.findTokenRange(document, position);
|
|
1179
1182
|
const CompletionItemSuggestions = [];
|
|
1180
1183
|
if (file_name.endsWith("/game/config.txt")) {
|
|
@@ -1226,8 +1229,8 @@ async function provideCompletionItems(document, position, connection) {
|
|
|
1226
1229
|
return CompletionItemSuggestions;
|
|
1227
1230
|
}
|
|
1228
1231
|
const wordMeta = require_utils.getWordAtPosition(document, _volar_language_server.Position.create(position.line, 0));
|
|
1229
|
-
const currentLine = documentTextArray[position.line];
|
|
1230
|
-
const commandType =
|
|
1232
|
+
const currentLine = documentTextArray[position.line] ?? "";
|
|
1233
|
+
const commandType = lineCommandTypes[position.line] ?? "";
|
|
1231
1234
|
const isSayCommandType = !resourcesMap[commandType];
|
|
1232
1235
|
if (token.startsWith("./") || !!~token.indexOf("/") || Object.keys(resourcesMap).includes(commandType) || token.startsWith("-")) {
|
|
1233
1236
|
const resourceBaseDir = isSayCommandType ? "vocal" : resourcesMap[commandType];
|
|
@@ -1252,10 +1255,9 @@ async function provideCompletionItems(document, position, connection) {
|
|
|
1252
1255
|
return CompletionItemSuggestions;
|
|
1253
1256
|
}
|
|
1254
1257
|
if (token) {
|
|
1255
|
-
|
|
1256
|
-
const currentPool = _webgal_language_core.GlobalMap.setVar;
|
|
1258
|
+
const currentPool = definitionMap.setVar;
|
|
1257
1259
|
for (const key in currentPool) if (key.includes(token)) {
|
|
1258
|
-
const latest =
|
|
1260
|
+
const latest = definitionMap.setVar[key][definitionMap.setVar[key].length - 1];
|
|
1259
1261
|
CompletionItemSuggestions.push({
|
|
1260
1262
|
label: key,
|
|
1261
1263
|
kind: _volar_language_server.CompletionItemKind.Variable,
|
|
@@ -1276,89 +1278,73 @@ async function provideCompletionItems(document, position, connection) {
|
|
|
1276
1278
|
|
|
1277
1279
|
//#endregion
|
|
1278
1280
|
//#region src/events/onDefinition.ts
|
|
1279
|
-
function provideDefinition(document, position) {
|
|
1281
|
+
function provideDefinition(document, position, definitionMap) {
|
|
1280
1282
|
const text = document.getText();
|
|
1281
1283
|
const findWord = require_utils.getWordAtPosition(document, position);
|
|
1282
1284
|
const definitionLinks = [];
|
|
1283
1285
|
if (!findWord) return definitionLinks;
|
|
1284
|
-
const
|
|
1285
|
-
const currentLine = documentTextArray[position.line];
|
|
1286
|
+
const currentLine = text.split("\n")[position.line];
|
|
1286
1287
|
const commandType = currentLine.substring(0, currentLine.indexOf(":") !== -1 ? currentLine.indexOf(":") : currentLine.indexOf(";"));
|
|
1287
|
-
|
|
1288
|
-
const
|
|
1289
|
-
const setVarMap = _webgal_language_core.GlobalMap.setVar;
|
|
1288
|
+
const jumpLabelMap = definitionMap.label;
|
|
1289
|
+
const setVarMap = definitionMap.setVar;
|
|
1290
1290
|
const targetPool = ["jumpLabel", "choose"].includes(commandType) ? jumpLabelMap : setVarMap;
|
|
1291
1291
|
if (!targetPool) return definitionLinks;
|
|
1292
1292
|
const targetPoolArray = targetPool[findWord.word];
|
|
1293
1293
|
if (!targetPoolArray) return definitionLinks;
|
|
1294
|
-
for (const current of targetPoolArray) if (current.word === findWord.word) definitionLinks.push(_volar_language_server.LocationLink.create(document.uri, _volar_language_server.Range.create(_volar_language_server.Position.create(position.line, findWord.start), _volar_language_server.Position.create(position.line, findWord.end)), _volar_language_server.Range.create(current.position, current.position), _volar_language_server.Range.create(_volar_language_server.Position.create(0, 0), _volar_language_server.Position.create(0, 0))));
|
|
1294
|
+
for (const current of targetPoolArray) if (current.word === findWord.word && current.position) definitionLinks.push(_volar_language_server.LocationLink.create(document.uri, _volar_language_server.Range.create(_volar_language_server.Position.create(position.line, findWord.start), _volar_language_server.Position.create(position.line, findWord.end)), _volar_language_server.Range.create(_volar_language_server.Position.create(current.position.line, current.position.character), _volar_language_server.Position.create(current.position.line, current.position.character)), _volar_language_server.Range.create(_volar_language_server.Position.create(0, 0), _volar_language_server.Position.create(0, 0))));
|
|
1295
1295
|
return definitionLinks;
|
|
1296
1296
|
}
|
|
1297
1297
|
|
|
1298
1298
|
//#endregion
|
|
1299
1299
|
//#region src/events/onDocumentLinks.ts
|
|
1300
|
-
async function provideDocumentLinks(document, connection) {
|
|
1301
|
-
const
|
|
1300
|
+
async function provideDocumentLinks(document, connection, candidates) {
|
|
1301
|
+
const toFileTarget = (path) => {
|
|
1302
|
+
if (!path) return;
|
|
1303
|
+
if (path.startsWith("file://")) return vscode_uri.URI.parse(path).toString();
|
|
1304
|
+
return vscode_uri.URI.file(path).toString();
|
|
1305
|
+
};
|
|
1302
1306
|
const pathArray = document.uri.split("/");
|
|
1303
1307
|
const currentDirectory = await connection.sendRequest("client/currentDirectory");
|
|
1304
1308
|
const documentLinks = [];
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
if (
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
documentLinks.push({
|
|
1323
|
-
target: "file:///" + basePath,
|
|
1324
|
-
range: _volar_language_server.Range.create(_volar_language_server.Position.create(i, match.index), _volar_language_server.Position.create(i, match.index + matchText.length)),
|
|
1325
|
-
tooltip: basePath
|
|
1326
|
-
});
|
|
1327
|
-
if (regex.lastIndex === match.index) regex.lastIndex++;
|
|
1309
|
+
const pathName = pathArray[pathArray.length - 3 > 0 ? pathArray.length - 3 : pathArray.length - 2];
|
|
1310
|
+
const isConfig = pathArray[pathArray.length - 1] === "config.txt" && pathArray[pathArray.length - 2] === "game" && pathName === pathArray[pathArray.length - 3];
|
|
1311
|
+
for (const candidate of candidates) {
|
|
1312
|
+
const matchText = candidate.text;
|
|
1313
|
+
const dirResources = getTypeDirectory(candidate.command, matchText);
|
|
1314
|
+
let targetPath;
|
|
1315
|
+
if (isConfig) targetPath = await connection.sendRequest("client/FJoin", currentDirectory + "/");
|
|
1316
|
+
else targetPath = await connection.sendRequest("client/FJoin", currentDirectory + "/" + dirResources);
|
|
1317
|
+
const defaultPath = await connection.sendRequest("client/FJoin", targetPath + "/" + matchText);
|
|
1318
|
+
let stat = await connection.sendRequest("client/FStat", defaultPath);
|
|
1319
|
+
let resolvedPath = defaultPath;
|
|
1320
|
+
if (!stat) {
|
|
1321
|
+
const foundPath = await connection.sendRequest("client/findFile", [currentDirectory, matchText]);
|
|
1322
|
+
if (foundPath) {
|
|
1323
|
+
resolvedPath = foundPath;
|
|
1324
|
+
stat = await connection.sendRequest("client/FStat", resolvedPath);
|
|
1325
|
+
}
|
|
1328
1326
|
}
|
|
1327
|
+
const tooltip = stat && resolvedPath ? resolvedPath : "unknown file";
|
|
1328
|
+
documentLinks.push({
|
|
1329
|
+
target: toFileTarget(resolvedPath),
|
|
1330
|
+
range: _volar_language_server.Range.create(_volar_language_server.Position.create(candidate.line, candidate.start), _volar_language_server.Position.create(candidate.line, candidate.end)),
|
|
1331
|
+
tooltip
|
|
1332
|
+
});
|
|
1329
1333
|
}
|
|
1330
1334
|
return [...documentLinks];
|
|
1331
1335
|
}
|
|
1332
1336
|
|
|
1333
1337
|
//#endregion
|
|
1334
1338
|
//#region src/events/onFoldingRanges.ts
|
|
1335
|
-
function provideFoldingRanges(
|
|
1336
|
-
|
|
1337
|
-
const foldingRanges = [];
|
|
1338
|
-
const regex = /label:([\s\S]*?)(?=(?:\r?\n|^)end|(?:\r?\n|^)label:|$)/g;
|
|
1339
|
-
let match;
|
|
1340
|
-
while (match = regex.exec(docText)) if (match !== null) {
|
|
1341
|
-
const startLine = doc.positionAt(match.index).line;
|
|
1342
|
-
const endPos = doc.positionAt(match.index + match[0].length);
|
|
1343
|
-
let endLine = endPos.line;
|
|
1344
|
-
if (endPos.character === 0) endLine = endPos.line - 1;
|
|
1345
|
-
if (endLine > startLine) foldingRanges.push({
|
|
1346
|
-
startLine,
|
|
1347
|
-
endLine,
|
|
1348
|
-
collapsedText: match[1].split("\n")[0].replace(/;/g, "").trim() || "...",
|
|
1349
|
-
kind: _volar_language_server.FoldingRangeKind.Region
|
|
1350
|
-
});
|
|
1351
|
-
}
|
|
1352
|
-
return foldingRanges;
|
|
1339
|
+
function provideFoldingRanges(_doc, ranges) {
|
|
1340
|
+
return ranges;
|
|
1353
1341
|
}
|
|
1354
1342
|
|
|
1355
1343
|
//#endregion
|
|
1356
1344
|
//#region src/events/onHover.ts
|
|
1357
|
-
async function provideHover(document, position, connection) {
|
|
1358
|
-
const file_name =
|
|
1359
|
-
const
|
|
1360
|
-
const currentLine = documentTextArray[position.line];
|
|
1361
|
-
const commandType = currentLine.substring(0, currentLine.indexOf(":") !== -1 ? currentLine.indexOf(":") : currentLine.indexOf(";"));
|
|
1345
|
+
async function provideHover(document, position, connection, definitionMap, lineCommandTypes, sourceUri) {
|
|
1346
|
+
const file_name = sourceUri;
|
|
1347
|
+
const commandType = lineCommandTypes[position.line] ?? "";
|
|
1362
1348
|
let findWordWithPattern = require_utils.getPatternAtPosition(document, position, /\{([^}]*)\}/);
|
|
1363
1349
|
findWordWithPattern = require_utils.getPatternAtPosition(document, position, /(?<=-)[\w]+/);
|
|
1364
1350
|
if (findWordWithPattern) {
|
|
@@ -1414,9 +1400,8 @@ async function provideHover(document, position, connection) {
|
|
|
1414
1400
|
].join("\n\n")
|
|
1415
1401
|
} };
|
|
1416
1402
|
}
|
|
1417
|
-
require_utils.updateGlobalMap(documentTextArray);
|
|
1418
1403
|
if (findWord && `{${findWord.word}}` !== "{}") {
|
|
1419
|
-
const current =
|
|
1404
|
+
const current = definitionMap.setVar[findWord.word];
|
|
1420
1405
|
if (!current || current.length <= 0) return { contents: [] };
|
|
1421
1406
|
const currentVariable = current[current.length - 1];
|
|
1422
1407
|
const hoverContent = [`### ${findWord.word}`];
|
|
@@ -1426,8 +1411,11 @@ async function provideHover(document, position, connection) {
|
|
|
1426
1411
|
hoverContent.push(currentVariable.desc);
|
|
1427
1412
|
}
|
|
1428
1413
|
hoverContent.push("<hr>");
|
|
1429
|
-
if (findWord.word in
|
|
1430
|
-
|
|
1414
|
+
if (findWord.word in definitionMap.setVar) {
|
|
1415
|
+
const positionValue = currentVariable.position;
|
|
1416
|
+
const line = positionValue && typeof positionValue.line === "number" ? positionValue.line : -1;
|
|
1417
|
+
const character = positionValue && typeof positionValue.character === "number" ? positionValue.character : -1;
|
|
1418
|
+
hoverContent.push(`Position: ${line + 1},${character + 1}`);
|
|
1431
1419
|
hoverContent.push("```webgal");
|
|
1432
1420
|
hoverContent.push(`${currentVariable.input?.replace(/\t\r\n/g, "")}\n\n\`\`\``);
|
|
1433
1421
|
}
|
|
@@ -1441,8 +1429,8 @@ async function provideHover(document, position, connection) {
|
|
|
1441
1429
|
|
|
1442
1430
|
//#endregion
|
|
1443
1431
|
//#region src/events/onDiagnostics.ts
|
|
1444
|
-
async function provideDiagnostics(document, connection) {
|
|
1445
|
-
return require_utils.validateTextDocument(connection, document);
|
|
1432
|
+
async function provideDiagnostics(document, connection, text) {
|
|
1433
|
+
return require_utils.validateTextDocument(connection, document, text);
|
|
1446
1434
|
}
|
|
1447
1435
|
|
|
1448
1436
|
//#endregion
|
|
@@ -1470,28 +1458,35 @@ function createWebgalService(connection) {
|
|
|
1470
1458
|
foldingRangeProvider: true,
|
|
1471
1459
|
definitionProvider: true
|
|
1472
1460
|
},
|
|
1473
|
-
create() {
|
|
1461
|
+
create(context) {
|
|
1462
|
+
const getDefinitionMap = (document) => require_utils.getWebgalDefinitionMap(context, document);
|
|
1463
|
+
const getVirtualCodeText = (document) => require_utils.getWebgalVirtualCodeText(context, document);
|
|
1464
|
+
const getVirtualCodeLines = (document) => require_utils.getWebgalVirtualCodeLines(context, document);
|
|
1465
|
+
const getLineCommandTypes = (document) => require_utils.getWebgalLineCommandTypes(context, document);
|
|
1466
|
+
const getSourceUriString = (document) => require_utils.getWebgalSourceUriString(context, document);
|
|
1467
|
+
const getDocumentLinkCandidates = (document) => require_utils.getWebgalDocumentLinkCandidates(context, document);
|
|
1468
|
+
const getFoldingRanges = (document) => require_utils.getWebgalFoldingRanges(context, document);
|
|
1474
1469
|
return {
|
|
1475
1470
|
async provideCompletionItems(document, position, _context, _token) {
|
|
1476
1471
|
return {
|
|
1477
1472
|
isIncomplete: false,
|
|
1478
|
-
items: await provideCompletionItems(document, position, connection)
|
|
1473
|
+
items: await provideCompletionItems(document, position, connection, getDefinitionMap(document), getVirtualCodeLines(document), getLineCommandTypes(document), getSourceUriString(document))
|
|
1479
1474
|
};
|
|
1480
1475
|
},
|
|
1481
1476
|
async provideHover(document, position, _token) {
|
|
1482
|
-
return provideHover(document, position, connection);
|
|
1477
|
+
return provideHover(document, position, connection, getDefinitionMap(document), getLineCommandTypes(document), getSourceUriString(document));
|
|
1483
1478
|
},
|
|
1484
1479
|
provideDefinition(document, position, _token) {
|
|
1485
|
-
return provideDefinition(document, position);
|
|
1480
|
+
return provideDefinition(document, position, getDefinitionMap(document));
|
|
1486
1481
|
},
|
|
1487
1482
|
async provideDocumentLinks(document, _token) {
|
|
1488
|
-
return provideDocumentLinks(document, connection);
|
|
1483
|
+
return provideDocumentLinks(document, connection, getDocumentLinkCandidates(document));
|
|
1489
1484
|
},
|
|
1490
1485
|
provideFoldingRanges(document, _token) {
|
|
1491
|
-
return provideFoldingRanges(document);
|
|
1486
|
+
return provideFoldingRanges(document, getFoldingRanges(document));
|
|
1492
1487
|
},
|
|
1493
1488
|
async provideDiagnostics(document, _token) {
|
|
1494
|
-
return provideDiagnostics(document, connection);
|
|
1489
|
+
return provideDiagnostics(document, connection, getVirtualCodeText(document));
|
|
1495
1490
|
}
|
|
1496
1491
|
};
|
|
1497
1492
|
}
|