Skip to content

fix: render signatures without parameter metadata and single parameters - #1712

Merged
angelozerr merged 2 commits into
redhat-developer:mainfrom
lagergren:fix/signature-help-rendering
Oct 18, 2026
Merged

angelozerr merged 2 commits into
redhat-developer:mainfrom
lagergren:fix/signature-help-rendering

Conversation

@lagergren

@lagergren lagergren commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Why?

Three cases in LSPParameterInfoHandler#updateUI produce no usable or wrong output for valid server responses.

  • A signature without parameters throws. In LSP, SignatureInformation.parameters is optional (parameters?: ParameterInformation[]), so a server may send a signature with only its label. updateUI calls parameters.size() and fails with NullPointerException: Cannot invoke "java.util.List.size()" because "parameters" is null.
  • The single-parameter presentation is empty. When IntelliJ asks the handler to render only the current parameter (ParameterInfoUIContext#isSingleParameterInfo()), the name is appended only in the non-single branch, so the handler renders <b></b>: an empty popup. When the current parameter is not the last one, it also appends the list's , separator after it.
  • An out-of-range active parameter highlights nothing. LSP says: "If omitted or the value lies outside the range of signatures[activeSignature].parameters defaults to 0 if the active signature has parameters." LSP4IJ applies the default only when the value is omitted, so an out-of-range value highlights no parameter, and the single-parameter presentation is empty.

How?

  • Without parameters, show the signature label and highlight nothing. "No parameters" would be wrong here, because the signature may still take arguments; the server simply did not describe them. A signature with an empty parameters list still shows IntelliJ's "no parameters" text, as before.
  • In the single-parameter presentation, append the parameter name between the <b> tags. That presentation is HTML (setupRawUIComponentPresentation), so the name, and the label when there are no parameters, is escaped: a label such as items: List<T> would otherwise be read as a tag. The , separator is only added in the full parameter list.
  • A current parameter outside the signature's parameters falls back to the first one, as LSP specifies.

Implications

Signatures without parameter metadata now show their label instead of failing, the single-parameter popup shows the current parameter alone, and an out-of-range active parameter highlights the first one. Rendering of signatures with an in-range parameter is unchanged.

Changes

  • LSPParameterInfoHandler#updateUI.
  • 10 tests (LSPParameterInfoHandlerTest), rendering through updateUI: a signature without parameters, also as a single parameter with characters that need escaping; an empty parameters list keeps "no parameters"; the current parameter is highlighted, including with label offsets; the single-parameter presentation includes the parameter, escaped, shows only the current one of several, and handles label offsets; and an out-of-range current parameter falls back to the first one.

Manual verification

To reproduce, have a server answer textDocument/signatureHelp with a signature that has a label but no parameters, then trigger parameter info. Without this change, rendering fails with the exception above; with it, the label is shown. I did not run this by hand; the tests above cover it.

Automated checks completed:

  • Against unchanged upstream cbe50d3d, 4 of the first 7 tests fail: the two missing-parameter tests with the NullPointerException above, and the two single-parameter tests, which render <b></b>. The other 3 pass on both and show the rest of the rendering is unchanged.
  • The 3 tests added in review fail without the second commit: the trailing separator (<b>first</b>, ) in two of them, and no highlight for an out-of-range parameter in the third. All 10 pass with this change.
  • ./gradlew check --rerun-tasks --no-build-cache: 500 tests passed, 3 existing skips, no failures or errors. Run with java.io.tmpdir under the home directory, since the default macOS temporary directory gives unrelated VfsRootAccess failures with and without this change.

LSPParameterInfoHandler#updateUI had two rendering bugs:

- A SignatureInformation without parameters threw a NullPointerException
  from parameters.size(). The parameters property is optional in LSP, so
  a server may legitimately omit it. Show the signature label instead,
  with nothing highlighted, because the signature may still take
  arguments. An empty parameter list still shows "no parameters".
- When IntelliJ asks for a single parameter (isSingleParameterInfo), the
  parameter name was never appended, so the popup showed an empty "<b></b>".
  Append the name, escaped, because this presentation is HTML.
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 19e91646-fbe9-472f-8835-e9b706988523
📥 Commits

Reviewing files that changed from the base of the PR and between 142863a and 257a8a9.

📒 Files selected for processing: 2
  • src/main/java/com/redhat/devtools/lsp4ij/features/signatureHelp/LSPParameterInfoHandler.java
  • src/test/java/com/redhat/devtools/lsp4ij/features/signatureHelp/LSPParameterInfoHandlerTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Signature help displays the signature label when parameter details are missing, while an explicitly empty parameter list still shows the no-parameters message.
    • Special characters in single-parameter signatures and parameter names are displayed safely.
    • Current-parameter highlighting handles label offsets and signature-text offsets; an out-of-range parameter index defaults to the first parameter.

The signature help handler now displays the signature label when the parameter list is null, defaults invalid parameter indexes to the first parameter, and escapes text in single-parameter mode. Tests cover these cases and parameter highlighting.

Changes: Signature Help Rendering

Layer / File(s) Summary
Parameter rendering and validation
src/main/java/com/redhat/devtools/lsp4ij/features/signatureHelp/LSPParameterInfoHandler.java, src/test/java/com/redhat/devtools/lsp4ij/features/signatureHelp/LSPParameterInfoHandlerTest.java
When the parameter list is null, the handler displays the signature label. An empty list retains the no-parameters message. Single-parameter mode escapes parameter names and signature labels. Tests cover these cases, index fallback, and parameter highlighting.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: angelozerr

Merge Risk: ⚪ Minimal · up to 257a8

The signature-help rendering changes have no identified actionable merge risk; the checked single-parameter path does not apply shifted highlight offsets.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 24 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly summarizes the main changes: rendering signatures without parameter metadata and rendering single parameters correctly.
Description check Passed The description directly explains the affected cases, implementation, tests, and verification results.
  • Fix all pre-merge checks with AI

Comment @coderabbitai help to get the list of available commands.

More tests for the parameter popup found two rendering bugs:

- The single-parameter presentation appended the ", " separator after
  the current parameter whenever it was not the last one, so it showed
  "<b>first</b>, ". The separator is now only added to the full list.
- A current parameter outside the signature's parameters highlighted
  nothing, and the single-parameter presentation was empty. LSP says an
  active parameter outside signatures[activeSignature].parameters
  defaults to 0, so it now falls back to the first parameter.

Tests: the single-parameter presentation shows only the current one of
several parameters, renders parameters given as label offsets (escaped),
and an out-of-range current parameter falls back to the first one.
@angelozerr angelozerr added bug Something isn't working signatureHelp labels Oct 18, 2026
@angelozerr angelozerr added this to the 0.21.1 milestone Oct 18, 2026
@angelozerr angelozerr moved this to In Progress in Java Tooling Oct 18, 2026
@angelozerr

Copy link
Copy Markdown
Contributor

LGTM Thanks @lagergren !

@angelozerr
angelozerr merged commit b7d8d9b into redhat-developer:main Oct 18, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Java Tooling Oct 18, 2026
@lagergren
lagergren deleted the fix/signature-help-rendering branch October 26, 2026 21:43
angelozerr pushed a commit that referenced this pull request Nov 4, 2026
* docs: describe the 0.30.0 LSP and DAP changes that the docs miss

Several changes merged for 0.30.0 changed behavior that the docs
describe, or added behavior that they don't. LSPSupport.md still said
that pull diagnostics don't support related documents, which #1723
changed.

LSP:
- LSPSupport.md, Pull Diagnostics: previousResultId, and the
  relatedDocuments of either kind of report (#1723, #1735), in place
  of "It doesn't support the related documents."
- LSPSupport.md, Inline Completion: the trigger kind and the selected
  completion item (#1715).
- LSPSupport.md, Signature Help: the retrigger, the active parameter
  of each signature, and signatures without parameters (#1712, #1734).
- LSPSupport.md, Formatting: a file without an open editor (#1707).
- LSPSupport.md, new Did Change Watched Files section: the directories
  outside the project that watchers name, and the watchers of a stopped
  server (#1742). The support list links to it.
- UserGuide.md, Formatting: the Do not format patterns (#1817).
- UserDefinedLanguageServer.md, Configuration tab: null properties
  (#1710, #1847) and invalid JSON (#1828).
- DeveloperGuide.md, Workspace Configuration: null members of
  createSettings() (#1710, #1847).

DAP, dap/UserGuide.md:
- Exception breakpoint: the hint built from exceptionInfo (#1761). The
  screenshot of the stop at the exception moves back after the example
  it shows; the Smart Step Into section had come between them.
- Large variables: a page with fewer children than asked for is the
  last one (#1851).

Validation: each statement was checked against the code at d1a281d:
DocumentContentSynchronizer.refreshPullDiagnostic,
LSPInlineCompletionProvider.createParams, LSPParameterInfoHandler,
ClientCapabilitiesFactory, AbstractLSPFormattingService.canFormat,
LSPFormattingSupport, FileSystemWatchRoots, LanguageServerPanel
.validateJsonFields, JsonSettingsTypeAdapterFactory,
DAPClient.getExceptionHint and DAPVariableChildren. The other changes
merged for 0.30.0 are already documented, by their own PRs, #1784 and
#1810, or change nothing that the docs describe.

Limits: docs only, no new screenshots, no build run.

* docs: say that the JSON fields of a language server are read leniently

CodeRabbit noted that "must be valid JSON" is stricter than what
LSP4IJ accepts. The dialog's check (LanguageServerPanel.jsonError,
JsonParser.parseString) and the readers at run time
(SettingsHelper.parseJson, JsonParser.parseReader for the
initialization options, experimental and installer, Gson.fromJson for
the client configuration and workspace folders) all read leniently.

The paragraph now says which JSON is accepted and which isn't.

Validation: probed Gson 2.15.0's JsonParser.parseString and
Gson.fromJson. Both accept // and /* */ and # comments, unquoted names
and single-quoted strings, and both reject a trailing comma, a missing
brace and an unescaped backslash, such as in C:\Users.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working signatureHelp

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants