Skip to content

Commit eba6480

Browse files
gselzerclaude
andcommitted
code-lsp: fold the script package into the core
ScriptDialect and ScriptDocument are now part of how sessions talk to servers (LanguageServerPlugin#dialect, ScriptSession), so they move from org.scijava.code.lsp.script into org.scijava.code.lsp. This also ends the cycle between the two packages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f53787e commit eba6480

12 files changed

Lines changed: 37 additions & 81 deletions

File tree

‎code-lsp/README.md‎

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ scripts.
2222
└──► server processes (e.g. jedi-language-server), via LspServerSpec
2323
```
2424

25-
It does four things, each in a package of its own.
25+
It does three things, each in a package of its own.
2626

2727
## 1. Brokering between scripts and servers (`org.scijava.code.lsp`)
2828

@@ -34,14 +34,21 @@ jedi's) combines them itself.
3434
Clients ask about a script through a `ScriptSession` from the service, with
3535
a server of its own: it keeps the server's copy of the script up to date,
3636
names it (its file's URI, or an `untitled:` one), takes offsets into its text
37-
(see `Positions`), and reports the problems found in it. Servers need know
38-
nothing of SciJava scripts: the session shows them plain code (see 3). For code typed into
37+
(see `Positions`), and reports the problems found in it. For code typed into
3938
a running interpreter, the server learns the interpreter's state through its
4039
`Environment`. Tools that ask once (e.g. to check a
4140
script) can call `LanguageServerService.diagnose`. For code typed into an
4241
interpreter whose language no plugin serves, a session completes the
4342
interpreter's variables.
4443

44+
Servers need know nothing of SciJava scripts. A SciJava script is not quite
45+
plain code of its language: its `#@` parameters define variables before it
46+
runs. `LanguageServerService.scriptParameters` parses them; a `ScriptDocument`
47+
is the script as plain code, with them declared with their run-time types, as
48+
a `ScriptDialect` says. Each `LanguageServerPlugin` names the dialect its
49+
servers read; a session shows its server the script in that dialect, and maps
50+
positions in the server's answers back.
51+
4552
## 2. Running server processes (`org.scijava.code.lsp.launch`)
4653

4754
For servers that are not Java in the SciJava process (e.g. jedi-language-server,
@@ -51,17 +58,7 @@ and returning its streams (an `LspConnection`). Plugins get such a server via
5158
`LanguageServerService.launch`: started when first needed, one per
5259
environment, restarted if it stops, and stopped when idle.
5360

54-
## 3. Translating SciJava scripts (`org.scijava.code.lsp.script`)
55-
56-
A SciJava script is not quite plain code of its language: its `#@`
57-
parameters define variables before it runs. `LanguageServerService.scriptParameters`
58-
parses them; a `ScriptDocument` is the script as plain code, with them
59-
declared with their run-time types, as a `ScriptDialect` says. Each
60-
`LanguageServerPlugin` names the dialect its servers read; a session shows its
61-
server the script in that dialect, and maps positions in the server's answers
62-
back.
63-
64-
## 4. A toolkit for in-process servers (`org.scijava.code.lsp.jvm`)
61+
## 3. A toolkit for in-process servers (`org.scijava.code.lsp.jvm`)
6562

6663
For servers of JVM languages, written in Java (e.g. Groovy's and Jython's):
6764
`ScriptLanguageServer`, a base class keeping the open documents and turning
@@ -73,13 +70,13 @@ javadoc.
7370

7471
## Who uses what
7572

76-
| | 1 | 2 | 3 | 4 |
77-
|-------------------------|---|---|---|---|
78-
| script-editor | ✓ | | | |
79-
| scripting-groovy | ✓ | | ✓ | ✓ |
80-
| scripting-jython | ✓ | ✓ | ✓ | ✓ |
81-
| scripting-appose-python | ✓ | ✓ | ✓ | |
73+
| | 1 | 2 | 3 |
74+
|-------------------------|---|---|---|
75+
| script-editor | ✓ | | |
76+
| scripting-groovy | ✓ | | ✓ |
77+
| scripting-jython | ✓ | ✓ | ✓ |
78+
| scripting-appose-python | ✓ | ✓ | |
8279

8380
The specialized packages depend only on `org.scijava.code.lsp`, never on each
84-
other. The module exports all four; its implementation
81+
other. The module exports all three; its implementation
8582
(`org.scijava.code.lsp.impl`) is internal.

‎code-lsp/src/main/java/module-info.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
exports org.scijava.code.lsp;
3535
exports org.scijava.code.lsp.jvm;
3636
exports org.scijava.code.lsp.launch;
37-
exports org.scijava.code.lsp.script;
3837

3938
// NB: SciJava Common, whose plugins and services these are.
4039
requires transitive org.scijava;

‎code-lsp/src/main/java/org/scijava/code/lsp/LanguageServerPlugin.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
package org.scijava.code.lsp;
3131

3232
import org.eclipse.lsp4j.services.LanguageServer;
33-
import org.scijava.code.lsp.script.ScriptDialect;
3433
import org.scijava.plugin.SciJavaPlugin;
3534
import org.scijava.script.ScriptLanguage;
3635

@@ -42,7 +41,7 @@
4241
* Servers need not know SciJava scripts: given the plugin's
4342
* {@link #dialect() dialect}, sessions show them each script as plain code of
4443
* its language, its parameters declared (see
45-
* {@link org.scijava.code.lsp.script.ScriptDocument}).
44+
* {@link ScriptDocument}).
4645
* </p>
4746
* <p>
4847
* Each language is served by the highest-priority plugin that supports it. A

‎code-lsp/src/main/java/org/scijava/code/lsp/LanguageServerService.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ default List<Diagnostic> diagnose(final ScriptLanguage language,
100100
* {@code // @} lines in its header) define before it runs, by name, with
101101
* their Java types ({@code Object} if unresolvable); in declaration order.
102102
* Sessions declare them for their servers (see
103-
* {@link org.scijava.code.lsp.script.ScriptDocument}). Half-typed declarations
103+
* {@link ScriptDocument}). Half-typed declarations
104104
* are expected, and parsed quietly.
105105
*/
106106
Map<String, Class<?>> scriptParameters(String text);

code-lsp/src/main/java/org/scijava/code/lsp/script/ScriptDialect.java renamed to code-lsp/src/main/java/org/scijava/code/lsp/ScriptDialect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* #L%
2828
*/
2929

30-
package org.scijava.code.lsp.script;
30+
package org.scijava.code.lsp;
3131

3232
import java.util.Collection;
3333
import java.util.Collections;

code-lsp/src/main/java/org/scijava/code/lsp/script/ScriptDocument.java renamed to code-lsp/src/main/java/org/scijava/code/lsp/ScriptDocument.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* #L%
2828
*/
2929

30-
package org.scijava.code.lsp.script;
30+
package org.scijava.code.lsp;
3131

3232
import java.util.ArrayList;
3333
import java.util.Collections;
@@ -40,7 +40,6 @@
4040

4141
import org.eclipse.lsp4j.Position;
4242
import org.eclipse.lsp4j.Range;
43-
import org.scijava.code.lsp.Positions;
4443

4544
/**
4645
* A SciJava script as plain code of its language (a "virtual document"), for

‎code-lsp/src/main/java/org/scijava/code/lsp/ScriptSession.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
import org.eclipse.lsp4j.services.LanguageClient;
7171
import org.eclipse.lsp4j.services.LanguageClientAware;
7272
import org.eclipse.lsp4j.services.LanguageServer;
73-
import org.scijava.code.lsp.script.ScriptDocument;
7473
import org.scijava.log.Logger;
7574
import org.scijava.script.ScriptLanguage;
7675

‎code-lsp/src/main/java/org/scijava/code/lsp/impl/DefaultLanguageServerService.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
import org.scijava.code.lsp.LanguageServerPlugin;
4040
import org.scijava.code.lsp.LanguageServerService;
4141
import org.scijava.code.lsp.ScriptSession;
42-
import org.scijava.code.lsp.script.ScriptDialect;
43-
import org.scijava.code.lsp.script.ScriptDocument;
42+
import org.scijava.code.lsp.ScriptDialect;
43+
import org.scijava.code.lsp.ScriptDocument;
4444
import org.scijava.log.LogService;
4545
import org.scijava.plugin.Parameter;
4646
import org.scijava.plugin.Plugin;

‎code-lsp/src/main/java/org/scijava/code/lsp/package-info.java‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,18 @@
4242
* from the highest-priority plugin serving the script's language.
4343
* </p>
4444
* <p>
45+
* Servers need know nothing of SciJava scripts. A SciJava script's {@code #@}
46+
* parameters define variables before it runs, which plain code of its
47+
* language would declare. A {@link org.scijava.code.lsp.ScriptDocument} is
48+
* the script as such code, with its parameters declared with their run-time
49+
* types, as a {@link org.scijava.code.lsp.ScriptDialect} says. A session shows
50+
* its server this text (in the dialect of the plugin offering the server),
51+
* and maps positions in the server's answers back to the script.
52+
* </p>
53+
* <p>
4554
* The subpackages are for those writing language servers:
46-
* {@link org.scijava.code.lsp.jvm} to write them in Java,
47-
* {@link org.scijava.code.lsp.launch} to run them as processes, and
48-
* {@link org.scijava.code.lsp.script} to show them SciJava scripts as plain
49-
* code.
55+
* {@link org.scijava.code.lsp.jvm} to write them in Java, and
56+
* {@link org.scijava.code.lsp.launch} to run them as processes.
5057
* </p>
5158
*/
5259
package org.scijava.code.lsp;

‎code-lsp/src/main/java/org/scijava/code/lsp/script/package-info.java‎

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

0 commit comments

Comments
 (0)