cucumber / cucumber/language-service

Parsing error for step definition written in Java

Open
#111 1 comment 0 reactions 0 assignees View on GitHub
:bug: bug java
Dominant language
TypeScript
Stars
29
Forks
44
PR merge metrics
No merged PRs in 30d

Description

### 👓 What did you see?

I have below step defined in my steps file:

```java
@Given("I have a menu item with name \"([^\"]+)\" and price (\\d+)")
```

The `\` before `"` is required by Java but the language server should only see `"`. Also, when I run the tests everything is well, so it's not an issue with the definition of the step or the feature file. However, the language server gives the below exception and the step is not recognized in the feature file:

```console
[Error - 5:03:40 PM] * Step Definition errors: Error: This Cucumber Expression has a problem at column 31:

I have a menu item with name \"([^\"]+)\" and price (\d+)
^
Only the characters '{', '}', '(', ')', '\', '/' and whitespace can be escaped.
If you did mean to use an '\' you can use '\\' to escape it
at RT (c:\Users\dstanciu\.vscode\extensions\cucumberopen.cucumber-official-1.5.1\out\extension.js:67:79988)
at d (c:\Users\dstanciu\.vscode\extensions\cucumberopen.cucumber-official-1.5.1\out\extension.js:84:501)
at c:\Users\dstanciu\.vscode\extensions\cucumberopen.cucumber-official-1.5.1\out\extension.js:84:702
at Array.forEach ()
at ac.tokenize (c:\Users\dstanciu\.vscode\extensions\cucumberopen.cucumber-official-1.5.1\out\extension.js:84:636)
at uc.parse (c:\Users\dstanciu\.vscode\extensions\cucumberopen.cucumber-official-1.5.1\out\extension.js:84:2357)
at new ji (c:\Users\dstanciu\.vscode\extensions\cucumberopen.cucumber-official-1.5.1\out\extension.js:84:5199)
at ga.createExpression (c:\Users\dstanciu\.vscode\extensions\cucumberopen.cucumber-official-1.5.1\out\extension.js:84:11717)
at c:\Users\dstanciu\.vscode\extensions\cucumberopen.cucumber-official-1.5.1\out\extension.js:427:748
at $f.eachStepDefinitionExpression (c:\Users\dstanciu\.vscode\extensions\cucumberopen.cucumber-official-1.5.1\out\extension.js:424:1769)
at Wf.build (c:\Users\dstanciu\.vscode\extensions\cucumberopen.cucumber-official-1.5.1\out\extension.js:427:695)
at Sc. (c:\Users\dstanciu\.vscode\extensions\cucumberopen.cucumber-official-1.5.1\out\extension.js:433:19176)
at Generator.next ()
at u (c:\Users\dstanciu\.vscode\extensions\cucumberopen.cucumber-official-1.5.1\out\extension.js:433:11215)
at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
```

### ✅ What did you expect to see?

The step definition would be parsed without error.

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

I am running VSCode with cucumber extension 1,5,1 as seen also in the stack trace.

### 🔬 How could we reproduce it?

Steps to reproduce the behavior:
1. Install VSCode with Cucumber extension version '1.5.1'
2. Create a Java based Cucumber project, with one feature and one step definition. Use \" in the step definition to allow " characters
3. Create a features file using that step.
4. The step is not recognized and the 'Cucumber Server Language' output window shows the exception mentioned above.

----

Contributor guide

Open the contributing guide

Research direction

Reproduce the Java step-definition case in VSCode with Cucumber extension 1.5.1 and inspect the Cucumber Server Language output for the parsing failure. Confirm that escaped quote syntax is accepted and the step is recognized in the feature file without the reported exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, typescript
Domain
testing, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.