Skip to content

Commit cc28ba8

Browse files
author
Kapil Borle
committed
Fix merge conflict with master
2 parents 967b897 + 80c26b1 commit cc28ba8

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

src/features/CodeActions.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
}

src/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
'use strict';
66

77
import vscode = require('vscode');
8-
98
import { Logger, LogLevel } from './logging';
109
import { IFeature } from './feature';
1110
import { SessionManager } from './session';
@@ -17,6 +16,7 @@ import { ShowHelpFeature } from './features/ShowOnlineHelp';
1716
import { FindModuleFeature } from './features/PowerShellFindModule';
1817
import { ExtensionCommandsFeature } from './features/ExtensionCommands';
1918
import { SelectPSSARulesFeature } from './features/SelectPSSARules';
19+
import { CodeActionsFeature } from './features/CodeActions';
2020

2121
// NOTE: We will need to find a better way to deal with the required
2222
// PS Editor Services version...
@@ -77,7 +77,8 @@ export function activate(context: vscode.ExtensionContext): void {
7777
new ShowHelpFeature(),
7878
new FindModuleFeature(),
7979
new ExtensionCommandsFeature(),
80-
new SelectPSSARulesFeature()
80+
new SelectPSSARulesFeature(),
81+
new CodeActionsFeature()
8182
];
8283

8384
sessionManager =

0 commit comments

Comments
 (0)