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 55'use strict' ;
66
77import vscode = require( 'vscode' ) ;
8-
98import { Logger , LogLevel } from './logging' ;
109import { IFeature } from './feature' ;
1110import { SessionManager } from './session' ;
@@ -16,6 +15,7 @@ import { ExpandAliasFeature } from './features/ExpandAlias';
1615import { ShowHelpFeature } from './features/ShowOnlineHelp' ;
1716import { FindModuleFeature } from './features/PowerShellFindModule' ;
1817import { ExtensionCommandsFeature } from './features/ExtensionCommands' ;
18+ import { CodeActionsFeature } from './features/CodeActions' ;
1919
2020// NOTE: We will need to find a better way to deal with the required
2121// PS Editor Services version...
@@ -75,7 +75,8 @@ export function activate(context: vscode.ExtensionContext): void {
7575 new ExpandAliasFeature ( ) ,
7676 new ShowHelpFeature ( ) ,
7777 new FindModuleFeature ( ) ,
78- new ExtensionCommandsFeature ( )
78+ new ExtensionCommandsFeature ( ) ,
79+ new CodeActionsFeature ( )
7980 ] ;
8081
8182 sessionManager =
You can’t perform that action at this time.
0 commit comments