File tree Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Expand file tree Collapse file tree 2 files changed +40
-2
lines changed Original file line number Diff line number Diff line change
1
+ import vscode = require( 'vscode' ) ;
2
+ import { LanguageClient , RequestType , NotificationType } from 'vscode-languageclient' ;
3
+ import Window = vscode . window ;
4
+ import { IFeature } from '../feature' ;
5
+
6
+ export class CodeActionsFeature implements IFeature {
7
+ private command : vscode . Disposable ;
8
+ private languageClient : LanguageClient ;
9
+
10
+ constructor ( ) {
11
+ this . command = vscode . commands . registerCommand ( 'PowerShell.ApplyCodeActionEdits' , ( edit : any ) => {
12
+ var editor = Window . activeTextEditor ;
13
+ var filePath = editor . document . fileName ;
14
+ var workspaceEdit = new vscode . WorkspaceEdit ( ) ;
15
+ workspaceEdit . set (
16
+ vscode . Uri . file ( filePath ) ,
17
+ [
18
+ new vscode . TextEdit (
19
+ new vscode . Range (
20
+ edit . StartLineNumber - 1 ,
21
+ edit . StartColumnNumber - 1 ,
22
+ edit . EndLineNumber - 1 ,
23
+ edit . EndColumnNumber - 1 ) ,
24
+ edit . Text )
25
+ ] ) ;
26
+ vscode . workspace . applyEdit ( workspaceEdit ) ;
27
+ } ) ;
28
+ }
29
+
30
+ public setLanguageClient ( languageclient : LanguageClient ) {
31
+ this . languageClient = languageclient ;
32
+ }
33
+
34
+ public dispose ( ) {
35
+ this . command . dispose ( ) ;
36
+ }
37
+ }
Original file line number Diff line number Diff line change 5
5
'use strict' ;
6
6
7
7
import vscode = require( 'vscode' ) ;
8
-
9
8
import { Logger , LogLevel } from './logging' ;
10
9
import { IFeature } from './feature' ;
11
10
import { SessionManager } from './session' ;
@@ -16,6 +15,7 @@ import { ExpandAliasFeature } from './features/ExpandAlias';
16
15
import { ShowHelpFeature } from './features/ShowOnlineHelp' ;
17
16
import { FindModuleFeature } from './features/PowerShellFindModule' ;
18
17
import { ExtensionCommandsFeature } from './features/ExtensionCommands' ;
18
+ import { CodeActionsFeature } from './features/CodeActions' ;
19
19
20
20
// NOTE: We will need to find a better way to deal with the required
21
21
// PS Editor Services version...
@@ -75,7 +75,8 @@ export function activate(context: vscode.ExtensionContext): void {
75
75
new ExpandAliasFeature ( ) ,
76
76
new ShowHelpFeature ( ) ,
77
77
new FindModuleFeature ( ) ,
78
- new ExtensionCommandsFeature ( )
78
+ new ExtensionCommandsFeature ( ) ,
79
+ new CodeActionsFeature ( )
79
80
] ;
80
81
81
82
sessionManager =
You can’t perform that action at this time.
0 commit comments