@spyglassmc/language-server 0.1.0 → 0.1.1
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/lib/server.js +24 -21
- package/lib/util/types.d.ts +3 -0
- package/package.json +5 -5
package/lib/server.js
CHANGED
|
@@ -54,13 +54,16 @@ const logger = {
|
|
|
54
54
|
};
|
|
55
55
|
let service;
|
|
56
56
|
connection.onInitialize(async (params) => {
|
|
57
|
+
const initializationOptions = params.initializationOptions;
|
|
57
58
|
logger.info(`[onInitialize] processId = ${JSON.stringify(params.processId)}`);
|
|
58
59
|
logger.info(`[onInitialize] clientInfo = ${JSON.stringify(params.clientInfo)}`);
|
|
59
|
-
logger.info(`[onInitialize] initializationOptions = ${JSON.stringify(
|
|
60
|
+
logger.info(`[onInitialize] initializationOptions = ${JSON.stringify(initializationOptions)}`);
|
|
60
61
|
capabilities = params.capabilities;
|
|
61
62
|
workspaceFolders = params.workspaceFolders ?? [];
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
if (initializationOptions?.inDevelopmentMode) {
|
|
64
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
65
|
+
logger.warn('Delayed 3 seconds manually. If you see this in production, it means SPGoding messed up.');
|
|
66
|
+
}
|
|
64
67
|
if (params.workDoneToken) {
|
|
65
68
|
progressReporter = connection.window.attachWorkDoneProgress(params.workDoneToken);
|
|
66
69
|
progressReporter.begin(locales.localize('server.progress.preparing.title'));
|
|
@@ -171,10 +174,10 @@ connection.onInitialized(async () => {
|
|
|
171
174
|
});
|
|
172
175
|
}
|
|
173
176
|
});
|
|
174
|
-
connection.onDidOpenTextDocument(
|
|
177
|
+
connection.onDidOpenTextDocument(({ textDocument: { text, uri, version, languageId: languageID } }) => {
|
|
175
178
|
service.project.onDidOpen(uri, languageID, version, text);
|
|
176
179
|
});
|
|
177
|
-
connection.onDidChangeTextDocument(
|
|
180
|
+
connection.onDidChangeTextDocument(({ contentChanges, textDocument: { uri, version } }) => {
|
|
178
181
|
service.project.onDidChange(uri, contentChanges, version);
|
|
179
182
|
});
|
|
180
183
|
connection.onDidCloseTextDocument(({ textDocument: { uri } }) => {
|
|
@@ -183,7 +186,7 @@ connection.onDidCloseTextDocument(({ textDocument: { uri } }) => {
|
|
|
183
186
|
connection.workspace.onDidRenameFiles(({}) => {
|
|
184
187
|
});
|
|
185
188
|
connection.onColorPresentation(async ({ textDocument: { uri }, color, range }) => {
|
|
186
|
-
const docAndNode = await service.project.
|
|
189
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
187
190
|
if (!docAndNode) {
|
|
188
191
|
return undefined;
|
|
189
192
|
}
|
|
@@ -192,7 +195,7 @@ connection.onColorPresentation(async ({ textDocument: { uri }, color, range }) =
|
|
|
192
195
|
return util_1.toLS.colorPresentationArray(presentation, doc);
|
|
193
196
|
});
|
|
194
197
|
connection.onDocumentColor(async ({ textDocument: { uri } }) => {
|
|
195
|
-
const docAndNode = await service.project.
|
|
198
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
196
199
|
if (!docAndNode) {
|
|
197
200
|
return undefined;
|
|
198
201
|
}
|
|
@@ -201,7 +204,7 @@ connection.onDocumentColor(async ({ textDocument: { uri } }) => {
|
|
|
201
204
|
return util_1.toLS.colorInformationArray(info, doc);
|
|
202
205
|
});
|
|
203
206
|
connection.onCompletion(async ({ textDocument: { uri }, position, context }) => {
|
|
204
|
-
const docAndNode = await service.project.
|
|
207
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
205
208
|
if (!docAndNode) {
|
|
206
209
|
return undefined;
|
|
207
210
|
}
|
|
@@ -214,7 +217,7 @@ connection.onRequest('spyglassmc/dataHackPubify', ({ initialism }) => {
|
|
|
214
217
|
return service.dataHackPubify(initialism);
|
|
215
218
|
});
|
|
216
219
|
connection.onDeclaration(async ({ textDocument: { uri }, position }) => {
|
|
217
|
-
const docAndNode = await service.project.
|
|
220
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
218
221
|
if (!docAndNode) {
|
|
219
222
|
return undefined;
|
|
220
223
|
}
|
|
@@ -223,7 +226,7 @@ connection.onDeclaration(async ({ textDocument: { uri }, position }) => {
|
|
|
223
226
|
return util_1.toLS.locationLink(ans, doc, capabilities.textDocument?.declaration?.linkSupport);
|
|
224
227
|
});
|
|
225
228
|
connection.onDefinition(async ({ textDocument: { uri }, position }) => {
|
|
226
|
-
const docAndNode = await service.project.
|
|
229
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
227
230
|
if (!docAndNode) {
|
|
228
231
|
return undefined;
|
|
229
232
|
}
|
|
@@ -232,7 +235,7 @@ connection.onDefinition(async ({ textDocument: { uri }, position }) => {
|
|
|
232
235
|
return util_1.toLS.locationLink(ans, doc, capabilities.textDocument?.definition?.linkSupport);
|
|
233
236
|
});
|
|
234
237
|
connection.onImplementation(async ({ textDocument: { uri }, position }) => {
|
|
235
|
-
const docAndNode = await service.project.
|
|
238
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
236
239
|
if (!docAndNode) {
|
|
237
240
|
return undefined;
|
|
238
241
|
}
|
|
@@ -241,7 +244,7 @@ connection.onImplementation(async ({ textDocument: { uri }, position }) => {
|
|
|
241
244
|
return util_1.toLS.locationLink(ans, doc, capabilities.textDocument?.implementation?.linkSupport);
|
|
242
245
|
});
|
|
243
246
|
connection.onReferences(async ({ textDocument: { uri }, position, context: { includeDeclaration } }) => {
|
|
244
|
-
const docAndNode = await service.project.
|
|
247
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
245
248
|
if (!docAndNode) {
|
|
246
249
|
return undefined;
|
|
247
250
|
}
|
|
@@ -250,7 +253,7 @@ connection.onReferences(async ({ textDocument: { uri }, position, context: { inc
|
|
|
250
253
|
return util_1.toLS.locationLink(ans, doc, false);
|
|
251
254
|
});
|
|
252
255
|
connection.onTypeDefinition(async ({ textDocument: { uri }, position }) => {
|
|
253
|
-
const docAndNode = await service.project.
|
|
256
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
254
257
|
if (!docAndNode) {
|
|
255
258
|
return undefined;
|
|
256
259
|
}
|
|
@@ -259,7 +262,7 @@ connection.onTypeDefinition(async ({ textDocument: { uri }, position }) => {
|
|
|
259
262
|
return util_1.toLS.locationLink(ans, doc, capabilities.textDocument?.typeDefinition?.linkSupport);
|
|
260
263
|
});
|
|
261
264
|
connection.onDocumentHighlight(async ({ textDocument: { uri }, position }) => {
|
|
262
|
-
const docAndNode = await service.project.
|
|
265
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
263
266
|
if (!docAndNode) {
|
|
264
267
|
return undefined;
|
|
265
268
|
}
|
|
@@ -268,7 +271,7 @@ connection.onDocumentHighlight(async ({ textDocument: { uri }, position }) => {
|
|
|
268
271
|
return util_1.toLS.documentHighlight(ans);
|
|
269
272
|
});
|
|
270
273
|
connection.onDocumentSymbol(async ({ textDocument: { uri } }) => {
|
|
271
|
-
const docAndNode = await service.project.
|
|
274
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
272
275
|
if (!docAndNode) {
|
|
273
276
|
return undefined;
|
|
274
277
|
}
|
|
@@ -276,7 +279,7 @@ connection.onDocumentSymbol(async ({ textDocument: { uri } }) => {
|
|
|
276
279
|
return util_1.toLS.documentSymbolsFromTables([service.project.symbols.global, ...core.AstNode.getLocalsToLeaves(node)], doc, capabilities.textDocument?.documentSymbol?.hierarchicalDocumentSymbolSupport, capabilities.textDocument?.documentSymbol?.symbolKind?.valueSet);
|
|
277
280
|
});
|
|
278
281
|
connection.onHover(async ({ textDocument: { uri }, position }) => {
|
|
279
|
-
const docAndNode = await service.project.
|
|
282
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
280
283
|
if (!docAndNode) {
|
|
281
284
|
return undefined;
|
|
282
285
|
}
|
|
@@ -285,7 +288,7 @@ connection.onHover(async ({ textDocument: { uri }, position }) => {
|
|
|
285
288
|
return ans ? util_1.toLS.hover(ans, doc) : undefined;
|
|
286
289
|
});
|
|
287
290
|
connection.onRequest('spyglassmc/inlayHints', async ({ textDocument: { uri }, range }) => {
|
|
288
|
-
const docAndNode = await service.project.
|
|
291
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
289
292
|
if (!docAndNode) {
|
|
290
293
|
return [];
|
|
291
294
|
}
|
|
@@ -301,7 +304,7 @@ connection.onRequest('spyglassmc/showCacheRoot', async () => {
|
|
|
301
304
|
return service.project.showCacheRoot();
|
|
302
305
|
});
|
|
303
306
|
connection.languages.semanticTokens.on(async ({ textDocument: { uri } }) => {
|
|
304
|
-
const docAndNode = await service.project.
|
|
307
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
305
308
|
if (!docAndNode) {
|
|
306
309
|
return { data: [] };
|
|
307
310
|
}
|
|
@@ -310,7 +313,7 @@ connection.languages.semanticTokens.on(async ({ textDocument: { uri } }) => {
|
|
|
310
313
|
return util_1.toLS.semanticTokens(tokens, doc);
|
|
311
314
|
});
|
|
312
315
|
connection.languages.semanticTokens.onRange(async ({ textDocument: { uri }, range }) => {
|
|
313
|
-
const docAndNode = await service.project.
|
|
316
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
314
317
|
if (!docAndNode) {
|
|
315
318
|
return { data: [] };
|
|
316
319
|
}
|
|
@@ -319,7 +322,7 @@ connection.languages.semanticTokens.onRange(async ({ textDocument: { uri }, rang
|
|
|
319
322
|
return util_1.toLS.semanticTokens(tokens, doc);
|
|
320
323
|
});
|
|
321
324
|
connection.onSignatureHelp(async ({ textDocument: { uri }, position }) => {
|
|
322
|
-
const docAndNode = await service.project.
|
|
325
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
323
326
|
if (!docAndNode) {
|
|
324
327
|
return undefined;
|
|
325
328
|
}
|
|
@@ -331,7 +334,7 @@ connection.onWorkspaceSymbol(({ query }) => {
|
|
|
331
334
|
return util_1.toLS.symbolInformationArrayFromTable(service.project.symbols.global, query, capabilities.textDocument?.documentSymbol?.symbolKind?.valueSet);
|
|
332
335
|
});
|
|
333
336
|
connection.onDocumentFormatting(async ({ textDocument: { uri }, options }) => {
|
|
334
|
-
const docAndNode = await service.project.
|
|
337
|
+
const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
|
|
335
338
|
if (!docAndNode) {
|
|
336
339
|
return undefined;
|
|
337
340
|
}
|
package/lib/util/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spyglassmc/language-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"main": "lib/server.js",
|
|
5
5
|
"types": "lib/server.d.ts",
|
|
6
6
|
"author": "SPGoding",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"env-paths": "^2.2.1",
|
|
21
21
|
"vscode-languageserver": "^7.0.0",
|
|
22
22
|
"vscode-languageserver-textdocument": "^1.0.1",
|
|
23
|
-
"@spyglassmc/core": "0.1.
|
|
24
|
-
"@spyglassmc/java-edition": "0.1.
|
|
25
|
-
"@spyglassmc/locales": "0.1.
|
|
26
|
-
"@spyglassmc/nbtdoc": "0.1.
|
|
23
|
+
"@spyglassmc/core": "0.1.1",
|
|
24
|
+
"@spyglassmc/java-edition": "0.1.1",
|
|
25
|
+
"@spyglassmc/locales": "0.1.1",
|
|
26
|
+
"@spyglassmc/nbtdoc": "0.1.1"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|