Skip to content

Commit 1fe4ace

Browse files
gselzerclaude
andcommitted
Add code-lsp: a Language Server Protocol bridge
LspServers starts language servers (one per environment scripts run in) in the background, restarts them if they stop, and stops them when idle or too many. LspClient asks them about ScriptDocuments in code-api terms: completions (the first few resolved for their signatures, the others for documentation on demand) and signature help, at positions of the original script. Answers are reused while the same question is asked, and a pending question is cancelled ($/cancelRequest) once another is asked about the same document. code-api: CodeCompleter#closed, so completers can release what they keep for a script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 2a0195d commit 1fe4ace

9 files changed

Lines changed: 1784 additions & 0 deletions

File tree

‎code-api/src/main/java/org/scijava/code/api/CodeCompleter.java‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ default void prepare(final CompletionRequest request) {
7373
// NB: Nothing to prepare.
7474
}
7575

76+
/**
77+
* Tells the completer that a script is no longer edited (e.g. its editor
78+
* was closed), so that it can release what it keeps for completing in it,
79+
* e.g. the script's document in a language server. (Changes need no
80+
* notice: each request carries the script's whole text.) The default does
81+
* nothing.
82+
*
83+
* @param request the script, as for {@link #prepare}
84+
*/
85+
default void closed(final CompletionRequest request) {
86+
// NB: Nothing to release.
87+
}
88+
7689
/**
7790
* Gets the signatures of the call around the request's caret (e.g. all
7891
* overloads of {@code max} in {@code Math.max(1.5, |)}), rated against the

‎code-lsp/pom.xml‎

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.scijava</groupId>
7+
<artifactId>pom-scijava</artifactId>
8+
<version>45.1.0</version>
9+
<relativePath />
10+
</parent>
11+
12+
<artifactId>scijava-code-lsp</artifactId>
13+
<version>0.1.0-SNAPSHOT</version>
14+
15+
<name>SciJava Code LSP</name>
16+
<description>Language Server Protocol bridge for SciJava code intelligence.</description>
17+
<url>https://github.com/scijava/scijava</url>
18+
<inceptionYear>2026</inceptionYear>
19+
<organization>
20+
<name>SciJava</name>
21+
<url>https://scijava.org/</url>
22+
</organization>
23+
<licenses>
24+
<license>
25+
<name>Simplified BSD License</name>
26+
<distribution>repo</distribution>
27+
</license>
28+
</licenses>
29+
30+
<developers>
31+
<developer>
32+
<id>ctrueden</id>
33+
<name>Curtis Rueden</name>
34+
<url>https://imagej.net/people/ctrueden</url>
35+
<roles>
36+
<role>founder</role>
37+
<role>lead</role>
38+
<role>developer</role>
39+
<role>debugger</role>
40+
<role>reviewer</role>
41+
<role>support</role>
42+
<role>maintainer</role>
43+
</roles>
44+
</developer>
45+
</developers>
46+
<contributors>
47+
<contributor>
48+
<name>None</name>
49+
</contributor>
50+
</contributors>
51+
52+
<mailingLists>
53+
<mailingList>
54+
<name>Image.sc Forum</name>
55+
<archive>https://forum.image.sc/tag/scijava</archive>
56+
</mailingList>
57+
</mailingLists>
58+
59+
<scm>
60+
<connection>scm:git:https://github.com/scijava/scijava</connection>
61+
<developerConnection>scm:git:git@github.com:scijava/scijava</developerConnection>
62+
<tag>HEAD</tag>
63+
<url>https://github.com/scijava/scijava</url>
64+
</scm>
65+
<issueManagement>
66+
<system>GitHub Issues</system>
67+
<url>https://github.com/scijava/scijava/issues</url>
68+
</issueManagement>
69+
<ciManagement>
70+
<system>GitHub Actions</system>
71+
<url>https://github.com/scijava/scijava/actions</url>
72+
</ciManagement>
73+
74+
<properties>
75+
<package-name>org.scijava.code.lsp</package-name>
76+
<license.licenseName>bsd_2</license.licenseName>
77+
<license.copyrightOwners>SciJava developers.</license.copyrightOwners>
78+
79+
<!-- TEMP: As scijava-code-api; remove after pom-scijava bump. -->
80+
<scijava-common.version>2.101.0</scijava-common.version>
81+
<lsp4j.version>1.0.0</lsp4j.version>
82+
</properties>
83+
84+
<dependencies>
85+
<!-- SciJava dependencies -->
86+
<dependency>
87+
<groupId>org.scijava</groupId>
88+
<artifactId>scijava-code-api</artifactId>
89+
<version>0.1.0-SNAPSHOT</version>
90+
</dependency>
91+
<dependency>
92+
<groupId>org.scijava</groupId>
93+
<artifactId>scijava-common</artifactId>
94+
</dependency>
95+
96+
<!-- Third-party dependencies -->
97+
<dependency>
98+
<groupId>org.eclipse.lsp4j</groupId>
99+
<artifactId>org.eclipse.lsp4j</artifactId>
100+
<version>${lsp4j.version}</version>
101+
</dependency>
102+
<dependency>
103+
<groupId>org.eclipse.lsp4j</groupId>
104+
<artifactId>org.eclipse.lsp4j.jsonrpc</artifactId>
105+
<version>${lsp4j.version}</version>
106+
</dependency>
107+
108+
<!-- Test scope dependencies -->
109+
<dependency>
110+
<groupId>org.junit.jupiter</groupId>
111+
<artifactId>junit-jupiter-api</artifactId>
112+
<scope>test</scope>
113+
</dependency>
114+
</dependencies>
115+
</project>

0 commit comments

Comments
 (0)