Skip to content

LSP-based code assistance - #80

Draft
gselzer wants to merge 21 commits into
mainfrom
lsp-completion
Draft

gselzer wants to merge 21 commits into
mainfrom
lsp-completion

Conversation

@gselzer

@gselzer gselzer commented Oct 21, 2026

Copy link
Copy Markdown
Member

This PR enables the script editor to provide real-time autocompletion, hover information, diagnostics, and more. It utilizes the Language Server Protocol, using scijava-code-lsp.

See scijava/scijava#294 for discussion

gselzer and others added 21 commits October 7, 2026 14:40
Make the script editor a thin adapter over scijava-common's toolkit-agnostic
completion SPI, so languages contribute completion with no Swing/RSTA code:

- SciJavaCompletionProvider: the single bridge translating neutral
  Completions to RSTA completions (BasicCompletion, or FunctionCompletion
  for callables so parameter assistance engages), and neutral
  ParameterChoices to RSTA's ParameterChoicesProvider.
- CodeCompleterLanguageSupport: lightweight completion tier installed for
  any language providing a CodeCompleterPlugin.
- SciJavaAutoCompletion + SciJavaCompletion/SciJavaFunctionCompletion +
  AdditionalEdits: apply language-neutral auto-imports (Completion.TextEdit)
  on acceptance, across both basic and function completions.
- EditorPane: resolve completion via explicit tiers (heavy RSTA plugin ->
  neutral CodeCompleter -> RSTA legacy -> Java fallback), tracking the
  installed support; existing LanguageSupportPlugins keep working.
- PromptPane: REPL Tab-completion via CodeCompletionService, so every
  language gets baseline interpreter completion.
- ClassUtil: reduced to a thin facade over scijava-common's ClassIndex.

pom.xml carries a temporary scijava-common.version override until a release
pins the new SPI.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Syntax highlighting requires an RSyntaxTextArea TokenMaker, which is
inherently editor-side. Provide it here so the toolkit-agnostic Jython
scripting plugin (scripting-jython) need not depend on the editor or RSTA;
this replaces the highlighter formerly in script-editor-jython.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Render the parameter tooltip's overload list from the completer's
  signature help: its order, styled by fit (conversions greyed,
  mismatches struck out), ignoring help about nested calls. Remove
  Overloads, whose language-specific parsing and rules moved to the
  completers.
* Ask for completion descriptions only when RSTA shows them, and show
  them for function completions too (RSTA's FunctionCompletion dropped
  them).
* Update the completion popup in place when a result announces a better
  one, if the text and caret are unchanged.
* Let completers prepare when a script's completion support installs.
* Pass the edited script's file path in completion requests.
* Color dimmed overloads from the Look & Feel's disabled text color.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For languages whose completer offers them: what is known about the code under the mouse as tooltip (HoverToolTipSupplier); problems as squiggles (DiagnosticsParser, an RSTA parser asking in the background); and, once a call's parenthesis is typed, its signatures in a popup following the caret through the call (SignaturePopup). Hover and problems can be turned off in the Options menu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The editor is now an LSP client of a LanguageServerService's merged server per language: DocumentSync keeps the server's copy of the script up to date (opened on install, changed with each edit, closed on uninstall, reopened when saved under another name). SciJavaCompletionProvider turns LSP completions into RSTA's: snippets with label details become function completions (parameter assistance with types), overloads listed with their signature-help fits, documentation resolved when shown, slower completions (UpdatingCompletionList) replacing the first. Parameter choices are what the server completes at the parameter. Hover, problems (as published) and the signature popup use the server too. Until code-api goes, CodeCompleters can still be used directly, via code-lsp's adapter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Completions' additional edits are AdditionalEdits.Edit; the REPL prompt
completes via the LanguageServerService (or a BindingsLanguageServer for
languages without servers); the tests use fake language servers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DocumentSync is replaced by code-lsp's ScriptSession: one per text area
(completion, signature help, hover and problems), and one per REPL
prompt, kept while its interpreter is the REPL's and closed with the
interpreter pane.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cleaned up some javadoc and deduped a few lines
BindingsLanguageServer is now internal to code-lsp, so the prompt's
javadoc no longer links to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ClassUtil only forwards to code-lsp's ClassIndex; it stays, for code
outside the script editor still calling it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
code-lsp no longer answers with completions now and better ones later,
nor rates signatures. The editor waits a moment for completions, and
shows slower ones as they arrive; signatures show in the server's order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sessions tell their servers off the caller's thread, so a test waits for
the server to hear of the script.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ScriptSession is made with a service only: FakeServers gives each test
session a fake server of its own, which sees scripts as they are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants