private getAutoFixCodeAction()

in vscode-extension/src/quickFix.ts [32:57]


    private getAutoFixCodeAction(diagnostic: vscode.Diagnostic): vscode.CodeAction {
        const fix = new vscode.CodeAction("", vscode.CodeActionKind.QuickFix);
        fix.edit = new vscode.WorkspaceEdit();
        const editor = vscode.window.activeTextEditor;

        if (!editor) {
            return fix;
        }

        const document = editor.document;
        const range = diagnostic.range;
        const targetCmdletName: string = diagnostic.source;

        switch (diagnostic.code) {
            case "RENAME": {
                fix.title = "Auto fix to " + targetCmdletName;
                fix.edit.replace(document.uri, range, targetCmdletName);
                break;
            }
            case "DO_NOTHING": {
                return null;
            }
        }

        return fix;
    }