@zzzen/pyright-internal 1.2.0-dev.20260705 → 1.2.0-dev.20260712
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/dist/tests/typeServer/inProcTypeServerTestUtils.d.ts +39 -0
- package/dist/tests/typeServer/inProcTypeServerTestUtils.js +366 -0
- package/dist/tests/typeServer/inProcTypeServerTestUtils.js.map +1 -0
- package/dist/tests/typeServer/notebook.typeServer.test.d.ts +1 -0
- package/dist/tests/typeServer/notebook.typeServer.test.js +315 -0
- package/dist/tests/typeServer/notebook.typeServer.test.js.map +1 -0
- package/dist/tests/typeServer/typeServer.inProc.test.d.ts +1 -0
- package/dist/tests/typeServer/typeServer.inProc.test.js +234 -0
- package/dist/tests/typeServer/typeServer.inProc.test.js.map +1 -0
- package/dist/tests/typeServer/typeServer.virtualFileRedirect.test.d.ts +1 -0
- package/dist/tests/typeServer/typeServer.virtualFileRedirect.test.js +298 -0
- package/dist/tests/typeServer/typeServer.virtualFileRedirect.test.js.map +1 -0
- package/dist/typeServer/cancellation.d.ts +5 -0
- package/dist/typeServer/cancellation.js +14 -0
- package/dist/typeServer/cancellation.js.map +1 -0
- package/dist/typeServer/diagnosticUtils.d.ts +4 -0
- package/dist/typeServer/diagnosticUtils.js +71 -0
- package/dist/typeServer/diagnosticUtils.js.map +1 -0
- package/dist/typeServer/enums.d.ts +14 -0
- package/dist/typeServer/enums.js +524 -0
- package/dist/typeServer/enums.js.map +1 -0
- package/dist/typeServer/eventEmitter.d.ts +12 -0
- package/dist/typeServer/eventEmitter.js +32 -0
- package/dist/typeServer/eventEmitter.js.map +1 -0
- package/dist/typeServer/nodeMain.d.ts +1 -0
- package/dist/typeServer/nodeMain.js +65 -0
- package/dist/typeServer/nodeMain.js.map +1 -0
- package/dist/typeServer/notebookCellChain.d.ts +34 -0
- package/dist/typeServer/notebookCellChain.js +182 -0
- package/dist/typeServer/notebookCellChain.js.map +1 -0
- package/dist/typeServer/notebookDocumentHandler.d.ts +23 -0
- package/dist/typeServer/notebookDocumentHandler.js +158 -0
- package/dist/typeServer/notebookDocumentHandler.js.map +1 -0
- package/dist/typeServer/notebookUriMapper.d.ts +39 -0
- package/dist/typeServer/notebookUriMapper.js +164 -0
- package/dist/typeServer/notebookUriMapper.js.map +1 -0
- package/dist/typeServer/profilingStub.d.ts +10 -0
- package/dist/typeServer/profilingStub.js +12 -0
- package/dist/typeServer/profilingStub.js.map +1 -0
- package/dist/typeServer/programTypes.d.ts +136 -0
- package/dist/typeServer/programTypes.js +3 -0
- package/dist/typeServer/programTypes.js.map +1 -0
- package/dist/typeServer/programWrapper.d.ts +134 -0
- package/dist/typeServer/programWrapper.js +731 -0
- package/dist/typeServer/programWrapper.js.map +1 -0
- package/dist/typeServer/protocol/tspSupplemental.d.ts +43 -0
- package/dist/typeServer/protocol/tspSupplemental.js +48 -0
- package/dist/typeServer/protocol/tspSupplemental.js.map +1 -0
- package/dist/typeServer/protocol/typeServerProtocol.d.ts +1102 -0
- package/dist/typeServer/protocol/typeServerProtocol.js +290 -0
- package/dist/typeServer/protocol/typeServerProtocol.js.map +1 -0
- package/dist/typeServer/server.d.ts +54 -0
- package/dist/typeServer/server.js +620 -0
- package/dist/typeServer/server.js.map +1 -0
- package/dist/typeServer/serverUtils.d.ts +4 -0
- package/dist/typeServer/serverUtils.js +21 -0
- package/dist/typeServer/serverUtils.js.map +1 -0
- package/dist/typeServer/stubGenerator.d.ts +42 -0
- package/dist/typeServer/stubGenerator.js +895 -0
- package/dist/typeServer/stubGenerator.js.map +1 -0
- package/dist/typeServer/typeCache.d.ts +31 -0
- package/dist/typeServer/typeCache.js +54 -0
- package/dist/typeServer/typeCache.js.map +1 -0
- package/dist/typeServer/typeEvalUtils.d.ts +13 -0
- package/dist/typeServer/typeEvalUtils.js +83 -0
- package/dist/typeServer/typeEvalUtils.js.map +1 -0
- package/dist/typeServer/typeGuards.d.ts +3 -0
- package/dist/typeServer/typeGuards.js +55 -0
- package/dist/typeServer/typeGuards.js.map +1 -0
- package/dist/typeServer/typeServerConversionTypes.d.ts +39 -0
- package/dist/typeServer/typeServerConversionTypes.js +448 -0
- package/dist/typeServer/typeServerConversionTypes.js.map +1 -0
- package/dist/typeServer/typeServerConversionUtils.d.ts +35 -0
- package/dist/typeServer/typeServerConversionUtils.js +524 -0
- package/dist/typeServer/typeServerConversionUtils.js.map +1 -0
- package/dist/typeServer/typeServerEvaluator.d.ts +16 -0
- package/dist/typeServer/typeServerEvaluator.js +36 -0
- package/dist/typeServer/typeServerEvaluator.js.map +1 -0
- package/dist/typeServer/typeServerFileSystem.d.ts +47 -0
- package/dist/typeServer/typeServerFileSystem.js +129 -0
- package/dist/typeServer/typeServerFileSystem.js.map +1 -0
- package/dist/typeServer/typeServerProtocolUtils.d.ts +2 -0
- package/dist/typeServer/typeServerProtocolUtils.js +7 -0
- package/dist/typeServer/typeServerProtocolUtils.js.map +1 -0
- package/dist/typeServer/typeServerServiceKeys.d.ts +7 -0
- package/dist/typeServer/typeServerServiceKeys.js +20 -0
- package/dist/typeServer/typeServerServiceKeys.js.map +1 -0
- package/dist/typeServer/typeUtils.d.ts +4 -0
- package/dist/typeServer/typeUtils.js +31 -0
- package/dist/typeServer/typeUtils.js.map +1 -0
- package/dist/typeServer/virtualFileOverlayFileSystem.d.ts +87 -0
- package/dist/typeServer/virtualFileOverlayFileSystem.js +181 -0
- package/dist/typeServer/virtualFileOverlayFileSystem.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypeServerProtocol = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* typeServerProtocol.ts
|
|
6
|
+
* Copyright (c) Microsoft Corporation.
|
|
7
|
+
* Licensed under the MIT license.
|
|
8
|
+
*
|
|
9
|
+
* Defines the interfaces and types for the type server protocol. A Type Server is a module that provides type information
|
|
10
|
+
* for code, such as type definitions, member information, and diagnostics.
|
|
11
|
+
*
|
|
12
|
+
* It's Python specific at the moment, but may be made generic in the future.
|
|
13
|
+
*
|
|
14
|
+
* This protocol is used to communicate between the type server and the client (e.g., a language server or an IDE).
|
|
15
|
+
*
|
|
16
|
+
* All the types in this file should be JSON serializable, as they are sent over the wire.
|
|
17
|
+
* The protocol is designed to be extensible, allowing for future additions of new requests and notifications.
|
|
18
|
+
*
|
|
19
|
+
* Single source of truth:
|
|
20
|
+
* - Within Pyright, this `.ts` file is authoritative. The sibling `tsp.json` and
|
|
21
|
+
* `tsp.schema.json` are GENERATED from it by `generate_json.py` (run that script
|
|
22
|
+
* after editing this file); do not hand-edit the JSON artifacts.
|
|
23
|
+
* - Across repos, this file is a synchronized copy of the canonical shared Type Server
|
|
24
|
+
* Protocol also consumed by Pylance. Version negotiation
|
|
25
|
+
* (`TypeServerVersion.current`) guards against gross cross-version mismatches, but it
|
|
26
|
+
* does NOT detect silent field-level drift within a version. Any wire-level change
|
|
27
|
+
* must be mirrored in the other repo's copy and coordinated cross-repo so the two
|
|
28
|
+
* cannot diverge.
|
|
29
|
+
*/
|
|
30
|
+
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
|
|
31
|
+
var TypeServerProtocol;
|
|
32
|
+
(function (TypeServerProtocol) {
|
|
33
|
+
TypeServerProtocol.ReturnSymbolName = '__return__'; // Special name for the return value of a function or method.
|
|
34
|
+
TypeServerProtocol.InvalidHandle = -1; // Special value for an invalid handle. This is used to indicate that a type or declaration is not valid.
|
|
35
|
+
/**
|
|
36
|
+
* Version of the type server protocol.
|
|
37
|
+
* Used for protocol negotiation between client and server to ensure compatibility.
|
|
38
|
+
*
|
|
39
|
+
* The version follows semantic versioning (semver), with the usual 0.x caveat:
|
|
40
|
+
* - Major version changes indicate breaking changes to the protocol
|
|
41
|
+
* - While the protocol is 0.x, minor version changes may indicate breaking changes
|
|
42
|
+
* - Patch version changes remain backward compatible
|
|
43
|
+
*
|
|
44
|
+
* Clients should check the server's supported version before making requests.
|
|
45
|
+
*/
|
|
46
|
+
let TypeServerVersion;
|
|
47
|
+
(function (TypeServerVersion) {
|
|
48
|
+
TypeServerVersion["v0_1_0"] = "0.1.0";
|
|
49
|
+
TypeServerVersion["v0_2_0"] = "0.2.0";
|
|
50
|
+
TypeServerVersion["v0_3_0"] = "0.3.0";
|
|
51
|
+
TypeServerVersion["v0_4_0"] = "0.4.0";
|
|
52
|
+
TypeServerVersion["current"] = "0.4.1";
|
|
53
|
+
})(TypeServerVersion = TypeServerProtocol.TypeServerVersion || (TypeServerProtocol.TypeServerVersion = {}));
|
|
54
|
+
/**
|
|
55
|
+
* Built-in transport kinds supported by the multi-connection protocol.
|
|
56
|
+
*
|
|
57
|
+
* The main connection may use any transport the server supports, but extra
|
|
58
|
+
* dynamically-opened connections are negotiated separately and are currently
|
|
59
|
+
* limited to local IPC.
|
|
60
|
+
*/
|
|
61
|
+
let ConnectionTransportKind;
|
|
62
|
+
(function (ConnectionTransportKind) {
|
|
63
|
+
ConnectionTransportKind["Ipc"] = "ipc";
|
|
64
|
+
})(ConnectionTransportKind = TypeServerProtocol.ConnectionTransportKind || (TypeServerProtocol.ConnectionTransportKind = {}));
|
|
65
|
+
// Flags that describe the characteristics of a type.
|
|
66
|
+
// These flags can be combined using bitwise operations.
|
|
67
|
+
let TypeFlags;
|
|
68
|
+
(function (TypeFlags) {
|
|
69
|
+
TypeFlags[TypeFlags["None"] = 0] = "None";
|
|
70
|
+
TypeFlags[TypeFlags["Instantiable"] = 1] = "Instantiable";
|
|
71
|
+
TypeFlags[TypeFlags["Instance"] = 2] = "Instance";
|
|
72
|
+
TypeFlags[TypeFlags["Callable"] = 4] = "Callable";
|
|
73
|
+
TypeFlags[TypeFlags["Literal"] = 8] = "Literal";
|
|
74
|
+
TypeFlags[TypeFlags["Interface"] = 16] = "Interface";
|
|
75
|
+
TypeFlags[TypeFlags["Generic"] = 32] = "Generic";
|
|
76
|
+
TypeFlags[TypeFlags["FromAlias"] = 64] = "FromAlias";
|
|
77
|
+
TypeFlags[TypeFlags["Unpacked"] = 128] = "Unpacked";
|
|
78
|
+
TypeFlags[TypeFlags["Optional"] = 256] = "Optional";
|
|
79
|
+
TypeFlags[TypeFlags["Unbound"] = 512] = "Unbound";
|
|
80
|
+
})(TypeFlags = TypeServerProtocol.TypeFlags || (TypeServerProtocol.TypeFlags = {}));
|
|
81
|
+
// Represents the category of a declaration in the type system.
|
|
82
|
+
// This is used to classify declarations such as variables, functions, classes, etc.
|
|
83
|
+
let DeclarationCategory;
|
|
84
|
+
(function (DeclarationCategory) {
|
|
85
|
+
DeclarationCategory[DeclarationCategory["Intrinsic"] = 0] = "Intrinsic";
|
|
86
|
+
DeclarationCategory[DeclarationCategory["Variable"] = 1] = "Variable";
|
|
87
|
+
DeclarationCategory[DeclarationCategory["Param"] = 2] = "Param";
|
|
88
|
+
DeclarationCategory[DeclarationCategory["TypeParam"] = 3] = "TypeParam";
|
|
89
|
+
DeclarationCategory[DeclarationCategory["TypeAlias"] = 4] = "TypeAlias";
|
|
90
|
+
DeclarationCategory[DeclarationCategory["Function"] = 5] = "Function";
|
|
91
|
+
DeclarationCategory[DeclarationCategory["Class"] = 6] = "Class";
|
|
92
|
+
DeclarationCategory[DeclarationCategory["Import"] = 7] = "Import";
|
|
93
|
+
})(DeclarationCategory = TypeServerProtocol.DeclarationCategory || (TypeServerProtocol.DeclarationCategory = {}));
|
|
94
|
+
/**
|
|
95
|
+
* Discriminator for the Union type.
|
|
96
|
+
* Identifies which variant of Type is being used.
|
|
97
|
+
*
|
|
98
|
+
* Used for type narrowing when processing Type objects:
|
|
99
|
+
* ```typescript
|
|
100
|
+
* if (handle.kind === TypeKind.Function) {
|
|
101
|
+
* // TypeScript knows this is FunctionType
|
|
102
|
+
* const returnType = handle.returnType;
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* Categories:
|
|
107
|
+
* - BuiltIn: Special types (unknown, any, never, etc.)
|
|
108
|
+
* - Declared: Base type for source declarations (rarely used directly)
|
|
109
|
+
* - Function: Function or method types from def statements
|
|
110
|
+
* - Class: Class types from class statements
|
|
111
|
+
* - Union: Multiple types combined (T1 | T2 | ...)
|
|
112
|
+
* - Module: Python module types
|
|
113
|
+
* - TypeVar: Generic type parameters (T, P, Ts)
|
|
114
|
+
* - Overloaded: Functions with @overload decorators
|
|
115
|
+
* - Synthesized: Generated stub content for type server created types
|
|
116
|
+
* - TypeReference: Reference to another type by ID
|
|
117
|
+
*/
|
|
118
|
+
let TypeKind;
|
|
119
|
+
(function (TypeKind) {
|
|
120
|
+
TypeKind[TypeKind["BuiltIn"] = 0] = "BuiltIn";
|
|
121
|
+
TypeKind[TypeKind["Declared"] = 1] = "Declared";
|
|
122
|
+
TypeKind[TypeKind["Function"] = 2] = "Function";
|
|
123
|
+
TypeKind[TypeKind["Class"] = 3] = "Class";
|
|
124
|
+
TypeKind[TypeKind["Union"] = 4] = "Union";
|
|
125
|
+
TypeKind[TypeKind["Module"] = 5] = "Module";
|
|
126
|
+
TypeKind[TypeKind["TypeVar"] = 6] = "TypeVar";
|
|
127
|
+
TypeKind[TypeKind["Overloaded"] = 7] = "Overloaded";
|
|
128
|
+
TypeKind[TypeKind["Synthesized"] = 8] = "Synthesized";
|
|
129
|
+
TypeKind[TypeKind["TypeReference"] = 9] = "TypeReference";
|
|
130
|
+
})(TypeKind = TypeServerProtocol.TypeKind || (TypeServerProtocol.TypeKind = {}));
|
|
131
|
+
/**
|
|
132
|
+
* Discriminator for the Declaration union type.
|
|
133
|
+
* Distinguishes between declarations that exist in source code versus those created by the type checker.
|
|
134
|
+
*
|
|
135
|
+
* Used to determine whether a declaration:
|
|
136
|
+
* - Has an actual AST node in the parse tree (Regular)
|
|
137
|
+
* - Was created implicitly by the type system (Synthesized)
|
|
138
|
+
*
|
|
139
|
+
* Examples:
|
|
140
|
+
* - Regular: `def my_function():` - has source code node
|
|
141
|
+
* - Synthesized: `__init__` method generated by @dataclass - no source node
|
|
142
|
+
* - Regular: `class MyClass:` - has source code node
|
|
143
|
+
* - Synthesized: Built-in `len` function - no user source code
|
|
144
|
+
*/
|
|
145
|
+
let DeclarationKind;
|
|
146
|
+
(function (DeclarationKind) {
|
|
147
|
+
DeclarationKind[DeclarationKind["Regular"] = 0] = "Regular";
|
|
148
|
+
DeclarationKind[DeclarationKind["Synthesized"] = 1] = "Synthesized";
|
|
149
|
+
})(DeclarationKind = TypeServerProtocol.DeclarationKind || (TypeServerProtocol.DeclarationKind = {}));
|
|
150
|
+
/**
|
|
151
|
+
* Describes the variance of a type parameter in a generic type.
|
|
152
|
+
* Variance controls how subtyping relationships work with generic types.
|
|
153
|
+
*
|
|
154
|
+
* Variance rules:
|
|
155
|
+
* - Covariant: If A is a subtype of B, then Generic[A] is a subtype of Generic[B]
|
|
156
|
+
* - Used when the type parameter appears only in output positions (return types)
|
|
157
|
+
* - Example: Tuple[T] is covariant in T
|
|
158
|
+
*
|
|
159
|
+
* - Contravariant: If A is a subtype of B, then Generic[B] is a subtype of Generic[A]
|
|
160
|
+
* - Used when the type parameter appears only in input positions (parameters)
|
|
161
|
+
* - Example: Callable[[T], None] is contravariant in T
|
|
162
|
+
*
|
|
163
|
+
* - Invariant: No subtyping relationship exists regardless of T
|
|
164
|
+
* - Used when the type parameter appears in both input and output positions
|
|
165
|
+
* - Example: List[T] is invariant in T
|
|
166
|
+
*
|
|
167
|
+
* Examples:
|
|
168
|
+
* ```python
|
|
169
|
+
* from typing import TypeVar, Generic
|
|
170
|
+
*
|
|
171
|
+
* T_co = TypeVar('T_co', covariant=True) # Covariant
|
|
172
|
+
* T_contra = TypeVar('T_contra', contravariant=True) # Contravariant
|
|
173
|
+
* T = TypeVar('T') # Invariant by default
|
|
174
|
+
*
|
|
175
|
+
* class Container(Generic[T_co]): # Covariant
|
|
176
|
+
* def get(self) -> T_co: ... # T_co in output position only
|
|
177
|
+
*
|
|
178
|
+
* class Consumer(Generic[T_contra]): # Contravariant
|
|
179
|
+
* def accept(self, value: T_contra) -> None: ... # T_contra in input only
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
let Variance;
|
|
183
|
+
(function (Variance) {
|
|
184
|
+
Variance[Variance["Auto"] = 0] = "Auto";
|
|
185
|
+
Variance[Variance["Unknown"] = 1] = "Unknown";
|
|
186
|
+
Variance[Variance["Invariant"] = 2] = "Invariant";
|
|
187
|
+
Variance[Variance["Covariant"] = 3] = "Covariant";
|
|
188
|
+
Variance[Variance["Contravariant"] = 4] = "Contravariant";
|
|
189
|
+
})(Variance = TypeServerProtocol.Variance || (TypeServerProtocol.Variance = {}));
|
|
190
|
+
// Requests and notifications for the type server protocol.
|
|
191
|
+
// Request for the computed type of a declaration or node. Computed type is the type that is inferred based on the code flow.
|
|
192
|
+
//
|
|
193
|
+
// Example:
|
|
194
|
+
// def foo(a: int | str):
|
|
195
|
+
// if instanceof(a, int):
|
|
196
|
+
// b = a + 1 # Computed type of 'b' is 'int'
|
|
197
|
+
let GetComputedTypeRequest;
|
|
198
|
+
(function (GetComputedTypeRequest) {
|
|
199
|
+
GetComputedTypeRequest.method = 'typeServer/getComputedType';
|
|
200
|
+
GetComputedTypeRequest.messageDirection = vscode_languageserver_protocol_1.MessageDirection.clientToServer;
|
|
201
|
+
GetComputedTypeRequest.type = new vscode_languageserver_protocol_1.ProtocolRequestType(GetComputedTypeRequest.method);
|
|
202
|
+
})(GetComputedTypeRequest = TypeServerProtocol.GetComputedTypeRequest || (TypeServerProtocol.GetComputedTypeRequest = {}));
|
|
203
|
+
// Request for the declared type of a declaration or node. Declared type is the type that is explicitly declared in the source code.
|
|
204
|
+
//
|
|
205
|
+
// Example:
|
|
206
|
+
// def foo(a: int | str): # Declared type of parameter 'a' is 'int | str'
|
|
207
|
+
// pass
|
|
208
|
+
let GetDeclaredTypeRequest;
|
|
209
|
+
(function (GetDeclaredTypeRequest) {
|
|
210
|
+
GetDeclaredTypeRequest.method = 'typeServer/getDeclaredType';
|
|
211
|
+
GetDeclaredTypeRequest.messageDirection = vscode_languageserver_protocol_1.MessageDirection.clientToServer;
|
|
212
|
+
GetDeclaredTypeRequest.type = new vscode_languageserver_protocol_1.ProtocolRequestType(GetDeclaredTypeRequest.method);
|
|
213
|
+
})(GetDeclaredTypeRequest = TypeServerProtocol.GetDeclaredTypeRequest || (TypeServerProtocol.GetDeclaredTypeRequest = {}));
|
|
214
|
+
// Request for the expected type of a declaration or node. Expected type is the type that the context expects.
|
|
215
|
+
//
|
|
216
|
+
// Example:
|
|
217
|
+
// def foo(a: int | str):
|
|
218
|
+
// pass
|
|
219
|
+
// foo(4) # Expected type of argument 'a' is 'int | str'
|
|
220
|
+
let GetExpectedTypeRequest;
|
|
221
|
+
(function (GetExpectedTypeRequest) {
|
|
222
|
+
GetExpectedTypeRequest.method = 'typeServer/getExpectedType';
|
|
223
|
+
GetExpectedTypeRequest.messageDirection = vscode_languageserver_protocol_1.MessageDirection.clientToServer;
|
|
224
|
+
GetExpectedTypeRequest.type = new vscode_languageserver_protocol_1.ProtocolRequestType(GetExpectedTypeRequest.method);
|
|
225
|
+
})(GetExpectedTypeRequest = TypeServerProtocol.GetExpectedTypeRequest || (TypeServerProtocol.GetExpectedTypeRequest = {}));
|
|
226
|
+
/**
|
|
227
|
+
* Request to get the search paths that the type server uses for Python modules.
|
|
228
|
+
*/
|
|
229
|
+
let GetPythonSearchPathsRequest;
|
|
230
|
+
(function (GetPythonSearchPathsRequest) {
|
|
231
|
+
GetPythonSearchPathsRequest.method = 'typeServer/getPythonSearchPaths';
|
|
232
|
+
GetPythonSearchPathsRequest.messageDirection = vscode_languageserver_protocol_1.MessageDirection.clientToServer;
|
|
233
|
+
GetPythonSearchPathsRequest.type = new vscode_languageserver_protocol_1.ProtocolRequestType(GetPythonSearchPathsRequest.method);
|
|
234
|
+
})(GetPythonSearchPathsRequest = TypeServerProtocol.GetPythonSearchPathsRequest || (TypeServerProtocol.GetPythonSearchPathsRequest = {}));
|
|
235
|
+
/**
|
|
236
|
+
* Request from client to get the current snapshot of the type server.
|
|
237
|
+
* A snapshot is a point-in-time representation of the type server's state, including all loaded files and their types.
|
|
238
|
+
* A type server should change its snapshot whenever any type it might have returned is no longer valid. Meaning types are
|
|
239
|
+
* only usable for the snapshot they were returned with.
|
|
240
|
+
*
|
|
241
|
+
* Snapshots are not meant to survive any changes that would make the type server throw away its internal cache. They are merely an
|
|
242
|
+
* identifier to indicate to the client that the type server will accept requests for types from that snapshot.
|
|
243
|
+
*/
|
|
244
|
+
let GetSnapshotRequest;
|
|
245
|
+
(function (GetSnapshotRequest) {
|
|
246
|
+
GetSnapshotRequest.method = 'typeServer/getSnapshot';
|
|
247
|
+
GetSnapshotRequest.messageDirection = vscode_languageserver_protocol_1.MessageDirection.clientToServer;
|
|
248
|
+
GetSnapshotRequest.type = new vscode_languageserver_protocol_1.ProtocolRequestType0(GetSnapshotRequest.method);
|
|
249
|
+
})(GetSnapshotRequest = TypeServerProtocol.GetSnapshotRequest || (TypeServerProtocol.GetSnapshotRequest = {}));
|
|
250
|
+
/**
|
|
251
|
+
* Request to get the version of the protocol the type server supports.
|
|
252
|
+
*
|
|
253
|
+
* Returns a string representation of the protocol version (should be semver format)
|
|
254
|
+
*/
|
|
255
|
+
let GetSupportedProtocolVersionRequest;
|
|
256
|
+
(function (GetSupportedProtocolVersionRequest) {
|
|
257
|
+
GetSupportedProtocolVersionRequest.method = 'typeServer/getSupportedProtocolVersion';
|
|
258
|
+
GetSupportedProtocolVersionRequest.messageDirection = vscode_languageserver_protocol_1.MessageDirection.clientToServer;
|
|
259
|
+
GetSupportedProtocolVersionRequest.type = new vscode_languageserver_protocol_1.ProtocolRequestType0(GetSupportedProtocolVersionRequest.method);
|
|
260
|
+
})(GetSupportedProtocolVersionRequest = TypeServerProtocol.GetSupportedProtocolVersionRequest || (TypeServerProtocol.GetSupportedProtocolVersionRequest = {}));
|
|
261
|
+
/**
|
|
262
|
+
* Request to resolve an import. This is used to resolve the import name to its location in the file system.
|
|
263
|
+
*/
|
|
264
|
+
let ResolveImportRequest;
|
|
265
|
+
(function (ResolveImportRequest) {
|
|
266
|
+
ResolveImportRequest.method = 'typeServer/resolveImport';
|
|
267
|
+
ResolveImportRequest.messageDirection = vscode_languageserver_protocol_1.MessageDirection.clientToServer;
|
|
268
|
+
ResolveImportRequest.type = new vscode_languageserver_protocol_1.ProtocolRequestType(ResolveImportRequest.method);
|
|
269
|
+
})(ResolveImportRequest = TypeServerProtocol.ResolveImportRequest || (TypeServerProtocol.ResolveImportRequest = {}));
|
|
270
|
+
/**
|
|
271
|
+
* Main-connection-only request used to open or close an extra TSP transport.
|
|
272
|
+
* Extra transports must remain read-only and must not be used for LSP traffic.
|
|
273
|
+
*/
|
|
274
|
+
let ConnectionRequest;
|
|
275
|
+
(function (ConnectionRequest) {
|
|
276
|
+
ConnectionRequest.method = 'typeServer/connection';
|
|
277
|
+
ConnectionRequest.messageDirection = vscode_languageserver_protocol_1.MessageDirection.clientToServer;
|
|
278
|
+
ConnectionRequest.type = new vscode_languageserver_protocol_1.ProtocolRequestType(ConnectionRequest.method);
|
|
279
|
+
})(ConnectionRequest = TypeServerProtocol.ConnectionRequest || (TypeServerProtocol.ConnectionRequest = {}));
|
|
280
|
+
/**
|
|
281
|
+
* Notification sent by the server to indicate any outstanding snapshots are invalid.
|
|
282
|
+
*/
|
|
283
|
+
let SnapshotChangedNotification;
|
|
284
|
+
(function (SnapshotChangedNotification) {
|
|
285
|
+
SnapshotChangedNotification.method = 'typeServer/snapshotChanged';
|
|
286
|
+
SnapshotChangedNotification.messageDirection = vscode_languageserver_protocol_1.MessageDirection.serverToClient;
|
|
287
|
+
SnapshotChangedNotification.type = new vscode_languageserver_protocol_1.ProtocolNotificationType(SnapshotChangedNotification.method);
|
|
288
|
+
})(SnapshotChangedNotification = TypeServerProtocol.SnapshotChangedNotification || (TypeServerProtocol.SnapshotChangedNotification = {}));
|
|
289
|
+
})(TypeServerProtocol || (exports.TypeServerProtocol = TypeServerProtocol = {}));
|
|
290
|
+
//# sourceMappingURL=typeServerProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeServerProtocol.js","sourceRoot":"","sources":["../../../../../../src/typeServer/protocol/typeServerProtocol.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,mFAMwC;AAExC,IAAiB,kBAAkB,CAo1ClC;AAp1CD,WAAiB,kBAAkB;IAClB,mCAAgB,GAAG,YAAY,CAAC,CAAC,6DAA6D;IAC9F,gCAAa,GAAG,CAAC,CAAC,CAAC,CAAC,yGAAyG;IA0B1I;;;;;;;;;;OAUG;IACH,IAAY,iBAMX;IAND,WAAY,iBAAiB;QACzB,qCAAgB,CAAA;QAChB,qCAAgB,CAAA;QAChB,qCAAgB,CAAA;QAChB,qCAAgB,CAAA;QAChB,sCAAiB,CAAA;IACrB,CAAC,EANW,iBAAiB,GAAjB,oCAAiB,KAAjB,oCAAiB,QAM5B;IAED;;;;;;OAMG;IACH,IAAY,uBAEX;IAFD,WAAY,uBAAuB;QAC/B,sCAAW,CAAA;IACf,CAAC,EAFW,uBAAuB,GAAvB,0CAAuB,KAAvB,0CAAuB,QAElC;IAyBD,qDAAqD;IACrD,wDAAwD;IACxD,IAAkB,SAYjB;IAZD,WAAkB,SAAS;QACvB,yCAAQ,CAAA;QACR,yDAAqB,CAAA;QACrB,iDAAiB,CAAA;QACjB,iDAAiB,CAAA;QACjB,+CAAgB,CAAA;QAChB,oDAAkB,CAAA;QAClB,gDAAgB,CAAA;QAChB,oDAAkB,CAAA;QAClB,mDAAiB,CAAA;QACjB,mDAAiB,CAAA;QACjB,iDAAgB,CAAA;IACpB,CAAC,EAZiB,SAAS,GAAT,4BAAS,KAAT,4BAAS,QAY1B;IAsBD,+DAA+D;IAC/D,oFAAoF;IACpF,IAAkB,mBASjB;IATD,WAAkB,mBAAmB;QACjC,uEAAS,CAAA;QACT,qEAAQ,CAAA;QACR,+DAAK,CAAA;QACL,uEAAS,CAAA;QACT,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ams, DidOpenTextDocumentParams, DocumentDiagnosticParams, ExecuteCommandParams, InitializeParams, InitializeResult } from 'vscode-languageserver-protocol';
|
|
3
|
+
import { CodeAction, Command } from 'vscode-languageserver-types';
|
|
4
|
+
import { ImportResolver } from '../analyzer/importResolver';
|
|
5
|
+
import { IPythonMode } from '../analyzer/sourceFile';
|
|
6
|
+
import { IBackgroundAnalysis } from '../backgroundAnalysisBase';
|
|
7
|
+
import { ConfigOptions } from '../common/configOptions';
|
|
8
|
+
import { Host } from '../common/host';
|
|
9
|
+
import { ServerOptions, ServerSettings } from '../common/languageServerInterface';
|
|
10
|
+
import { ProgressReporter } from '../common/progressReporter';
|
|
11
|
+
import { ServiceProvider } from '../common/serviceProvider';
|
|
12
|
+
import { Uri } from '../common/uri/uri';
|
|
13
|
+
import { LanguageServerBase } from '../languageServerBase';
|
|
14
|
+
import { Workspace } from '../workspaceFactory';
|
|
15
|
+
export declare class TypeServer extends LanguageServerBase {
|
|
16
|
+
private readonly _handleToUriMap;
|
|
17
|
+
private _initializedComplete;
|
|
18
|
+
private _globalTypeCache;
|
|
19
|
+
private _notebookManager;
|
|
20
|
+
private readonly _uriMapper;
|
|
21
|
+
constructor(serverOptions: ServerOptions, connection: Connection);
|
|
22
|
+
dispose(): void;
|
|
23
|
+
getWorkspaceForFile(fileUri: Uri, pythonPath?: Uri): Promise<Workspace>;
|
|
24
|
+
getContainingWorkspacesForFile(fileUri: Uri): Promise<Workspace[]>;
|
|
25
|
+
getSettings(workspace: Workspace): Promise<ServerSettings>;
|
|
26
|
+
createBackgroundAnalysis(serviceId: string, workspaceRoot: Uri): IBackgroundAnalysis | undefined;
|
|
27
|
+
protected isLongRunningCommand(command: string): boolean;
|
|
28
|
+
protected isRefactoringCommand(command: string): boolean;
|
|
29
|
+
protected executeCodeAction(params: CodeActionParams, token: CancellationToken): Promise<(Command | CodeAction)[] | undefined | null>;
|
|
30
|
+
protected createHost(): Host;
|
|
31
|
+
protected createImportResolver(serviceProvider: ServiceProvider, options: ConfigOptions, host: Host): ImportResolver;
|
|
32
|
+
protected createProgressReporter(): ProgressReporter;
|
|
33
|
+
protected executeCommand(params: ExecuteCommandParams, token: CancellationToken): Promise<any>;
|
|
34
|
+
protected setupConnection(supportedCommands: string[], supportedCodeActions: string[]): void;
|
|
35
|
+
protected initialize(params: InitializeParams, supportedCommands: string[], supportedCodeActions: string[]): Promise<InitializeResult>;
|
|
36
|
+
protected convertLspUriStringToUri(lspUri: string): Uri;
|
|
37
|
+
protected onInitialized(): void;
|
|
38
|
+
protected onWorkspaceCreated(workspace: Workspace): void;
|
|
39
|
+
protected onDidOpenTextDocument(params: DidOpenTextDocumentParams, ipythonMode?: IPythonMode): Promise<void>;
|
|
40
|
+
protected onDiagnostics(params: DocumentDiagnosticParams, token: CancellationToken): Promise<import("vscode-languageserver").RelatedFullDocumentDiagnosticReport>;
|
|
41
|
+
private _getStringValues;
|
|
42
|
+
private _getParserOutput;
|
|
43
|
+
private _getWorkspaceForUri;
|
|
44
|
+
private _getExistingIPythonMode;
|
|
45
|
+
private _getProgram;
|
|
46
|
+
private _onGetSnapshot;
|
|
47
|
+
private _onGetSupportedProtocolVersion;
|
|
48
|
+
private _onGetType;
|
|
49
|
+
private _onResolveImport;
|
|
50
|
+
private _onGetPythonSearchPaths;
|
|
51
|
+
private _onSetVirtualFileRedirect;
|
|
52
|
+
private _onRemoveVirtualFileRedirect;
|
|
53
|
+
private _onSnapshotChanged;
|
|
54
|
+
}
|