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 RunCode command for CodeLens providers #1928

Merged

Conversation

TylerLeonhardt
Copy link
Member

PR Summary

This feature adds a generic PowerShell.RunCode command so that CodeLens providers have a mechanism for executing whatever code is needed in the codelens...

An example:
Invoke-Build could offer a Run task | Debug task CodeLens:

image

This would call PowerShell.RunCode so that it can run:

script: Invoke-Build
args: TaskName, path/to/foo.build.ps1

With this, Invoke-Build, psake, or any other big name module could provide CodeLens without having to ship their own extension or add to PSES directly. They can take advantage of public types already available within the PSES session and use RunCode to run their specific scenario.

PR Checklist

Note: Tick the boxes below that apply to this pull request by putting an x between the square brackets.
Please mark anything not applicable to this PR NA.

  • PR has a meaningful title
  • Summarized changes
  • PR has tests
  • This PR is ready to merge and is not work in progress
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready

@TylerLeonhardt
Copy link
Member Author

TylerLeonhardt commented Apr 28, 2019

I have the 2 classes needed for Invoke-Build to work:
https://gist.github.com/TylerLeonhardt/0d5147ad409c1b90a22fe18d87070097

these would just need to be Add-Type'd and then you call:

$psEditor.Components.Get([Microsoft.PowerShell.EditorServices.CodeLenses.ICodeLenses]).Providers.Add([PSakeCodeLensProvider]::new())

(ignore the references to PSake - I started with it but then changed to InvokeBuild later... consider them... the same :) )

@TylerLeonhardt
Copy link
Member Author

src/features/RunCode.ts Outdated Show resolved Hide resolved
@TylerLeonhardt
Copy link
Member Author

Ok I did some refactoring and added a test - this should be good now :)

@TylerLeonhardt TylerLeonhardt marked this pull request as ready for review April 29, 2019 02:31
@TylerLeonhardt
Copy link
Member Author

I'm not going to bother backporting this

@TylerLeonhardt TylerLeonhardt merged commit b63979d into PowerShell:master May 3, 2019
@TylerLeonhardt TylerLeonhardt deleted the add-run-code-feature branch May 3, 2019 00:01
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.

2 participants