cucumber / language-service

Cucumber Language Service
MIT License
12 stars 22 forks source link

Autocomplete not working with RegExp step definitions #60

Closed yipingw closed 2 years ago

yipingw commented 2 years ago

๐Ÿ‘“ What did you see?

Plugin cannot recognize feature file and autocomplete not working, keyword highlight not working as well.

โœ… What did you expect to see?

Autocomplete should be working correctly and keyword like Feature, Given, When etc should be highlighted.

๐Ÿ“ฆ Which tool/library version are you using?

Version: 1.67.2 (user setup) Commit: c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5 Date: 2022-05-17T18:15:52.058Z Electron: 17.4.1 Chromium: 98.0.4758.141 Node.js: 16.13.0 V8: 9.8.177.13-electron.0 OS: Windows_NT x64 10.0.22000 Cucumber plugin version: v1.0.9

๐Ÿ”ฌ How could we reproduce it?

Steps to reproduce the behavior:

  1. Install plugin with version 1.0.9
  2. Create a feature and typing some steps.
  3. No autocomplete or keyword highlight even setting feature file path or glue path.
image
aurelien-reeves commented 2 years ago

Hi @yipingw

Thanks for your report.

Could you please take a look in the [output] tab of vscode: do you have a task related to the cucumber language server? If so, what is reported there?

yipingw commented 2 years ago

Hi @aurelien-reeves This is the output:

[Info - 17:13:54] Registering request handler for workspace/didChangeConfiguration failed. [Info - 17:13:54] Could not register DidChangeConfigurationNotification: "Unhandled method client/registerCapability" - this is OK [Info - 17:13:54] CucumberLanguageServer initialized! [Info - 17:13:54] onInitialized [Info - 17:13:54] Scheduling reindexing in 0 ms [Info - 17:13:54] Reindexing... [Info - 17:13:54] Found 1 feature file(s) [Info - 17:13:54] Found 3 steps in those feature files [Info - 17:13:54] Found 3 glue file(s) [Info - 17:13:54] Found 12 step definitions in those glue files [Info - 17:13:54] * Built 12 suggestions for auto complete

aslakhellesoy commented 2 years ago

Judging from the log output it looks like everything is fine. @yipingw do you have any other Cucumber or Gherkin extensions installed? Have you tried deactivating or uninstalling them?

yipingw commented 2 years ago

@aslakhellesoy I've installed Cucumber (Gherkin) Full Support. But uninstall it and then install cucumber official plugin with no luck.

aslakhellesoy commented 2 years ago

@yipingw are you seeing the same issue with extension version 1.2.2? There are some recent bug fixes that may have fixed this.

yipingw commented 2 years ago

@aslakhellesoy I found some changes base on latest release(v1.2.2), please reference the following screenshot that display undefined step, that was not displayed in v1.0.9

image

output:

[Info - 21:32:57] Registering request handler for workspace/didChangeConfiguration failed. [Info - 21:32:57] Client does not support client/registerCapability. This is OK. [Info - 21:32:57] Cucumber Language Server 0.12.4 initialized [Info - 21:32:57] Scheduling reindexing in 3000 ms [Info - 21:32:57] Generating diagnostics [Info - 21:32:57] Reindexing... [Info - 21:32:57] * Found 1 feature file(s) in ["features//*.feature","src/test/*/.feature"] [Info - 21:32:57] Found 3 steps in those feature files [Info - 21:32:57] Found 2 glue file(s) in ["features//*.php","features//*.rb","features/*/.ts","src/test//.java","specs*//.cs"] [Info - 21:32:57] Found 0 parameter types in those glue files [Info - 21:32:57] Found 0 step definitions in those glue files [Info - 21:32:57] Generating diagnostics [Info - 21:32:57] Built 3 suggestions for auto complete [Info - 21:32:57] Unable to generate step definition. Please create one first manually. [Info - 21:33:00] Reindexing... [Info - 21:33:00] Found 1 feature file(s) in ["features//*.feature","src/test//.feature"] [Info - 21:33:00] Found 3 steps in those feature files [Info - 21:33:00] * Found 2 glue file(s) in ["features/*/.php","features//*.rb","features//*.ts","src/test/*/.java","specs//.cs"] [Info - 21:33:00] Found 0 parameter types in those glue files [Info - 21:33:00] Found 0 step definitions in those glue files [Info - 21:33:00] Generating diagnostics [Info - 21:33:00] * Built 3 suggestions for auto complete [Info - 21:33:00] Unable to generate step definition. Please create one first manually. [Info - 21:33:03] Unable to generate step definition. Please create one first manually. [Info - 21:33:03] Unable to generate step definition. Please create one first manually. [Info - 21:33:07] Unable to generate step definition. Please create one first manually. [Info - 21:33:07] Unable to generate step definition. Please create one first manually. [Info - 21:33:20] Unable to generate step definition. Please create one first manually. [Info - 21:33:20] Unable to generate step definition. Please create one first manually. [Info - 21:33:21] Unable to generate step definition. Please create one first manually. [Info - 21:35:05] Unable to generate step definition. Please create one first manually.

aslakhellesoy commented 2 years ago

Thanks for that @yipingw.

Have you overridden any settings for the extension? Can you share them here please?

aslakhellesoy commented 2 years ago

Also, what programming language are you using for step definitions?

yipingw commented 2 years ago

@aslakhellesoy No, I used default setting, there's not any manually cucumber setting in settings.json. Java project.

aslakhellesoy commented 2 years ago

The globs in the last output you shared look different from those in the default settings.

Can you please paste it again, ensuring itโ€™s exactly as printed? Add a line with triple backticks above and below the logs to ensure it is properly formatted. See https://github.github.com/gfm/#fenced-code-blocks

aslakhellesoy commented 2 years ago

One more question - are you using annotation style step definitions or lambda style ones?

yipingw commented 2 years ago

One more question - are you using annotation style step definitions or lambda style ones?

Annotation style.

yipingw commented 2 years ago
{
    "editor.fontFamily": "'Fira Code', ๅพฎ่ฝฏ้›…้ป‘, Consolas, 'Courier New', monospace",
    "editor.fontLigatures": true,
    "files.autoSave": "onFocusChange",
    "terminal.integrated.fontFamily": "'FiraCode Nerd Font Retina', ๅพฎ่ฝฏ้›…้ป‘",
    "editor.fontSize": 14,
    "terminal.external.osxExec": "iTerm.app",
    "terminal.integrated.fontSize": 14,
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "java.configuration.checkProjectSettingsExclusions": false,
    "explorer.confirmDelete": false,
    "java.jdt.ls.vmargs": "-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication -javaagent:\"c:\\Users\\yipin\\.vscode\\extensions\\gabrielbb.vscode-lombok-1.0.1\\server\\lombok.jar\" -Dfile.encoding=UTF-8",
    "[typescript]": {
        "editor.codeActionsOnSave": {
            "source.organizeImports": false
        }
    },
    "[typescriptreact]": {
        "editor.codeActionsOnSave": {
            "source.organizeImports": false
        }
    },
    "maven.executable.preferMavenWrapper": true,
    "redhat.telemetry.enabled": false,
    "spring-boot.ls.java.home": "C:\\Program Files\\Java\\jdk-11.0.11",
    "terminal.integrated.tabs.enabled": true,
    "security.workspace.trust.untrustedFiles": "newWindow",
    "spring.initializr.defaultJavaVersion": "11",
    "spring.initializr.defaultLanguage": "Java",
    "spring.initializr.defaultPackaging": "JAR",
    "settingsSync.ignoredSettings": [
        "markdown-pdf.executablePath",
        "spring-boot.ls.java.home"
    ],
    "maven.pomfile.prefetchEffectivePom": true,
    "maven.pomfile.autoUpdateEffectivePOM": true,
    "maven.terminal.useJavaHome": true,
    "vsicons.dontShowNewVersionMessage": true,
    "java.completion.favoriteStaticMembers": [
        "org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*",
        "org.springframework.test.web.servlet.result.MockMvcResultMatchers.*",
        "org.assertj.core.api.Assertions.assertThat"
    ],
    "editor.unicodeHighlight.nonBasicASCII": false,
    "workbench.editor.untitled.hint": "hidden",
    "dart.openDevTools": "flutter",
    "[dart]": {
        "editor.formatOnSave": true,
        "editor.formatOnType": true,
        "editor.rulers": [
            80
        ],
        "editor.selectionHighlight": false,
        "editor.suggest.snippetsPreventQuickSuggestions": false,
        "editor.suggestSelection": "first",
        "editor.tabCompletion": "onlySnippets",
        "editor.wordBasedSuggestions": false
    },
    "workbench.iconTheme": "vscode-icons",
    "code-runner.executorMap": {
        "java": "cd $dir && javac -encoding utf-8 $fileName && java $fileNameWithoutExt"
    },
    "code-runner.runInTerminal": true,
    "java.debug.settings.vmArgs": "-Dfile.encoding=UTF-8",
    "workbench.colorTheme": "Atom One Dark",
    "explorer.confirmDragAndDrop": false,
    "eslint.packageManager": "yarn",
    "search.exclude": {
        "**/dist": true
    },
    "files.eol": "\n",
    "typescript.preferences.quoteStyle": "single",
    "javascript.preferences.quoteStyle": "single"
}
aslakhellesoy commented 2 years ago

@yipingw we need the logs from the Cucumber Language Server, not your settings.xml. You pasted it above, but it needs to be in fenced code blocks so we can read it.

yipingw commented 2 years ago

Hi @aslakhellesoy , This is runnable java project. The screenshot from vscode Cucumber Language Server output log:

image
[Info  - 08:59:47] Registering request handler for workspace/didChangeConfiguration failed.
[Info  - 08:59:47] Client does not support client/registerCapability. This is OK.
[Info  - 08:59:47] Cucumber Language Server 0.12.4 initialized
[Info  - 08:59:47] Scheduling reindexing in 3000 ms
[Info  - 08:59:47] Scheduling reindexing in 3000 ms
[Info  - 08:59:47] Generating diagnostics
[Info  - 08:59:47] Reindexing...
[Info  - 08:59:47] * Found 1 feature file(s) in ["features/**/*.feature","src/test/**/*.feature"]
[Info  - 08:59:47] * Found 5 steps in those feature files
[Info  - 08:59:47] * Found 2 glue file(s) in ["features/**/*.php","features/**/*.rb","features/**/*.ts","src/test/**/*.java","*specs*/**/.cs"]
[Info  - 08:59:47] * Found 0 parameter types in those glue files
[Info  - 08:59:47] * Found 3 step definitions in those glue files
[Info  - 08:59:47] Generating diagnostics
[Info  - 08:59:47] * Built 3 suggestions for auto complete
[Error - 08:59:47] Cannot read properties of null (reading 'join')
[Info  - 08:59:53] Reindexing...
[Info  - 08:59:53] * Found 1 feature file(s) in ["features/**/*.feature","src/test/**/*.feature"]
[Info  - 08:59:53] * Found 5 steps in those feature files
[Info  - 08:59:53] * Found 2 glue file(s) in ["features/**/*.php","features/**/*.rb","features/**/*.ts","src/test/**/*.java","*specs*/**/.cs"]
[Info  - 08:59:53] * Found 0 parameter types in those glue files
[Info  - 08:59:53] * Found 3 step definitions in those glue files
[Info  - 08:59:53] Generating diagnostics
[Info  - 08:59:53] * Built 3 suggestions for auto complete
[Error - 08:59:53] Failed to reindex: Cannot read properties of null (reading 'join')
[Info  - 17:49:57] Scheduling reindexing in 3000 ms
[Info  - 17:50:00] Reindexing...
[Info  - 17:50:00] * Found 1 feature file(s) in ["features/**/*.feature","src/test/**/*.feature"]
[Info  - 17:50:00] * Found 5 steps in those feature files
[Info  - 17:50:00] * Found 2 glue file(s) in ["features/**/*.php","features/**/*.rb","features/**/*.ts","src/test/**/*.java","*specs*/**/.cs"]
[Info  - 17:50:00] * Found 0 parameter types in those glue files
[Info  - 17:50:00] * Found 3 step definitions in those glue files
[Info  - 17:50:00] Generating diagnostics
[Info  - 17:50:00] * Built 3 suggestions for auto complete
[Error - 17:50:00] Failed to reindex: Cannot read properties of null (reading 'join')
[Info  - 17:50:08] Scheduling reindexing in 3000 ms
[Info  - 17:50:08] Generating diagnostics
[Info  - 17:50:08] Scheduling reindexing in 3000 ms
[Info  - 17:50:08] Generating diagnostics
[Info  - 17:50:09] Scheduling reindexing in 3000 ms
[Info  - 17:50:09] Generating diagnostics
[Info  - 17:50:09] Scheduling reindexing in 3000 ms
[Info  - 17:50:09] Generating diagnostics
[Info  - 17:50:12] Reindexing...
[Info  - 17:50:12] * Found 1 feature file(s) in ["features/**/*.feature","src/test/**/*.feature"]
[Info  - 17:50:12] * Found 5 steps in those feature files
[Info  - 17:50:12] * Found 2 glue file(s) in ["features/**/*.php","features/**/*.rb","features/**/*.ts","src/test/**/*.java","*specs*/**/.cs"]
[Info  - 17:50:12] * Found 0 parameter types in those glue files
[Info  - 17:50:12] * Found 3 step definitions in those glue files
[Info  - 17:50:12] Generating diagnostics
[Info  - 17:50:12] * Built 3 suggestions for auto complete
[Error - 17:50:12] Failed to reindex: Cannot read properties of null (reading 'join')
aslakhellesoy commented 2 years ago

Thank you @yipingw. Please try again with the VSCode extension version 1.2.4. It has a few bug fixes and also improved logging in case something goes wrong.

aslakhellesoy commented 2 years ago

It would also be useful if you could paste the 3 step definition regexps you have in your .php files. I think there might be a bug with how we parse regexps, and knowing yours would help us reproduce the problem.

yipingw commented 2 years ago

Hi, This is a Java project, please see the code snippet below:

package com.example;

import io.cucumber.java.PendingException;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;

import com.niimbot.Checkout;
import static org.junit.jupiter.api.Assertions.*;

public class CheckoutSteps {

    private int singlePrice;
    private Checkout checkout;

    public CheckoutSteps() {
        singlePrice = 0;
        checkout = new Checkout();
    }

    @Given("^the price of a \"(.*?)\" is (\\d+)c$")
    public void the_price_of_a_is_c(String name, int price) throws Throwable {
        singlePrice = price;
    }
    @When("^I checkout (\\d+) \"(.*?)\"$")
    public void i_checkout(int itemCount, String itemName) throws Throwable {
        checkout.add(itemCount, singlePrice);
    }
    @Then("^the total price should be (\\d+)c$")
    public void the_total_price_should_be_c(int total) throws Throwable {
        assertEquals(total, checkout.total());
    }
}
aslakhellesoy commented 2 years ago

Thanks. Did you try 1.2.4 yet?

yipingw commented 2 years ago

Thanks. Did you try 1.2.4 yet?

Still not working, I tried to disabled all of plugins in current workspace but enable cucumber only, keyword highlight works well but autocomplete feature still not working. I don't know which plugin cause this issue.

image

PS: Highlight issue related theme named "Atom One Dark", I tried to switch to other theme works well.

aslakhellesoy commented 2 years ago

This should be fixed in extension 1.2.5. If not, please reopen this issue. Thanks for providing all the info to help us fix this!