@stateward/language-server 1.0.0 → 1.0.1-rc.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/dist/server.js +28 -1
- package/package.json +3 -3
package/dist/server.js
CHANGED
|
@@ -114,6 +114,20 @@ export function startServer(connection, { idleMs = ENGINE_IDLE_MS, cacheDir = (p
|
|
|
114
114
|
.all()
|
|
115
115
|
.filter((document) => isTypeScriptFile(document.uri))
|
|
116
116
|
.map((document) => [toTypeScriptPath(fileURLToPath(document.uri)), document.version]));
|
|
117
|
+
/**
|
|
118
|
+
* The version each open file document had when it was opened, by path (`toTypeScriptPath`): one
|
|
119
|
+
* still at that version holds the text it was opened with, so its fast pass may take its results
|
|
120
|
+
* from the cache.
|
|
121
|
+
*/
|
|
122
|
+
const versionsAtOpen = new Map();
|
|
123
|
+
/** The files of `files` whose document is unedited since it was opened. */
|
|
124
|
+
const uneditedSinceOpen = (files) => {
|
|
125
|
+
const now = openVersions();
|
|
126
|
+
return files.filter((file) => {
|
|
127
|
+
const version = now.get(toTypeScriptPath(file));
|
|
128
|
+
return version !== undefined && version === versionsAtOpen.get(toTypeScriptPath(file));
|
|
129
|
+
});
|
|
130
|
+
};
|
|
117
131
|
/** The engine of the config `file` belongs to, if it runs. */
|
|
118
132
|
const engineOf = (file) => {
|
|
119
133
|
const configFile = locator.configOf(file);
|
|
@@ -353,7 +367,9 @@ export function startServer(connection, { idleMs = ENGINE_IDLE_MS, cacheDir = (p
|
|
|
353
367
|
if (targets.length === 0)
|
|
354
368
|
return;
|
|
355
369
|
try {
|
|
356
|
-
|
|
370
|
+
// A document just opened usually holds the text the saved results were computed on: its
|
|
371
|
+
// findings then come from the cache, with no type checking (a large app's first findings).
|
|
372
|
+
const result = editor.checkFiles(targets, open, uneditedSinceOpen(targets));
|
|
357
373
|
for (const file of targets) {
|
|
358
374
|
const merged = mergeFastPass({ file, fast: result });
|
|
359
375
|
// Only the file rules ran: the project rules' entries are not matched here.
|
|
@@ -677,6 +693,9 @@ export function startServer(connection, { idleMs = ENGINE_IDLE_MS, cacheDir = (p
|
|
|
677
693
|
}
|
|
678
694
|
});
|
|
679
695
|
documents.onDidOpen((event) => {
|
|
696
|
+
if (event.document.uri.startsWith("file:")) {
|
|
697
|
+
versionsAtOpen.set(toTypeScriptPath(fileURLToPath(event.document.uri)), event.document.version);
|
|
698
|
+
}
|
|
680
699
|
engineForDocument(event.document.uri);
|
|
681
700
|
});
|
|
682
701
|
documents.onDidChangeContent((event) => {
|
|
@@ -703,6 +722,9 @@ export function startServer(connection, { idleMs = ENGINE_IDLE_MS, cacheDir = (p
|
|
|
703
722
|
void runFull(engine).catch(logUnexpected);
|
|
704
723
|
});
|
|
705
724
|
documents.onDidClose((event) => {
|
|
725
|
+
if (event.document.uri.startsWith("file:")) {
|
|
726
|
+
versionsAtOpen.delete(toTypeScriptPath(fileURLToPath(event.document.uri)));
|
|
727
|
+
}
|
|
706
728
|
if (!isSyncedFile(event.document.uri))
|
|
707
729
|
return;
|
|
708
730
|
const engine = engineOf(fileURLToPath(event.document.uri));
|
|
@@ -938,6 +960,11 @@ export function startServer(connection, { idleMs = ENGINE_IDLE_MS, cacheDir = (p
|
|
|
938
960
|
const editor = checkerOf(params.textDocument.uri);
|
|
939
961
|
if (document === undefined || editor === undefined)
|
|
940
962
|
return [];
|
|
963
|
+
// Hints come from a full pass's summaries, and the client is asked again after each one: before
|
|
964
|
+
// the first, answering would build and bind the programs ahead of the open file's findings.
|
|
965
|
+
const engine = guarded(() => engineOf(fileURLToPath(document.uri)));
|
|
966
|
+
if (refreshHints && engine?.firstFullDone !== true)
|
|
967
|
+
return [];
|
|
941
968
|
const hints = guarded(() => {
|
|
942
969
|
const index = buildLineIndex(document.getText());
|
|
943
970
|
const found = editor.inlayHints(fileURLToPath(document.uri), (kind) => hintEnabled(hintSettings, kind));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stateward/language-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1-rc.1",
|
|
4
4
|
"description": "The stateward language server: exclusive states and predictable code paths in any editor that speaks LSP, with findings, quick fixes and hints.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -41,12 +41,12 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"vscode-languageserver": "^11.0.0",
|
|
43
43
|
"vscode-languageserver-textdocument": "^1.0.16",
|
|
44
|
-
"@stateward/core": "1.0.
|
|
44
|
+
"@stateward/core": "1.0.1-rc.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/react": "^19.3.0",
|
|
48
48
|
"react": "^19.3.1",
|
|
49
49
|
"vscode-jsonrpc": "10.0.0",
|
|
50
|
-
"@stateward/plugin-react-context": "1.0.
|
|
50
|
+
"@stateward/plugin-react-context": "1.0.1-rc.1"
|
|
51
51
|
}
|
|
52
52
|
}
|