|
7 | 7 | ExtensionContext,
|
8 | 8 | OutputChannel,
|
9 | 9 | TextDocument,
|
| 10 | + TextEditor, |
10 | 11 | Uri,
|
11 | 12 | window,
|
12 | 13 | workspace,
|
@@ -210,6 +211,7 @@ function activateHieNoCheck(context: ExtensionContext, folder: WorkspaceFolder,
|
210 | 211 | registerHiePointCommand('hie.commands.deleteDef', 'hare:deletedef', context);
|
211 | 212 | registerHiePointCommand('hie.commands.genApplicative', 'hare:genapplicative', context);
|
212 | 213 | registerHiePointCommand('hie.commands.caseSplit', 'ghcmod:casesplit', context);
|
| 214 | + registerHieFileCommand('hie.commands.applyAll', 'applyrefact:applyAll', context); |
213 | 215 | hieCommandsRegistered = true;
|
214 | 216 | }
|
215 | 217 |
|
@@ -246,18 +248,42 @@ async function isHieInstalled(): Promise<boolean> {
|
246 | 248 | }
|
247 | 249 |
|
248 | 250 | /*
|
249 |
| - * Create an editor command that calls an action on the active LSP server. |
| 251 | + * Create an editor command that calls an action on the active LSP server at a particular place in the text. |
250 | 252 | */
|
251 | 253 | async function registerHiePointCommand(name: string, command: string, context: ExtensionContext) {
|
252 |
| - const editorCmd = commands.registerTextEditorCommand(name, (editor, edit) => { |
| 254 | + registerHieCommand(name, command, context, editor => { |
| 255 | + return [ |
| 256 | + { |
| 257 | + file: editor.document.uri.toString(), |
| 258 | + pos: editor.selections[0].active |
| 259 | + } |
| 260 | + ]; |
| 261 | + }); |
| 262 | +} |
| 263 | + |
| 264 | +/* |
| 265 | + * Create an editor command that calls an action on the active LSP server for a file |
| 266 | + */ |
| 267 | +async function registerHieFileCommand(name: string, command: string, context: ExtensionContext) { |
| 268 | + registerHieCommand(name, command, context, editor => { |
| 269 | + return [editor.document.uri.toString()]; |
| 270 | + }); |
| 271 | +} |
| 272 | + |
| 273 | +/* |
| 274 | + * Create an editor command that calls an action on the active LSP server. |
| 275 | + */ |
| 276 | +async function registerHieCommand( |
| 277 | + name: string, |
| 278 | + command: string, |
| 279 | + context: ExtensionContext, |
| 280 | + getArgs: (editor: TextEditor) => any[] |
| 281 | +) { |
| 282 | + const editorCmd = commands.registerTextEditorCommand(name, editor => { |
| 283 | + let args = getArgs(editor); |
253 | 284 | const cmd = {
|
254 | 285 | command,
|
255 |
| - arguments: [ |
256 |
| - { |
257 |
| - file: editor.document.uri.toString(), |
258 |
| - pos: editor.selections[0].active |
259 |
| - } |
260 |
| - ] |
| 286 | + arguments: args |
261 | 287 | };
|
262 | 288 | // Get the current file and workspace folder.
|
263 | 289 | const uri = editor.document.uri;
|
|
0 commit comments