cucumber / cucumber/language-service

Invalid regular expression for PHP

Open
#199 2 comments 0 reactions 0 assignees View on GitHub
:bug: bug php
Dominant language
TypeScript
Stars
29
Forks
44
PR merge metrics
No merged PRs in 30d

Description

### 👓 What did you see?

Hello, I'm setting Cucumber LSP for nvim, and I'm getting errors during regex parsing.
I'm trying to glue steps from package: https://github.com/FriendsOfBehat/MinkExtension

Regex parsing fails with error:
```
[ERROR][2024-04-06 11:07:53] ...lsp/handlers.lua:535 'Failed to reindex: Invalid regular expression: /Opens specified page\n * Example: Given I am on "http://batman.com"\n * Example: And I am on "/articles/isBatmanBruceWayne"\n * Example: When I go to "/articles/isBatmanBruceWayne"\n *\n * /^(?:|I )am on "(?P[^"]+)"$/\n * @When /^(?:|I )go to "(?P[^"]+)"$//: Invalid group'
```

Here is the corresponding bloc:
```php
/**
* Opens specified page
* Example: Given I am on "http://batman.com"
* Example: And I am on "/articles/isBatmanBruceWayne"
* Example: When I go to "/articles/isBatmanBruceWayne"
*
* @Given /^(?:|I )am on "(?P[^"]+)"$/
* @When /^(?:|I )go to "(?P[^"]+)"$/
*/
public function visit($page)
{
$this->visitPath($page);
}
```

What can be wrong? And what package is responsible for parsing those steps? I can't find _Invalid regular expression_ anywhere in the source code.

Thanks!

### ✅ What did you expect to see?

Regex parsing should work, as those steps are executed successfully during testing.

### 📦 Which tool/library version are you using?

node 21.7.1
npm 10.5.0
nvim 0.9.5
@cucumber/language-server 1.5.0

### 🔬 How could we reproduce it?

Use this nvim lspconfig and check lsp logs:
```lua
require('lspconfig').cucumber_language_server.setup {
capabilities = capabilities,
settings = {
cucumber = {
features = { 'behat/**/*.feature' },
glue = { 'vendor/friends-of-behat/mink-extension/src/Behat/MinkExtension/Context/**/*.php' },
},
}
}
```

### 📚 Any additional context?

I've never installed this package before, so maybe I'm missing a package or configuration.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with @cucumber/language-server 1.5.0, the provided nvim configuration, and the PHP glue file containing the @Given and @When expressions. Trace the reindexing path that reports the invalid group, then verify that these Behat expressions are parsed without the LSP error while preserving support for the existing language-server configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, typescript
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.