-
Notifications
You must be signed in to change notification settings - Fork 235
Add events for PowerShell execution status (running, completed, etc). #632
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol; | ||
|
||
namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer | ||
{ | ||
/// <summary> | ||
/// Defines an event type for PowerShell context execution status changes (e.g. execution has completed) | ||
/// </summary> | ||
public class ExecutionStatusChangedEvent | ||
{ | ||
/// <summary> | ||
/// The notification type for execution status change events in the message protocol | ||
/// </summary> | ||
/// <returns></returns> | ||
public static readonly | ||
NotificationType<object, object> Type = | ||
NotificationType<object, object>.Create("powerShell/executionStatusChanged"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,9 @@ public LanguageServer( | |
{ | ||
this.Logger = logger; | ||
this.editorSession = editorSession; | ||
// Attach to the underlying PowerShell context to listen for changes in the runspace or execution status | ||
this.editorSession.PowerShellContext.RunspaceChanged += PowerShellContext_RunspaceChanged; | ||
this.editorSession.PowerShellContext.ExecutionStatusChanged += PowerShellContext_ExecutionStatusChanged; | ||
|
||
// Attach to ExtensionService events | ||
this.editorSession.ExtensionService.CommandAdded += ExtensionService_ExtensionAdded; | ||
|
@@ -1273,6 +1275,19 @@ await this.messageSender.SendEvent( | |
new Protocol.LanguageServer.RunspaceDetails(e.NewRunspace)); | ||
} | ||
|
||
/// <summary> | ||
/// Event hook on the PowerShell context to listen for changes in script execution status | ||
/// </summary> | ||
/// <param name="sender">the PowerShell context sending the execution event</param> | ||
/// <param name="e">details of the execution status change</param> | ||
/// <returns></returns> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: maybe delete this line unless others in the file have the same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking through the file and the codebase and the documentation, I noticed we didn't have as much documentation as in the PowerShell codebase (in fact, the web docs on the code base are out of date and refer to classes that no longer exist). I was thinking that anything I contribute I should document. Ideally I'd want to see comments documenting most things, just so we can make contributing easier, but for now I think some documentation is better than none. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rjmholt Definitely agree! Documentation is an area needs a lot of work here :) In this case, I believe he's referring to just the empty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see. Yes agreed! |
||
private async void PowerShellContext_ExecutionStatusChanged(object sender, ExecutionStatusChangedEventArgs e) | ||
{ | ||
await this.messageSender.SendEvent( | ||
ExecutionStatusChangedEvent.Type, | ||
e); | ||
} | ||
|
||
private async void ExtensionService_ExtensionAdded(object sender, EditorCommand e) | ||
{ | ||
await this.messageSender.SendEvent( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same