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

Implement Document Symbols Request #98

Closed
aslakhellesoy opened this issue Oct 4, 2022 · 4 comments · Fixed by #106
Closed

Implement Document Symbols Request #98

aslakhellesoy opened this issue Oct 4, 2022 · 4 comments · Fixed by #106
Assignees

Comments

@aslakhellesoy
Copy link
Contributor

🤔 What's the problem you're trying to solve?

See the outline of a Gherkin Document in my editor

✨ What's your proposed solution?

Implement Document Symbols Request.

⛏ Have you considered any alternatives or workarounds?

Yes - implementing it directly in a VSCode Extension. This would limit usage to VSCode users - other editor users would not get the functionality. See cucumber/vscode#111 (review)


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

@10xtechie
Copy link
Member

@aslakhellesoy ,
Which keywords (Scenario, Rule) of Cucumber should we provided by this new service?

@aslakhellesoy
Copy link
Contributor Author

We should look for the following keywords: Feature, Rule, Scenario, Examples. We might also want to add Given/When/Then/And (steps), but let's omit that for now.

I think you should add a new getGherkinDocumentSymbols(gherkinSource: string): readonly DocumentSymbol[] function in src/service/getGherkinDocumentSymbols.ts.

I recommend you start by writing a failing test that:

  • calls getGherkinDocumentSymbols(gherkinSource) with a simple Gherkin source
  • verifies that the returned document symbols are what you expect.

Look at https://github.com/cucumber/language-service/blob/main/test/service/getGherkinDiagnostics.test.ts for inspiration.

You might be able to implement the function with the help of the walkGherkinDocument function. It's already used in some of the other src/service/*.ts functions.

@aslakhellesoy
Copy link
Contributor Author

Hi @10xtechie - have you made any progress on this? I have an implementation of this that I haven't pushed - I wanted to give you a chance to complete yours first :-)

@10xtechie
Copy link
Member

@aslakhellesoy ,
I am sorry for this late reply as I was tied up. Thanks for awaiting my implementations. I have just pushed my initial changes. I am in two minds: should LSP return the array of Document Symbols with custom tree format or should it return Document Symbols using Tree View API Basics.
Please provide me with your feedback; also not sure why the current test is failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants