@lewin671/lsp-client 0.1.0

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.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -0
  3. package/lib/common/Feature.d.ts +192 -0
  4. package/lib/common/Feature.js +159 -0
  5. package/lib/common/Feature.js.map +1 -0
  6. package/lib/common/LanguageClient.d.ts +230 -0
  7. package/lib/common/LanguageClient.js +512 -0
  8. package/lib/common/LanguageClient.js.map +1 -0
  9. package/lib/common/features/CompletionFeature.d.ts +23 -0
  10. package/lib/common/features/CompletionFeature.js +101 -0
  11. package/lib/common/features/CompletionFeature.js.map +1 -0
  12. package/lib/common/features/DefinitionFeature.d.ts +23 -0
  13. package/lib/common/features/DefinitionFeature.js +49 -0
  14. package/lib/common/features/DefinitionFeature.js.map +1 -0
  15. package/lib/common/features/DiagnosticFeature.d.ts +15 -0
  16. package/lib/common/features/DiagnosticFeature.js +39 -0
  17. package/lib/common/features/DiagnosticFeature.js.map +1 -0
  18. package/lib/common/features/DocumentSymbolFeature.d.ts +23 -0
  19. package/lib/common/features/DocumentSymbolFeature.js +87 -0
  20. package/lib/common/features/DocumentSymbolFeature.js.map +1 -0
  21. package/lib/common/features/FormattingFeature.d.ts +32 -0
  22. package/lib/common/features/FormattingFeature.js +72 -0
  23. package/lib/common/features/FormattingFeature.js.map +1 -0
  24. package/lib/common/features/HoverFeature.d.ts +23 -0
  25. package/lib/common/features/HoverFeature.js +49 -0
  26. package/lib/common/features/HoverFeature.js.map +1 -0
  27. package/lib/common/features/ReferencesFeature.d.ts +23 -0
  28. package/lib/common/features/ReferencesFeature.js +48 -0
  29. package/lib/common/features/ReferencesFeature.js.map +1 -0
  30. package/lib/common/features/RenameFeature.d.ts +37 -0
  31. package/lib/common/features/RenameFeature.js +72 -0
  32. package/lib/common/features/RenameFeature.js.map +1 -0
  33. package/lib/common/features/index.d.ts +8 -0
  34. package/lib/common/features/index.js +21 -0
  35. package/lib/common/features/index.js.map +1 -0
  36. package/lib/common/utils/index.d.ts +2 -0
  37. package/lib/common/utils/index.js +19 -0
  38. package/lib/common/utils/index.js.map +1 -0
  39. package/lib/common/utils/is.d.ts +15 -0
  40. package/lib/common/utils/is.js +56 -0
  41. package/lib/common/utils/is.js.map +1 -0
  42. package/lib/common/utils/uuid.d.ts +17 -0
  43. package/lib/common/utils/uuid.js +87 -0
  44. package/lib/common/utils/uuid.js.map +1 -0
  45. package/lib/demo/custom-lsp/client.d.ts +1 -0
  46. package/lib/demo/custom-lsp/client.js +86 -0
  47. package/lib/demo/custom-lsp/client.js.map +1 -0
  48. package/lib/demo/custom-lsp/server.d.ts +1 -0
  49. package/lib/demo/custom-lsp/server.js +64 -0
  50. package/lib/demo/custom-lsp/server.js.map +1 -0
  51. package/lib/demo/go-demo/client.d.ts +14 -0
  52. package/lib/demo/go-demo/client.js +697 -0
  53. package/lib/demo/go-demo/client.js.map +1 -0
  54. package/lib/demo/typescript-demo/client.d.ts +14 -0
  55. package/lib/demo/typescript-demo/client.js +680 -0
  56. package/lib/demo/typescript-demo/client.js.map +1 -0
  57. package/lib/demo/typescript-demo/sample-project/src/index.d.ts +9 -0
  58. package/lib/demo/typescript-demo/sample-project/src/index.js +65 -0
  59. package/lib/demo/typescript-demo/sample-project/src/index.js.map +1 -0
  60. package/lib/demo/typescript-demo/sample-project/src/math.d.ts +38 -0
  61. package/lib/demo/typescript-demo/sample-project/src/math.js +63 -0
  62. package/lib/demo/typescript-demo/sample-project/src/math.js.map +1 -0
  63. package/lib/demo/typescript-demo/sample-project/src/models/person.d.ts +41 -0
  64. package/lib/demo/typescript-demo/sample-project/src/models/person.js +53 -0
  65. package/lib/demo/typescript-demo/sample-project/src/models/person.js.map +1 -0
  66. package/lib/demo/typescript-demo/sample-project/src/services/calculator.d.ts +39 -0
  67. package/lib/demo/typescript-demo/sample-project/src/services/calculator.js +69 -0
  68. package/lib/demo/typescript-demo/sample-project/src/services/calculator.js.map +1 -0
  69. package/lib/demo/typescript-demo/sample-project/src/services/user-service.d.ts +40 -0
  70. package/lib/demo/typescript-demo/sample-project/src/services/user-service.js +88 -0
  71. package/lib/demo/typescript-demo/sample-project/src/services/user-service.js.map +1 -0
  72. package/lib/index.d.ts +8 -0
  73. package/lib/index.js +32 -0
  74. package/lib/index.js.map +1 -0
  75. package/lib/interfaces/IHost.d.ts +19 -0
  76. package/lib/interfaces/IHost.js +3 -0
  77. package/lib/interfaces/IHost.js.map +1 -0
  78. package/lib/transports/ITransport.d.ts +8 -0
  79. package/lib/transports/ITransport.js +3 -0
  80. package/lib/transports/ITransport.js.map +1 -0
  81. package/lib/transports/StdioTransport.d.ts +13 -0
  82. package/lib/transports/StdioTransport.js +27 -0
  83. package/lib/transports/StdioTransport.js.map +1 -0
  84. package/package.json +48 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Lewin671
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # Universal LSP Client SDK
2
+
3
+ A TypeScript SDK for building Language Server Protocol (LSP) clients that run in any environment (Node.js, Browser, Electron, VS Code, etc.).
4
+
5
+ ## Features
6
+
7
+ - **Universal**: Decoupled from VS Code API. Runs anywhere.
8
+ - **Type-Safe**: Built with TypeScript.
9
+ - **Pluggable Transports**: Support for Stdio, IPC, WebSocket, and custom transports.
10
+ - **Flexible Architecture**: Middleware, Plugins, and Host abstractions.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install lsp-client
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ### Basic Example
21
+
22
+ ```typescript
23
+ import { LanguageClient, StdioTransport } from 'lsp-client';
24
+
25
+ // 1. Create a transport (e.g., Stdio for a local server)
26
+ const transport = new StdioTransport('path/to/server-executable', ['--stdio']);
27
+
28
+ // 2. Initialize the client
29
+ const client = new LanguageClient({
30
+ name: 'My Language Client',
31
+ transport: transport,
32
+ // ... other options
33
+ });
34
+
35
+ // 3. Start the client
36
+ await client.start();
37
+
38
+ // 4. Send a request
39
+ const result = await client.sendRequest('textDocument/hover', { ... });
40
+ ```
41
+
42
+ ## Architecture
43
+
44
+ See [Agents.md](./Agents.md) for architectural details.
45
+
46
+ ## Development
47
+
48
+ ### Build
49
+
50
+ ```bash
51
+ npm install
52
+ npm run build
53
+ ```
54
+
55
+ ### Run Demo
56
+
57
+ ```bash
58
+ npm run demo
59
+ ```
60
+
61
+ ## License
62
+
63
+ MIT
64
+
@@ -0,0 +1,192 @@
1
+ import { ClientCapabilities, ServerCapabilities, InitializeParams, DocumentSelector, RegistrationType, TextDocumentRegistrationOptions, StaticRegistrationOptions } from 'vscode-languageserver-protocol';
2
+ /**
3
+ * Helper function to ensure a property exists on an object
4
+ */
5
+ export declare function ensure<T, K extends keyof T>(target: T, key: K): T[K];
6
+ /**
7
+ * Registration data for dynamic features
8
+ */
9
+ export interface RegistrationData<T> {
10
+ id: string;
11
+ registerOptions: T;
12
+ }
13
+ /**
14
+ * Feature state kind
15
+ */
16
+ export type FeatureStateKind = 'document' | 'workspace' | 'static' | 'window';
17
+ /**
18
+ * Feature state describes the current state of a feature
19
+ */
20
+ export type FeatureState = {
21
+ kind: 'document';
22
+ id: string;
23
+ registrations: boolean;
24
+ matches: boolean;
25
+ } | {
26
+ kind: 'workspace';
27
+ id: string;
28
+ registrations: boolean;
29
+ } | {
30
+ kind: 'window';
31
+ id: string;
32
+ registrations: boolean;
33
+ } | {
34
+ kind: 'static';
35
+ };
36
+ /**
37
+ * A static feature. A static feature can't be dynamically activated via the
38
+ * server. It is wired during the initialize sequence.
39
+ */
40
+ export interface StaticFeature {
41
+ /**
42
+ * Called to fill the initialize params.
43
+ */
44
+ fillInitializeParams?: (params: InitializeParams) => void;
45
+ /**
46
+ * Called to fill in the client capabilities this feature implements.
47
+ */
48
+ fillClientCapabilities(capabilities: ClientCapabilities): void;
49
+ /**
50
+ * A preflight where the server capabilities are shown to all features
51
+ * before a feature is actually initialized.
52
+ */
53
+ preInitialize?: (capabilities: ServerCapabilities, documentSelector: DocumentSelector | undefined) => void;
54
+ /**
55
+ * Initialize the feature. This method is called on a feature instance
56
+ * when the client has successfully received the initialize request from
57
+ * the server and before the client sends the initialized notification
58
+ * to the server.
59
+ */
60
+ initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector | undefined): void;
61
+ /**
62
+ * Returns the state the feature is in.
63
+ */
64
+ getState(): FeatureState;
65
+ /**
66
+ * Called when the client is stopped or re-started to clear this feature.
67
+ */
68
+ clear(): void;
69
+ }
70
+ export declare namespace StaticFeature {
71
+ function is(value: any): value is StaticFeature;
72
+ }
73
+ /**
74
+ * A dynamic feature can be activated via the server.
75
+ */
76
+ export interface DynamicFeature<RO> {
77
+ /**
78
+ * Called to fill the initialize params.
79
+ */
80
+ fillInitializeParams?: (params: InitializeParams) => void;
81
+ /**
82
+ * Called to fill in the client capabilities this feature implements.
83
+ */
84
+ fillClientCapabilities(capabilities: ClientCapabilities): void;
85
+ /**
86
+ * A preflight where the server capabilities are shown to all features
87
+ * before a feature is actually initialized.
88
+ */
89
+ preInitialize?: (capabilities: ServerCapabilities, documentSelector: DocumentSelector | undefined) => void;
90
+ /**
91
+ * Initialize the feature.
92
+ */
93
+ initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector | undefined): void;
94
+ /**
95
+ * Returns the state the feature is in.
96
+ */
97
+ getState(): FeatureState;
98
+ /**
99
+ * The signature (e.g. method) for which this features support dynamic activation / registration.
100
+ */
101
+ registrationType: RegistrationType<RO>;
102
+ /**
103
+ * Is called when the server send a register request for the given message.
104
+ */
105
+ register(data: RegistrationData<RO>): void;
106
+ /**
107
+ * Is called when the server wants to unregister a feature.
108
+ */
109
+ unregister(id: string): void;
110
+ /**
111
+ * Called when the client is stopped or re-started to clear this feature.
112
+ */
113
+ clear(): void;
114
+ }
115
+ export declare namespace DynamicFeature {
116
+ function is<T>(value: any): value is DynamicFeature<T>;
117
+ }
118
+ /**
119
+ * Helper interface for getting registration options
120
+ */
121
+ export interface DocumentSelectorOptions {
122
+ documentSelector: DocumentSelector;
123
+ }
124
+ /**
125
+ * Base class for features that work with text documents
126
+ */
127
+ export declare abstract class TextDocumentFeature<PO, RO extends TextDocumentRegistrationOptions & PO, MW = any> implements DynamicFeature<RO> {
128
+ protected readonly _client: any;
129
+ protected readonly _registrations: Map<string, {
130
+ data: RegistrationData<RO>;
131
+ disposable?: {
132
+ dispose(): void;
133
+ };
134
+ }>;
135
+ protected readonly _registrationType: RegistrationType<RO>;
136
+ constructor(_client: any, registrationType: RegistrationType<RO>);
137
+ get registrationType(): RegistrationType<RO>;
138
+ abstract fillClientCapabilities(capabilities: ClientCapabilities): void;
139
+ abstract initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector | undefined): void;
140
+ getState(): FeatureState;
141
+ register(data: RegistrationData<RO>): void;
142
+ unregister(id: string): void;
143
+ clear(): void;
144
+ /**
145
+ * Get registration info from server capabilities
146
+ */
147
+ protected getRegistration(documentSelector: DocumentSelector | undefined, capability: undefined | PO | (RO & StaticRegistrationOptions)): [string | undefined, (RO & {
148
+ documentSelector: DocumentSelector;
149
+ }) | undefined];
150
+ protected getRegistrationOptions(documentSelector: DocumentSelector | undefined, capability: undefined | PO): (RO & {
151
+ documentSelector: DocumentSelector;
152
+ }) | undefined;
153
+ }
154
+ /**
155
+ * Base class for workspace features
156
+ */
157
+ export declare abstract class WorkspaceFeature<RO, MW = any> implements DynamicFeature<RO> {
158
+ protected readonly _client: any;
159
+ protected readonly _registrations: Map<string, {
160
+ disposable?: {
161
+ dispose(): void;
162
+ };
163
+ }>;
164
+ protected readonly _registrationType: RegistrationType<RO>;
165
+ constructor(_client: any, registrationType: RegistrationType<RO>);
166
+ get registrationType(): RegistrationType<RO>;
167
+ abstract fillClientCapabilities(capabilities: ClientCapabilities): void;
168
+ abstract initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector | undefined): void;
169
+ getState(): FeatureState;
170
+ register(data: RegistrationData<RO>): void;
171
+ unregister(id: string): void;
172
+ clear(): void;
173
+ }
174
+ export interface Feature {
175
+ /**
176
+ * Called to fill the initialize params.
177
+ */
178
+ fillInitializeParams?: (params: InitializeParams) => void;
179
+ /**
180
+ * Called to fill in the client capabilities this feature implements.
181
+ */
182
+ fillClientCapabilities(capabilities: ClientCapabilities): void;
183
+ /**
184
+ * Initialize the feature. This method is called when the client has successfully
185
+ * received the initialize request from the server.
186
+ */
187
+ initialize(capabilities: ServerCapabilities): void;
188
+ /**
189
+ * Called when the client is stopped to clear this feature.
190
+ */
191
+ clear(): void;
192
+ }
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkspaceFeature = exports.TextDocumentFeature = exports.DynamicFeature = exports.StaticFeature = void 0;
4
+ exports.ensure = ensure;
5
+ const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
6
+ const Is = require("./utils/is");
7
+ const UUID = require("./utils/uuid");
8
+ /**
9
+ * Helper function to ensure a property exists on an object
10
+ */
11
+ function ensure(target, key) {
12
+ if (target[key] === undefined) {
13
+ target[key] = {};
14
+ }
15
+ return target[key];
16
+ }
17
+ var StaticFeature;
18
+ (function (StaticFeature) {
19
+ function is(value) {
20
+ const candidate = value;
21
+ return candidate !== undefined && candidate !== null &&
22
+ Is.func(candidate.fillClientCapabilities) &&
23
+ Is.func(candidate.initialize) &&
24
+ Is.func(candidate.getState) &&
25
+ Is.func(candidate.clear) &&
26
+ (candidate.fillInitializeParams === undefined || Is.func(candidate.fillInitializeParams));
27
+ }
28
+ StaticFeature.is = is;
29
+ })(StaticFeature || (exports.StaticFeature = StaticFeature = {}));
30
+ var DynamicFeature;
31
+ (function (DynamicFeature) {
32
+ function is(value) {
33
+ const candidate = value;
34
+ return candidate !== undefined && candidate !== null &&
35
+ Is.func(candidate.fillClientCapabilities) &&
36
+ Is.func(candidate.initialize) &&
37
+ Is.func(candidate.getState) &&
38
+ Is.func(candidate.clear) &&
39
+ (candidate.fillInitializeParams === undefined || Is.func(candidate.fillInitializeParams)) &&
40
+ Is.func(candidate.register) &&
41
+ Is.func(candidate.unregister) &&
42
+ candidate.registrationType !== undefined;
43
+ }
44
+ DynamicFeature.is = is;
45
+ })(DynamicFeature || (exports.DynamicFeature = DynamicFeature = {}));
46
+ /**
47
+ * Base class for features that work with text documents
48
+ */
49
+ class TextDocumentFeature {
50
+ constructor(_client, registrationType) {
51
+ this._client = _client;
52
+ this._registrations = new Map();
53
+ this._registrationType = registrationType;
54
+ }
55
+ get registrationType() {
56
+ return this._registrationType;
57
+ }
58
+ getState() {
59
+ const registrations = this._registrations.size > 0;
60
+ return { kind: 'document', id: this.registrationType.method, registrations, matches: registrations };
61
+ }
62
+ register(data) {
63
+ if (!data.registerOptions.documentSelector) {
64
+ return;
65
+ }
66
+ this._registrations.set(data.id, { data });
67
+ }
68
+ unregister(id) {
69
+ const registration = this._registrations.get(id);
70
+ if (registration !== undefined) {
71
+ this._registrations.delete(id);
72
+ if (registration.disposable) {
73
+ registration.disposable.dispose();
74
+ }
75
+ }
76
+ }
77
+ clear() {
78
+ this._registrations.forEach((value) => {
79
+ if (value.disposable) {
80
+ value.disposable.dispose();
81
+ }
82
+ });
83
+ this._registrations.clear();
84
+ }
85
+ /**
86
+ * Get registration info from server capabilities
87
+ */
88
+ getRegistration(documentSelector, capability) {
89
+ var _a;
90
+ if (!capability) {
91
+ return [undefined, undefined];
92
+ }
93
+ else if (vscode_languageserver_protocol_1.TextDocumentRegistrationOptions.is(capability)) {
94
+ const id = vscode_languageserver_protocol_1.StaticRegistrationOptions.hasId(capability) ? capability.id : UUID.generateUuid();
95
+ const selector = (_a = capability.documentSelector) !== null && _a !== void 0 ? _a : documentSelector;
96
+ if (selector) {
97
+ return [id, Object.assign({}, capability, { documentSelector: selector })];
98
+ }
99
+ }
100
+ else if (Is.boolean(capability) && capability === true || vscode_languageserver_protocol_1.WorkDoneProgressOptions.is(capability)) {
101
+ if (!documentSelector) {
102
+ return [undefined, undefined];
103
+ }
104
+ const options = (Is.boolean(capability) && capability === true
105
+ ? { documentSelector }
106
+ : Object.assign({}, capability, { documentSelector }));
107
+ return [UUID.generateUuid(), options];
108
+ }
109
+ return [undefined, undefined];
110
+ }
111
+ getRegistrationOptions(documentSelector, capability) {
112
+ if (!documentSelector || !capability) {
113
+ return undefined;
114
+ }
115
+ return (Is.boolean(capability) && capability === true
116
+ ? { documentSelector }
117
+ : Object.assign({}, capability, { documentSelector }));
118
+ }
119
+ }
120
+ exports.TextDocumentFeature = TextDocumentFeature;
121
+ /**
122
+ * Base class for workspace features
123
+ */
124
+ class WorkspaceFeature {
125
+ constructor(_client, registrationType) {
126
+ this._client = _client;
127
+ this._registrations = new Map();
128
+ this._registrationType = registrationType;
129
+ }
130
+ get registrationType() {
131
+ return this._registrationType;
132
+ }
133
+ getState() {
134
+ const registrations = this._registrations.size > 0;
135
+ return { kind: 'workspace', id: this.registrationType.method, registrations };
136
+ }
137
+ register(data) {
138
+ this._registrations.set(data.id, {});
139
+ }
140
+ unregister(id) {
141
+ const registration = this._registrations.get(id);
142
+ if (registration !== undefined) {
143
+ this._registrations.delete(id);
144
+ if (registration.disposable) {
145
+ registration.disposable.dispose();
146
+ }
147
+ }
148
+ }
149
+ clear() {
150
+ this._registrations.forEach((value) => {
151
+ if (value.disposable) {
152
+ value.disposable.dispose();
153
+ }
154
+ });
155
+ this._registrations.clear();
156
+ }
157
+ }
158
+ exports.WorkspaceFeature = WorkspaceFeature;
159
+ //# sourceMappingURL=Feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Feature.js","sourceRoot":"","sources":["../../src/common/Feature.ts"],"names":[],"mappings":";;;AAgBA,wBAKC;AArBD,mFASwC;AACxC,iCAAiC;AACjC,qCAAqC;AAErC;;GAEG;AACH,SAAgB,MAAM,CAAuB,MAAS,EAAE,GAAM;IAC1D,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC,GAAG,EAAS,CAAC;IAC5B,CAAC;IACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AA2ED,IAAiB,aAAa,CAU7B;AAVD,WAAiB,aAAa;IAC1B,SAAgB,EAAE,CAAC,KAAU;QACzB,MAAM,SAAS,GAAkB,KAAK,CAAC;QACvC,OAAO,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,IAAI;YAChD,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC;YACzC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;YAC7B,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;YAC3B,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YACxB,CAAC,SAAS,CAAC,oBAAoB,KAAK,SAAS,IAAI,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,oBAAoB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,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IAChC,CAAC;CACJ;AA/CD,4CA+CC"}
@@ -0,0 +1,230 @@
1
+ import { MessageConnection, InitializeResult, DidOpenTextDocumentParams, DidChangeTextDocumentParams, DidCloseTextDocumentParams, DidSaveTextDocumentParams, ClientCapabilities, ServerCapabilities, DocumentSelector, RegistrationParams, UnregistrationParams, ProtocolNotificationType, ProtocolNotificationType0, ProtocolRequestType, ProtocolRequestType0, NotificationType, NotificationType0, RequestType, RequestType0, CancellationToken, NotificationHandler, NotificationHandler0, RequestHandler, RequestHandler0, GenericNotificationHandler, GenericRequestHandler, TextDocumentSyncKind } from 'vscode-languageserver-protocol';
2
+ import { IHost } from '../interfaces/IHost';
3
+ import { ITransport } from '../transports/ITransport';
4
+ import { Feature, StaticFeature, DynamicFeature } from './Feature';
5
+ /**
6
+ * Client state enum
7
+ */
8
+ export declare enum ClientState {
9
+ Initial = "initial",
10
+ Starting = "starting",
11
+ StartFailed = "startFailed",
12
+ Running = "running",
13
+ Stopping = "stopping",
14
+ Stopped = "stopped"
15
+ }
16
+ /**
17
+ * Public state for external consumers
18
+ */
19
+ export declare enum State {
20
+ Stopped = 1,
21
+ Starting = 3,
22
+ StartFailed = 4,
23
+ Running = 2
24
+ }
25
+ /**
26
+ * State change event
27
+ */
28
+ export interface StateChangeEvent {
29
+ oldState: State;
30
+ newState: State;
31
+ }
32
+ /**
33
+ * Error action enum
34
+ */
35
+ export declare enum ErrorAction {
36
+ Continue = 1,
37
+ Shutdown = 2
38
+ }
39
+ /**
40
+ * Close action enum
41
+ */
42
+ export declare enum CloseAction {
43
+ DoNotRestart = 1,
44
+ Restart = 2
45
+ }
46
+ /**
47
+ * Error handler interface
48
+ */
49
+ export interface ErrorHandler {
50
+ error(error: Error, message: any | undefined, count: number | undefined): {
51
+ action: ErrorAction;
52
+ };
53
+ closed(): {
54
+ action: CloseAction;
55
+ };
56
+ }
57
+ /**
58
+ * Middleware interface for intercepting requests/notifications
59
+ */
60
+ export interface Middleware {
61
+ didOpen?: (params: DidOpenTextDocumentParams, next: (params: DidOpenTextDocumentParams) => void) => void;
62
+ didChange?: (params: DidChangeTextDocumentParams, next: (params: DidChangeTextDocumentParams) => void) => void;
63
+ didClose?: (params: DidCloseTextDocumentParams, next: (params: DidCloseTextDocumentParams) => void) => void;
64
+ didSave?: (params: DidSaveTextDocumentParams, next: (params: DidSaveTextDocumentParams) => void) => void;
65
+ handleDiagnostics?: (uri: string, diagnostics: any[], next: (uri: string, diagnostics: any[]) => void) => void;
66
+ handleRegisterCapability?: (params: RegistrationParams, next: (params: RegistrationParams) => Promise<void>) => Promise<void>;
67
+ handleUnregisterCapability?: (params: UnregistrationParams, next: (params: UnregistrationParams) => Promise<void>) => Promise<void>;
68
+ }
69
+ /**
70
+ * Language Client options
71
+ */
72
+ export interface LanguageClientOptions {
73
+ documentSelector?: DocumentSelector;
74
+ middleware?: Middleware;
75
+ initializationOptions?: any | (() => any);
76
+ errorHandler?: ErrorHandler;
77
+ }
78
+ /**
79
+ * Resolved text document sync capabilities
80
+ */
81
+ export interface ResolvedTextDocumentSyncCapabilities {
82
+ openClose?: boolean;
83
+ change?: TextDocumentSyncKind;
84
+ save?: {
85
+ includeText?: boolean;
86
+ } | boolean;
87
+ }
88
+ /**
89
+ * Event emitter for state changes
90
+ */
91
+ type StateChangeListener = (event: StateChangeEvent) => void;
92
+ export declare class LanguageClient {
93
+ private host;
94
+ private transport;
95
+ private clientCapabilities;
96
+ private options;
97
+ private connection;
98
+ private _features;
99
+ private _dynamicFeatures;
100
+ private _legacyFeatures;
101
+ private _state;
102
+ private _initializeResult;
103
+ private _capabilities;
104
+ private _onStart;
105
+ private _onStop;
106
+ private _stateChangeListeners;
107
+ private _errorHandler;
108
+ private _middleware;
109
+ private _documentSelector;
110
+ private _ignoredRegistrations;
111
+ constructor(host: IHost, transport: ITransport, clientCapabilities?: ClientCapabilities, options?: LanguageClientOptions);
112
+ /**
113
+ * Get current state
114
+ */
115
+ get state(): State;
116
+ private get $state();
117
+ private set $state(value);
118
+ private getPublicState;
119
+ /**
120
+ * Add state change listener
121
+ */
122
+ onDidChangeState(listener: StateChangeListener): {
123
+ dispose(): void;
124
+ };
125
+ /**
126
+ * Get initialize result
127
+ */
128
+ get initializeResult(): InitializeResult | undefined;
129
+ /**
130
+ * Get server capabilities
131
+ */
132
+ get capabilities(): ServerCapabilities | undefined;
133
+ /**
134
+ * Check if client is running
135
+ */
136
+ isRunning(): boolean;
137
+ /**
138
+ * Register a legacy feature
139
+ */
140
+ registerFeature(feature: Feature): void;
141
+ /**
142
+ * Register a static or dynamic feature
143
+ */
144
+ registerFeatures(features: (StaticFeature | DynamicFeature<any>)[]): void;
145
+ /**
146
+ * Register a single static or dynamic feature
147
+ */
148
+ registerStaticOrDynamicFeature(feature: StaticFeature | DynamicFeature<any>): void;
149
+ /**
150
+ * Get a dynamic feature by method
151
+ */
152
+ getFeature(method: string): DynamicFeature<any> | undefined;
153
+ /**
154
+ * Start the language client
155
+ */
156
+ start(): Promise<void>;
157
+ private doStart;
158
+ private registerBuiltinListeners;
159
+ private initialize;
160
+ private handleRegistrationRequest;
161
+ private handleUnregistrationRequest;
162
+ /**
163
+ * Stop the language client
164
+ */
165
+ stop(timeout?: number): Promise<void>;
166
+ private doStop;
167
+ /**
168
+ * Send a request to the server
169
+ */
170
+ sendRequest<R, PR, E, RO>(type: ProtocolRequestType0<R, PR, E, RO>, token?: CancellationToken): Promise<R>;
171
+ sendRequest<P, R, PR, E, RO>(type: ProtocolRequestType<P, R, PR, E, RO>, params: P, token?: CancellationToken): Promise<R>;
172
+ sendRequest<R, E>(type: RequestType0<R, E>, token?: CancellationToken): Promise<R>;
173
+ sendRequest<P, R, E>(type: RequestType<P, R, E>, params: P, token?: CancellationToken): Promise<R>;
174
+ sendRequest<R>(method: string, token?: CancellationToken): Promise<R>;
175
+ sendRequest<R>(method: string, param: any, token?: CancellationToken): Promise<R>;
176
+ /**
177
+ * Register a request handler
178
+ */
179
+ onRequest<R, PR, E, RO>(type: ProtocolRequestType0<R, PR, E, RO>, handler: RequestHandler0<R, E>): {
180
+ dispose(): void;
181
+ };
182
+ onRequest<P, R, PR, E, RO>(type: ProtocolRequestType<P, R, PR, E, RO>, handler: RequestHandler<P, R, E>): {
183
+ dispose(): void;
184
+ };
185
+ onRequest<R, E>(type: RequestType0<R, E>, handler: RequestHandler0<R, E>): {
186
+ dispose(): void;
187
+ };
188
+ onRequest<P, R, E>(type: RequestType<P, R, E>, handler: RequestHandler<P, R, E>): {
189
+ dispose(): void;
190
+ };
191
+ onRequest<R, E>(method: string, handler: GenericRequestHandler<R, E>): {
192
+ dispose(): void;
193
+ };
194
+ /**
195
+ * Send a notification to the server
196
+ */
197
+ sendNotification<RO>(type: ProtocolNotificationType0<RO>): Promise<void>;
198
+ sendNotification<P, RO>(type: ProtocolNotificationType<P, RO>, params?: P): Promise<void>;
199
+ sendNotification(type: NotificationType0): Promise<void>;
200
+ sendNotification<P>(type: NotificationType<P>, params?: P): Promise<void>;
201
+ sendNotification(method: string): Promise<void>;
202
+ sendNotification(method: string, params: any): Promise<void>;
203
+ /**
204
+ * Register a notification handler
205
+ */
206
+ onNotification<RO>(type: ProtocolNotificationType0<RO>, handler: NotificationHandler0): {
207
+ dispose(): void;
208
+ };
209
+ onNotification<P, RO>(type: ProtocolNotificationType<P, RO>, handler: NotificationHandler<P>): {
210
+ dispose(): void;
211
+ };
212
+ onNotification(type: NotificationType0, handler: NotificationHandler0): {
213
+ dispose(): void;
214
+ };
215
+ onNotification<P>(type: NotificationType<P>, handler: NotificationHandler<P>): {
216
+ dispose(): void;
217
+ };
218
+ onNotification(method: string, handler: GenericNotificationHandler): {
219
+ dispose(): void;
220
+ };
221
+ didOpen(params: DidOpenTextDocumentParams): void;
222
+ didChange(params: DidChangeTextDocumentParams): void;
223
+ didClose(params: DidCloseTextDocumentParams): void;
224
+ didSave(params: DidSaveTextDocumentParams): void;
225
+ getConnection(): MessageConnection | undefined;
226
+ getHost(): IHost;
227
+ get middleware(): Middleware;
228
+ get documentSelector(): DocumentSelector | undefined;
229
+ }
230
+ export {};