@bscotch/gml-language-server 0.0.0-stage → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +29 -0
- package/README.md +74 -2
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +8 -0
- package/dist/cli.js.map +1 -0
- package/dist/features.d.ts +53 -0
- package/dist/features.d.ts.map +1 -0
- package/dist/features.js +631 -0
- package/dist/features.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.d.ts +131 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +58 -0
- package/dist/protocol.js.map +1 -0
- package/dist/server.d.ts +50 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +350 -0
- package/dist/server.js.map +1 -0
- package/dist/session.d.ts +66 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +172 -0
- package/dist/session.js.map +1 -0
- package/dist/uri.d.ts +9 -0
- package/dist/uri.d.ts.map +1 -0
- package/dist/uri.js +22 -0
- package/dist/uri.js.map +1 -0
- package/package.json +56 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type GmlLanguageServer } from './server.ts';
|
|
2
|
+
export * from './protocol.ts';
|
|
3
|
+
export { GmlLanguageServer, startServer } from './server.ts';
|
|
4
|
+
export { ProjectSession, type SessionOptions } from './session.ts';
|
|
5
|
+
export { pathToUri, uriToPath } from './uri.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Run the server in this process, talking to the client over the transport
|
|
8
|
+
* given on the command line (`--stdio`, `--node-ipc` or `--socket=<port>`).
|
|
9
|
+
*/
|
|
10
|
+
export declare function runServer(): GmlLanguageServer;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAElE,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,SAAS,IAAI,iBAAiB,CAE7C"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createConnection, ProposedFeatures } from 'vscode-languageserver/node';
|
|
2
|
+
import { startServer } from "./server.js";
|
|
3
|
+
export * from "./protocol.js";
|
|
4
|
+
export { GmlLanguageServer, startServer } from "./server.js";
|
|
5
|
+
export { ProjectSession } from "./session.js";
|
|
6
|
+
export { pathToUri, uriToPath } from "./uri.js";
|
|
7
|
+
/**
|
|
8
|
+
* Run the server in this process, talking to the client over the transport
|
|
9
|
+
* given on the command line (`--stdio`, `--node-ipc` or `--socket=<port>`).
|
|
10
|
+
*/
|
|
11
|
+
export function runServer() {
|
|
12
|
+
return startServer(createConnection(ProposedFeatures.all));
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,WAAW,EAA0B,MAAM,aAAa,CAAC;AAElE,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAuB,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEhD;;;GAGG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,WAAW,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Stitch-specific parts of the language server's protocol: its
|
|
3
|
+
* initialization options, settings, and custom `stitch/*` messages.
|
|
4
|
+
*
|
|
5
|
+
* This module has no dependencies, so clients can import it without pulling
|
|
6
|
+
* in the server.
|
|
7
|
+
*/
|
|
8
|
+
export type DiagnosticLevel = 'error' | 'warning' | 'info' | 'hint' | 'off';
|
|
9
|
+
export type FormatPreset = 'standard' | 'bscotch';
|
|
10
|
+
/** Settings that change how the server behaves. All are optional. */
|
|
11
|
+
export interface GmlServerSettings {
|
|
12
|
+
diagnostics?: {
|
|
13
|
+
/**
|
|
14
|
+
* Asset-tree folders (e.g. `Libraries/Vendor`) whose files get no
|
|
15
|
+
* diagnostics.
|
|
16
|
+
*/
|
|
17
|
+
suppressGroups?: string[];
|
|
18
|
+
/** Undeclared variables with these prefixes are assumed to exist */
|
|
19
|
+
autoDeclaredGlobalsPrefixes?: string[];
|
|
20
|
+
/** Global functions, constructors, etc. without doc comments. @default 'off' */
|
|
21
|
+
missingDocs?: DiagnosticLevel;
|
|
22
|
+
/** Mixed operators without parentheses. @default 'off' */
|
|
23
|
+
mixedOperators?: DiagnosticLevel;
|
|
24
|
+
/** Calls where more than one argument has side effects. @default 'off' */
|
|
25
|
+
argumentEvaluationOrder?: DiagnosticLevel;
|
|
26
|
+
/** Arguments whose types clearly don't match. @default 'warning' */
|
|
27
|
+
argumentTypes?: DiagnosticLevel;
|
|
28
|
+
};
|
|
29
|
+
format?: {
|
|
30
|
+
/** @default 'bscotch' */
|
|
31
|
+
preset?: FormatPreset;
|
|
32
|
+
};
|
|
33
|
+
completion?: {
|
|
34
|
+
/**
|
|
35
|
+
* Symbols with this prefix are left out of completions, unless they're
|
|
36
|
+
* declared in the same file.
|
|
37
|
+
*/
|
|
38
|
+
ignoredPrefix?: string | null;
|
|
39
|
+
};
|
|
40
|
+
workspaceSymbols?: {
|
|
41
|
+
/** Include object, constructor and mixin variables. @default true */
|
|
42
|
+
includeInstanceVariables?: boolean;
|
|
43
|
+
/** Include the local variables of the active file. @default true */
|
|
44
|
+
includeLocalVariables?: boolean;
|
|
45
|
+
/** @default 30 */
|
|
46
|
+
maxResults?: number;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* How long to wait (ms) after an edit before re-analyzing. Requests that
|
|
50
|
+
* need up-to-date results don't wait. @default 50
|
|
51
|
+
*/
|
|
52
|
+
analysisDelay?: number;
|
|
53
|
+
}
|
|
54
|
+
/** The `initializationOptions` the server expects */
|
|
55
|
+
export interface GmlServerInitializationOptions {
|
|
56
|
+
/** Absolute path to the project's `.yyp` file */
|
|
57
|
+
yypPath: string;
|
|
58
|
+
/**
|
|
59
|
+
* `GmlSpec.xml` files to load built-in functions, variables and constants
|
|
60
|
+
* from. Defaults to the spec bundled with the server.
|
|
61
|
+
*/
|
|
62
|
+
specs?: string[];
|
|
63
|
+
settings?: GmlServerSettings;
|
|
64
|
+
}
|
|
65
|
+
/** Server → client notification: what the server is doing */
|
|
66
|
+
export declare const statusNotification = "stitch/status";
|
|
67
|
+
export interface StatusParams {
|
|
68
|
+
state: 'loading' | 'ready' | 'error';
|
|
69
|
+
message?: string;
|
|
70
|
+
/** When ready: how many GML files were analyzed, and how long it took */
|
|
71
|
+
files?: number;
|
|
72
|
+
ms?: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Client → server request: describe the symbol at a position, e.g. to decide
|
|
76
|
+
* which commands apply to it.
|
|
77
|
+
*/
|
|
78
|
+
export declare const symbolInfoRequest = "stitch/symbolInfo";
|
|
79
|
+
export interface SymbolInfoParams {
|
|
80
|
+
textDocument: {
|
|
81
|
+
uri: string;
|
|
82
|
+
};
|
|
83
|
+
position: {
|
|
84
|
+
line: number;
|
|
85
|
+
character: number;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export interface SymbolInfo {
|
|
89
|
+
name: string;
|
|
90
|
+
/** e.g. `function`, `variable`, `asset`, `enum` */
|
|
91
|
+
kind: string;
|
|
92
|
+
native: boolean;
|
|
93
|
+
/** For assets, their kind (`sprites`, `sounds`, ...) */
|
|
94
|
+
assetKind?: string;
|
|
95
|
+
/** The symbol's type, in Feather notation (e.g. `Real|String`) */
|
|
96
|
+
type: string;
|
|
97
|
+
/** For constructors, the type of the struct they create (e.g. `Struct.Foo`) */
|
|
98
|
+
constructs?: string;
|
|
99
|
+
deprecated?: boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Client → server request: the code edits that rename every reference to an
|
|
103
|
+
* asset. Ask *before* renaming the asset's files, and apply the edits before
|
|
104
|
+
* or after the rename (they only touch code that refers to the asset).
|
|
105
|
+
*
|
|
106
|
+
* Returns an LSP `WorkspaceEdit`.
|
|
107
|
+
*/
|
|
108
|
+
export declare const assetRenameEditsRequest = "stitch/assetRenameEdits";
|
|
109
|
+
export interface AssetRenameEditsParams {
|
|
110
|
+
name: string;
|
|
111
|
+
newName: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Client → server notification: which document is in the active editor
|
|
115
|
+
* (`uri: null` when none is). Workspace symbols include its local variables.
|
|
116
|
+
*/
|
|
117
|
+
export declare const activeDocumentNotification = "stitch/activeDocument";
|
|
118
|
+
export interface ActiveDocumentParams {
|
|
119
|
+
uri: string | null;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Client → server request: the names of the global symbols the project
|
|
123
|
+
* defines (functions, constructors, macros, enums, global variables and
|
|
124
|
+
* assets; not built-ins). Returns `string[]`.
|
|
125
|
+
*/
|
|
126
|
+
export declare const globalNamesRequest = "stitch/globalNames";
|
|
127
|
+
/** The semantic token types the server uses, in legend order */
|
|
128
|
+
export declare const semanticTokenTypes: readonly ["function", "variable", "enum", "macro", "class", "enumMember", "parameter", "property"];
|
|
129
|
+
/** The semantic token modifiers the server uses, in legend order */
|
|
130
|
+
export declare const semanticTokenModifiers: readonly ["readonly", "defaultLibrary", "declaration", "static", "deprecated", "local", "asset", "global"];
|
|
131
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"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"}
|
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Stitch-specific parts of the language server's protocol: its
|
|
3
|
+
* initialization options, settings, and custom `stitch/*` messages.
|
|
4
|
+
*
|
|
5
|
+
* This module has no dependencies, so clients can import it without pulling
|
|
6
|
+
* in the server.
|
|
7
|
+
*/
|
|
8
|
+
//#region Custom messages
|
|
9
|
+
/** Server → client notification: what the server is doing */
|
|
10
|
+
export const statusNotification = 'stitch/status';
|
|
11
|
+
/**
|
|
12
|
+
* Client → server request: describe the symbol at a position, e.g. to decide
|
|
13
|
+
* which commands apply to it.
|
|
14
|
+
*/
|
|
15
|
+
export const symbolInfoRequest = 'stitch/symbolInfo';
|
|
16
|
+
/**
|
|
17
|
+
* Client → server request: the code edits that rename every reference to an
|
|
18
|
+
* asset. Ask *before* renaming the asset's files, and apply the edits before
|
|
19
|
+
* or after the rename (they only touch code that refers to the asset).
|
|
20
|
+
*
|
|
21
|
+
* Returns an LSP `WorkspaceEdit`.
|
|
22
|
+
*/
|
|
23
|
+
export const assetRenameEditsRequest = 'stitch/assetRenameEdits';
|
|
24
|
+
/**
|
|
25
|
+
* Client → server notification: which document is in the active editor
|
|
26
|
+
* (`uri: null` when none is). Workspace symbols include its local variables.
|
|
27
|
+
*/
|
|
28
|
+
export const activeDocumentNotification = 'stitch/activeDocument';
|
|
29
|
+
/**
|
|
30
|
+
* Client → server request: the names of the global symbols the project
|
|
31
|
+
* defines (functions, constructors, macros, enums, global variables and
|
|
32
|
+
* assets; not built-ins). Returns `string[]`.
|
|
33
|
+
*/
|
|
34
|
+
export const globalNamesRequest = 'stitch/globalNames';
|
|
35
|
+
//#endregion
|
|
36
|
+
/** The semantic token types the server uses, in legend order */
|
|
37
|
+
export const semanticTokenTypes = [
|
|
38
|
+
'function',
|
|
39
|
+
'variable',
|
|
40
|
+
'enum',
|
|
41
|
+
'macro',
|
|
42
|
+
'class',
|
|
43
|
+
'enumMember',
|
|
44
|
+
'parameter',
|
|
45
|
+
'property',
|
|
46
|
+
];
|
|
47
|
+
/** The semantic token modifiers the server uses, in legend order */
|
|
48
|
+
export const semanticTokenModifiers = [
|
|
49
|
+
'readonly',
|
|
50
|
+
'defaultLibrary',
|
|
51
|
+
'declaration',
|
|
52
|
+
'static',
|
|
53
|
+
'deprecated',
|
|
54
|
+
'local',
|
|
55
|
+
'asset',
|
|
56
|
+
'global',
|
|
57
|
+
];
|
|
58
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+DH,yBAAyB;AAEzB,6DAA6D;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AASlD;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAmBrD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAMjE;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;AAKlE;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEvD,YAAY;AAEZ,gEAAgE;AAChE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,UAAU;IACV,UAAU;IACV,MAAM;IACN,OAAO;IACP,OAAO;IACP,YAAY;IACZ,WAAW;IACX,UAAU;CACF,CAAC;AAEX,oEAAoE;AACpE,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,UAAU;IACV,gBAAgB;IAChB,aAAa;IACb,QAAQ;IACR,YAAY;IACZ,OAAO;IACP,OAAO;IACP,QAAQ;CACA,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
2
|
+
import { TextDocuments, type CancellationToken, type Connection, type InitializeParams, type InitializeResult, type TextDocumentPositionParams } from 'vscode-languageserver/node';
|
|
3
|
+
import { type GmlServerInitializationOptions, type GmlServerSettings, type StatusParams } from './protocol.ts';
|
|
4
|
+
import { ProjectSession } from './session.ts';
|
|
5
|
+
export declare class GmlLanguageServer {
|
|
6
|
+
readonly connection: Connection;
|
|
7
|
+
readonly documents: TextDocuments<TextDocument>;
|
|
8
|
+
protected options: GmlServerInitializationOptions | undefined;
|
|
9
|
+
protected settings: GmlServerSettings;
|
|
10
|
+
protected session: ProjectSession | undefined;
|
|
11
|
+
/** Resolves once the project has loaded (to undefined if it couldn't be) */
|
|
12
|
+
protected loading: Promise<ProjectSession | undefined> | undefined;
|
|
13
|
+
protected updateTimer: NodeJS.Timeout | undefined;
|
|
14
|
+
protected fullDiagnosticsTimer: NodeJS.Timeout | undefined;
|
|
15
|
+
/** The diagnostics last published for each file (as JSON), by file id */
|
|
16
|
+
protected readonly published: Map<string, string>;
|
|
17
|
+
protected canRefreshSemanticTokens: boolean;
|
|
18
|
+
/** The document in the client's active editor */
|
|
19
|
+
protected activeUri: string | null;
|
|
20
|
+
protected disposed: boolean;
|
|
21
|
+
constructor(connection: Connection);
|
|
22
|
+
protected initialize(params: InitializeParams): InitializeResult;
|
|
23
|
+
/** Load the project. Requests made while loading wait for it. */
|
|
24
|
+
protected load(): Promise<ProjectSession | undefined>;
|
|
25
|
+
dispose(): void;
|
|
26
|
+
protected status(params: StatusParams): void;
|
|
27
|
+
protected openText(file: string): string | undefined;
|
|
28
|
+
protected get openFileIds(): string[];
|
|
29
|
+
protected scheduleUpdate(): void;
|
|
30
|
+
/** Bring the analysis up to date and publish what changed */
|
|
31
|
+
protected update(): Promise<void>;
|
|
32
|
+
/** Wait for loading, and for any pending changes to be analyzed */
|
|
33
|
+
protected ready(): Promise<ProjectSession | undefined>;
|
|
34
|
+
protected refreshSemanticTokens(): void;
|
|
35
|
+
protected publishDiagnostics(fileIds: Iterable<string>, force?: boolean): void;
|
|
36
|
+
protected publishAllDiagnostics(force?: boolean): void;
|
|
37
|
+
protected scheduleFullDiagnostics(): void;
|
|
38
|
+
protected changeSettings(settings: GmlServerSettings): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Run a handler for a position in a project GML file, once the file's
|
|
41
|
+
* analysis is up to date. Returns `fallback` for other files.
|
|
42
|
+
*/
|
|
43
|
+
protected atPosition<T, F>(params: TextDocumentPositionParams, fallback: F, fn: (session: ProjectSession, fileId: string, offset: number) => T, token?: CancellationToken): Promise<T | F>;
|
|
44
|
+
protected registerHandlers(): void;
|
|
45
|
+
protected globalNames(): Promise<string[]>;
|
|
46
|
+
protected asRenameResult<T>(fn: () => T): T;
|
|
47
|
+
}
|
|
48
|
+
/** Start a language server on a connection */
|
|
49
|
+
export declare function startServer(connection: Connection): GmlLanguageServer;
|
|
50
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAGL,aAAa,EAEb,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,0BAA0B,EAChC,MAAM,4BAA4B,CAAC;AAkBpC,OAAO,EAUL,KAAK,8BAA8B,EACnC,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAElB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAM9C,qBAAa,iBAAiB;IAC5B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,SAAS,8BAAmC;IACrD,SAAS,CAAC,OAAO,EAAE,8BAA8B,GAAG,SAAS,CAAC;IAC9D,SAAS,CAAC,QAAQ,EAAE,iBAAiB,CAAM;IAC3C,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,SAAS,CAAC;IAC9C,4EAA4E;IAC5E,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IACnE,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC;IAClD,SAAS,CAAC,oBAAoB,EAAE,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC;IAC3D,yEAAyE;IACzE,SAAS,CAAC,QAAQ,CAAC,SAAS,sBAA6B;IACzD,SAAS,CAAC,wBAAwB,UAAS;IAC3C,iDAAiD;IACjD,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC1C,SAAS,CAAC,QAAQ,UAAS;gBAEf,UAAU,EAAE,UAAU;IAQlC,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB;IA0ChE,iEAAiE;IACjE,SAAS,CAAC,IAAI,IAAI,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAuCrD,OAAO;IAOP,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY;IAQrC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIpD,SAAS,KAAK,WAAW,IAAI,MAAM,EAAE,CAQpC;IAED,SAAS,CAAC,cAAc;IAQxB,6DAA6D;cAC7C,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IA6BvC,mEAAmE;cACnD,KAAK,IAAI,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAM5D,SAAS,CAAC,qBAAqB;IAW/B,SAAS,CAAC,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,UAAQ;IAiBrE,SAAS,CAAC,qBAAqB,CAAC,KAAK,UAAQ;IAK7C,SAAS,CAAC,uBAAuB;cAYjB,cAAc,CAAC,QAAQ,EAAE,iBAAiB;IAqB1D;;;OAGG;cACa,UAAU,CAAC,CAAC,EAAE,CAAC,EAC7B,MAAM,EAAE,0BAA0B,EAClC,QAAQ,EAAE,CAAC,EACX,EAAE,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC,EAClE,KAAK,CAAC,EAAE,iBAAiB,GACxB,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC;IAejB,SAAS,CAAC,gBAAgB;cA2IV,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAShD,SAAS,CAAC,cAAc,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;CAY5C;AAED,8CAA8C;AAC9C,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,GAAG,iBAAiB,CAIrE"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The language server: LSP handlers, document syncing, and scheduling of
|
|
3
|
+
* analysis and diagnostics for one GameMaker project.
|
|
4
|
+
*/
|
|
5
|
+
import { ids } from '@bscotch/gml-parser';
|
|
6
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
7
|
+
import { ErrorCodes, ResponseError, TextDocuments, TextDocumentSyncKind, } from 'vscode-languageserver/node';
|
|
8
|
+
import { assetRenameEdits, completions, definition, diagnostics, formatDocument, hover, prepareRename, references, rename, RenameError, semanticTokens, signatureHelp, symbolInfo, typeDefinition, workspaceSymbols, } from "./features.js";
|
|
9
|
+
import { activeDocumentNotification, assetRenameEditsRequest, globalNamesRequest, semanticTokenModifiers, semanticTokenTypes, statusNotification, symbolInfoRequest, } from "./protocol.js";
|
|
10
|
+
import { ProjectSession } from "./session.js";
|
|
11
|
+
import { pathToUri, uriToPath } from "./uri.js";
|
|
12
|
+
/** How long to wait after the last change before re-checking every file's diagnostics */
|
|
13
|
+
const FULL_DIAGNOSTICS_DELAY = 750;
|
|
14
|
+
export class GmlLanguageServer {
|
|
15
|
+
connection;
|
|
16
|
+
documents = new TextDocuments(TextDocument);
|
|
17
|
+
options;
|
|
18
|
+
settings = {};
|
|
19
|
+
session;
|
|
20
|
+
/** Resolves once the project has loaded (to undefined if it couldn't be) */
|
|
21
|
+
loading;
|
|
22
|
+
updateTimer;
|
|
23
|
+
fullDiagnosticsTimer;
|
|
24
|
+
/** The diagnostics last published for each file (as JSON), by file id */
|
|
25
|
+
published = new Map();
|
|
26
|
+
canRefreshSemanticTokens = false;
|
|
27
|
+
/** The document in the client's active editor */
|
|
28
|
+
activeUri = null;
|
|
29
|
+
disposed = false;
|
|
30
|
+
constructor(connection) {
|
|
31
|
+
this.connection = connection;
|
|
32
|
+
this.documents.listen(connection);
|
|
33
|
+
this.registerHandlers();
|
|
34
|
+
}
|
|
35
|
+
//#region Lifecycle
|
|
36
|
+
initialize(params) {
|
|
37
|
+
const options = params.initializationOptions;
|
|
38
|
+
if (!options?.yypPath) {
|
|
39
|
+
throw new ResponseError(ErrorCodes.InvalidParams, 'The `yypPath` initialization option is required.');
|
|
40
|
+
}
|
|
41
|
+
this.options = options;
|
|
42
|
+
this.settings = options.settings ?? {};
|
|
43
|
+
this.canRefreshSemanticTokens =
|
|
44
|
+
!!params.capabilities.workspace?.semanticTokens?.refreshSupport;
|
|
45
|
+
return {
|
|
46
|
+
capabilities: {
|
|
47
|
+
textDocumentSync: TextDocumentSyncKind.Incremental,
|
|
48
|
+
hoverProvider: true,
|
|
49
|
+
completionProvider: {
|
|
50
|
+
triggerCharacters: ['.', '{', '<', '|', '@'],
|
|
51
|
+
},
|
|
52
|
+
signatureHelpProvider: {
|
|
53
|
+
triggerCharacters: ['(', ','],
|
|
54
|
+
retriggerCharacters: [','],
|
|
55
|
+
},
|
|
56
|
+
definitionProvider: true,
|
|
57
|
+
typeDefinitionProvider: true,
|
|
58
|
+
referencesProvider: true,
|
|
59
|
+
renameProvider: { prepareProvider: true },
|
|
60
|
+
semanticTokensProvider: {
|
|
61
|
+
legend: {
|
|
62
|
+
tokenTypes: [...semanticTokenTypes],
|
|
63
|
+
tokenModifiers: [...semanticTokenModifiers],
|
|
64
|
+
},
|
|
65
|
+
full: true,
|
|
66
|
+
},
|
|
67
|
+
workspaceSymbolProvider: true,
|
|
68
|
+
documentFormattingProvider: true,
|
|
69
|
+
},
|
|
70
|
+
serverInfo: { name: 'gml-language-server' },
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** Load the project. Requests made while loading wait for it. */
|
|
74
|
+
load() {
|
|
75
|
+
const options = this.options;
|
|
76
|
+
this.status({ state: 'loading', message: 'Loading project...' });
|
|
77
|
+
const started = Date.now();
|
|
78
|
+
this.loading = ProjectSession.open(options.yypPath, {
|
|
79
|
+
specs: options.specs,
|
|
80
|
+
autoDeclareGlobalsPrefixes: this.settings.diagnostics?.autoDeclaredGlobalsPrefixes,
|
|
81
|
+
openText: (file) => this.openText(file),
|
|
82
|
+
onError: (err) => this.connection.console.warn(String(err.message)),
|
|
83
|
+
onDirty: () => this.scheduleUpdate(),
|
|
84
|
+
}).then((session) => {
|
|
85
|
+
if (this.disposed) {
|
|
86
|
+
session.dispose();
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
this.session?.dispose();
|
|
90
|
+
this.session = session;
|
|
91
|
+
this.status({
|
|
92
|
+
state: 'ready',
|
|
93
|
+
files: session.fileIds.length,
|
|
94
|
+
ms: Date.now() - started,
|
|
95
|
+
});
|
|
96
|
+
this.publishAllDiagnostics();
|
|
97
|
+
this.refreshSemanticTokens();
|
|
98
|
+
return session;
|
|
99
|
+
}, (err) => {
|
|
100
|
+
this.connection.console.error(`Could not load the project: ${err.stack ?? err.message}`);
|
|
101
|
+
this.status({ state: 'error', message: err.message });
|
|
102
|
+
return undefined;
|
|
103
|
+
});
|
|
104
|
+
return this.loading;
|
|
105
|
+
}
|
|
106
|
+
dispose() {
|
|
107
|
+
this.disposed = true;
|
|
108
|
+
clearTimeout(this.updateTimer);
|
|
109
|
+
clearTimeout(this.fullDiagnosticsTimer);
|
|
110
|
+
this.session?.dispose();
|
|
111
|
+
}
|
|
112
|
+
status(params) {
|
|
113
|
+
void this.connection.sendNotification(statusNotification, params);
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region Documents and updates
|
|
117
|
+
openText(file) {
|
|
118
|
+
return this.documents.get(pathToUri(file))?.getText();
|
|
119
|
+
}
|
|
120
|
+
get openFileIds() {
|
|
121
|
+
const session = this.session;
|
|
122
|
+
if (!session)
|
|
123
|
+
return [];
|
|
124
|
+
return this.documents
|
|
125
|
+
.keys()
|
|
126
|
+
.map((uri) => uriToPath(uri))
|
|
127
|
+
.map((file) => (file ? session.fileIdOf(file) : undefined))
|
|
128
|
+
.filter((id) => !!id);
|
|
129
|
+
}
|
|
130
|
+
scheduleUpdate() {
|
|
131
|
+
clearTimeout(this.updateTimer);
|
|
132
|
+
this.updateTimer = setTimeout(() => void this.update(), this.settings.analysisDelay ?? 50);
|
|
133
|
+
}
|
|
134
|
+
/** Bring the analysis up to date and publish what changed */
|
|
135
|
+
async update() {
|
|
136
|
+
clearTimeout(this.updateTimer);
|
|
137
|
+
const session = this.session;
|
|
138
|
+
if (!session)
|
|
139
|
+
return;
|
|
140
|
+
let result;
|
|
141
|
+
try {
|
|
142
|
+
result = await session.update();
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
this.connection.console.error(`Analysis failed: ${err.stack ?? err}`);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
for (const id of result.removed) {
|
|
149
|
+
this.published.delete(id);
|
|
150
|
+
void this.connection.sendDiagnostics({
|
|
151
|
+
uri: pathToUri(session.pathOf(id)),
|
|
152
|
+
diagnostics: [],
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
if (!result.checked.size && !result.touched.size)
|
|
156
|
+
return;
|
|
157
|
+
// Changed and open files right away, the rest once things settle
|
|
158
|
+
this.publishDiagnostics(new Set([...result.checked, ...result.touched, ...this.openFileIds]));
|
|
159
|
+
this.scheduleFullDiagnostics();
|
|
160
|
+
this.refreshSemanticTokens();
|
|
161
|
+
}
|
|
162
|
+
/** Wait for loading, and for any pending changes to be analyzed */
|
|
163
|
+
async ready() {
|
|
164
|
+
const session = await this.loading;
|
|
165
|
+
if (session?.hasPendingChanges)
|
|
166
|
+
await this.update();
|
|
167
|
+
return session;
|
|
168
|
+
}
|
|
169
|
+
refreshSemanticTokens() {
|
|
170
|
+
if (!this.canRefreshSemanticTokens)
|
|
171
|
+
return;
|
|
172
|
+
void this.connection.languages.semanticTokens
|
|
173
|
+
.refresh()
|
|
174
|
+
.catch(() => undefined);
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region Diagnostics
|
|
178
|
+
publishDiagnostics(fileIds, force = false) {
|
|
179
|
+
const session = this.session;
|
|
180
|
+
if (!session)
|
|
181
|
+
return;
|
|
182
|
+
for (const id of fileIds) {
|
|
183
|
+
if (!session.sourceFile(id))
|
|
184
|
+
continue;
|
|
185
|
+
const result = diagnostics(session, id, this.settings);
|
|
186
|
+
const json = JSON.stringify(result);
|
|
187
|
+
if (!force && this.published.get(id) === json)
|
|
188
|
+
continue;
|
|
189
|
+
if (!result.length && !this.published.has(id) && !force)
|
|
190
|
+
continue;
|
|
191
|
+
this.published.set(id, json);
|
|
192
|
+
void this.connection.sendDiagnostics({
|
|
193
|
+
uri: pathToUri(session.pathOf(id)),
|
|
194
|
+
diagnostics: result,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
publishAllDiagnostics(force = false) {
|
|
199
|
+
clearTimeout(this.fullDiagnosticsTimer);
|
|
200
|
+
if (this.session)
|
|
201
|
+
this.publishDiagnostics(this.session.fileIds, force);
|
|
202
|
+
}
|
|
203
|
+
scheduleFullDiagnostics() {
|
|
204
|
+
clearTimeout(this.fullDiagnosticsTimer);
|
|
205
|
+
this.fullDiagnosticsTimer = setTimeout(() => this.publishAllDiagnostics(), FULL_DIAGNOSTICS_DELAY);
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region Settings
|
|
209
|
+
async changeSettings(settings) {
|
|
210
|
+
const before = JSON.stringify(this.settings.diagnostics?.autoDeclaredGlobalsPrefixes ?? []);
|
|
211
|
+
this.settings = settings ?? {};
|
|
212
|
+
const after = JSON.stringify(this.settings.diagnostics?.autoDeclaredGlobalsPrefixes ?? []);
|
|
213
|
+
if (before !== after && this.options) {
|
|
214
|
+
// Changes how files are checked, so start over
|
|
215
|
+
await this.loading;
|
|
216
|
+
await this.load();
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
this.publishAllDiagnostics(true);
|
|
220
|
+
}
|
|
221
|
+
//#endregion
|
|
222
|
+
//#region Handlers
|
|
223
|
+
/**
|
|
224
|
+
* Run a handler for a position in a project GML file, once the file's
|
|
225
|
+
* analysis is up to date. Returns `fallback` for other files.
|
|
226
|
+
*/
|
|
227
|
+
async atPosition(params, fallback, fn, token) {
|
|
228
|
+
const session = await this.ready();
|
|
229
|
+
if (!session || token?.isCancellationRequested)
|
|
230
|
+
return fallback;
|
|
231
|
+
const file = uriToPath(params.textDocument.uri);
|
|
232
|
+
const fileId = file ? session.fileIdOf(file) : undefined;
|
|
233
|
+
if (!fileId)
|
|
234
|
+
return fallback;
|
|
235
|
+
if (session.isStale(fileId)) {
|
|
236
|
+
session.markDirty(file);
|
|
237
|
+
await this.update();
|
|
238
|
+
}
|
|
239
|
+
const lines = session.analyzer.getFile(fileId)?.lines;
|
|
240
|
+
if (!lines)
|
|
241
|
+
return fallback;
|
|
242
|
+
return fn(session, fileId, lines.offsetAt(params.position));
|
|
243
|
+
}
|
|
244
|
+
registerHandlers() {
|
|
245
|
+
const { connection, documents } = this;
|
|
246
|
+
connection.onInitialize((params) => this.initialize(params));
|
|
247
|
+
connection.onInitialized(() => void this.load());
|
|
248
|
+
connection.onShutdown(() => this.dispose());
|
|
249
|
+
connection.onDidChangeConfiguration((params) => {
|
|
250
|
+
// (Some clients send `null` for settings they don't manage)
|
|
251
|
+
if (params.settings && typeof params.settings === 'object') {
|
|
252
|
+
void this.changeSettings(params.settings);
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
// Keep up with the editor's documents and the file system
|
|
256
|
+
documents.onDidChangeContent((e) => {
|
|
257
|
+
const file = uriToPath(e.document.uri);
|
|
258
|
+
if (file)
|
|
259
|
+
this.session?.markDirty(file);
|
|
260
|
+
});
|
|
261
|
+
documents.onDidClose((e) => {
|
|
262
|
+
const file = uriToPath(e.document.uri);
|
|
263
|
+
// Back to what's on disk
|
|
264
|
+
if (file)
|
|
265
|
+
this.session?.markDirty(file);
|
|
266
|
+
});
|
|
267
|
+
connection.onDidChangeWatchedFiles((params) => {
|
|
268
|
+
const files = params.changes
|
|
269
|
+
.map((c) => uriToPath(c.uri))
|
|
270
|
+
.filter((f) => !!f);
|
|
271
|
+
this.session?.project.notifyChanged(files);
|
|
272
|
+
});
|
|
273
|
+
connection.onHover((params, token) => this.atPosition(params, null, hover, token));
|
|
274
|
+
connection.onDefinition((params, token) => this.atPosition(params, [], definition, token));
|
|
275
|
+
connection.onTypeDefinition((params, token) => this.atPosition(params, [], typeDefinition, token));
|
|
276
|
+
connection.onReferences((params, token) => this.atPosition(params, [], (session, fileId, offset) => references(session, fileId, offset, params.context.includeDeclaration), token));
|
|
277
|
+
connection.onSignatureHelp((params, token) => this.atPosition(params, null, signatureHelp, token));
|
|
278
|
+
connection.onCompletion((params, token) => this.atPosition(params, null, (session, fileId, offset) => completions(session, fileId, offset, params.context?.triggerCharacter, this.settings), token));
|
|
279
|
+
connection.onPrepareRename((params) => this.atPosition(params, null, (session, fileId, offset) => this.asRenameResult(() => prepareRename(session, fileId, offset))));
|
|
280
|
+
connection.onRenameRequest((params) => this.atPosition(params, null, (session, fileId, offset) => this.asRenameResult(() => rename(session, fileId, offset, params.newName))));
|
|
281
|
+
connection.languages.semanticTokens.on(async (params) => {
|
|
282
|
+
const session = await this.ready();
|
|
283
|
+
const file = uriToPath(params.textDocument.uri);
|
|
284
|
+
const fileId = file && session?.fileIdOf(file);
|
|
285
|
+
if (!session || !fileId)
|
|
286
|
+
return { data: [] };
|
|
287
|
+
if (session.isStale(fileId)) {
|
|
288
|
+
session.markDirty(file);
|
|
289
|
+
await this.update();
|
|
290
|
+
}
|
|
291
|
+
return semanticTokens(session, fileId);
|
|
292
|
+
});
|
|
293
|
+
connection.onWorkspaceSymbol(async (params) => {
|
|
294
|
+
const session = await this.ready();
|
|
295
|
+
if (!session)
|
|
296
|
+
return [];
|
|
297
|
+
const activeFile = this.activeUri ? uriToPath(this.activeUri) : undefined;
|
|
298
|
+
return workspaceSymbols(session, params.query, this.settings, activeFile ? session.fileIdOf(activeFile) : undefined);
|
|
299
|
+
});
|
|
300
|
+
connection.onDocumentFormatting((params) => {
|
|
301
|
+
const document = documents.get(params.textDocument.uri);
|
|
302
|
+
if (!document)
|
|
303
|
+
return null;
|
|
304
|
+
const { edits, error } = formatDocument(document.getText(), this.settings);
|
|
305
|
+
if (error) {
|
|
306
|
+
connection.console.warn(`Not formatting: ${error}`);
|
|
307
|
+
}
|
|
308
|
+
return edits;
|
|
309
|
+
});
|
|
310
|
+
// Stitch's own requests
|
|
311
|
+
connection.onRequest(symbolInfoRequest, (params) => this.atPosition(params, null, symbolInfo));
|
|
312
|
+
connection.onNotification(activeDocumentNotification, (params) => {
|
|
313
|
+
this.activeUri = params.uri;
|
|
314
|
+
});
|
|
315
|
+
connection.onRequest(globalNamesRequest, () => this.globalNames());
|
|
316
|
+
connection.onRequest(assetRenameEditsRequest, async (params) => {
|
|
317
|
+
const session = await this.ready();
|
|
318
|
+
if (!session)
|
|
319
|
+
return { changes: {} };
|
|
320
|
+
return assetRenameEdits(session, params.name, params.newName);
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
async globalNames() {
|
|
324
|
+
const session = await this.ready();
|
|
325
|
+
if (!session)
|
|
326
|
+
return [];
|
|
327
|
+
return session.analyzer.table
|
|
328
|
+
.listMembers(ids.globalShape)
|
|
329
|
+
.filter((s) => !s.native && (s.def || s.kind === 'asset'))
|
|
330
|
+
.map((s) => s.name);
|
|
331
|
+
}
|
|
332
|
+
asRenameResult(fn) {
|
|
333
|
+
try {
|
|
334
|
+
return fn();
|
|
335
|
+
}
|
|
336
|
+
catch (err) {
|
|
337
|
+
if (err instanceof RenameError) {
|
|
338
|
+
throw new ResponseError(ErrorCodes.InvalidRequest, err.message);
|
|
339
|
+
}
|
|
340
|
+
throw err;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
/** Start a language server on a connection */
|
|
345
|
+
export function startServer(connection) {
|
|
346
|
+
const server = new GmlLanguageServer(connection);
|
|
347
|
+
connection.listen();
|
|
348
|
+
return server;
|
|
349
|
+
}
|
|
350
|
+
//# sourceMappingURL=server.js.map
|