UNPKG

1.9 kBTypeScriptView Raw
1import type * as atomIde from "atom-ide-base";
2import * as linter from "atom/linter";
3import LinterPushV2Adapter from "./linter-push-v2-adapter";
4import IdeDiagnosticAdapter from "./diagnostic-adapter";
5import { CodeAction, Command, LanguageClientConnection, ServerCapabilities } from "../languageclient";
6import { Range, TextEditor } from "atom";
7export default class CodeActionAdapter {
8 /** @returns A {Boolean} indicating this adapter can adapt the server based on the given serverCapabilities. */
9 static canAdapt(serverCapabilities: ServerCapabilities): boolean;
10 /**
11 * Public: Retrieves code actions for a given editor, range, and context (diagnostics). Throws an error if
12 * codeActionProvider is not a registered capability.
13 *
14 * @param connection A {LanguageClientConnection} to the language server that provides highlights.
15 * @param serverCapabilities The {ServerCapabilities} of the language server that will be used.
16 * @param editor The Atom {TextEditor} containing the diagnostics.
17 * @param range The Atom {Range} to fetch code actions for.
18 * @param linterMessages An {Array<linter$Message>} to fetch code actions for. This is typically a list of messages
19 * intersecting `range`.
20 * @returns A {Promise} of an {Array} of {atomIde$CodeAction}s to display.
21 */
22 static getCodeActions(connection: LanguageClientConnection, serverCapabilities: ServerCapabilities, linterAdapter: LinterPushV2Adapter | IdeDiagnosticAdapter | undefined, editor: TextEditor, range: Range, linterMessages: linter.Message[] | atomIde.Diagnostic[], filterActions?: (actions: (Command | CodeAction)[] | null) => (Command | CodeAction)[] | null, onApply?: (action: Command | CodeAction) => Promise<boolean>): Promise<atomIde.CodeAction[]>;
23 private static createCodeAction;
24 private static applyWorkspaceEdit;
25 private static executeCommand;
26}