@jupyterlab/lsp 4.0.0-alpha.11 → 4.0.0-alpha.12
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/lib/adapters/adapter.d.ts +184 -54
- package/lib/adapters/adapter.js +177 -132
- package/lib/adapters/adapter.js.map +1 -1
- package/lib/adapters/statusmessage.d.ts +47 -0
- package/lib/adapters/statusmessage.js +74 -0
- package/lib/adapters/statusmessage.js.map +1 -0
- package/lib/connection.d.ts +113 -26
- package/lib/connection.js +166 -105
- package/lib/connection.js.map +1 -1
- package/lib/connection_manager.d.ts +143 -18
- package/lib/connection_manager.js +163 -49
- package/lib/connection_manager.js.map +1 -1
- package/lib/extractors/index.d.ts +3 -0
- package/lib/extractors/index.js +6 -0
- package/lib/extractors/index.js.map +1 -0
- package/lib/extractors/manager.d.ts +21 -4
- package/lib/extractors/manager.js +22 -5
- package/lib/extractors/manager.js.map +1 -1
- package/lib/extractors/text_extractor.d.ts +34 -7
- package/lib/extractors/text_extractor.js +11 -0
- package/lib/extractors/text_extractor.js.map +1 -1
- package/lib/extractors/types.d.ts +8 -6
- package/lib/extractors/types.js +2 -0
- package/lib/extractors/types.js.map +1 -1
- package/lib/feature.d.ts +18 -3
- package/lib/feature.js +20 -3
- package/lib/feature.js.map +1 -1
- package/lib/index.d.ts +6 -9
- package/lib/index.js +8 -13
- package/lib/index.js.map +1 -1
- package/lib/lsp.d.ts +10 -4
- package/lib/lsp.js +2 -0
- package/lib/lsp.js.map +1 -1
- package/lib/manager.d.ts +103 -16
- package/lib/manager.js +118 -31
- package/lib/manager.js.map +1 -1
- package/lib/plugin.d.ts +18 -13
- package/lib/plugin.js +2 -1
- package/lib/plugin.js.map +1 -1
- package/lib/positioning.d.ts +43 -6
- package/lib/positioning.js +28 -2
- package/lib/positioning.js.map +1 -1
- package/lib/schema.js +2 -1
- package/lib/schema.js.map +1 -1
- package/lib/tokens.d.ts +275 -45
- package/lib/tokens.js +28 -0
- package/lib/tokens.js.map +1 -1
- package/lib/utils.d.ts +15 -1
- package/lib/utils.js +18 -2
- package/lib/utils.js.map +1 -1
- package/lib/virtual/document.d.ts +374 -78
- package/lib/virtual/document.js +375 -148
- package/lib/virtual/document.js.map +1 -1
- package/lib/ws-connection/server-capability-registration.d.ts +18 -0
- package/lib/ws-connection/server-capability-registration.js +46 -0
- package/lib/ws-connection/server-capability-registration.js.map +1 -0
- package/lib/ws-connection/types.d.ts +75 -0
- package/lib/ws-connection/types.js +7 -0
- package/lib/ws-connection/types.js.map +1 -0
- package/lib/ws-connection/ws-connection.d.ts +82 -0
- package/lib/ws-connection/ws-connection.js +201 -0
- package/lib/ws-connection/ws-connection.js.map +1 -0
- package/package.json +15 -16
- package/style/index.css +0 -2
- package/style/index.js +0 -2
package/lib/manager.js
CHANGED
|
@@ -1,61 +1,102 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
1
3
|
import { PageConfig, URLExt } from '@jupyterlab/coreutils';
|
|
2
4
|
import { ServerConnection } from '@jupyterlab/services';
|
|
3
5
|
import { Signal } from '@lumino/signaling';
|
|
4
6
|
import { ILanguageServerManager } from './tokens';
|
|
7
|
+
import { PromiseDelegate } from '@lumino/coreutils';
|
|
5
8
|
export class LanguageServerManager {
|
|
6
9
|
constructor(options) {
|
|
7
|
-
|
|
10
|
+
/**
|
|
11
|
+
* map of language server sessions.
|
|
12
|
+
*/
|
|
8
13
|
this._sessions = new Map();
|
|
14
|
+
/**
|
|
15
|
+
* Map of language server specs.
|
|
16
|
+
*/
|
|
9
17
|
this._specs = new Map();
|
|
18
|
+
/**
|
|
19
|
+
* Set of emitted warning message, message in this set will not be warned again.
|
|
20
|
+
*/
|
|
10
21
|
this._warningsEmitted = new Set();
|
|
22
|
+
/**
|
|
23
|
+
* A promise resolved when this server manager is ready.
|
|
24
|
+
*/
|
|
25
|
+
this._ready = new PromiseDelegate();
|
|
26
|
+
/**
|
|
27
|
+
* Signal emitted when a language server session is changed
|
|
28
|
+
*/
|
|
29
|
+
this._sessionsChanged = new Signal(this);
|
|
30
|
+
this._isDisposed = false;
|
|
11
31
|
this._settings = options.settings || ServerConnection.makeSettings();
|
|
12
32
|
this._baseUrl = options.baseUrl || PageConfig.getBaseUrl();
|
|
13
33
|
this._retries = options.retries || 2;
|
|
14
34
|
this._retriesInterval = options.retriesInterval || 10000;
|
|
15
35
|
this._statusCode = -1;
|
|
16
36
|
this._configuration = {};
|
|
17
|
-
this.fetchSessions().catch(e => console.
|
|
37
|
+
this.fetchSessions().catch(e => console.log(e));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Check if the manager is disposed.
|
|
41
|
+
*/
|
|
42
|
+
get isDisposed() {
|
|
43
|
+
return this._isDisposed;
|
|
18
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Get the language server specs.
|
|
47
|
+
*/
|
|
19
48
|
get specs() {
|
|
20
49
|
return this._specs;
|
|
21
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Get the status end point.
|
|
53
|
+
*/
|
|
22
54
|
get statusUrl() {
|
|
23
55
|
return URLExt.join(this._baseUrl, ILanguageServerManager.URL_NS, 'status');
|
|
24
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Signal emitted when a language server session is changed
|
|
59
|
+
*/
|
|
25
60
|
get sessionsChanged() {
|
|
26
61
|
return this._sessionsChanged;
|
|
27
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Get the map of language server sessions.
|
|
65
|
+
*/
|
|
28
66
|
get sessions() {
|
|
29
67
|
return this._sessions;
|
|
30
68
|
}
|
|
31
|
-
|
|
32
|
-
|
|
69
|
+
/**
|
|
70
|
+
* A promise resolved when this server manager is ready.
|
|
71
|
+
*/
|
|
72
|
+
get ready() {
|
|
73
|
+
return this._ready.promise;
|
|
33
74
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Get the status code of server's responses.
|
|
77
|
+
*/
|
|
78
|
+
get statusCode() {
|
|
79
|
+
return this._statusCode;
|
|
39
80
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.warnOnce(`Two matching servers: ${a} and ${b} have the same priority; choose which one to use by changing the priority in Advanced Settings Editor`);
|
|
47
|
-
return a.localeCompare(b);
|
|
81
|
+
/**
|
|
82
|
+
* Dispose the manager.
|
|
83
|
+
*/
|
|
84
|
+
dispose() {
|
|
85
|
+
if (this._isDisposed) {
|
|
86
|
+
return;
|
|
48
87
|
}
|
|
49
|
-
|
|
50
|
-
|
|
88
|
+
this._isDisposed = true;
|
|
89
|
+
Signal.clearData(this);
|
|
51
90
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return spec.languages.some((language) => language.toLocaleLowerCase() == lowerCaseLanguage);
|
|
91
|
+
/**
|
|
92
|
+
* Update the language server configuration.
|
|
93
|
+
*/
|
|
94
|
+
setConfiguration(configuration) {
|
|
95
|
+
this._configuration = configuration;
|
|
58
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Get matching language server for input language option.
|
|
99
|
+
*/
|
|
59
100
|
getMatchingServers(options) {
|
|
60
101
|
if (!options.language) {
|
|
61
102
|
console.error('Cannot match server by language: language not available; ensure that kernel and specs provide language and MIME type');
|
|
@@ -67,8 +108,11 @@ export class LanguageServerManager {
|
|
|
67
108
|
matchingSessionsKeys.push(key);
|
|
68
109
|
}
|
|
69
110
|
}
|
|
70
|
-
return matchingSessionsKeys.sort(this.
|
|
111
|
+
return matchingSessionsKeys.sort(this.compareRanks.bind(this));
|
|
71
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Get matching language server spec for input language option.
|
|
115
|
+
*/
|
|
72
116
|
getMatchingSpecs(options) {
|
|
73
117
|
const result = new Map();
|
|
74
118
|
for (const [key, specification] of this._specs.entries()) {
|
|
@@ -78,18 +122,25 @@ export class LanguageServerManager {
|
|
|
78
122
|
}
|
|
79
123
|
return result;
|
|
80
124
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Fetch the server session list from the status endpoint. The server
|
|
127
|
+
* manager is ready once this method finishes.
|
|
128
|
+
*/
|
|
84
129
|
async fetchSessions() {
|
|
85
130
|
let response = await ServerConnection.makeRequest(this.statusUrl, { method: 'GET' }, this._settings);
|
|
86
131
|
this._statusCode = response.status;
|
|
87
132
|
if (!response.ok) {
|
|
88
|
-
|
|
133
|
+
// if(response.status === 404){
|
|
134
|
+
// this._retries = -1
|
|
135
|
+
// }
|
|
89
136
|
if (this._retries > 0) {
|
|
90
137
|
this._retries -= 1;
|
|
91
138
|
setTimeout(this.fetchSessions.bind(this), this._retriesInterval);
|
|
92
139
|
}
|
|
140
|
+
else {
|
|
141
|
+
this._ready.resolve(undefined);
|
|
142
|
+
console.log('Missing jupyter_lsp server extension, skipping.');
|
|
143
|
+
}
|
|
93
144
|
return;
|
|
94
145
|
}
|
|
95
146
|
let sessions;
|
|
@@ -97,7 +148,7 @@ export class LanguageServerManager {
|
|
|
97
148
|
const data = await response.json();
|
|
98
149
|
sessions = data.sessions;
|
|
99
150
|
try {
|
|
100
|
-
this.
|
|
151
|
+
this.version = data.version;
|
|
101
152
|
this._specs = new Map(Object.entries(data.specs));
|
|
102
153
|
}
|
|
103
154
|
catch (err) {
|
|
@@ -106,6 +157,7 @@ export class LanguageServerManager {
|
|
|
106
157
|
}
|
|
107
158
|
catch (err) {
|
|
108
159
|
console.warn(err);
|
|
160
|
+
this._ready.resolve(undefined);
|
|
109
161
|
return;
|
|
110
162
|
}
|
|
111
163
|
for (let key of Object.keys(sessions)) {
|
|
@@ -125,6 +177,41 @@ export class LanguageServerManager {
|
|
|
125
177
|
}
|
|
126
178
|
}
|
|
127
179
|
this._sessionsChanged.emit(void 0);
|
|
180
|
+
this._ready.resolve(undefined);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Check if input language option maths the language server spec.
|
|
184
|
+
*/
|
|
185
|
+
isMatchingSpec(options, spec) {
|
|
186
|
+
// most things speak language
|
|
187
|
+
// if language is not known, it is guessed based on MIME type earlier
|
|
188
|
+
// so some language should be available by now (which can be not so obvious, e.g. "plain" for txt documents)
|
|
189
|
+
const lowerCaseLanguage = options.language.toLocaleLowerCase();
|
|
190
|
+
return spec.languages.some((language) => language.toLocaleLowerCase() == lowerCaseLanguage);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Helper function to warn a message only once.
|
|
194
|
+
*/
|
|
195
|
+
warnOnce(arg) {
|
|
196
|
+
if (!this._warningsEmitted.has(arg)) {
|
|
197
|
+
this._warningsEmitted.add(arg);
|
|
198
|
+
console.warn(arg);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Compare the rank of two servers with the same language.
|
|
203
|
+
*/
|
|
204
|
+
compareRanks(a, b) {
|
|
205
|
+
var _a, _b, _c, _d;
|
|
206
|
+
const DEFAULT_RANK = 50;
|
|
207
|
+
const aRank = (_b = (_a = this._configuration[a]) === null || _a === void 0 ? void 0 : _a.rank) !== null && _b !== void 0 ? _b : DEFAULT_RANK;
|
|
208
|
+
const bRank = (_d = (_c = this._configuration[b]) === null || _c === void 0 ? void 0 : _c.rank) !== null && _d !== void 0 ? _d : DEFAULT_RANK;
|
|
209
|
+
if (aRank == bRank) {
|
|
210
|
+
this.warnOnce(`Two matching servers: ${a} and ${b} have the same rank; choose which one to use by changing the rank in Advanced Settings Editor`);
|
|
211
|
+
return a.localeCompare(b);
|
|
212
|
+
}
|
|
213
|
+
// higher rank = higher in the list (descending order)
|
|
214
|
+
return bRank - aRank;
|
|
128
215
|
}
|
|
129
216
|
}
|
|
130
217
|
//# sourceMappingURL=manager.js.map
|
package/lib/manager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../src/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAW,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACL,sBAAsB,EAKvB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../src/manager.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAW,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACL,sBAAsB,EAKvB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,OAAO,qBAAqB;IAChC,YAAY,OAAwC;QAsOpD;;WAEG;QACK,cAAS,GAAgB,IAAI,GAAG,EAAE,CAAC;QAE3C;;WAEG;QACK,WAAM,GAAc,IAAI,GAAG,EAAE,CAAC;QAgCtC;;WAEG;QACK,qBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;QAE7C;;WAEG;QACK,WAAM,GAAG,IAAI,eAAe,EAAQ,CAAC;QAE7C;;WAEG;QACK,qBAAgB,GAAyC,IAAI,MAAM,CACzE,IAAI,CACL,CAAC;QAEM,gBAAW,GAAG,KAAK,CAAC;QA9R1B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,IAAI,gBAAgB,CAAC,YAAY,EAAE,CAAC;QACrE,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;QAC3D,IAAI,C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AI,mCAAI,YAAY,CAAC;QAC3D,MAAM,KAAK,GAAG,MAAA,MAAA,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,0CAAE,IAAI,mCAAI,YAAY,CAAC;QAC3D,IAAI,KAAK,IAAI,KAAK,EAAE;YAClB,IAAI,CAAC,QAAQ,CACX,yBAAyB,CAAC,QAAQ,CAAC,+FAA+F,CACnI,CAAC;YACF,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;SAC3B;QACD,sDAAsD;QACtD,OAAO,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CA4DF"}
|
package/lib/plugin.d.ts
CHANGED
|
@@ -4,37 +4,42 @@
|
|
|
4
4
|
* and run jlpm build:schema to regenerate this file.
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
|
-
* When multiple servers match specific document/language, the server with the highest
|
|
7
|
+
* When multiple servers match specific document/language, the server with the highest rank will be used
|
|
8
8
|
*/
|
|
9
|
-
export declare type
|
|
9
|
+
export declare type RankOfTheServer = number;
|
|
10
10
|
/**
|
|
11
|
-
* Whether to ask server to send logs with execution trace (for debugging).
|
|
11
|
+
* Whether to ask server to send logs with execution trace (for debugging). Accepted values are: "off", "messages", "verbose". Servers are allowed to ignore this request.
|
|
12
12
|
*/
|
|
13
13
|
export declare type AskServersToSendTraceNotifications = 'off' | 'messages' | 'verbose';
|
|
14
|
+
/**
|
|
15
|
+
* Enable or disable the logging feature of the language servers.
|
|
16
|
+
*/
|
|
17
|
+
export declare type LogCommunication = boolean;
|
|
14
18
|
/**
|
|
15
19
|
* Language Server Protocol settings.
|
|
16
20
|
*/
|
|
17
|
-
export interface
|
|
18
|
-
|
|
21
|
+
export interface LanguageServers {
|
|
22
|
+
languageServers?: LanguageServer;
|
|
19
23
|
setTrace?: AskServersToSendTraceNotifications;
|
|
24
|
+
logAllCommunication?: LogCommunication;
|
|
20
25
|
[k: string]: any;
|
|
21
26
|
}
|
|
22
27
|
/**
|
|
23
28
|
* Language-server specific configuration, keyed by implementation
|
|
24
29
|
*/
|
|
25
|
-
export interface
|
|
26
|
-
[k: string]:
|
|
30
|
+
export interface LanguageServer {
|
|
31
|
+
[k: string]: LanguageServer1;
|
|
27
32
|
}
|
|
28
33
|
/**
|
|
29
|
-
* This interface was referenced by `
|
|
34
|
+
* This interface was referenced by `LanguageServer`'s JSON-Schema definition
|
|
30
35
|
* via the `patternProperty` ".*".
|
|
31
36
|
*
|
|
32
|
-
* This interface was referenced by `
|
|
33
|
-
* via the `definition` "
|
|
37
|
+
* This interface was referenced by `LanguageServers`'s JSON-Schema
|
|
38
|
+
* via the `definition` "languageServer".
|
|
34
39
|
*/
|
|
35
|
-
export interface
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
export interface LanguageServer1 {
|
|
41
|
+
configuration?: LanguageServerConfigurations;
|
|
42
|
+
rank?: RankOfTheServer;
|
|
38
43
|
[k: string]: any;
|
|
39
44
|
}
|
|
40
45
|
/**
|
package/lib/plugin.js
CHANGED
package/lib/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D"}
|
package/lib/positioning.d.ts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { CodeEditor } from '@jupyterlab/codeeditor';
|
|
2
|
-
import type * as CodeMirror from 'codemirror';
|
|
3
2
|
import type * as lsp from 'vscode-languageserver-protocol';
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
4
|
+
* CM5 position interface.
|
|
5
|
+
*
|
|
6
|
+
* TODO: Migrate to offset-only mode once `CodeEditor.IPosition`
|
|
7
|
+
* is migrated.
|
|
6
8
|
*/
|
|
7
|
-
export interface IPosition
|
|
9
|
+
export interface IPosition {
|
|
10
|
+
/**
|
|
11
|
+
* Line number
|
|
12
|
+
*/
|
|
13
|
+
line: number;
|
|
14
|
+
/**
|
|
15
|
+
* Position of character in line
|
|
16
|
+
*/
|
|
17
|
+
ch: number;
|
|
8
18
|
}
|
|
9
|
-
|
|
19
|
+
/**
|
|
20
|
+
* is_* attributes are there only to enforce strict interface type checking
|
|
21
|
+
*/
|
|
10
22
|
export interface ISourcePosition extends IPosition {
|
|
11
23
|
isSource: true;
|
|
12
24
|
}
|
|
@@ -19,10 +31,35 @@ export interface IVirtualPosition extends IPosition {
|
|
|
19
31
|
export interface IRootPosition extends ISourcePosition {
|
|
20
32
|
isRoot: true;
|
|
21
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Compare two `IPosition` variable.
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
export declare function isEqual(self: IPosition, other: IPosition): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Given a list of line and an offset from the start, compute the corresponding
|
|
41
|
+
* position in form of line and column number
|
|
42
|
+
*
|
|
43
|
+
* @param offset - number of spaces counted from the start of first line
|
|
44
|
+
* @param lines - list of lines to compute the position
|
|
45
|
+
* @return - the position of cursor
|
|
46
|
+
*/
|
|
22
47
|
export declare function positionAtOffset(offset: number, lines: string[]): CodeEditor.IPosition;
|
|
48
|
+
/**
|
|
49
|
+
* Given a list of line and position in form of line and column number,
|
|
50
|
+
* compute the offset from the start of first line.
|
|
51
|
+
* @param position - postion of cursor
|
|
52
|
+
* @param lines - list of lines to compute the position
|
|
53
|
+
* @param linesIncludeBreaks - should count the line break as space?
|
|
54
|
+
* return - offset number
|
|
55
|
+
*/
|
|
23
56
|
export declare function offsetAtPosition(position: CodeEditor.IPosition, lines: string[], linesIncludeBreaks?: boolean): number;
|
|
24
|
-
export declare class PositionError extends Error {
|
|
25
|
-
}
|
|
26
57
|
export declare namespace ProtocolCoordinates {
|
|
58
|
+
/**
|
|
59
|
+
* Check if the position is in the input range
|
|
60
|
+
*
|
|
61
|
+
* @param position - position in form of line and character number.
|
|
62
|
+
* @param range - range in from of start and end position.
|
|
63
|
+
*/
|
|
27
64
|
function isWithinRange(position: lsp.Position, range: lsp.Range): boolean;
|
|
28
65
|
}
|
package/lib/positioning.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
/**
|
|
4
|
+
* Compare two `IPosition` variable.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
1
7
|
export function isEqual(self, other) {
|
|
2
8
|
return other && self.line === other.line && self.ch === other.ch;
|
|
3
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Given a list of line and an offset from the start, compute the corresponding
|
|
12
|
+
* position in form of line and column number
|
|
13
|
+
*
|
|
14
|
+
* @param offset - number of spaces counted from the start of first line
|
|
15
|
+
* @param lines - list of lines to compute the position
|
|
16
|
+
* @return - the position of cursor
|
|
17
|
+
*/
|
|
4
18
|
export function positionAtOffset(offset, lines) {
|
|
5
19
|
let line = 0;
|
|
6
20
|
let column = 0;
|
|
@@ -17,6 +31,14 @@ export function positionAtOffset(offset, lines) {
|
|
|
17
31
|
}
|
|
18
32
|
return { line, column };
|
|
19
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Given a list of line and position in form of line and column number,
|
|
36
|
+
* compute the offset from the start of first line.
|
|
37
|
+
* @param position - postion of cursor
|
|
38
|
+
* @param lines - list of lines to compute the position
|
|
39
|
+
* @param linesIncludeBreaks - should count the line break as space?
|
|
40
|
+
* return - offset number
|
|
41
|
+
*/
|
|
20
42
|
export function offsetAtPosition(position, lines, linesIncludeBreaks = false) {
|
|
21
43
|
let breakIncrement = linesIncludeBreaks ? 0 : 1;
|
|
22
44
|
let offset = 0;
|
|
@@ -32,10 +54,14 @@ export function offsetAtPosition(position, lines, linesIncludeBreaks = false) {
|
|
|
32
54
|
}
|
|
33
55
|
return offset;
|
|
34
56
|
}
|
|
35
|
-
export class PositionError extends Error {
|
|
36
|
-
}
|
|
37
57
|
export var ProtocolCoordinates;
|
|
38
58
|
(function (ProtocolCoordinates) {
|
|
59
|
+
/**
|
|
60
|
+
* Check if the position is in the input range
|
|
61
|
+
*
|
|
62
|
+
* @param position - position in form of line and character number.
|
|
63
|
+
* @param range - range in from of start and end position.
|
|
64
|
+
*/
|
|
39
65
|
function isWithinRange(position, range) {
|
|
40
66
|
const { line, character } = position;
|
|
41
67
|
return (line >= range.start.line &&
|
package/lib/positioning.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"positioning.js","sourceRoot":"","sources":["../src/positioning.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"positioning.js","sourceRoot":"","sources":["../src/positioning.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AA0C3D;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,IAAe,EAAE,KAAgB;IACvD,OAAO,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC;AACnE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAc,EACd,KAAe;IAEf,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,IAAI,QAAQ,IAAI,KAAK,EAAE;QAC1B,oEAAoE;QACpE,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,EAAE;YACjC,MAAM,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;YAC9B,IAAI,IAAI,CAAC,CAAC;SACX;aAAM;YACL,MAAM,GAAG,MAAM,CAAC;YAChB,MAAM;SACP;KACF;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAA8B,EAC9B,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"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D"}
|