@spyglassmc/language-server 0.2.0 → 0.3.0

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 CHANGED
@@ -7,7 +7,7 @@ import * as mcdoc from '@spyglassmc/mcdoc';
7
7
  import envPaths from 'env-paths';
8
8
  import url from 'url';
9
9
  import * as util from 'util';
10
- import * as ls from 'vscode-languageserver/node';
10
+ import * as ls from 'vscode-languageserver/node.js';
11
11
  import { toCore, toLS } from './util/index.js';
12
12
  export * from './util/types.js';
13
13
  if (process.argv.length === 2) {
@@ -60,6 +60,7 @@ connection.onInitialize(async (params) => {
60
60
  'cache#save',
61
61
  'project#init',
62
62
  'project#ready',
63
+ 'project#ready#bind',
63
64
  ]),
64
65
  project: {
65
66
  cacheRoot: fileUtil.ensureEndingSlash(url.pathToFileURL(cacheRoot).toString()),
@@ -155,10 +156,10 @@ connection.onInitialized(async () => {
155
156
  }
156
157
  });
157
158
  connection.onDidOpenTextDocument(({ textDocument: { text, uri, version, languageId: languageID } }) => {
158
- service.project.onDidOpen(uri, languageID, version, text);
159
+ return service.project.onDidOpen(uri, languageID, version, text);
159
160
  });
160
161
  connection.onDidChangeTextDocument(({ contentChanges, textDocument: { uri, version } }) => {
161
- service.project.onDidChange(uri, contentChanges, version);
162
+ return service.project.onDidChange(uri, contentChanges, version);
162
163
  });
163
164
  connection.onDidCloseTextDocument(({ textDocument: { uri } }) => {
164
165
  service.project.onDidClose(uri);
@@ -166,7 +167,7 @@ connection.onDidCloseTextDocument(({ textDocument: { uri } }) => {
166
167
  connection.workspace.onDidRenameFiles(({}) => {
167
168
  });
168
169
  connection.onColorPresentation(async ({ textDocument: { uri }, color, range }) => {
169
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
170
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
170
171
  if (!docAndNode) {
171
172
  return undefined;
172
173
  }
@@ -175,7 +176,7 @@ connection.onColorPresentation(async ({ textDocument: { uri }, color, range }) =
175
176
  return toLS.colorPresentationArray(presentation, doc);
176
177
  });
177
178
  connection.onDocumentColor(async ({ textDocument: { uri } }) => {
178
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
179
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
179
180
  if (!docAndNode) {
180
181
  return undefined;
181
182
  }
@@ -184,7 +185,7 @@ connection.onDocumentColor(async ({ textDocument: { uri } }) => {
184
185
  return toLS.colorInformationArray(info, doc);
185
186
  });
186
187
  connection.onCompletion(async ({ textDocument: { uri }, position, context }) => {
187
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
188
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
188
189
  if (!docAndNode) {
189
190
  return undefined;
190
191
  }
@@ -197,7 +198,7 @@ connection.onRequest('spyglassmc/dataHackPubify', ({ initialism }) => {
197
198
  return service.dataHackPubify(initialism);
198
199
  });
199
200
  connection.onDeclaration(async ({ textDocument: { uri }, position }) => {
200
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
201
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
201
202
  if (!docAndNode) {
202
203
  return undefined;
203
204
  }
@@ -206,7 +207,7 @@ connection.onDeclaration(async ({ textDocument: { uri }, position }) => {
206
207
  return toLS.locationLink(ans, doc, capabilities.textDocument?.declaration?.linkSupport);
207
208
  });
208
209
  connection.onDefinition(async ({ textDocument: { uri }, position }) => {
209
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
210
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
210
211
  if (!docAndNode) {
211
212
  return undefined;
212
213
  }
@@ -215,7 +216,7 @@ connection.onDefinition(async ({ textDocument: { uri }, position }) => {
215
216
  return toLS.locationLink(ans, doc, capabilities.textDocument?.definition?.linkSupport);
216
217
  });
217
218
  connection.onImplementation(async ({ textDocument: { uri }, position }) => {
218
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
219
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
219
220
  if (!docAndNode) {
220
221
  return undefined;
221
222
  }
@@ -224,7 +225,7 @@ connection.onImplementation(async ({ textDocument: { uri }, position }) => {
224
225
  return toLS.locationLink(ans, doc, capabilities.textDocument?.implementation?.linkSupport);
225
226
  });
226
227
  connection.onReferences(async ({ textDocument: { uri }, position, context: { includeDeclaration } }) => {
227
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
228
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
228
229
  if (!docAndNode) {
229
230
  return undefined;
230
231
  }
@@ -233,7 +234,7 @@ connection.onReferences(async ({ textDocument: { uri }, position, context: { inc
233
234
  return toLS.locationLink(ans, doc, false);
234
235
  });
235
236
  connection.onTypeDefinition(async ({ textDocument: { uri }, position }) => {
236
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
237
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
237
238
  if (!docAndNode) {
238
239
  return undefined;
239
240
  }
@@ -242,7 +243,7 @@ connection.onTypeDefinition(async ({ textDocument: { uri }, position }) => {
242
243
  return toLS.locationLink(ans, doc, capabilities.textDocument?.typeDefinition?.linkSupport);
243
244
  });
244
245
  connection.onDocumentHighlight(async ({ textDocument: { uri }, position }) => {
245
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
246
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
246
247
  if (!docAndNode) {
247
248
  return undefined;
248
249
  }
@@ -251,7 +252,7 @@ connection.onDocumentHighlight(async ({ textDocument: { uri }, position }) => {
251
252
  return toLS.documentHighlight(ans);
252
253
  });
253
254
  connection.onDocumentSymbol(async ({ textDocument: { uri } }) => {
254
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
255
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
255
256
  if (!docAndNode) {
256
257
  return undefined;
257
258
  }
@@ -259,7 +260,7 @@ connection.onDocumentSymbol(async ({ textDocument: { uri } }) => {
259
260
  return toLS.documentSymbolsFromTables([service.project.symbols.global, ...core.AstNode.getLocalsToLeaves(node)], doc, capabilities.textDocument?.documentSymbol?.hierarchicalDocumentSymbolSupport, capabilities.textDocument?.documentSymbol?.symbolKind?.valueSet);
260
261
  });
261
262
  connection.onHover(async ({ textDocument: { uri }, position }) => {
262
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
263
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
263
264
  if (!docAndNode) {
264
265
  return undefined;
265
266
  }
@@ -268,7 +269,7 @@ connection.onHover(async ({ textDocument: { uri }, position }) => {
268
269
  return ans ? toLS.hover(ans, doc) : undefined;
269
270
  });
270
271
  connection.onRequest('spyglassmc/inlayHints', async ({ textDocument: { uri }, range }) => {
271
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
272
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
272
273
  if (!docAndNode) {
273
274
  return [];
274
275
  }
@@ -284,7 +285,7 @@ connection.onRequest('spyglassmc/showCacheRoot', async () => {
284
285
  return service.project.showCacheRoot();
285
286
  });
286
287
  connection.languages.semanticTokens.on(async ({ textDocument: { uri } }) => {
287
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
288
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
288
289
  if (!docAndNode) {
289
290
  return { data: [] };
290
291
  }
@@ -293,7 +294,7 @@ connection.languages.semanticTokens.on(async ({ textDocument: { uri } }) => {
293
294
  return toLS.semanticTokens(tokens, doc, capabilities.textDocument?.semanticTokens?.multilineTokenSupport);
294
295
  });
295
296
  connection.languages.semanticTokens.onRange(async ({ textDocument: { uri }, range }) => {
296
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
297
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
297
298
  if (!docAndNode) {
298
299
  return { data: [] };
299
300
  }
@@ -302,7 +303,7 @@ connection.languages.semanticTokens.onRange(async ({ textDocument: { uri }, rang
302
303
  return toLS.semanticTokens(tokens, doc, capabilities.textDocument?.semanticTokens?.multilineTokenSupport);
303
304
  });
304
305
  connection.onSignatureHelp(async ({ textDocument: { uri }, position }) => {
305
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
306
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
306
307
  if (!docAndNode) {
307
308
  return undefined;
308
309
  }
@@ -314,7 +315,7 @@ connection.onWorkspaceSymbol(({ query }) => {
314
315
  return toLS.symbolInformationArrayFromTable(service.project.symbols.global, query, capabilities.textDocument?.documentSymbol?.symbolKind?.valueSet);
315
316
  });
316
317
  connection.onDocumentFormatting(async ({ textDocument: { uri }, options }) => {
317
- const docAndNode = await service.project.ensureParsedAndCheckedOnlyWhenReady(uri);
318
+ const docAndNode = await service.project.ensureClientManagedChecked(uri);
318
319
  if (!docAndNode) {
319
320
  return undefined;
320
321
  }
@@ -1,6 +1,6 @@
1
1
  import * as core from '@spyglassmc/core';
2
2
  import type { TextDocument } from 'vscode-languageserver-textdocument';
3
- import type * as ls from 'vscode-languageserver/node';
3
+ import type * as ls from 'vscode-languageserver/node.js';
4
4
  export declare function offset(position: ls.Position, doc: TextDocument): number;
5
5
  export declare function range(range: ls.Range, doc: TextDocument): core.Range;
6
6
  export declare function color(color: ls.Color): core.Color;
@@ -1,6 +1,6 @@
1
1
  import * as core from '@spyglassmc/core';
2
2
  import type { TextDocument } from 'vscode-languageserver-textdocument';
3
- import * as ls from 'vscode-languageserver/node';
3
+ import * as ls from 'vscode-languageserver/node.js';
4
4
  import type { MyLspInlayHint } from './types.js';
5
5
  export declare function color(color: core.Color): ls.Color;
6
6
  export declare function colorInformation(info: core.ColorInfo, doc: TextDocument): ls.ColorInformation;
package/lib/util/toLS.js CHANGED
@@ -4,8 +4,8 @@
4
4
  * Functions are named after types in `vscode-languageserver`.
5
5
  */
6
6
  import * as core from '@spyglassmc/core';
7
- import * as ls from 'vscode-languageserver/node';
8
- import { InsertTextFormat } from 'vscode-languageserver/node';
7
+ import * as ls from 'vscode-languageserver/node.js';
8
+ import { InsertTextFormat } from 'vscode-languageserver/node.js';
9
9
  const ZeroPosition = { line: 0, character: 0 };
10
10
  const ZeroRange = { start: ZeroPosition, end: ZeroPosition };
11
11
  export function color(color) {
@@ -1,4 +1,4 @@
1
- import type * as ls from 'vscode-languageserver/node';
1
+ import type * as ls from 'vscode-languageserver/node.js';
2
2
  export interface CustomInitializationOptions {
3
3
  inDevelopmentMode?: boolean;
4
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spyglassmc/language-server",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "main": "lib/server.js",
6
6
  "types": "lib/server.d.ts",
@@ -21,10 +21,10 @@
21
21
  "env-paths": "^2.2.1",
22
22
  "vscode-languageserver": "^7.0.0",
23
23
  "vscode-languageserver-textdocument": "^1.0.1",
24
- "@spyglassmc/core": "0.2.0",
25
- "@spyglassmc/java-edition": "0.2.0",
26
- "@spyglassmc/locales": "0.2.0",
27
- "@spyglassmc/mcdoc": "0.2.0"
24
+ "@spyglassmc/core": "0.3.0",
25
+ "@spyglassmc/java-edition": "0.3.0",
26
+ "@spyglassmc/locales": "0.3.0",
27
+ "@spyglassmc/mcdoc": "0.3.0"
28
28
  },
29
29
  "publishConfig": {
30
30
  "access": "public"