-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathtypes.ts
86 lines (66 loc) · 1.99 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/******************************************************************************
* Copyright 2022 TypeFox GmbH
* This program and the accompanying materials are made available under the
* terms of the MIT License, which is available in the project root.
******************************************************************************/
import { AstNode } from "langium";
import { Diagnostic } from "vscode-languageserver";
export declare type DedicatedWorkerGlobalScope = any;
export type PlaygroundMessageType = "validated" | "changing" | "error" | "ast";
export interface PlaygroundMessageBase {
type: PlaygroundMessageType;
}
export interface PlaygroundError extends PlaygroundMessageBase {
type: "error";
errors: Diagnostic[];
}
export interface PlaygroundOK extends PlaygroundMessageBase {
type: "validated";
grammar: string;
}
export interface PlaygroundAst extends PlaygroundMessageBase {
type: "ast";
root: AstNode;
}
export interface PlaygroundChanging extends PlaygroundMessageBase {
type: "changing";
}
export type PlaygroundMessage =
| PlaygroundChanging
| PlaygroundError
| PlaygroundOK
| PlaygroundAst;
export interface MessageBase {
jsonrpc: "2.0";
}
export interface Request extends MessageBase {
method: string;
params?: any[];
id: string;
}
export interface ResponseOK extends MessageBase {
result: any;
id: string;
}
export interface ResponseError extends MessageBase {
error: any;
id: string;
}
export interface Notification extends MessageBase {
method: string;
params?: any[];
}
export interface PlaygroundParameters {
grammar: string;
content: string;
}
export function isNotification(msg: Message): msg is Notification {
return !("id" in msg) && ("method" in msg);
}
export type Message = Request | ResponseError | ResponseOK | Notification;
export const MagicAction = "PlaygroundMagic";
export interface MessageWrapper<T> {
wrap(message: T): Message;
unwrap(message: Message): T | null;
}
export type MessageCallback<T> = (data: T) => void;