cucumber / language-service

Cucumber Language Service
MIT License
12 stars 22 forks source link

Plugin doesn't recognize steps that use `` instead of '' or "" #101

Closed onthespotqa closed 1 year ago

onthespotqa commented 1 year ago

πŸ‘“ What did you see?

Extension does not recognize steps that use backticks instead of quotes.

βœ… What did you expect to see?

I would expect the extension to recognize steps that use backticks.

πŸ”¬ How could we reproduce it?

In a step file create a step that uses backticks

When(`I fill:`, () => {
  console.log('filling in')
});
xeger commented 1 year ago

I'm encountering this, too!

aslakhellesoy commented 1 year ago

Partial support for template literals (I fill:) would be trivial to add. However, string interpolation cannot be supported (I ${something}).

This library parses the source code (using the tree-sitter library) to extract the step definition expressions, but it doesn’t execute or interpret the source code, which would be necessary in order to evaluate string interpolation.

We could recognise template literals without interpolation and process those, and ignore template literals with interpolation.

Are you relying on interpolation at all? And if not, why are you using template literals and not simple single/double quoted strings?

xeger commented 1 year ago

Good question! In my project, I'm using template literals because my steps frequently use both ' (in the grammatical genitive/possessive sense and " (to quote multi-word parameters). The backtick is a handy way avoid escaping one or the other. I don't use substitution in my template literals, and naturally I wouldn't expect Cucumber to help if I were to.

Your proposal to handle substitution-free literals would work ideally for me. Trying to account for them would probably just cause confusion.

P.S. thank you for providing an official VS Code plugin; both gherkin/cucumber and Code have become instrumental to my workflow.

aslakhellesoy commented 1 year ago

@xeger @onthespotqa the #107 fix is released in Cucumber VSCode 1.5.0. I thought it was fine, but I'm still not seeing step definitions defined with template literals working, so I might have to reopen this. Or you could reopen this if it's not working for you either.

xeger commented 1 year ago

Confirmed that it's not working for me, either, with 1.5.0. πŸ€” I will review your PR and see if there's an obvious reason.

I lack permission to reopen this issue; will open a new one if I have anything useful to contribute in the way of troubleshooting details.

aslakhellesoy commented 1 year ago

I just pushed 1.5.1 where I believe it's fixed. The fix was 001e34f4014499b6ec6a30c529269f1515eec348.

aslakhellesoy commented 1 year ago

Now did I earn some ⭐⭐⭐⭐⭐ at the marketplace? πŸ₯Ί

xeger commented 1 year ago

You've earned a lot more than that, my friend, with all of the excellent tooling you've given me over the years!

onthespotqa commented 1 year ago

confirmed its fixed. thanks for the quick turnaround.