ADFA-4747: Fix Add-import code action not appearing on unresolved references#1547
ADFA-4747: Fix Add-import code action not appearing on unresolved references#1547itsaky-adfa wants to merge 4 commits into
Conversation
…nces AddImportAction.prepare() gated visibility on findSymbolBySimpleName(name, 0), but the helper ended with Sequence.take(limit) and take(0) returns empty, so the action was invisible for every unresolved-reference diagnostic - dead since ADFA-3754. Treat limit <= 0 as unbounded, honoring the documented ReadableIndex.query contract the helper was violating. Also extract hasImportableClassifier and a non-suspend computeImportCandidates (runCatching, KtFile fetched before project.read) for testability and crash-safety, and drop the no-op CMD_FORMAT_CODE. Adds AddImportActionTest (visibility-gate regression) and EditExtsTest.
Replace the SQLite-backed visibility gate with an in-memory check on the unresolved-reference marker. prepare() runs synchronously on the UI thread during menu build, so resolving against the symbol index there was main-thread disk I/O; that resolution now happens only in the background execAction.
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
Warning Review limit reached
Next review available in: 20 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
Jira: ADFA-4747
What & why
The "Add import" code action (shipped in ADFA-3754) never appeared on an unresolved-reference diagnostic - dead since it shipped.
KtSymbolIndex.findSymbolBySimpleNameended withSequence.take(limit)and its only caller passedlimit = 0, sotake(0)returned empty andprepare()always went invisible.limit <= 0as unbounded, honouring theReadableIndex.querycontract. ExtractcomputeImportCandidates(non-suspend,runCatching,KtFilebeforeproject.read); drop the no-opCMD_FORMAT_CODE.prepare()- decide from the in-memoryunresolvedReferencemarker; index resolution moves entirely to the backgroundexecAction.flashError) when a shown action resolves nothing.Tests
:lsp:kotlin:testV7DebugUnitTest --tests AddImportActionTest5/5 (incl. thetake(0)-unbounded regression guard);EditExtsTestcovers sorted-insert/dedup;:lsp:kotlin:assembleV8Debugbuilds.Merge gate (manual QA)
On-device: "No imports found" on a typo; single-candidate auto-apply vs multi-candidate picker; no main-thread jank.
Follow-ups (out of scope)
insertImportdoes not dedup a concrete import already covered by a wildcard (no impact today).Supersedes the PR originally opened under ADFA-4610 (that subtask tracks the original feature, delivered via ADFA-3754); the same commits are re-attached here under the correctly-scoped bug ADFA-4747.