File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 176
176
{
177
177
"command" : " elixir-tools.fromPipe" ,
178
178
"title" : " Convert from pipe (Next LS)"
179
+ },
180
+ {
181
+ "command" : " elixir-tools.aliasRefactor" ,
182
+ "title" : " Refactor a module to an alias (Next LS)"
179
183
}
180
184
],
181
185
"grammars" : [
224
228
"sinon" : " ^17.0.1" ,
225
229
"typescript" : " ^4.9.5"
226
230
}
227
- }
231
+ }
Original file line number Diff line number Diff line change
1
+ import * as vscode from "vscode" ;
2
+
3
+ import {
4
+ LanguageClient ,
5
+ ExecuteCommandRequest ,
6
+ } from "vscode-languageclient/node" ;
7
+
8
+ export const run = async ( client : LanguageClient ) => {
9
+ const position = vscode . window . activeTextEditor ?. selection . start ;
10
+
11
+ client . sendRequest ( ExecuteCommandRequest . type , {
12
+ command : "alias-refactor" ,
13
+ arguments : [
14
+ {
15
+ uri : vscode . window . activeTextEditor ?. document . uri . toString ( ) ,
16
+ position : position ,
17
+ } ,
18
+ ] ,
19
+ } ) ;
20
+ } ;
21
+
22
+ function registerAliasRefactorCommand (
23
+ client : LanguageClient ,
24
+ context : vscode . ExtensionContext
25
+ ) {
26
+ const aliasRefactorCommand = "elixir-tools.aliasRefactor" ;
27
+ const aliasRefactor = async ( ) => run ( client ) ;
28
+ context . subscriptions . push (
29
+ vscode . commands . registerCommand ( aliasRefactorCommand , aliasRefactor )
30
+ ) ;
31
+ }
32
+
33
+ export default registerAliasRefactorCommand ;
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
16
16
import registerUninstallCommand from "./commands/uninstall" ;
17
17
import registerToPipeCommand from "./commands/to-pipe" ;
18
18
import registerFromPipeCommand from "./commands/from-pipe" ;
19
+ import registerAliasRefactorCommand from "./commands/alias-refactor" ;
19
20
20
21
let credoClient : LanguageClient ;
21
22
let nextLSClient : LanguageClient ;
@@ -193,6 +194,7 @@ async function activateNextLS(
193
194
registerToPipeCommand ( nextLSClient , context ) ;
194
195
registerFromPipeCommand ( nextLSClient , context ) ;
195
196
registerUninstallCommand ( config , context ) ;
197
+ registerAliasRefactorCommand ( nextLSClient , context ) ;
196
198
197
199
// Start the nextLSClient. This will also launch the server
198
200
nextLSClient . start ( ) ;
You can’t perform that action at this time.
0 commit comments