cucumber / vscode

Official Visual Studio Code Extension for Cucumber
MIT License
66 stars 17 forks source link

Scope paths where step definition snippets are generated #242

Open ibrahimBeladi opened 3 months ago

ibrahimBeladi commented 3 months ago

🤔 What's the problem you've observed?

When using a package that provides a list of gherkins, and when having custom gherkin, then the step definition will suggest both the package's step definition files and the local files. Where it should be only the local files, or a specified list of files.

"cucumber.glue": [
    // writable
    "uuv/cucumber/**/*.ts",

    "node_modules/@uuv/*/src/cucumber/step_definitions/*/unsafe/**/_en-*.ts",
    "node_modules/@uuv/*/src/cucumber/step_definitions/*/generated/en/*.ts",
    "node_modules/@uuv/*/src/cucumber/step_definitions/*/generated/enriched/*/*.ts"
  ],

image

✨ Do you have a proposal for making it better?

I am thinking of 2 solutions:

📚 Any additional context?

I am using uuv, so this issue is not wide spread yet

kieran-ryan commented 3 months ago

Thanks for your interest in the project @ibrahimBeladi! To ensure clarity on your feature request, could you advise whether I am correct in stating that the request is to: scope paths where step definition snippets can be generated.

ibrahimBeladi commented 3 months ago

Hello @kieran-ryan, I think yes. But let me further clarify just in case.

In the image that I included in the original post, you can see that there are many paths that are suggested to write into, however some of them are unhealthy to write into (the ones in node_modules). The tops ones will not be written into, and only the last 3 will be writable, or I can configure which ones of the 3 are writable in the configuration.

So, what I am suggesting some paths to be writable, and some paths are not. In this case, when I set a path to be not writable, then it would be shown in the auto-completion of snippets, but not shown in the generation/creation of new step definition.

kieran-ryan commented 3 months ago

Perfect, is clear @ibrahimBeladi.

In that case, would suggest we keep the 'glue' section as-is and provide additional configuration to scope the paths for snippet generation (which should default to the configured 'glue' paths). Are you aware of any libraries or extensions with similar path configuration that we could take a look at as a point of reference?

Support would need to be implemented in the Cucumber Language Server. If this is an implementation you would be interested to open a PR on (even partially) I would be happy to support you with it. Otherwise feel free to drop any relevant information here that you feel would be useful for someone if they were to pick up this issue. Appreciate the support!

ibrahimBeladi commented 3 months ago

Unfortunately I don't know of a similar path configuration. What would you recommend the key/name for the new property?

I think I can work on it, but I don't have enough time. If no one picks this up, then I might eventually create a PR for it.

kieran-ryan commented 3 months ago

Potentially snippet.paths: [] or snippetPaths: [], though we can return to the naming once we have a solution.

I think I can work on it, but I don't have enough time. If no one picks this up, then I might eventually create a PR for it.

No worries, if you pick it up at any stage and raise a PR, will support you on it - thanks again, good to have this captured!