Skip to content

Commit 8cbf10b

Browse files
gselzerclaude
andcommitted
code-lsp: let sessions follow where their scripts run
A ScriptSession now watches where its script runs, as its dialect says (ScriptDocument.environment), before each request; when that changes, it moves to a new server of the new environment, launched by the service. It talks to its server off the caller's thread, in order, and starts it on first use. Sessions are made with the service (new ScriptSession( servers, language)), which no longer makes them; it offers dialect() and document() instead. RoutingLanguageServer is gone: a server analyzes scripts in exactly the environment it is given. So jedi no longer installs dependency overlays itself (nor uv, to do so): scripting-appose-python's dialect includes them in the environment it reports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c354e4e commit 8cbf10b

23 files changed

Lines changed: 433 additions & 1790 deletions

File tree

‎code-lsp-groovy/src/test/java/org/scijava/code/lsp/groovy/GroovyLanguageServerTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ public void testImportOffset() {
314314

315315
/** A session about plain Groovy, with a server of its own. */
316316
private static ScriptSession session(final Environment env) {
317-
return new ScriptSession(new GroovyLanguageServer(env),
317+
return new ScriptSession(e -> new GroovyLanguageServer(env),
318318
ScriptDocument::of);
319319
}
320320

‎code-lsp-jedi/README.md‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,23 @@ editors:
1010
the word is typed on; questions no longer of interest are cancelled; and
1111
the first completions of a word get their signatures, as snippets with
1212
their parameters and types.
13-
* Packages a script declares (in its PEP 723 `# /// script` block) but its
14-
environment lacks, e.g. a dependency just added, are installed for
15-
completion only, into a separate directory (an "overlay", which Jedi
16-
searches), a moment after the dependencies stop changing; so they are known
17-
before the script's environment is (re)built.
1813

1914
Script languages whose scripts become plain Python (e.g.
2015
scripting-appose-python's) get it this way; and servers building on Python's
2116
(e.g. scijava-code-lsp-jython's, beside Jython's own analysis).
2217

2318
The server runs as a process, one per environment scripts run in (see
2419
`JediLauncher`), in a small environment of its own (`code-lsp-jedi`: Python,
25-
Jedi, jedi-language-server, NumPy, and uv to install overlays), which
20+
Jedi, jedi-language-server, and NumPy), which
2621
[Appose](https://github.com/apposed/appose) builds next to its other
2722
environments the first time the server is needed; that takes a while only
28-
then. Its error output goes to `code-lsp-jedi-server.log`, and overlays to
29-
`code-lsp-jedi-overlays`, next to the environment.
23+
then. Its error output goes to `code-lsp-jedi-server.log`, next to the
24+
environment.
3025

31-
Each server analyzes scripts against the environment they run in, as given
32-
by the script language: its Python (if any; otherwise the server's own) and
33-
extra search paths.
26+
Each server analyzes scripts in exactly the environment it is given: its
27+
Python (if any; otherwise the server's own) and extra search paths (e.g. an
28+
overlay of packages a script declares, as scripting-appose-python's dialect
29+
adds).
3430

3531
## Example
3632

‎code-lsp-jedi/src/main/java/org/scijava/code/lsp/jedi/DependencyOverlays.java‎

Lines changed: 0 additions & 227 deletions
This file was deleted.

0 commit comments

Comments
 (0)