Conversation
Go-to-definition only works from a Gherkin step to its step
definition. Editors that ask the reverse question ("which steps use
this definition?") got nothing, because the server neither advertised
referencesProvider nor kept the Gherkin sources after indexing.
Match every Gherkin step against the expressions located at the
request position. Steps are taken from the compiled pickles, so a
Scenario Outline step matches with its Examples values substituted
and is reported once, at the outline's line.
With language-service 1.7.0 every Rust step definition reports the whole glue file as its target range, so a references request from anywhere in that file resolves to every step definition in it, even from a function that is not a step definition. Test such links against the expression literal instead: the cursor has to be on the literal, body positions return nothing. Once cucumber/language-service#315 is released the ranges are real and the fallback no longer triggers.
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.
Closes #145
onReferencesreturns the location of every Gherkin step matched by the step definitions whosetargetRangecontains the request position.An outline step's own text still contains the
<placeholders>and matches no expression. We therefore match it through the compiled pickles, because they carry the text with each Examples row substituted. The pickles yield one match per row, but the step exists only once in the file, so it is reported as a single location, at the outline step's line.References need the Gherkin sources after indexing, so
reindex()now keeps them on the instance instead of dropping them once the step texts for completion are extracted.@cucumber/gherkinand@cucumber/messagesbecome direct dependencies (both were already resolved transitively through language-service).Body positions resolve only as far as
targetRangeis accurate. With language-service 1.7.0 it is for every language except Rust, where the range spans the whole file (cucumber/language-service#315), so a request from anywhere in a Rust glue file would match every step definition in it. The second commit therefore falls back totargetSelectionRangewhentargetRangestarts at the top of the file. Until #315 is released, Rust users need the cursor on the expression literal.The VSCode extension already attaches to glue files, so references work there without a change.