Repository navigation
Conversation
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>
code-api: CodeCompleter#hover (what is known about the code at a position, e.g. documentation; with updates, like signature help) and CodeCompleter#diagnose (problems in a script, e.g. syntax errors, once found). code-lsp: LspClient#hover (textDocument/hover) and LspClient#diagnose, from the diagnostics the server publishes, awaited for the version of the document sent; positions mapped back to the original script, problems in the added lines left out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LspServerPlugins offer a language server for a language (e.g. jedi-language-server for Python); DefaultLspService keeps one LspServers per language, shared by the completers that want one, and stops them when the context is disposed. PythonLspClient (reading Python signatures) moves here from scripting-appose-python, for Jython's use too. Gson is declared directly, so that consumers need not resolve lsp4j's range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SciJavaLanguageServer serves the completions, signature help, hover and diagnostics of the context's code completers over the Language Server Protocol, for editors outside SciJava (e.g. VS Code); Main runs it over standard input and output, keeping SciJava's output off the protocol's stream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every source of code intelligence becomes an lsp4j LanguageServer: in-process, or a server process (LaunchedLanguageServer, over LspServers). LanguageServerPlugins offer them per SciJava script language; LanguageServerService keeps them, one per plugin and Environment, and hands callers a MergedLanguageServer per language, which keeps each document in sync on every server for it (moving it as its environment changes) and merges their answers: completions in priority order without duplicates, slower ones as an UpdatingCompletionList; the first signature help and hover; all diagnostics. RatedSignatureInformation keeps overload fits; TransformingLanguageServer shows a server SciJava scripts as plain code (ScriptDocument). Until each language has a server of its own, CodeCompleterServerPlugin offers code-api's CodeCompleters as one. The default completer reads live bindings from a ScriptContext too, as servers get no engine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The adapter serves languages with a completer of their own (so editors can tell which are served), can serve a single completer (e.g. in tests), and looks for problems a moment after the last change, as editors send every keystroke. Merging keeps overloads: completions are the same only if they insert the same name with the same parameters (label details). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merging dropped completions inserting the same name with the same parameters even within one server's list, e.g. Groovy's each() from Iterable, Collection, List and Object. Only those duplicating an earlier server's are dropped now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ScriptLanguageServer: a base class keeping the open documents, answering requests by asking the subclass about a document and offset, resolving documentation on demand, and publishing problems a moment after each change. Callable: something to call, as a snippet completion with typed label details, or as a rated signature. Members: completions for Java classes' members, by reflection. Signatures: rating calls' arguments, on Callables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Callable.of(item) reads a callable from a completion's label details. Merging compares completions without an edit (e.g. jedi's "length") by the word before the caret, so that they match those replacing more (e.g. Jython's "s.length"). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PythonCompletionServer wraps a Python language server (e.g. jedi-language-server) as editors want it: it asks at a word's first character and caches the answer, cancels superseded requests, filters by the word typed, and gives the top completions their signatures. DelegatingLanguageServer forwards everything, for such decorators. Cancelling a completion now cancels the request it waits on, through TransformingLanguageServer and LaunchedLanguageServer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Code intelligence is now lsp4j language servers throughout. What code-api had that servers still need moves into code-lsp: ScriptDocument, ScriptDialect, PositionMap and ClassIndex; script parameter parsing, as LanguageServerService.scriptParameters; and Environment in place of EnvironmentContext. Positions replaces LspClient's offset conversions, and Python signatures are parsed by PythonCompletionServer. Gone: the code-api adapter, LspClient and PythonLspClient. In their place, BindingsLanguageServer completes a running interpreter's variables, for languages without servers. The outside-editor server (SciJavaLanguageServer) is now a front for the service's merged servers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ScriptSession is where a client (an editor, a REPL, a tool checking a script) asks about a SciJava script, in terms of its text and offsets: it keeps the servers' copy up to date, names the script (its file's URI, or an untitled one; following Save As), and receives its problems. Each request carries the text it is about. The LanguageServerService makes sessions, each owning a merged server of its own; for languages no plugin serves, a session completes a running interpreter's variables. diagnose is now a session asked once. Where scripts run can change without them changing (e.g. an environment is built): plugins now say so via environmentsChanged(), which moves open scripts to the servers of where they run now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing runs it: editors in the SciJava process ask the service for servers directly, and none outside it has been wired to this one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It is specific to Python (completing Java members on objects a Python server cannot see into), so it belongs with the one plugin using it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The module does several things, each now in a package of its own: - org.scijava.code.lsp: brokering between scripts and servers (the service, plugins, script sessions, environments), plus SciJava's additions to LSP (updating completion lists, rated signatures). - .launch: running language server processes. - .script: SciJava scripts as plain code (#@ parameters declared). - .jvm: a toolkit for in-process servers of JVM languages. - .impl: the implementation, not exported. The specialized packages depend only on the base package, never on each other. A module-info exports the four public packages; it is open, for SciJava Common's reflection. Package infos say what each is for. To keep the implementation internal, clients get sessions via ScriptSession.owning, the service no longer offers its servers directly (LanguageServerService.server), and data is no longer assumed to be Gson's (the module no longer reads Gson). Tests run on the classpath, not the module path, where the tests' plugin index would shadow the module's own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ScriptSession.server, language, text and uri, and setFile(File), had no callers outside tests; nor had LanguageServerService.session(File). Clients set a file supplier, as editors follow Save As. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop UpdatingCompletionList and RatedSignatureInformation, SciJava's additions to LSP: - Merged completions come once all servers have answered, as signature help and hover already did; clients that must not wait ask asynchronously. - In-process servers still order overloads best fit first (Fit moves to Signatures), but signatures no longer carry their fit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop MergedLanguageServer: a language is served by the highest-priority plugin supporting it, and a server combining several sources (e.g. an in-process analysis and jedi) combines them itself. Each session gets a server of its own, which it initializes (awaiting the answer, as LSP says) and shuts down when closed. Server processes stay shared, one per environment. With it go the service's shared servers and diagnostics routing, moving scripts between servers as where they run changes (LanguageServerPlugin.environment, environmentsChanged), and waiting for several servers' problems. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both are ordered places imports are resolved from; each server reads them as its language does. Nothing read the classpath. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A script document maps positions between its script and its text itself: by offset, and by LSP position and range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ScriptSession now transforms each script into plain code of its language, in the dialect of the plugin offering its server (LanguageServerPlugin#dialect), and maps positions in the server's answers back. Servers need know nothing of SciJava scripts. TransformingLanguageServer, which did this inside some servers, is gone, and so is ScriptDocument's unused environment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The declarations a session adds are real code: imports of the parameters' types bind names (e.g. numpy) the script does not. A dialect now says which name each import binds (ScriptDialect#imported); unless the script mentions it, the session leaves completions of it out (see ScriptDocument#added). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
A server process is now offered by a ServerProcessPlugin, in the core package: it starts the process for an LSP language and an environment, and says how to initialize it (options, workspace root). The launch package (LspServerPlugin, LspServerSpec, LspConnection) and the separate LspService are gone; LanguageServerService#launch serves the processes itself. The implementation follows the new names: ServerProcesses keeps a language's ServerProcess per environment, and a ProcessLanguageServer shows one as an lsp4j LanguageServer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LanguageServerService.launch can now take a function from a document to its environment, which ProcessLanguageServer consults before each request: a document whose environment changes is closed on its old server process and opened on its new one. Completions remember which process answered them, so that they are resolved by it. Also note in ScriptDialect's javadoc why a dialect describes the translation of scripts, rather than doing it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ServerProcessPlugin for python, moved here from scripting-appose-python so that script languages can use jedi without depending on each other (e.g. scripting-jython). It runs jedi-language-server in a small Appose environment of its own (code-lsp-jedi: Python 3.12, Jedi, NumPy), built the first time it is needed, under a launcher that exits once the JVM is gone. JediLifecycleIntegrationTest starts a server via LanguageServerService, asks it about a script, and checks that its process stops with the context. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LanguageServerService.launch(languageId, environment) now gets a server for any LSP language a plugin serves, in-process or not: plugins say so via supports(String), and supports(ScriptLanguage) for sessions. Server processes are served by ProcessLanguageServerPlugin (internal), which owns them and stops them when disposed; LanguageServerService also tells whether a language is served at all, via supports(String). Servers analyze scripts in one environment, given when created: plugins whose scripts say where they run keep a server per environment themselves. ProcessLanguageServer no longer moves documents. Also: - Rename ScriptLanguageServer to AbstractLanguageServer. - Throw rather than return null when no plugin serves a language. - Remove LanguageServerService.diagnose: a session does as much. - Stop started server processes directly on shutdown, rather than via the starter, whose shutdown could drop the stop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Test new-style (#@) lines, old-style header parameters and shebangs separately, checking the variables they declare by name and type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Partition ServerProcessesTest: ProcessLanguageServer's tests move to a ProcessLanguageServerTest, and the plugin's to an AbstractProcessLanguageServerPluginTest, sharing the fake servers in FakeServers. Split the tests covering several behaviors, document each test's goal, and check sharing by process rather than by slot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Document each test's goal, and simplify: one fake dialect, importing NumPy under a private alias as real dialects should; a short mapping test in place of the exhaustive round trips; and a plain-text test checking the fallback's language. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical capability-advertising and process-lifecycle defects can disable core LSP features, leak server processes, and leave requests pending indefinitely.
9 open issues
Ensure destroying the wrapper also terminates and reaps ty · New Advertise the proxy’s supported LSP capabilities · New Cancel timers and guard deferred work against document changes · New Complete queued startup promises when shutting down · New Run slot cleanup independently of the shutdown-discarded executor · New Respect aliases when checking whether an import binds a name · New Anchor import edits outside the synthetic dialect header · New Insert a line break when adding imports at EOF · New Exclude CRLF terminators and prevent offset overflow · New
What changed in this PR
This PR introduces SciJava’s language-server infrastructure, connecting script editing features to pluggable Groovy, Python (ty), and Jython backends.
Changes:
- Adds language-server discovery, environment configuration, script transformation, and completion utilities.
- Implements shared external-process management and language-specific plugin integration.
- Adds module configuration, usage examples, and unit and integration tests.
| File | Description |
|---|---|
| scijava-code-lsp/src/test/java/org/scijava/code/lsp/server/ServerProcessesTest.java | Tests process sharing, restart, retry, and eviction. |
| scijava-code-lsp/src/test/java/org/scijava/code/lsp/server/ProcessLanguageServerTest.java | Tests document synchronization, diagnostics, and closure. |
| scijava-code-lsp/src/test/java/org/scijava/code/lsp/server/FakeServers.java | Provides pipe-connected test servers. |
| scijava-code-lsp/src/test/java/org/scijava/code/lsp/server/AbstractProcessLanguageServerPluginTest.java | Tests plugin support and lifecycle. |
| scijava-code-lsp/src/test/java/org/scijava/code/lsp/ScriptProcessingTest.java | Tests script parameter preprocessing. |
| scijava-code-lsp/src/test/java/org/scijava/code/lsp/ScriptDocumentTest.java | Tests transformed text and position mapping. |
| scijava-code-lsp/src/test/java/org/scijava/code/lsp/PositionsTest.java | Tests position conversion and call detection. |
| scijava-code-lsp/src/test/java/org/scijava/code/lsp/jvm/ClassIndexTest.java | Tests runtime class indexing. |
| scijava-code-lsp/src/test/java/org/scijava/code/lsp/CompletionItemsTest.java | Tests snippets and reflected member completions. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/server/ServerProcesses.java | Manages per-environment process lifecycles. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/server/ServerLauncher.java | Defines external server launch configuration. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/server/ProcessLanguageServer.java | Proxies requests and schedules diagnostics. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/server/package-info.java | Documents external server integration. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/server/AbstractProcessLanguageServerPlugin.java | Supplies reusable process-backed plugin support. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/ScriptProcessing.java | Extracts parameters and removable script lines. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/ScriptDocument.java | Builds virtual documents and maps positions. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/ScriptDialect.java | Defines language-specific script adaptation. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/Positions.java | Provides offset and position utilities. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/package-info.java | Documents the core API. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/LanguageServerService.java | Defines server discovery and launch services. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/LanguageServerPlugin.java | Defines the server plugin contract. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/jvm/package-info.java | Documents JVM server utilities. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/impl/package-info.java | Describes internal implementations. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/impl/DefaultLanguageServerService.java | Selects plugins and manages disposal. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/impl/BindingsLanguageServer.java | Provides interpreter-binding fallback completions. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/Environment.java | Models interpreter, search paths, and live bindings. |
| scijava-code-lsp/src/main/java/org/scijava/code/lsp/CompletionItems.java | Builds snippets and reflected member suggestions. |
| scijava-code-lsp/src/main/java/module-info.java | Declares core module exports and dependencies. |
| scijava-code-lsp/README.md | Introduces server and script-session usage. |
| scijava-code-lsp/pom.xml | Configures core dependencies and testing. |
| scijava-code-lsp-ty/src/test/java/org/scijava/code/lsp/ty/TyLifecycleIntegrationTest.java | Tests real ty startup and disposal. |
| scijava-code-lsp-ty/src/test/java/org/scijava/code/lsp/ty/TyLauncherTest.java | Tests launch options and parent-process monitoring. |
| scijava-code-lsp-ty/src/test/java/org/scijava/code/lsp/ty/TyLanguageServerIntegrationTest.java | Tests Python editing features end to end. |
| scijava-code-lsp-ty/src/main/java/org/scijava/code/lsp/ty/TyLauncher.java | Builds ty’s environment and launches its process. |
| scijava-code-lsp-ty/src/main/java/org/scijava/code/lsp/ty/TyLanguageServerPlugin.java | Registers the Python backend. |
| scijava-code-lsp-ty/src/main/java/module-info.java | Declares ty module dependencies. |
| scijava-code-lsp-ty/README.md | Demonstrates Python server usage. |
| scijava-code-lsp-ty/pom.xml | Configures ty integration dependencies and tests. |
| scijava-code-lsp-jython/src/test/java/org/scijava/code/lsp/jython/JythonLanguageServerTest.java | Tests Jython completions and signature help. |
| scijava-code-lsp-jython/src/test/java/org/scijava/code/lsp/jython/JavaStubsTest.java | Tests generated Java type stubs. |
| scijava-code-lsp-jython/src/main/java/org/scijava/code/lsp/jython/JythonLanguageServerPlugin.java | Registers the Jython backend. |
| scijava-code-lsp-jython/src/main/java/org/scijava/code/lsp/jython/JythonImports.java | Generates Java class import edits. |
| scijava-code-lsp-jython/src/main/java/module-info.java | Declares Jython module dependencies. |
| scijava-code-lsp-jython/README.md | Demonstrates Jython server usage. |
| scijava-code-lsp-jython/pom.xml | Configures Jython and Python backend dependencies. |
| scijava-code-lsp-groovy/src/test/java/org/scijava/code/lsp/groovy/GroovyServerPluginTest.java | Tests Groovy plugin discovery and launch. |
| scijava-code-lsp-groovy/src/main/java/org/scijava/code/lsp/groovy/Overload.java | Models overloads for completions and signatures. |
| scijava-code-lsp-groovy/src/main/java/org/scijava/code/lsp/groovy/GroovyServerPlugin.java | Registers the Groovy backend. |
| scijava-code-lsp-groovy/src/main/java/module-info.java | Declares Groovy module dependencies. |
| scijava-code-lsp-groovy/README.md | Demonstrates Groovy server usage. |
| scijava-code-lsp-groovy/pom.xml | Configures Groovy backend dependencies and tests. |
| pom.xml | Adds the four modules to the reactor. |
Review effort: Balanced
Tests of ScriptSession move to ScriptSessionTest, of DefaultLanguageServerService and BindingsLanguageServer to their own tests in the impl package, sharing fake plugins in FakeLanguageServers. Each test has a Javadoc stating its goal, and checks one behavior; tests of what other classes do are left to those classes' tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A launcher may start a wrapper around the actual server (e.g. ty's Python launcher). Destroying only the wrapper, when a server fails to initialize or does not shut down, left the server running, orphaned. Now its descendants are destroyed as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ProcessLanguageServer answered initialize with no capabilities, so a client following them would neither sync documents nor ask for completion, hover or signature help. Now initializing starts the process, and passes on its capabilities: of the features the proxy forwards, those the process has; with documents always synced by their whole text, as the proxy requires. If the process cannot start, no features are claimed. Also, tests that need a failing ServerProcesses now make their own, rather than replacing (and, in testRetry, leaking) the one setUp made. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Requests and diagnoses wait for the process to start, which can take long. They then synced the document as it was when they were made: so the process could be told stale text, or a document closed meanwhile (and so open it anew). Now they sync it only if still open at that version, checked under its lock, which closing it takes too; skipped requests are answered with nothing, rather than left pending. Shutting down also cancels documents' pending diagnoses, which would otherwise start the process anew. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ServerProcesses.shutdown() stopped the starter with shutdownNow(), which drops queued starts without completing their futures, so whoever waited on them waited forever. Now it fails the starts not yet done at once, and asking for a process afterwards fails rather than throwing. A start that finishes anyway shuts its process down itself, and a start interrupted by the shutdown is not warned of. A failed start is noted before its future fails, so its users wait out the retry delay from the right time. The fake servers' process says it has no children, so destroying it does not throw, and the delayed fake server is shared by both tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
If we do it on `starter` then it is vulnerable to being terminated on shutdown, preventing normal shutdown completion Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
A completion's additional edits are mapped back to the script, and those in the dialect's header dropped. But when a script has no imports yet, Jython's server inserts a class's import at the very top, in the header, so accepting the class lost its import. As a HACK, an insertion at the very start of the text now goes at the start of the script. NB: That places imports above a script's parameter block, where SciJava scripts conventionally put them after it. Ideally new imports would go right after the parameters at the top. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a script's last import was its last line, without a line break, accepting a Java class appended its import onto that line (e.g. "from java.lang import Mathfrom java.util import ArrayList"). Now an import inserted where no line starts goes after a line break instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Positions.offset clamped a character past a line's end to its \n, so on a line ending in \r\n, it pointed between the \r and the \n. And it added the character to the line's start before clamping, so a huge one (as some clients send, for the end of the line) overflowed to a negative offset. Now a line ends before its line break, \r\n included, and the character is clamped before it is added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its API is the Language Server Protocol's, through and through, and its system properties (scijava.lsp.*) and threads were named so already. The modules become scijava-lsp, scijava-lsp-groovy, scijava-lsp-jython and scijava-lsp-ty, and their packages and Java modules org.scijava.lsp.*. NB: ty's environment keeps its name (code-lsp-ty), lest users' existing environments be left behind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


This PR introduces a few new modules to the monorepo:
scijava-code-lspwranglesLanguageServersThe central package,
scijava-code-lspis designed to assist with the management of Language Servers, following the Language Server Protocol, usinglsp4j. ALanguageServerServiceoffers the ability to launch aLanguageServerbased on a desired programming language andEnvironment(interpreter path, module search paths, existing bindings) for general usage.As the central use case is assisting the development of SciJava scripts, a
ScriptSessionclass is also offered. Users provide (1) the text of a SciJava script to aScriptSessionand (2) aLanguageServerService, and can then query for autocomplete, hover info, etc. as well as listen to diagnostic feedback.Of course,
LanguageServers (can/should) not understand SciJava scripts as written, soscijava-code-lspoffers aScriptDialectplugin describing how to convert text specific to SciJava scripts (e.g. script parameters) to headers that a language server could under stand and reason about. Thescijava/scripting-Xrepositories are where I'm planning for these implementations to live (PRs to follow shortly)Finally,
scijava-code-lspcontains utilities common to multiple language servers, which leads us into:scijava-code-lsp-groovyoffers aGroovyLanguageServerThis language server is fully in-process and uses Groovy's compiler process to develop a typed AST that is used to answer LSP queries.
scijava-code-lsp-jedioffers aPythonLanguageServerThis language server is inter-process and uses
jedi-language-serverto answer LSP queries.scijava-code-lsp-jythonoffers aJythonLanguageServerThis language server is inter-process and uses
PythonLanguageServerindirectly. It also autogenerates type stubs to enable java types to be handled by the Python language server.Points of Discussion
lsp4jis a significant dependency to bring in (~640KB) - I'd be receptive to the case that it's not worth it to use the existing work, and we could consider ascijava-code-lsp-apimodule, because it's unfortunate to bring this in because a library that just wants to declare aScriptDialectimplementation now gets this dependency.jediwas chosen by Claude for the Python language server, but that is apparently in maintenance mode. We probably ought to choose a different server - options includety,zuban, andpyright- should be very easy to switch.