Skip to content

Commit 5ecc6a0

Browse files
gselzerclaude
andcommitted
Move off scijava-code-api, now removed
Its remaining types (ScriptDocument, ScriptDialect, ClassIndex, Signatures, Environment) come from scijava-code-lsp, and script parameters from the LanguageServerService. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent d43e685 commit 5ecc6a0

8 files changed

Lines changed: 38 additions & 47 deletions

File tree

‎pom.xml‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
<!-- TEMP: for Task#log(); drop once propagated to pom-scijava. -->
9696
<scijava-common.version>2.101.0</scijava-common.version>
9797

98-
<scijava-code-api.version>0.1.0-SNAPSHOT</scijava-code-api.version>
98+
<scijava-code-lsp.version>0.1.0-SNAPSHOT</scijava-code-lsp.version>
9999
<tree-sitter.version>0.26.6</tree-sitter.version>
100100
<tree-sitter-python.version>0.25.0</tree-sitter-python.version>
101101
</properties>
@@ -110,15 +110,10 @@
110110
<groupId>org.scijava</groupId>
111111
<artifactId>script-editor</artifactId>
112112
</dependency>
113-
<dependency>
114-
<groupId>org.scijava</groupId>
115-
<artifactId>scijava-code-api</artifactId>
116-
<version>${scijava-code-api.version}</version>
117-
</dependency>
118113
<dependency>
119114
<groupId>org.scijava</groupId>
120115
<artifactId>scijava-code-lsp</artifactId>
121-
<version>${scijava-code-api.version}</version>
116+
<version>${scijava-code-lsp.version}</version>
122117
</dependency>
123118

124119
<!-- Third-party dependencies -->

‎src/main/java/org/scijava/plugins/scripting/appose/python/JediServerPlugin.java‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@
3535
import org.eclipse.lsp4j.TextDocumentItem;
3636
import org.eclipse.lsp4j.services.LanguageServer;
3737
import org.scijava.Priority;
38-
import org.scijava.code.api.CodeCompletionService;
39-
import org.scijava.code.api.ScriptDocument;
38+
import org.scijava.code.lsp.LanguageServerService;
39+
import org.scijava.code.lsp.ScriptDocument;
4040
import org.scijava.code.lsp.Environment;
4141
import org.scijava.code.lsp.LanguageServerPlugin;
42-
import org.scijava.code.lsp.LanguageServerService;
4342
import org.scijava.code.lsp.PythonCompletionServer;
4443
import org.scijava.code.lsp.TransformingLanguageServer;
4544
import org.scijava.plugin.Parameter;
@@ -77,8 +76,6 @@ public class JediServerPlugin implements LanguageServerPlugin {
7776
@Parameter
7877
private ResidentWorkerService workers;
7978

80-
@Parameter(required = false)
81-
private CodeCompletionService completion;
8279

8380
@Override
8481
public boolean supports(final ScriptLanguage language) {
@@ -102,9 +99,9 @@ public LanguageServer create(final Environment environment) {
10299

103100
/** The script as plain Python, for the server. */
104101
ScriptDocument document(final String text, final Environment environment) {
105-
final Map<String, Class<?>> params = completion == null ? Collections
106-
.emptyMap() : completion.scriptParameters(text);
102+
final Map<String, Class<?>> params = servers == null ? Collections
103+
.emptyMap() : servers.scriptParameters(text);
107104
return ScriptDocument.of(text, params, PythonSyntaxLanguageServer.DIALECT,
108-
environment.toContext());
105+
environment);
109106
}
110107
}

‎src/main/java/org/scijava/plugins/scripting/appose/python/PythonSyntaxLanguageServer.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import org.eclipse.lsp4j.CompletionItem;
4040
import org.eclipse.lsp4j.CompletionItemKind;
4141
import org.eclipse.lsp4j.CompletionList;
42-
import org.scijava.code.api.CodeCompletionService;
42+
import org.scijava.code.lsp.LanguageServerService;
4343
import org.scijava.code.lsp.ScriptLanguageServer;
4444
import org.scijava.plugins.scripting.appose.python.completion.ApposePythonDialect;
4545
import org.scijava.plugins.scripting.appose.python.completion.PythonSyntax;
@@ -59,12 +59,12 @@ public class PythonSyntaxLanguageServer extends ScriptLanguageServer {
5959

6060
static final ApposePythonDialect DIALECT = new ApposePythonDialect();
6161

62-
private final CodeCompletionService completion;
62+
private final LanguageServerService servers;
6363

64-
/** @param completion Reads the scripts' parameters. */
65-
public PythonSyntaxLanguageServer(final CodeCompletionService completion) {
64+
/** @param servers Reads the scripts' parameters. */
65+
public PythonSyntaxLanguageServer(final LanguageServerService servers) {
6666
super(null);
67-
this.completion = completion;
67+
this.servers = servers;
6868
}
6969

7070
@Override
@@ -85,8 +85,8 @@ protected CompletionList complete(final Document doc, final int caret) {
8585
*/
8686
private Map<String, String> parameters(final String text) {
8787
final Map<String, String> params = new LinkedHashMap<>();
88-
if (completion == null) return params;
89-
completion.scriptParameters(text).forEach((name, type) -> params.put(name,
88+
if (servers == null) return params;
89+
servers.scriptParameters(text).forEach((name, type) -> params.put(name,
9090
DIALECT.runtimeType(type)));
9191
return params;
9292
}

‎src/main/java/org/scijava/plugins/scripting/appose/python/PythonSyntaxServerPlugin.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
package org.scijava.plugins.scripting.appose.python;
3131

3232
import org.eclipse.lsp4j.services.LanguageServer;
33-
import org.scijava.code.api.CodeCompletionService;
33+
import org.scijava.code.lsp.LanguageServerService;
3434
import org.scijava.code.lsp.Environment;
3535
import org.scijava.code.lsp.LanguageServerPlugin;
3636
import org.scijava.plugin.Parameter;
@@ -48,7 +48,7 @@
4848
public class PythonSyntaxServerPlugin implements LanguageServerPlugin {
4949

5050
@Parameter(required = false)
51-
private CodeCompletionService completion;
51+
private LanguageServerService servers;
5252

5353
@Override
5454
public boolean supports(final ScriptLanguage language) {
@@ -57,6 +57,6 @@ public boolean supports(final ScriptLanguage language) {
5757

5858
@Override
5959
public LanguageServer create(final Environment environment) {
60-
return new PythonSyntaxLanguageServer(completion);
60+
return new PythonSyntaxLanguageServer(servers);
6161
}
6262
}

‎src/main/java/org/scijava/plugins/scripting/appose/python/completion/ApposePythonDialect.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import net.imglib2.RandomAccessibleInterval;
4242

4343
import org.apposed.appose.NDArray;
44-
import org.scijava.code.api.ScriptDialect;
44+
import org.scijava.code.lsp.ScriptDialect;
4545

4646
/**
4747
* How Python scripts run via Appose see their script parameters: as the

‎src/main/java/org/scijava/plugins/scripting/appose/python/completion/JediLanguageServerSpec.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import java.util.Map;
3636
import java.util.concurrent.Callable;
3737

38-
import org.scijava.code.api.EnvironmentContext;
38+
import org.scijava.code.lsp.Environment;
3939
import org.scijava.code.lsp.LspConnection;
4040
import org.scijava.code.lsp.LspServerSpec;
4141

@@ -96,7 +96,7 @@ public String languageId() {
9696
}
9797

9898
@Override
99-
public LspConnection start(final EnvironmentContext env)
99+
public LspConnection start(final Environment env)
100100
throws IOException
101101
{
102102
final String exe;
@@ -120,7 +120,7 @@ public LspConnection start(final EnvironmentContext env)
120120
}
121121

122122
@Override
123-
public Object initializationOptions(final EnvironmentContext env) {
123+
public Object initializationOptions(final Environment env) {
124124
final Map<String, Object> workspaceOptions = new LinkedHashMap<>();
125125
// NB: Without an environment, Jedi uses the server's own Python.
126126
if (env.interpreter() != null) {
@@ -139,7 +139,7 @@ public Object initializationOptions(final EnvironmentContext env) {
139139
}
140140

141141
@Override
142-
public String rootUri(final EnvironmentContext env) {
142+
public String rootUri(final Environment env) {
143143
// NB: jedi-language-server applies its workspace options only with a
144144
// root. An empty one, so that nothing irrelevant gets indexed.
145145
workspace.mkdirs();

‎src/test/java/org/scijava/plugins/scripting/appose/python/ApposePythonCompletionIntegrationTest.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
import org.junit.Test;
6464
import org.scijava.Context;
6565
import org.scijava.code.lsp.LanguageServerService;
66-
import org.scijava.code.lsp.LspClient;
66+
import org.scijava.code.lsp.Positions;
6767
import org.scijava.code.lsp.MergedLanguageServer;
6868
import org.scijava.code.lsp.UpdatingCompletionList;
6969
import org.scijava.module.ModuleService;
@@ -158,7 +158,7 @@ public void testSignatureHelp() throws Exception {
158158
SignatureHelp help = null;
159159
while (help == null && System.currentTimeMillis() < deadline) {
160160
help = server.signatureHelp(new SignatureHelpParams(
161-
new TextDocumentIdentifier(uri), LspClient.position(code, code
161+
new TextDocumentIdentifier(uri), Positions.position(code, code
162162
.length()))).get(1, TimeUnit.MINUTES);
163163
}
164164
assertTrue(help.getSignatures().get(0).getLabel().contains("dumps("));
@@ -174,15 +174,15 @@ public void testHover() throws Exception {
174174
Hover hover = null;
175175
while (hover == null && System.currentTimeMillis() < deadline) {
176176
hover = server.hover(new HoverParams(new TextDocumentIdentifier(uri),
177-
LspClient.position(code, code.indexOf("dumps") + 2))).get(1,
177+
Positions.position(code, code.indexOf("dumps") + 2))).get(1,
178178
TimeUnit.MINUTES);
179179
}
180180
assertTrue(String.valueOf(hover), hover.getContents().getRight().getValue()
181181
.contains("JSON"));
182182
// The word's range, in the script.
183-
assertEquals(LspClient.position(code, code.indexOf("dumps")), hover
183+
assertEquals(Positions.position(code, code.indexOf("dumps")), hover
184184
.getRange().getStart());
185-
assertEquals(LspClient.position(code, code.indexOf("dumps") + 5), hover
185+
assertEquals(Positions.position(code, code.indexOf("dumps") + 5), hover
186186
.getRange().getEnd());
187187
}
188188

@@ -297,7 +297,7 @@ private static List<CompletionItem> complete(final String code,
297297
{
298298
final String uri = sync(code, path);
299299
CompletionList list = server.completion(new CompletionParams(
300-
new TextDocumentIdentifier(uri), LspClient.position(code, code.length())))
300+
new TextDocumentIdentifier(uri), Positions.position(code, code.length())))
301301
.get(1, TimeUnit.MINUTES).getRight();
302302
if (settled && list instanceof UpdatingCompletionList) {
303303
final CompletionList better = ((UpdatingCompletionList) list).update()
@@ -324,7 +324,7 @@ private static void report(final String code, final String path,
324324
final String uri = sync(other, path);
325325
t0 = System.nanoTime();
326326
final CompletionList first = server.completion(new CompletionParams(
327-
new TextDocumentIdentifier(uri), LspClient.position(other, other
327+
new TextDocumentIdentifier(uri), Positions.position(other, other
328328
.length()))).get(1, TimeUnit.MINUTES).getRight();
329329
final long wait = System.nanoTime() - t0;
330330
final CompletionList update = first instanceof UpdatingCompletionList

‎src/test/java/org/scijava/plugins/scripting/appose/python/ApposePythonServersTest.java‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,10 @@
5151
import org.junit.Before;
5252
import org.junit.Test;
5353
import org.scijava.Context;
54-
import org.scijava.code.api.CodeCompletionService;
54+
import org.scijava.code.lsp.LanguageServerService;
5555
import org.scijava.code.lsp.Environment;
5656
import org.scijava.code.lsp.LanguageServerPlugin;
57-
import org.scijava.code.lsp.LanguageServerService;
58-
import org.scijava.code.lsp.LspClient;
57+
import org.scijava.code.lsp.Positions;
5958
import org.scijava.plugin.PluginService;
6059
import org.scijava.plugins.scripting.appose.python._internal.ResidentWorkerService;
6160
import org.scijava.plugins.scripting.appose.python.completion.ApposePythonDialect;
@@ -83,7 +82,7 @@ public class ApposePythonServersTest {
8382

8483
@Before
8584
public void setUp() {
86-
context = new Context(ScriptService.class, CodeCompletionService.class,
85+
context = new Context(ScriptService.class, LanguageServerService.class,
8786
ResidentWorkerService.class, LanguageServerService.class);
8887
language = context.service(ScriptService.class).getLanguageByName(
8988
"appose-python");
@@ -293,13 +292,13 @@ public void testServerOptions() {
293292
"didChange=true, didSave=false}";
294293
assertEquals("{workspace={environmentPath=/env/bin/python, " +
295294
"extraPaths=[/overlay]}, " + diagnostics + "}", String.valueOf(spec
296-
.initializationOptions(new org.scijava.code.api.EnvironmentContext(
297-
"/env/bin/python", Collections.singletonList("/overlay"), null))));
295+
.initializationOptions(new Environment(
296+
"/env/bin/python", Collections.singletonList("/overlay"), null, null))));
298297
// Without a script environment: the server's own.
299298
assertEquals("{workspace={extraPaths=[]}, " + diagnostics + "}", String
300299
.valueOf(spec.initializationOptions(
301-
org.scijava.code.api.EnvironmentContext.EMPTY)));
302-
assertTrue(spec.rootUri(org.scijava.code.api.EnvironmentContext.EMPTY)
300+
Environment.NONE)));
301+
assertTrue(spec.rootUri(Environment.NONE)
303302
.startsWith("file:"));
304303
new File("workspace").delete();
305304
}
@@ -309,12 +308,12 @@ public void testServerOptions() {
309308
/** Completes with the syntax-only server. */
310309
private List<String> complete(final String code) {
311310
final PythonSyntaxLanguageServer server = new PythonSyntaxLanguageServer(
312-
context.service(CodeCompletionService.class));
311+
context.service(LanguageServerService.class));
313312
server.didOpen(new DidOpenTextDocumentParams(new TextDocumentItem(
314313
"untitled:/a.py", "appose-python", 1, code)));
315314
try {
316315
return server.completion(new CompletionParams(new TextDocumentIdentifier(
317-
"untitled:/a.py"), LspClient.position(code, code.length()))).get(10,
316+
"untitled:/a.py"), Positions.position(code, code.length()))).get(10,
318317
TimeUnit.SECONDS).getRight().getItems().stream().map(
319318
CompletionItem::getLabel).collect(Collectors.toList());
320319
}

0 commit comments

Comments
 (0)