Skip to content

Commit 77b2d7f

Browse files
gselzerclaude
andcommitted
Add a Python language server's completions, via Java stubs
If a Python language server is offered (see code-lsp's LspService), its completions follow Jython's own: for Python modules, and for Java classes from Python stubs of the packages the script imports and its parameters' types (JavaStubs, written by reflection in the background, with the packages their signatures refer to). JythonDialect declares parameters as Python types for the server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent da5bc98 commit 77b2d7f

7 files changed

Lines changed: 1104 additions & 4 deletions

File tree

‎README.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ in addition to being usable directly as a `javax.script.ScriptEngineFactory`,
1212
it also provides some functionality on top, such as the ability to generate
1313
lines of script code based on SciJava events.
1414

15+
## Code completion
16+
17+
The Script Editor completes code in Jython scripts: Java classes, their
18+
members and constructors (with their overloads), imports, the script's `#@`
19+
parameters and, in a live interpreter, its variables. This is Jython's own
20+
completion, which knows Java exactly.
21+
22+
If a Python language server is available (e.g. jedi-language-server, as
23+
offered by the `appose-python` scripting plugin), its completions are added
24+
too: for Python modules, and for Java classes, from Python type stubs
25+
(`.pyi`) of the Java packages the script imports, written in the background
26+
to `~/.cache/scijava/jython-stubs` (or `-Dscijava.jython.stubs=<dir>`). The
27+
server analyzes the script as CPython (Jython's standard library is Python
28+
2's, but mostly the same); so it is asked for completions only, not for
29+
problems.
30+
1531
For a complete list of scripting languages available as part of the SciJava
1632
platform, see the
1733
[Scripting](https://github.com/scijava/scijava-common/wiki/Scripting) page on

‎pom.xml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686

8787
<scijava-common.version>2.101.0</scijava-common.version>
8888
<scijava-code-api.version>0.1.0-SNAPSHOT</scijava-code-api.version>
89+
<!-- NB: As Fiji ships, for scijava-code-lsp (lsp4j); newer than pom-scijava 34's. -->
90+
<gson.version>2.14.0</gson.version>
8991

9092
<license.licenseName>bsd_2</license.licenseName>
9193
<license.copyrightOwners>SciJava developers.</license.copyrightOwners>
@@ -106,6 +108,11 @@
106108
<artifactId>scijava-code-api</artifactId>
107109
<version>${scijava-code-api.version}</version>
108110
</dependency>
111+
<dependency>
112+
<groupId>org.scijava</groupId>
113+
<artifactId>scijava-code-lsp</artifactId>
114+
<version>${scijava-code-api.version}</version>
115+
</dependency>
109116

110117
<!-- Third-party dependencies -->
111118
<dependency>

0 commit comments

Comments
 (0)