Skip to content

Improve LSP Hover and Completion for Reduce Action Bindings#84

Merged
ehwan merged 6 commits into
mainfrom
hover_type
Jun 23, 2026
Merged

Improve LSP Hover and Completion for Reduce Action Bindings#84
ehwan merged 6 commits into
mainfrom
hover_type

Conversation

@ehwan

@ehwan ehwan commented Jun 23, 2026

Copy link
Copy Markdown
Owner
  • Add resolved type information to LSP hover and completion details for reduce action bindings such as data, lookahead, shift, Err, @0, and @$.
  • Resolve grammar substitution variables and aliases before displaying types, including %moduleprefix, %userdata, %location, %error / %errortype, and %tokentype.
  • Add hover and completion support for mapped symbols used as plain identifiers inside reduce actions.
  • Show production-token reference context for mapped symbols, $1 / $2 positional values, and @1 / @2 location references using a caret marker under the referenced RHS token.
  • Keep completion documentation aligned with hover documentation for reduce action variables and bindings.

@ehwan ehwan self-assigned this Jun 23, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request enhances the Language Server Protocol (LSP) implementation for RustyLR by providing rich hover information and completion suggestions inside reduce actions. It introduces support for resolving semantic value bindings, positional variables, location references, and GLR control variables (such as data, lookahead, shift, and Err), including resolving types after substitution (e.g., resolving $moduleprefix references). Feedback on the changes includes addressing a stack corruption issue in resolve_provider_stream due to an early return bypassing stack.pop(), and decoupling the collection of default binding types from token references in variables_for_offset to ensure types are always populated when a grammar is available.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread rusty_lr_executable/src/lsp/hover.rs
Comment on lines +645 to +659
if let (Some(grammar), Some(reference)) =
(&grammar, token_references.get(variables.value_count - 1))
{
collect_default_binding_types(
args,
grammar,
pattern,
&mut variables.value_types,
);
collect_default_binding_references(
pattern,
reference,
&mut variables.value_references,
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

In variables_for_offset, the collection of default binding types is incorrectly coupled with the presence of reference (token references). If reference is None (e.g., if reference resolution fails or is not applicable), collect_default_binding_types is never called, meaning default bindings will not have their types populated and won't be suggested in completion. Decouple the two operations so that default binding types are always collected as long as grammar is available.

Suggested change
if let (Some(grammar), Some(reference)) =
(&grammar, token_references.get(variables.value_count - 1))
{
collect_default_binding_types(
args,
grammar,
pattern,
&mut variables.value_types,
);
collect_default_binding_references(
pattern,
reference,
&mut variables.value_references,
);
}
if let Some(grammar) = &grammar {
collect_default_binding_types(
args,
grammar,
pattern,
&mut variables.value_types,
);
}
if let Some(reference) = token_references.get(variables.value_count - 1) {
collect_default_binding_references(
pattern,
reference,
&mut variables.value_references,
);
}

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@ehwan ehwan merged commit 94df5db into main Jun 23, 2026
1 check passed
@ehwan ehwan deleted the hover_type branch June 23, 2026 23:43
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