Skip to content

Add rust-analyzer inlay hints tool#4

Merged
qkal merged 10 commits into
mainfrom
feat/ra-inlay-hints-clean
May 24, 2026
Merged

Add rust-analyzer inlay hints tool#4
qkal merged 10 commits into
mainfrom
feat/ra-inlay-hints-clean

Conversation

@qkal
Copy link
Copy Markdown
Owner

@qkal qkal commented May 24, 2026

Summary

  • Add readonly ra_inlay_hints MCP tool with whole-file or selected-range requests, kind filtering, bounded grouped output, and optional raw hints.
  • Add rust-analyzer textDocument/inlayHint client support plus formatter/validation helpers.
  • Update README/tool instructions and integration coverage while preserving the existing rename-preview and cargo-build tools from main.

Testing

  • cargo fmt --check
  • cargo test --locked --all
  • cargo clippy --locked --all-targets -- -D warnings

Open in Devin Review

Summary by CodeRabbit

  • New Features

    • Added inlay hints tool to query and preview Rust-analyzer inlay hints with support for line-range filtering, kind-based selection, and configurable result limits.
  • Documentation

    • Updated README to document inlay hints functionality and clarify that Rust-analyzer query tools are read-only analysis tools.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 24, 2026

Warning

Review limit reached

@qkal, we couldn't start this review because you've used your available PR reviews for now.

Your plan includes 1 review of capacity. Refill in 51 minutes and 26 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a748ac04-6d7b-41e4-8b3c-f780305fad63

📥 Commits

Reviewing files that changed from the base of the PR and between eebca40 and 1527ca6.

📒 Files selected for processing (1)
  • src/ra/inlay_hints.rs
📝 Walkthrough

Walkthrough

This PR adds a complete ra_inlay_hints MCP tool that requests, validates, filters, groups, and formats rust-analyzer inlay hints with support for line ranges, kind filtering, truncation, and optional raw output. Changes span request parameter contracts, validation and formatting logic, LSP client support, server orchestration, documentation, and integration tests.

Changes

Inlay Hints Feature Implementation

Layer / File(s) Summary
Request Parameters & Limits
src/ra/params.rs
InlayHintsParams struct defines file path, optional line range, kind filters, max-hints override, and raw-hints flag; DEFAULT_MAX_INLAY_HINTS (200) and MAX_INLAY_HINTS (1000) constants establish configuration bounds; schema and constant tests included.
Validation, Filtering & Formatting Logic
src/ra/inlay_hints.rs
Core module provides max_hints_value, request_range, parse_kind_filters, read_source_lines, and format_inlay_hints helpers that validate parameters, map inclusive line ranges to LSP Range, filter by kind, sort by position, truncate with tracking, group by line with source text, render labels, and optionally include raw hints; comprehensive unit tests cover range validation, filter parsing, label rendering, grouping/sorting, and truncation ordering.
LSP Client Method
src/lsp/client.rs
RustAnalyzerClient::inlay_hints async method sends textDocument/inlayHint request for a given Range, returning Vec<InlayHint> or empty vector on null response.
MCP Tool Integration & Orchestration
src/ra/mod.rs, src/server/mod.rs, src/tools.rs
ra_inlay_hints tool resolves file from workspace, reads source lines, validates max hints and kind filters, computes request range, fetches hints from rust-analyzer, formats output (optionally with raw hints), aggregates notes, and reports truncation; module wiring and re-export formatting; tool instructions updated to clarify readonly vs. workspace-mutation semantics for ra_* tools.
Documentation & Integration Tests
README.md, tests/integration_basic.rs
README documents new tool parameters, LSP UTF-16 positioning, truncation behavior, and removes inlay hints from Phase-Two Ideas; smoke test polls for successful hints requests; error-handling test asserts unknown kind rejection before server request; tools/list test expectations updated.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit hops through lines of code,
Requesting hints along the road,
With kind filters and truncation's grace,
Inlay hints now have their place! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add rust-analyzer inlay hints tool' directly and clearly describes the main change: introduction of a new MCP tool for rust-analyzer inlay hints. It is specific, concise, and accurately reflects the primary objective of the pull request.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ra-inlay-hints-clean

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 4 additional findings in Devin Review.

Open in Devin Review

Comment thread src/ra/inlay_hints.rs
Comment on lines +68 to +70
let Some(kinds) = kinds else {
return Ok(None);
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Empty kinds array silently filters out all inlay hints instead of returning all

When the user passes "kinds": [] (an empty array), parse_kind_filters at src/ra/inlay_hints.rs:68-86 returns Ok(Some(BTreeSet::new())) — a Some wrapping an empty set. In format_inlay_hints at src/ra/inlay_hints.rs:136-140, the filter check filters.map(|f| f.contains(...)).unwrap_or(true) will always return false for Some(empty_set), silently discarding every hint. This is semantically different from omitting kinds entirely (None), which correctly returns all hints. A user or agent passing "kinds": [] likely intends "no filter" (all kinds) but gets zero results with no error or warning.

Suggested change
let Some(kinds) = kinds else {
return Ok(None);
};
let Some(kinds) = kinds.filter(|k| !k.is_empty()) else {
return Ok(None);
};
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

coderabbitai[bot]

This comment was marked as resolved.

@qkal qkal merged commit b820d58 into main May 24, 2026
4 checks passed
@qkal qkal deleted the feat/ra-inlay-hints-clean branch May 24, 2026 22:53
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.

1 participant