atom-languageclient
Version:
Integrate Language Servers with Atom
27 lines (26 loc) • 1.9 kB
TypeScript
import type * as atomIde from "atom-ide-base";
import * as linter from "atom/linter";
import LinterPushV2Adapter from "./linter-push-v2-adapter";
import IdeDiagnosticAdapter from "./diagnostic-adapter";
import { CodeAction, Command, LanguageClientConnection, ServerCapabilities } from "../languageclient";
import { Range, TextEditor } from "atom";
export default class CodeActionAdapter {
/** @returns A {Boolean} indicating this adapter can adapt the server based on the given serverCapabilities. */
static canAdapt(serverCapabilities: ServerCapabilities): boolean;
/**
* Public: Retrieves code actions for a given editor, range, and context (diagnostics). Throws an error if
* codeActionProvider is not a registered capability.
*
* @param connection A {LanguageClientConnection} to the language server that provides highlights.
* @param serverCapabilities The {ServerCapabilities} of the language server that will be used.
* @param editor The Atom {TextEditor} containing the diagnostics.
* @param range The Atom {Range} to fetch code actions for.
* @param linterMessages An {Array<linter$Message>} to fetch code actions for. This is typically a list of messages
* intersecting `range`.
* @returns A {Promise} of an {Array} of {atomIde$CodeAction}s to display.
*/
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[]>;
private static createCodeAction;
private static applyWorkspaceEdit;
private static executeCommand;
}