@markdy/language-server 0.7.18 → 0.7.19
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 +13 -6
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -175,29 +175,33 @@ function buildSemanticTokenData(document) {
|
|
|
175
175
|
for (let line = 0; line < lines.length; line++) {
|
|
176
176
|
const content = lines[line];
|
|
177
177
|
const head = content.trim();
|
|
178
|
+
const tokens = [];
|
|
178
179
|
for (const keyword of KEYWORDS) {
|
|
179
|
-
|
|
180
|
-
if (idx === 0) {
|
|
180
|
+
if (head.startsWith(keyword) && !/\w/.test(head.charAt(keyword.length))) {
|
|
181
181
|
const start = content.indexOf(keyword);
|
|
182
|
-
if (start >= 0)
|
|
182
|
+
if (start >= 0) tokens.push({ char: start, length: keyword.length, type: "keyword" });
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
for (const name of actors) {
|
|
186
186
|
const match = new RegExp(`\\b${name}\\b`).exec(content);
|
|
187
187
|
if (match?.index !== void 0) {
|
|
188
|
-
|
|
188
|
+
tokens.push({ char: match.index, length: name.length, type: "variable" });
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
191
|
const actionMatch = /\.\s*([A-Za-z_]\w*)\s*\(/.exec(content);
|
|
192
192
|
if (actionMatch?.index !== void 0) {
|
|
193
193
|
const actionName = actionMatch[1];
|
|
194
194
|
const actionStart = actionMatch.index + actionMatch[0].indexOf(actionName);
|
|
195
|
-
|
|
195
|
+
tokens.push({ char: actionStart, length: actionName.length, type: "method" });
|
|
196
196
|
}
|
|
197
197
|
const defMatch = /^def\s+([A-Za-z_]\w*)/.exec(head);
|
|
198
198
|
if (defMatch) {
|
|
199
199
|
const start = content.indexOf(defMatch[1]);
|
|
200
|
-
if (start >= 0)
|
|
200
|
+
if (start >= 0) tokens.push({ char: start, length: defMatch[1].length, type: "class" });
|
|
201
|
+
}
|
|
202
|
+
tokens.sort((a, b) => a.char - b.char);
|
|
203
|
+
for (const token of tokens) {
|
|
204
|
+
pushSemanticToken(data, cursor, line, token.char, token.length, token.type);
|
|
201
205
|
}
|
|
202
206
|
}
|
|
203
207
|
return data;
|
|
@@ -277,6 +281,9 @@ connection.onInitialize((_params) => ({
|
|
|
277
281
|
}));
|
|
278
282
|
documents.onDidOpen((e) => validateTextDocument(e.document));
|
|
279
283
|
documents.onDidChangeContent((e) => validateTextDocument(e.document));
|
|
284
|
+
documents.onDidClose((e) => {
|
|
285
|
+
connection.sendDiagnostics({ uri: e.document.uri, diagnostics: [] });
|
|
286
|
+
});
|
|
280
287
|
connection.onCompletion((params) => {
|
|
281
288
|
const doc = documents.get(params.textDocument.uri);
|
|
282
289
|
if (!doc) return [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/language-server",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.19",
|
|
4
4
|
"description": "Language Server Protocol implementation for MarkdyScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"vscode-languageserver": "^9.0.1",
|
|
46
46
|
"vscode-languageserver-textdocument": "^1.0.12",
|
|
47
|
-
"@markdy/core": "0.7.
|
|
47
|
+
"@markdy/core": "0.7.19"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"tsup": "^8.5.1",
|