vscode: migrate rust-analyzer-api to import * as lc as per matklad and kjeremy
This commit is contained in:
parent
72e81dae71
commit
18b97d9d36
@ -2,17 +2,17 @@
|
|||||||
* This file mirrors `crates/rust-analyzer/src/req.rs` declarations.
|
* This file mirrors `crates/rust-analyzer/src/req.rs` declarations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { RequestType, TextDocumentIdentifier, Position, Range, TextDocumentPositionParams, Location, NotificationType, WorkspaceEdit } from "vscode-languageclient";
|
import * as lc from "vscode-languageclient";
|
||||||
|
|
||||||
type Option<T> = null | T;
|
type Option<T> = null | T;
|
||||||
type Vec<T> = T[];
|
type Vec<T> = T[];
|
||||||
type FxHashMap<K extends PropertyKey, V> = Record<K, V>;
|
type FxHashMap<K extends PropertyKey, V> = Record<K, V>;
|
||||||
|
|
||||||
function request<TParams, TResult>(method: string) {
|
function request<TParams, TResult>(method: string) {
|
||||||
return new RequestType<TParams, TResult, unknown>(`rust-analyzer/${method}`);
|
return new lc.RequestType<TParams, TResult, unknown>(`rust-analyzer/${method}`);
|
||||||
}
|
}
|
||||||
function notification<TParam>(method: string) {
|
function notification<TParam>(method: string) {
|
||||||
return new NotificationType<TParam>(method);
|
return new lc.NotificationType<TParam>(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -23,15 +23,15 @@ export const collectGarbage = request<null, null>("collectGarbage");
|
|||||||
|
|
||||||
|
|
||||||
export interface SyntaxTreeParams {
|
export interface SyntaxTreeParams {
|
||||||
textDocument: TextDocumentIdentifier;
|
textDocument: lc.TextDocumentIdentifier;
|
||||||
range: Option<Range>;
|
range: Option<lc.Range>;
|
||||||
}
|
}
|
||||||
export const syntaxTree = request<SyntaxTreeParams, string>("syntaxTree");
|
export const syntaxTree = request<SyntaxTreeParams, string>("syntaxTree");
|
||||||
|
|
||||||
|
|
||||||
export interface ExpandMacroParams {
|
export interface ExpandMacroParams {
|
||||||
textDocument: TextDocumentIdentifier;
|
textDocument: lc.TextDocumentIdentifier;
|
||||||
position: Option<Position>;
|
position: Option<lc.Position>;
|
||||||
}
|
}
|
||||||
export interface ExpandedMacro {
|
export interface ExpandedMacro {
|
||||||
name: string;
|
name: string;
|
||||||
@ -41,10 +41,10 @@ export const expandMacro = request<ExpandMacroParams, Option<ExpandedMacro>>("ex
|
|||||||
|
|
||||||
|
|
||||||
export interface FindMatchingBraceParams {
|
export interface FindMatchingBraceParams {
|
||||||
textDocument: TextDocumentIdentifier;
|
textDocument: lc.TextDocumentIdentifier;
|
||||||
offsets: Vec<Position>;
|
offsets: Vec<lc.Position>;
|
||||||
}
|
}
|
||||||
export const findMatchingBrace = request<FindMatchingBraceParams, Vec<Position>>("findMatchingBrace");
|
export const findMatchingBrace = request<FindMatchingBraceParams, Vec<lc.Position>>("findMatchingBrace");
|
||||||
|
|
||||||
|
|
||||||
export interface PublishDecorationsParams {
|
export interface PublishDecorationsParams {
|
||||||
@ -52,31 +52,31 @@ export interface PublishDecorationsParams {
|
|||||||
decorations: Vec<Decoration>;
|
decorations: Vec<Decoration>;
|
||||||
}
|
}
|
||||||
export interface Decoration {
|
export interface Decoration {
|
||||||
range: Range;
|
range: lc.Range;
|
||||||
tag: string;
|
tag: string;
|
||||||
bindingHash: Option<string>;
|
bindingHash: Option<string>;
|
||||||
}
|
}
|
||||||
export const decorationsRequest = request<TextDocumentIdentifier, Vec<Decoration>>("decorationsRequest");
|
export const decorationsRequest = request<lc.TextDocumentIdentifier, Vec<Decoration>>("decorationsRequest");
|
||||||
|
|
||||||
|
|
||||||
export const parentModule = request<TextDocumentPositionParams, Vec<Location>>("parentModule");
|
export const parentModule = request<lc.TextDocumentPositionParams, Vec<lc.Location>>("parentModule");
|
||||||
|
|
||||||
|
|
||||||
export interface JoinLinesParams {
|
export interface JoinLinesParams {
|
||||||
textDocument: TextDocumentIdentifier;
|
textDocument: lc.TextDocumentIdentifier;
|
||||||
range: Range;
|
range: lc.Range;
|
||||||
}
|
}
|
||||||
export const joinLines = request<JoinLinesParams, SourceChange>("joinLines");
|
export const joinLines = request<JoinLinesParams, SourceChange>("joinLines");
|
||||||
|
|
||||||
|
|
||||||
export const onEnter = request<TextDocumentPositionParams, Option<SourceChange>>("onEnter");
|
export const onEnter = request<lc.TextDocumentPositionParams, Option<SourceChange>>("onEnter");
|
||||||
|
|
||||||
export interface RunnablesParams {
|
export interface RunnablesParams {
|
||||||
textDocument: TextDocumentIdentifier;
|
textDocument: lc.TextDocumentIdentifier;
|
||||||
position: Option<Position>;
|
position: Option<lc.Position>;
|
||||||
}
|
}
|
||||||
export interface Runnable {
|
export interface Runnable {
|
||||||
range: Range;
|
range: lc.Range;
|
||||||
label: string;
|
label: string;
|
||||||
bin: string;
|
bin: string;
|
||||||
args: Vec<string>;
|
args: Vec<string>;
|
||||||
@ -91,12 +91,12 @@ export const enum InlayKind {
|
|||||||
ParameterHint = "ParameterHint",
|
ParameterHint = "ParameterHint",
|
||||||
}
|
}
|
||||||
export interface InlayHint {
|
export interface InlayHint {
|
||||||
range: Range;
|
range: lc.Range;
|
||||||
kind: InlayKind;
|
kind: InlayKind;
|
||||||
label: string;
|
label: string;
|
||||||
}
|
}
|
||||||
export interface InlayHintsParams {
|
export interface InlayHintsParams {
|
||||||
textDocument: TextDocumentIdentifier;
|
textDocument: lc.TextDocumentIdentifier;
|
||||||
}
|
}
|
||||||
export const inlayHints = request<InlayHintsParams, Vec<InlayHint>>("inlayHints");
|
export const inlayHints = request<InlayHintsParams, Vec<InlayHint>>("inlayHints");
|
||||||
|
|
||||||
@ -112,6 +112,6 @@ export const publishDecorations = notification<PublishDecorationsParams>("publis
|
|||||||
|
|
||||||
export interface SourceChange {
|
export interface SourceChange {
|
||||||
label: string;
|
label: string;
|
||||||
workspaceEdit: WorkspaceEdit;
|
workspaceEdit: lc.WorkspaceEdit;
|
||||||
cursorPosition: Option<TextDocumentPositionParams>;
|
cursorPosition: Option<lc.TextDocumentPositionParams>;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user