File tree Expand file tree Collapse file tree 6 files changed +132
-15
lines changed
PowerShellEditorServices.Protocol
test/PowerShellEditorServices.Test/Extensions Expand file tree Collapse file tree 6 files changed +132
-15
lines changed Original file line number Diff line number Diff line change @@ -107,5 +107,25 @@ public static readonly
107107 RequestType < string , EditorCommandResponse > Type =
108108 RequestType < string , EditorCommandResponse > . Create ( "editor/openFile" ) ;
109109 }
110+ public class ShowInformationMessageRequest
111+ {
112+ public static readonly
113+ RequestType < string , EditorCommandResponse > Type =
114+ RequestType < string , EditorCommandResponse > . Create ( "editor/showInformationMessage" ) ;
115+ }
116+
117+ public class ShowWarningMessageRequest
118+ {
119+ public static readonly
120+ RequestType < string , EditorCommandResponse > Type =
121+ RequestType < string , EditorCommandResponse > . Create ( "editor/showWarningMessage" ) ;
122+ }
123+
124+ public class ShowErrorMessageRequest
125+ {
126+ public static readonly
127+ RequestType < string , EditorCommandResponse > Type =
128+ RequestType < string , EditorCommandResponse > . Create ( "editor/showErrorMessage" ) ;
129+ }
110130}
111131
Original file line number Diff line number Diff line change @@ -109,5 +109,33 @@ public Task OpenFile(string filePath)
109109 filePath ,
110110 true ) ;
111111 }
112+
113+ public Task ShowInformationMessage ( string message )
114+ {
115+ return
116+ this . messageSender . SendRequest (
117+ ShowInformationMessageRequest . Type ,
118+ message ,
119+ true ) ;
120+ }
121+
122+ public Task ShowErrorMessage ( string message )
123+ {
124+ return
125+ this . messageSender . SendRequest (
126+ ShowErrorMessageRequest . Type ,
127+ message ,
128+ true ) ;
129+ }
130+
131+ public Task ShowWarningMessage ( string message )
132+ {
133+ return
134+ this . messageSender . SendRequest (
135+ ShowWarningMessageRequest . Type ,
136+ message ,
137+ true ) ;
138+
139+ }
112140 }
113141}
Original file line number Diff line number Diff line change @@ -109,6 +109,39 @@ public void SetSelection(BufferRange selectionRange)
109109 . Wait ( ) ;
110110 }
111111
112+ /// <summary>
113+ ///
114+ /// </summary>
115+ /// <param name="message"></param>
116+ public void ShowInformationMessage ( string message )
117+ {
118+ this . editorOperations
119+ . ShowInformationMessage ( message )
120+ . Wait ( ) ;
121+ }
122+
123+ /// <summary>
124+ ///
125+ /// </summary>
126+ /// <param name="message"></param>
127+ public void ShowErrorMessage ( string message )
128+ {
129+ this . editorOperations
130+ . ShowErrorMessage ( message )
131+ . Wait ( ) ;
132+ }
133+
134+ /// <summary>
135+ ///
136+ /// </summary>
137+ /// <param name="message"></param>
138+ public void ShowWarningMessage ( string message )
139+ {
140+ this . editorOperations
141+ . ShowWarningMessage ( message )
142+ . Wait ( ) ;
143+ }
144+
112145 #endregion
113146 }
114147}
Original file line number Diff line number Diff line change @@ -43,6 +43,27 @@ public interface IEditorOperations
4343 /// <param name="selectionRange">The range over which the selection will be made.</param>
4444 /// <returns>A Task that can be tracked for completion.</returns>
4545 Task SetSelection ( BufferRange selectionRange ) ;
46+
47+ /// <summary>
48+ ///
49+ /// </summary>
50+ /// <param name="message"></param>
51+ /// <returns></returns>
52+ Task ShowInformationMessage ( string message ) ;
53+
54+ /// <summary>
55+ ///
56+ /// </summary>
57+ /// <param name="message"></param>
58+ /// <returns></returns>
59+ Task ShowErrorMessage ( string message ) ;
60+
61+ /// <summary>
62+ ///
63+ /// </summary>
64+ /// <param name="message"></param>
65+ /// <returns></returns>
66+ Task ShowWarningMessage ( string message ) ;
4667 }
4768}
4869
Original file line number Diff line number Diff line change @@ -499,26 +499,26 @@ private void ParseFileContents()
499499 {
500500#if PowerShellv5r2
501501 // This overload appeared with Windows 10 Update 1
502- if ( this . powerShellVersion . Major >= 5 &&
503- this . powerShellVersion . Build >= 10586 )
504- {
505- // Include the file path so that module relative
506- // paths are evaluated correctly
507- this . ScriptAst =
508- Parser . ParseInput (
509- this . Contents ,
510- this . FilePath ,
511- out this . scriptTokens ,
512- out parseErrors ) ;
513- }
514- else
515- {
502+ // if (this.powerShellVersion.Major >= 5 &&
503+ // this.powerShellVersion.Build >= 10586)
504+ // {
505+ // // Include the file path so that module relative
506+ // // paths are evaluated correctly
507+ // this.ScriptAst =
508+ // Parser.ParseInput(
509+ // this.Contents,
510+ // this.FilePath,
511+ // out this.scriptTokens,
512+ // out parseErrors);
513+ // }
514+ // else
515+ // {
516516 this . ScriptAst =
517517 Parser . ParseInput (
518518 this . Contents ,
519519 out this . scriptTokens ,
520520 out parseErrors ) ;
521- }
521+ // }
522522#else
523523 this . ScriptAst =
524524 Parser . ParseInput (
Original file line number Diff line number Diff line change @@ -187,6 +187,21 @@ public Task<EditorContext> GetEditorContext()
187187 {
188188 throw new NotImplementedException ( ) ;
189189 }
190+
191+ public Task ShowInformationMessage ( string message )
192+ {
193+ throw new NotImplementedException ( ) ;
194+ }
195+
196+ public Task ShowErrorMessage ( string message )
197+ {
198+ throw new NotImplementedException ( ) ;
199+ }
200+
201+ public Task ShowWarningMessage ( string message )
202+ {
203+ throw new NotImplementedException ( ) ;
204+ }
190205 }
191206}
192207
You can’t perform that action at this time.
0 commit comments