mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-12 17:48:19 +01:00
1904cd8d84
Part of #62110 - Adds a new field `canAutoApply` to code actions. This field indicates that a code action can be applied without additional user input. For quick fixes, this should be set if the fix properly addresses the error - Enable auto fixes for TS spelling errors - Added a `editor.action.autoFix` command to triggers auto fixes at the current cursor position
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { startsWith } from 'vs/base/common/strings';
|
|
|
|
export class CodeActionKind {
|
|
private static readonly sep = '.';
|
|
|
|
public static readonly Empty = new CodeActionKind('');
|
|
public static readonly QuickFix = new CodeActionKind('quickfix');
|
|
public static readonly Refactor = new CodeActionKind('refactor');
|
|
public static readonly Source = new CodeActionKind('source');
|
|
public static readonly SourceOrganizeImports = new CodeActionKind('source.organizeImports');
|
|
|
|
constructor(
|
|
public readonly value: string
|
|
) { }
|
|
|
|
public contains(other: string): boolean {
|
|
return this.value === other || startsWith(other, this.value + CodeActionKind.sep);
|
|
}
|
|
}
|
|
|
|
export const enum CodeActionAutoApply {
|
|
IfSingle = 1,
|
|
First = 2,
|
|
Never = 3
|
|
}
|
|
|
|
export interface CodeActionFilter {
|
|
readonly kind?: CodeActionKind;
|
|
readonly includeSourceActions?: boolean;
|
|
readonly autoFixesOnly?: boolean;
|
|
}
|
|
|
|
export interface CodeActionTrigger {
|
|
readonly type: 'auto' | 'manual';
|
|
readonly filter?: CodeActionFilter;
|
|
readonly autoApply?: CodeActionAutoApply;
|
|
} |