Add the missing source locations to the owned AST - #3044
Open
soutaro wants to merge 3 commits into
Open
Conversation
`KeywordParam` carried only a name and a `FunctionParam`, so the owned AST could not answer where a keyword parameter or its key is in the source. A consumer wanting to highlight `name:` in `(name: String) -> void` had to keep a side table of keyword locations next to the AST. The C AST has no single node for a keyword parameter -- it is a hash entry pairing a key symbol with a function param node -- so `KeywordParamLocation` spans the two: `range` runs from the start of the key to the end of the param, and `name_range` covers the key. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`RecordField` had no location at all, so `{ name: String }` in the owned
AST could not say where the field or its key sits in the source.
As with keyword parameters, the C AST spreads a record field over a key
node and a field type node, so `RecordFieldLocation` spans the two: `range`
runs from the start of the key to the end of the field, and `key_range`
covers the key.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`MethodDefinitionOverload` had no location, so a method definition with several overloads could not say which source range each overload occupies without reaching into its `MethodType`. The C AST does have an overload node, so this is its range verbatim. Note that the range starts at the `:` or `|` separator preceding the overload, which is worth knowing before slicing the source with it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fills the source-location gaps in the owned AST (
rust/ruby-rbs/src/ast/), so keyword parameters, record fields, and overloads can be located without keeping a side table of positions next to the AST. One commit each:KeywordParam— newKeywordParamLocation:range=name: String,name_range=nameRecordField— newRecordFieldLocation:range="id" => Integer,key_range="id"MethodDefinitionOverload— newLocationRange, the C overload node's range verbatim, which starts at the leading:or|🤖 Generated with Claude Code