Hook up experimental TS refactor error

For https://github.com/microsoft/TypeScript/pull/37871
This commit is contained in:
Matt Bierner 2020-04-10 17:07:09 -07:00
parent be3df0a396
commit f3ceb33c5c

View file

@ -19,6 +19,9 @@ import FormattingOptionsManager from './fileConfigurationManager';
const localize = nls.loadMessageBundle();
interface RefactorActionInfo extends Proto.RefactorActionInfo {
error?: string
}
class ApplyRefactoringCommand implements Command {
public static readonly ID = '_typescript.applyRefactoring';
@ -280,13 +283,20 @@ class TypeScriptRefactorProvider implements vscode.CodeActionProvider {
}
private refactorActionToCodeAction(
action: Proto.RefactorActionInfo,
action: RefactorActionInfo,
document: vscode.TextDocument,
info: Proto.ApplicableRefactorInfo,
rangeOrSelection: vscode.Range | vscode.Selection,
allActions: readonly Proto.RefactorActionInfo[],
) {
const codeAction = new vscode.CodeAction(action.description, TypeScriptRefactorProvider.getKind(action));
// https://github.com/microsoft/TypeScript/pull/37871
if (action.error) {
codeAction.disabled = { reason: action.error };
return codeAction;
}
codeAction.command = {
title: action.description,
command: ApplyRefactoringCommand.ID,