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

Provide pester functions (it, context, describe) in document symbols #490

Merged
merged 16 commits into from
Jun 5, 2017

Conversation

kapilmb
Copy link

@kapilmb kapilmb commented Jun 5, 2017

This provides pester symbols (it, context and describe) for a pester file whenever the server receives a textDocument/documentSymbol request. As such, it allows easier navigation of a pester test file.

@kapilmb kapilmb force-pushed the add-pester-symbols branch from 06a4ade to c627165 Compare June 5, 2017 07:09
@daviwil
Copy link
Contributor

daviwil commented Jun 5, 2017

Heh, oh man, perfect timing, I've got an awesome use for this ;)

@nightroman
Copy link

Is it something that others can use, too? I am thinking of Invoke-Build and psake task symbols, for example.

Copy link
Contributor

@daviwil daviwil left a comment

Choose a reason for hiding this comment

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

This is great, thanks man!

@@ -54,6 +55,12 @@ public LanguageService(PowerShellContext powerShellContext)

this.CmdletToAliasDictionary = new Dictionary<String, List<String>>(StringComparer.OrdinalIgnoreCase);
this.AliasToCmdletDictionary = new Dictionary<String, String>(StringComparer.OrdinalIgnoreCase);
this.documentSymbolProviders = new DocumentSymbolProvider[]
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you reading my mind? I was just about to implement a generic "feature provider" model in certain parts of PSES :)

@daviwil
Copy link
Contributor

daviwil commented Jun 5, 2017

@nightroman it will be soon, I'm going to expose functionality like this through the $psEditor model. Possibly even for this week's release :)

@daviwil daviwil merged commit 88fabb3 into PowerShell:master Jun 5, 2017
@daviwil daviwil added this to the 1.3.0 milestone Jun 5, 2017
@daviwil
Copy link
Contributor

daviwil commented Jun 5, 2017

@nightroman by the way, having a built-in task symbols provider would be really nice, would you be interested in contributing one similarly to how Kapil added the Pester symbol provider? What did you have in mind for how you'd use this?

@nightroman
Copy link

@daviwil I am not completely sure yet what a symbol provider is. I would like to see it in action at first.

@daviwil
Copy link
Contributor

daviwil commented Jun 5, 2017

Ahhh, sorry, it's basically the concept that Kapil added to PSES in this PR: for a given ScriptFile, return SymbolReference instances which mark any special symbols in the file, like Task definitions.

@daviwil
Copy link
Contributor

daviwil commented Jun 5, 2017

You'd basically be implementing another class like this that looks for Task instead of Describe, etc:

https://github.com/kapilmb/PowerShellEditorServices/blob/c6271653dce470319384974430ccc36f34cb1e22/src/PowerShellEditorServices/Language/PesterDocumentSymbolProvider.cs

In fact, it'd be mostly a copy/paste job ;)

@nightroman
Copy link

In fact, it'd be mostly a copy/paste job ;)

Oh, in that case, count me in!

I am still interested in the API for not built-in stuff, looking forward to 1.3.0.

@kapilmb
Copy link
Author

kapilmb commented Jun 5, 2017

@nightroman When I wrote this I had InvokeBuildin mind but wanted to test the waters first with Pester and if things go well then we could've proceeded with InvokeBuild. An approach similar to that of TabExpansionPlusPlus, such that any module can register their symbols providers would be ideal. But I couldn't think of any modules other than Pester, InvokeBuild and psake that use DSL-like syntax - I am sure there probably are more but I am not aware of them. I wanted an efficient way to navigate Pester test files and the current approach seemed to achieve that with least possible effort. However, with the extensibility model that David will soon be pushing, I think we can move towards the ideal approach sooner rather than later. But as @daviwil has already pointed out, please feel free to add InvokeBuild symbol providers.

@daviwil
Copy link
Contributor

daviwil commented Jun 5, 2017

I think just a general task symbol provider might be good enough to support both psake and Invoke-Build since they both use the Task command syntax, but Invoke-Build should also be able to provide its own for anything outside of that.

@kapilmb kapilmb deleted the add-pester-symbols branch June 7, 2017 07:06
TylerLeonhardt pushed a commit to TylerLeonhardt/PowerShellEditorServices that referenced this pull request Feb 26, 2019
…er-tests-dbg-snippet

Update dbg config snippets to be consistent w/node
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 this pull request may close these issues.

4 participants