cucumber/language-service

Add support for Python (Behave)

aslakhellesoy opened this issue · 10 comments

See CONTRIBUTING.md for details.

Hi! I am actively working on this.

Excellent! Shout out if you need help.

How is ot going @mrkaiser? Anything I can do to help?

Hi!

I have gotten the tests passing. I'm currently cleaning up my implementation and doing testing to make sure the experience actually works. I'm also working on updating some of the documentation since there were some call outs that I figured out after the fact (one example: There are specific aliases to use for the expressions in the the tree sitter queries. I chose my own and things did not work ) that I think would be helpful for future implementers.

Thanks

Thanks - looking forward to seeing it! And thanks for helping out with the contributor guide too.

Hi,

Testing is going to take more time than originally anticipated. Currently autocomplete and go to definition is not working and I'm not sure why and I'm about to go on vacation next week.

@aslakhellesoy Do you have any thoughts as to where to look? All the tests are currently passing in the language-service. I have the correct capturing nodes and some steps are not underlined. I don't have any logs since the contributing guidelines say to run without debugging.

Thanks!

Hi @mrkaiser if you submit a draft pull request I can take a look.

Logs are still available in non-debug mode. All the debug mode gives you is ability to set breakpoints.

See https://github.com/cucumber/vscode/blob/main/CONTRIBUTING.md#console-output for details.

Hi @aslakhellesoy

After much debugging, I figured out what my initial issues were. They were not code related, but rather local build related (through some process I never got the appropriate WASM executable for python and thus tree-sitter could not parse the python files).

After manually copying the executable into the appropriate directory, the plugin did start working. I used a real world repo to verify and test functionality inside of vscode. Many step definitions worked as expected with auto-complete and go-to definition working as expected.

However many step definitions did not work. Here is one such example:

[Error - 9:51:21 PM] * Step Definition errors: This Cucumber Expression has a problem at column 36:

approximately \(~\) is defined as \+/- (?P<margin>\d+\.?\d*) (?P<units>{regex_of_approximate_parameters_units}) for (?P<parameter_name>{regex_of_approximate_parameters_names})
                                   ^
Only the characters '{', '}', '(', ')', '\', '/' and whitespace can be escaped.
If you did mean to use an '\' you can use '\\' to escape it

I believe this expression likely should use Parameter Types, however it is unclear after spending time looking at the behave documentation (i.e use_step_matcher) and the documentation for parameter types how to use them with each other.

A little stuck here and would like to find either workarounds on the repo side, or a way to support it within the IDE before calling the python work complete.

Behave does not support Cucumber Expressions or parameter types. See behave/behave#968.

The error you are seeing is from the JavaScript Cucumber Expressions library.
It's failing to parse a Regular Expression as a Cucumber Expression.
This is to be expected, they are two different languages, with different syntax and grammar.

I have left another review on #69 with some more details.

I made further updates on #69. It should be ready for merge.