Skip to content

fix(completion): improve semantic context for Solidity expressions#226

Draft
rifuki wants to merge 1 commit into
asyncswap:mainfrom
rifuki:fix/semantic-completion-context
Draft

fix(completion): improve semantic context for Solidity expressions#226
rifuki wants to merge 1 commit into
asyncswap:mainfrom
rifuki:fix/semantic-completion-context

Conversation

@rifuki

@rifuki rifuki commented Jun 7, 2026

Copy link
Copy Markdown

Refs #225.

Summary

This improves completion behavior in several semantic contexts that are common in Solidity projects:

  • Keep member-access completion in dot context while typing a prefix, so general/class completions do not leak into expressions like RafluxTypes.ListingStatus.AC....
  • Resolve nested contract/library members even when solc omits typeDescriptions on enum/struct declarations, allowing RafluxTypes.ListingStatus. to complete enum values.
  • Apply using Library for Type; extension methods to values of the matching type, including using SafeERC20 for IERC20; so paymentToken. can complete safeTransfer / safeTransferFrom.
  • Avoid adding value extension methods to direct type-name completions such as IERC20..
  • Make no-cache/live-text completion cursor-scope aware so active function params/local variables are returned as variables, while sibling function params do not leak.

Why

Without these fixes, valid Solidity can look unsupported in the editor. One especially confusing case is SafeERC20: IERC20 itself does not define safeTransferFrom, but using SafeERC20 for IERC20; makes it callable on IERC20 values. The LSP should reflect that compiler behavior in completion.

Tests

cargo check
cargo test --test completion
cargo test

Also smoke-tested through Neovim headless against a real Foundry project:

  • paymentToken. includes safeTransfer and safeTransferFrom.
  • emit TicketBought(list...) includes local/function-scope variables as LSP Variable items.
  • RafluxTypes.ListingStatus. returns enum members.

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