Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Tree #108

Closed
wants to merge 2 commits into from
Closed

Add a Tree #108

wants to merge 2 commits into from

Conversation

aslakhellesoy
Copy link
Contributor

🤔 What's changed?

Implement a tree view

⚡️ What's your motivation?

Fix #94

🏷️ What kind of change is this?

  • 🏦 Refactoring/debt/DX (improvement to code design, tooling, documentation etc. without changing behaviour)
  • 🐛 Bug fix (non-breaking change which fixes a defect)
  • ⚡ New feature (non-breaking change which adds new behaviour)
  • 💥 Breaking change (incompatible changes to the API)

♻️ Anything particular you want feedback on?

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

This text was originally generated from a template, then edited by hand. You can modify the template here.

@@ -0,0 +1,414 @@

import { spawn } from 'child_process';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're aiming to be able to run as a VSCode Web Extesion (#1) so using node-js specific APIs should be avoided.

From https://code.visualstudio.com/api/extension-guides/web-extensions#web-extension-main-file

Node.js globals and libraries such as process, os, setImmediate, path, util, url are not available at runtime.

Copy link
Contributor Author

@aslakhellesoy aslakhellesoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this code - it's super helpful for building a tree view for this extension.

I really like the UI code, but I have some issues with how the tree view is built:

  • It uses child_process and fs, which are unavailable in web extensions
  • Parsing is incompatible with Gherkin's I18n
  • A lot of this could be implemented in @cucumber/language-service and be reusable in many editors

I wonder if TypeHierarchy might be a possible way to implement this. Or possibly through an extension to the LSP like https://github.com/scalameta/metals-languageclient seems to have done.


## Tree View

I gave it a try and implemented my tree view example into the cucumber extension. In general it does work well, but there are some unknowns which I don't know by now. All my local tests I did with cucumber cpp in combination with my example (just pull it and build it): https://github.com/ThoSe1990/cucumber_example
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's interesting to read about your approach, but I think it would be better if you moved this content to the pull request description.

The purpose of the README is to give users a showcase of what this extension does. They are not interested in the details about how a particular feature has been implemented.

It's great to have screenshots!

@@ -0,0 +1,414 @@

import { spawn } from 'child_process';
import * as fs from 'fs';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For filesystem access we hide implementation details behind a facade - VscodeFiles.

Please extend this class instead.


export class tree_view implements vscode.TreeDataProvider<tree_item>
{
private data : tree_view_data = new tree_view_data();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use camelCase for variables and functions.


readonly onDidChangeTreeData? : vscode.Event<tree_item | undefined> = this.event_emitter.event;

private readonly regex_feature = new RegExp('(?<=Feature:).*');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot rely on regexps to parse the source code. Gherkin supports 77 languages, and we should use the @cucumber/gherkin library to parse Gherkin source.

@aslakhellesoy
Copy link
Contributor Author

This is superseded by cucumber/language-service#98

@kieran-ryan kieran-ryan added 🐛 bug Defect / Bug ⚡ enhancement Request for new functionality and removed 🐛 bug Defect / Bug labels Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡ enhancement Request for new functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support vscode outline panel for feature files
2 participants