From 39efb301ff7946592ac0d8a64749582daaa67b86 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Tue, 25 Feb 2020 00:48:44 +0200 Subject: vscode: create rust-analyzer-api.ts --- editors/code/src/rust-analyzer-api.ts | 117 ++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 editors/code/src/rust-analyzer-api.ts (limited to 'editors') diff --git a/editors/code/src/rust-analyzer-api.ts b/editors/code/src/rust-analyzer-api.ts new file mode 100644 index 000000000..d2738fef3 --- /dev/null +++ b/editors/code/src/rust-analyzer-api.ts @@ -0,0 +1,117 @@ +/** + * This file mirrors `crates/rust-analyzer/src/req.rs` declarations. + */ + +import { RequestType, TextDocumentIdentifier, Position, Range, TextDocumentPositionParams, Location, NotificationType, WorkspaceEdit } from "vscode-languageclient"; + +type Option = null | T; +type Vec = T[]; +type FxHashMap = Record; + +function request(method: string) { + return new RequestType(`rust-analyzer/${method}`); +} +function notification(method: string) { + return new NotificationType(method); +} + + +export const analyzerStatus = request("analyzerStatus"); + + +export const collectGarbage = request("collectGarbage"); + + +export interface SyntaxTreeParams { + textDocument: TextDocumentIdentifier; + range: Option; +} +export const syntaxTree = request("syntaxTree"); + + +export interface ExpandMacroParams { + textDocument: TextDocumentIdentifier; + position: Option; +} +export interface ExpandedMacro { + name: string; + expansion: string; +} +export const expandMacro = request>("expandMacro"); + + +export interface FindMatchingBraceParams { + textDocument: TextDocumentIdentifier; + offsets: Vec; +} +export const findMatchingBrace = request>("findMatchingBrace"); + + +export interface PublishDecorationsParams { + uri: string; + decorations: Vec; +} +export interface Decoration { + range: Range; + tag: string; + bindingHash: Option; +} +export const decorationsRequest = request>("decorationsRequest"); + + +export const parentModule = request>("parentModule"); + + +export interface JoinLinesParams { + textDocument: TextDocumentIdentifier; + range: Range; +} +export const joinLines = request("joinLines"); + + +export const onEnter = request>("onEnter"); + +export interface RunnablesParams { + textDocument: TextDocumentIdentifier; + position: Option; +} +export interface Runnable { + range: Range; + label: string; + bin: string; + args: Vec; + env: FxHashMap; + cwd: Option; +} +export const runnables = request>("runnables"); + + +export const enum InlayKind { + TypeHint = "TypeHint", + ParameterHint = "ParameterHint", +} +export interface InlayHint { + range: Range; + kind: InlayKind; + label: string; +} +export interface InlayHintsParams { + textDocument: TextDocumentIdentifier; +} +export const inlayHints = request>("inlayHints"); + + +export interface SsrParams { + arg: string; +} +export const ssr = request("ssr"); + + +export const publishDecorations = notification("publishDecorations"); + + +export interface SourceChange { + label: string; + workspaceEdit: WorkspaceEdit; + cursorPosition: Option; +} -- cgit v1.2.3