@difizen/libro-lsp 0.1.2
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 +21 -0
- package/README.md +0 -0
- package/es/adapters/adapter.d.ts +255 -0
- package/es/adapters/adapter.d.ts.map +1 -0
- package/es/adapters/adapter.js +647 -0
- package/es/adapters/notebook-adapter.d.ts +150 -0
- package/es/adapters/notebook-adapter.d.ts.map +1 -0
- package/es/adapters/notebook-adapter.js +588 -0
- package/es/adapters/status-message.d.ts +48 -0
- package/es/adapters/status-message.d.ts.map +1 -0
- package/es/adapters/status-message.js +110 -0
- package/es/connection-manager.d.ts +199 -0
- package/es/connection-manager.d.ts.map +1 -0
- package/es/connection-manager.js +685 -0
- package/es/connection.d.ts +149 -0
- package/es/connection.d.ts.map +1 -0
- package/es/connection.js +591 -0
- package/es/extractors/index.d.ts +4 -0
- package/es/extractors/index.d.ts.map +1 -0
- package/es/extractors/index.js +6 -0
- package/es/extractors/manager.d.ts +31 -0
- package/es/extractors/manager.d.ts.map +1 -0
- package/es/extractors/manager.js +90 -0
- package/es/extractors/text-extractor.d.ts +56 -0
- package/es/extractors/text-extractor.d.ts.map +1 -0
- package/es/extractors/text-extractor.js +72 -0
- package/es/extractors/types.d.ts +68 -0
- package/es/extractors/types.d.ts.map +1 -0
- package/es/extractors/types.js +1 -0
- package/es/feature.d.ts +29 -0
- package/es/feature.d.ts.map +1 -0
- package/es/feature.js +85 -0
- package/es/index.d.ts +19 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +21 -0
- package/es/lsp-app-contribution.d.ts +19 -0
- package/es/lsp-app-contribution.d.ts.map +1 -0
- package/es/lsp-app-contribution.js +155 -0
- package/es/lsp-protocol.d.ts +10 -0
- package/es/lsp-protocol.d.ts.map +1 -0
- package/es/lsp-protocol.js +1 -0
- package/es/lsp.d.ts +136 -0
- package/es/lsp.d.ts.map +1 -0
- package/es/lsp.js +141 -0
- package/es/manager.d.ts +142 -0
- package/es/manager.d.ts.map +1 -0
- package/es/manager.js +423 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +21 -0
- package/es/plugin.d.ts +56 -0
- package/es/plugin.d.ts.map +1 -0
- package/es/plugin.js +0 -0
- package/es/positioning.d.ts +66 -0
- package/es/positioning.d.ts.map +1 -0
- package/es/positioning.js +96 -0
- package/es/schema.d.ts +240 -0
- package/es/schema.d.ts.map +1 -0
- package/es/schema.js +0 -0
- package/es/tokens.d.ts +677 -0
- package/es/tokens.d.ts.map +1 -0
- package/es/tokens.js +183 -0
- package/es/utils.d.ts +33 -0
- package/es/utils.d.ts.map +1 -0
- package/es/utils.js +168 -0
- package/es/virtual/document.d.ts +546 -0
- package/es/virtual/document.d.ts.map +1 -0
- package/es/virtual/document.js +1263 -0
- package/es/ws-connection/server-capability-registration.d.ts +19 -0
- package/es/ws-connection/server-capability-registration.d.ts.map +1 -0
- package/es/ws-connection/server-capability-registration.js +51 -0
- package/es/ws-connection/types.d.ts +76 -0
- package/es/ws-connection/types.d.ts.map +1 -0
- package/es/ws-connection/types.js +1 -0
- package/es/ws-connection/ws-connection.d.ts +105 -0
- package/es/ws-connection/ws-connection.d.ts.map +1 -0
- package/es/ws-connection/ws-connection.js +301 -0
- package/package.json +67 -0
- package/src/adapters/adapter.ts +611 -0
- package/src/adapters/notebook-adapter.ts +463 -0
- package/src/adapters/status-message.ts +93 -0
- package/src/connection-manager.ts +626 -0
- package/src/connection.ts +570 -0
- package/src/extractors/index.ts +6 -0
- package/src/extractors/manager.ts +82 -0
- package/src/extractors/text-extractor.ts +94 -0
- package/src/extractors/types.ts +78 -0
- package/src/feature.ts +60 -0
- package/src/index.spec.ts +10 -0
- package/src/index.ts +21 -0
- package/src/lsp-app-contribution.ts +83 -0
- package/src/lsp-protocol.ts +10 -0
- package/src/lsp.ts +160 -0
- package/src/manager.ts +358 -0
- package/src/module.ts +32 -0
- package/src/plugin.ts +62 -0
- package/src/positioning.ts +121 -0
- package/src/schema.ts +249 -0
- package/src/tokens.ts +843 -0
- package/src/utils.ts +109 -0
- package/src/virtual/document.ts +1250 -0
- package/src/ws-connection/server-capability-registration.ts +77 -0
- package/src/ws-connection/types.ts +102 -0
- package/src/ws-connection/ws-connection.ts +320 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _class;
|
|
3
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
8
|
+
// Copyright (c) Jupyter Development Team.
|
|
9
|
+
// Distributed under the terms of the Modified BSD License.
|
|
10
|
+
|
|
11
|
+
import { singleton } from '@difizen/mana-app';
|
|
12
|
+
import { ILSPCodeExtractorsManager } from "../tokens.js";
|
|
13
|
+
/**
|
|
14
|
+
* Manager for the code extractors
|
|
15
|
+
*/
|
|
16
|
+
export var CodeExtractorsManager = (_dec = singleton({
|
|
17
|
+
token: ILSPCodeExtractorsManager
|
|
18
|
+
}), _dec(_class = /*#__PURE__*/function () {
|
|
19
|
+
function CodeExtractorsManager() {
|
|
20
|
+
_classCallCheck(this, CodeExtractorsManager);
|
|
21
|
+
this._extractorMap = new Map();
|
|
22
|
+
this._extractorMapAnyLanguage = new Map();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get the extractors for the input cell type and the main language of
|
|
27
|
+
* the document
|
|
28
|
+
*
|
|
29
|
+
* @param cellType - type of cell
|
|
30
|
+
* @param hostLanguage - main language of the document
|
|
31
|
+
*/
|
|
32
|
+
_createClass(CodeExtractorsManager, [{
|
|
33
|
+
key: "getExtractors",
|
|
34
|
+
value: function getExtractors(cellType, hostLanguage) {
|
|
35
|
+
if (hostLanguage) {
|
|
36
|
+
var _currentMap$get;
|
|
37
|
+
var currentMap = this._extractorMap.get(cellType);
|
|
38
|
+
if (!currentMap) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
return (_currentMap$get = currentMap.get(hostLanguage)) !== null && _currentMap$get !== void 0 ? _currentMap$get : [];
|
|
42
|
+
} else {
|
|
43
|
+
var _this$_extractorMapAn;
|
|
44
|
+
return (_this$_extractorMapAn = this._extractorMapAnyLanguage.get(cellType)) !== null && _this$_extractorMapAn !== void 0 ? _this$_extractorMapAn : [];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Register an extractor to extract foreign code from host documents of specified language.
|
|
50
|
+
*/
|
|
51
|
+
}, {
|
|
52
|
+
key: "register",
|
|
53
|
+
value: function register(extractor, hostLanguage) {
|
|
54
|
+
var _this = this;
|
|
55
|
+
var cellType = extractor.cellType;
|
|
56
|
+
if (hostLanguage) {
|
|
57
|
+
cellType.forEach(function (type) {
|
|
58
|
+
if (!_this._extractorMap.has(type)) {
|
|
59
|
+
_this._extractorMap.set(type, new Map());
|
|
60
|
+
}
|
|
61
|
+
var currentMap = _this._extractorMap.get(type);
|
|
62
|
+
var extractorList = currentMap.get(hostLanguage);
|
|
63
|
+
if (!extractorList) {
|
|
64
|
+
currentMap.set(hostLanguage, [extractor]);
|
|
65
|
+
} else {
|
|
66
|
+
extractorList.push(extractor);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
cellType.forEach(function (type) {
|
|
71
|
+
if (!_this._extractorMapAnyLanguage.has(type)) {
|
|
72
|
+
_this._extractorMapAnyLanguage.set(type, []);
|
|
73
|
+
}
|
|
74
|
+
_this._extractorMapAnyLanguage.get(type).push(extractor);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The map with key is the type of cell, value is another map between
|
|
81
|
+
* the language of cell and its code extractor.
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The map with key is the cell type, value is the code extractor associated
|
|
86
|
+
* with this cell type, this is used for the non-code cell types.
|
|
87
|
+
*/
|
|
88
|
+
}]);
|
|
89
|
+
return CodeExtractorsManager;
|
|
90
|
+
}()) || _class);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { LanguageIdentifier } from '../lsp.js';
|
|
2
|
+
import type { IExtractedCode, IForeignCodeExtractor } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* The code extractor for the raw and markdown text.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TextForeignCodeExtractor implements IForeignCodeExtractor {
|
|
7
|
+
constructor(options: TextForeignCodeExtractor.IOptions);
|
|
8
|
+
/**
|
|
9
|
+
* The foreign language.
|
|
10
|
+
*/
|
|
11
|
+
readonly language: LanguageIdentifier;
|
|
12
|
+
/**
|
|
13
|
+
* Should the foreign code be appended (False) to the previously established virtual document of the same language,
|
|
14
|
+
* or is it standalone snippet which requires separate connection?
|
|
15
|
+
*/
|
|
16
|
+
readonly standalone: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Extension of the virtual document (some servers check extensions of files), e.g. 'py' or 'R'.
|
|
19
|
+
*/
|
|
20
|
+
readonly fileExtension: string;
|
|
21
|
+
/**
|
|
22
|
+
* The supported cell types.
|
|
23
|
+
*/
|
|
24
|
+
readonly cellType: string[];
|
|
25
|
+
/**
|
|
26
|
+
* Test if there is any foreign code in provided code snippet.
|
|
27
|
+
*/
|
|
28
|
+
hasForeignCode(code: string, cellType: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Split the code into the host and foreign code (if any foreign code was detected)
|
|
31
|
+
*/
|
|
32
|
+
extractForeignCode(code: string): IExtractedCode[];
|
|
33
|
+
}
|
|
34
|
+
declare namespace TextForeignCodeExtractor {
|
|
35
|
+
interface IOptions {
|
|
36
|
+
/**
|
|
37
|
+
* The foreign language.
|
|
38
|
+
*/
|
|
39
|
+
language: string;
|
|
40
|
+
/**
|
|
41
|
+
* Should the foreign code be appended (False) to the previously established virtual document of the same language,
|
|
42
|
+
* or is it standalone snippet which requires separate connection?
|
|
43
|
+
*/
|
|
44
|
+
isStandalone: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Extension of the virtual document (some servers check extensions of files), e.g. 'py' or 'R'.
|
|
47
|
+
*/
|
|
48
|
+
file_extension: string;
|
|
49
|
+
/**
|
|
50
|
+
* The supported cell types.
|
|
51
|
+
*/
|
|
52
|
+
cellType: string[];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=text-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-extractor.d.ts","sourceRoot":"","sources":["../../src/extractors/text-extractor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAGpD,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExE;;GAEG;AACH,qBAAa,wBAAyB,YAAW,qBAAqB;gBACxD,OAAO,EAAE,wBAAwB,CAAC,QAAQ;IAMtD;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IAEtC;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAE5B;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIvD;;OAEG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,EAAE;CAmBnD;AAED,kBAAU,wBAAwB,CAAC;IACjC,UAAiB,QAAQ;QACvB;;WAEG;QACH,QAAQ,EAAE,MAAM,CAAC;QAEjB;;;WAGG;QACH,YAAY,EAAE,OAAO,CAAC;QAEtB;;WAEG;QACH,cAAc,EAAE,MAAM,CAAC;QAEvB;;WAEG;QACH,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB;CACF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
// Copyright (c) Jupyter Development Team.
|
|
8
|
+
// Distributed under the terms of the Modified BSD License.
|
|
9
|
+
|
|
10
|
+
import { positionAtOffset } from "../positioning.js";
|
|
11
|
+
/**
|
|
12
|
+
* The code extractor for the raw and markdown text.
|
|
13
|
+
*/
|
|
14
|
+
export var TextForeignCodeExtractor = /*#__PURE__*/function () {
|
|
15
|
+
function TextForeignCodeExtractor(options) {
|
|
16
|
+
_classCallCheck(this, TextForeignCodeExtractor);
|
|
17
|
+
this.language = options.language;
|
|
18
|
+
this.standalone = options.isStandalone;
|
|
19
|
+
this.fileExtension = options.file_extension;
|
|
20
|
+
this.cellType = options.cellType;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The foreign language.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Should the foreign code be appended (False) to the previously established virtual document of the same language,
|
|
28
|
+
* or is it standalone snippet which requires separate connection?
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Extension of the virtual document (some servers check extensions of files), e.g. 'py' or 'R'.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The supported cell types.
|
|
37
|
+
*/
|
|
38
|
+
_createClass(TextForeignCodeExtractor, [{
|
|
39
|
+
key: "hasForeignCode",
|
|
40
|
+
value:
|
|
41
|
+
/**
|
|
42
|
+
* Test if there is any foreign code in provided code snippet.
|
|
43
|
+
*/
|
|
44
|
+
function hasForeignCode(code, cellType) {
|
|
45
|
+
return this.cellType.includes(cellType);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Split the code into the host and foreign code (if any foreign code was detected)
|
|
50
|
+
*/
|
|
51
|
+
}, {
|
|
52
|
+
key: "extractForeignCode",
|
|
53
|
+
value: function extractForeignCode(code) {
|
|
54
|
+
var lines = code.split('\n');
|
|
55
|
+
var extracts = new Array();
|
|
56
|
+
var foreignCodeFragment = code;
|
|
57
|
+
var start = positionAtOffset(0, lines);
|
|
58
|
+
var end = positionAtOffset(foreignCodeFragment.length, lines);
|
|
59
|
+
extracts.push({
|
|
60
|
+
hostCode: '',
|
|
61
|
+
foreignCode: foreignCodeFragment,
|
|
62
|
+
range: {
|
|
63
|
+
start: start,
|
|
64
|
+
end: end
|
|
65
|
+
},
|
|
66
|
+
virtualShift: null
|
|
67
|
+
});
|
|
68
|
+
return extracts;
|
|
69
|
+
}
|
|
70
|
+
}]);
|
|
71
|
+
return TextForeignCodeExtractor;
|
|
72
|
+
}();
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { IRange, IPosition } from '@difizen/libro-code-editor';
|
|
2
|
+
import type { LanguageIdentifier } from '../lsp.js';
|
|
3
|
+
export interface IExtractedCode {
|
|
4
|
+
/**
|
|
5
|
+
* Foreign code (may be empty, for example line of '%R') or null if none.
|
|
6
|
+
*/
|
|
7
|
+
foreignCode: string | null;
|
|
8
|
+
/**
|
|
9
|
+
* Range of the foreign code relative to the original source.
|
|
10
|
+
* `null` is used internally to represent a leftover host code after extraction.
|
|
11
|
+
*/
|
|
12
|
+
range: IRange | null;
|
|
13
|
+
/**
|
|
14
|
+
* Shift due to any additional code inserted at the beginning of the virtual document
|
|
15
|
+
* (usually in order to mock the arguments passed to a magic, or to provide other context clues for the linters)
|
|
16
|
+
*/
|
|
17
|
+
virtualShift: IPosition | null;
|
|
18
|
+
/**
|
|
19
|
+
* Code to be retained in the virtual document of the host.
|
|
20
|
+
*/
|
|
21
|
+
hostCode: string | null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Foreign code extractor makes it possible to analyze code of language X embedded in code (or notebook) of language Y.
|
|
25
|
+
*
|
|
26
|
+
* The typical examples are:
|
|
27
|
+
* - (X=CSS< Y=HTML), or
|
|
28
|
+
* - (X=JavaScript, Y=HTML),
|
|
29
|
+
*
|
|
30
|
+
* while in the data analysis realm, examples include:
|
|
31
|
+
* - (X=R, Y=IPython),
|
|
32
|
+
* - (X=LATEX Y=IPython),
|
|
33
|
+
* - (X=SQL, Y=IPython)
|
|
34
|
+
*
|
|
35
|
+
* This extension does not aim to provide comprehensive abilities for foreign code extraction,
|
|
36
|
+
* but it does intend to provide stable interface for other extensions to build on it.
|
|
37
|
+
*
|
|
38
|
+
* A simple, regular expression based, configurable foreign extractor is implemented
|
|
39
|
+
* to provide a good reference and a good initial experience for the users.
|
|
40
|
+
*/
|
|
41
|
+
export interface IForeignCodeExtractor {
|
|
42
|
+
/**
|
|
43
|
+
* The foreign language.
|
|
44
|
+
*/
|
|
45
|
+
readonly language: LanguageIdentifier;
|
|
46
|
+
/**
|
|
47
|
+
* The supported cell types.
|
|
48
|
+
*/
|
|
49
|
+
readonly cellType: string[];
|
|
50
|
+
/**
|
|
51
|
+
* Split the code into the host and foreign code (if any foreign code was detected)
|
|
52
|
+
*/
|
|
53
|
+
extractForeignCode(code: string): IExtractedCode[];
|
|
54
|
+
/**
|
|
55
|
+
* Does the extractor produce code which should be appended to the previously established virtual document (False)
|
|
56
|
+
* of the same language, or does it produce standalone snippets which require separate connections (True)?
|
|
57
|
+
*/
|
|
58
|
+
readonly standalone: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Test if there is any foreign code in provided code snippet.
|
|
61
|
+
*/
|
|
62
|
+
hasForeignCode(code: string, cellType: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Extension of the virtual document (some servers check extensions of files), e.g. 'py' or 'R'.
|
|
65
|
+
*/
|
|
66
|
+
readonly fileExtension: string;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/extractors/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;OAGG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;;OAGG;IACH,YAAY,EAAE,SAAS,GAAG,IAAI,CAAC;IAC/B;;OAEG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAE5B;;OAEG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,EAAE,CAAC;IAEnD;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B;;OAEG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAExD;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/feature.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Event } from '@difizen/mana-app';
|
|
2
|
+
import { Emitter } from '@difizen/mana-app';
|
|
3
|
+
import type { ClientCapabilities } from './lsp.js';
|
|
4
|
+
import type { IFeature } from './tokens.js';
|
|
5
|
+
import { ILSPFeatureManager } from './tokens.js';
|
|
6
|
+
/**
|
|
7
|
+
* Class to manager the registered features of the language servers.
|
|
8
|
+
*/
|
|
9
|
+
export declare class FeatureManager implements ILSPFeatureManager {
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* List of registered features
|
|
13
|
+
*/
|
|
14
|
+
readonly features: IFeature[];
|
|
15
|
+
/**
|
|
16
|
+
* Signal emitted when a new feature is registered.
|
|
17
|
+
*/
|
|
18
|
+
get featuresRegistered(): Event<IFeature>;
|
|
19
|
+
/**
|
|
20
|
+
* Register a new feature, skip if it is already registered.
|
|
21
|
+
*/
|
|
22
|
+
register(feature: IFeature): void;
|
|
23
|
+
/**
|
|
24
|
+
* Get the capabilities of all clients.
|
|
25
|
+
*/
|
|
26
|
+
clientCapabilities(): ClientCapabilities;
|
|
27
|
+
protected _featuresRegistered: Emitter<IFeature>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=feature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../src/feature.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAI5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD;;GAEG;AACH,qBACa,cAAe,YAAW,kBAAkB;;IAIvD;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAM;IAEnC;;OAEG;IACH,IAAI,kBAAkB,IAAI,KAAK,CAAC,QAAQ,CAAC,CAExC;IAED;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI;IASjC;;OAEG;IACH,kBAAkB,IAAI,kBAAkB;IAWxC,SAAS,CAAC,mBAAmB,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;CAClD"}
|
package/es/feature.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _dec, _class;
|
|
3
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
6
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
7
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
8
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
9
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
10
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
11
|
+
// Copyright (c) Jupyter Development Team.
|
|
12
|
+
// Distributed under the terms of the Modified BSD License.
|
|
13
|
+
|
|
14
|
+
import { Emitter } from '@difizen/mana-app';
|
|
15
|
+
import { singleton } from '@difizen/mana-app';
|
|
16
|
+
import mergeWith from 'lodash.mergewith';
|
|
17
|
+
import { ILSPFeatureManager } from "./tokens.js";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Class to manager the registered features of the language servers.
|
|
21
|
+
*/
|
|
22
|
+
export var FeatureManager = (_dec = singleton({
|
|
23
|
+
token: ILSPFeatureManager
|
|
24
|
+
}), _dec(_class = /*#__PURE__*/function () {
|
|
25
|
+
function FeatureManager() {
|
|
26
|
+
_classCallCheck(this, FeatureManager);
|
|
27
|
+
/**
|
|
28
|
+
* List of registered features
|
|
29
|
+
*/
|
|
30
|
+
this.features = [];
|
|
31
|
+
this._featuresRegistered = new Emitter();
|
|
32
|
+
}
|
|
33
|
+
_createClass(FeatureManager, [{
|
|
34
|
+
key: "featuresRegistered",
|
|
35
|
+
get:
|
|
36
|
+
/**
|
|
37
|
+
* Signal emitted when a new feature is registered.
|
|
38
|
+
*/
|
|
39
|
+
function get() {
|
|
40
|
+
return this._featuresRegistered.event;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Register a new feature, skip if it is already registered.
|
|
45
|
+
*/
|
|
46
|
+
}, {
|
|
47
|
+
key: "register",
|
|
48
|
+
value: function register(feature) {
|
|
49
|
+
if (this.features.some(function (ft) {
|
|
50
|
+
return ft.id === feature.id;
|
|
51
|
+
})) {
|
|
52
|
+
console.warn("Feature with id ".concat(feature.id, " is already registered, skipping."));
|
|
53
|
+
} else {
|
|
54
|
+
this.features.push(feature);
|
|
55
|
+
this._featuresRegistered.fire(feature);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get the capabilities of all clients.
|
|
61
|
+
*/
|
|
62
|
+
}, {
|
|
63
|
+
key: "clientCapabilities",
|
|
64
|
+
value: function clientCapabilities() {
|
|
65
|
+
var capabilities = {};
|
|
66
|
+
var _iterator = _createForOfIteratorHelper(this.features),
|
|
67
|
+
_step;
|
|
68
|
+
try {
|
|
69
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
70
|
+
var feature = _step.value;
|
|
71
|
+
if (!feature.capabilities) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
capabilities = mergeWith(capabilities, feature.capabilities);
|
|
75
|
+
}
|
|
76
|
+
} catch (err) {
|
|
77
|
+
_iterator.e(err);
|
|
78
|
+
} finally {
|
|
79
|
+
_iterator.f();
|
|
80
|
+
}
|
|
81
|
+
return capabilities;
|
|
82
|
+
}
|
|
83
|
+
}]);
|
|
84
|
+
return FeatureManager;
|
|
85
|
+
}()) || _class);
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module lsp
|
|
4
|
+
*/
|
|
5
|
+
export * from './module.js';
|
|
6
|
+
export * from './adapters/adapter.js';
|
|
7
|
+
export * from './connection-manager.js';
|
|
8
|
+
export * from './extractors/index.js';
|
|
9
|
+
export * from './feature.js';
|
|
10
|
+
export * from './manager.js';
|
|
11
|
+
export * from './plugin.js';
|
|
12
|
+
export * from './positioning.js';
|
|
13
|
+
export * from './tokens.js';
|
|
14
|
+
export * from './utils.js';
|
|
15
|
+
export * from './virtual/document.js';
|
|
16
|
+
export * from './connection.js';
|
|
17
|
+
export * from './lsp.js';
|
|
18
|
+
export * from './lsp-protocol.js';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC"}
|
package/es/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright (c) Jupyter Development Team.
|
|
2
|
+
// Distributed under the terms of the Modified BSD License.
|
|
3
|
+
/**
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
* @module lsp
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export * from "./module.js";
|
|
9
|
+
export * from "./adapters/adapter.js";
|
|
10
|
+
export * from "./connection-manager.js";
|
|
11
|
+
export * from "./extractors/index.js";
|
|
12
|
+
export * from "./feature.js";
|
|
13
|
+
export * from "./manager.js";
|
|
14
|
+
export * from "./plugin.js";
|
|
15
|
+
export * from "./positioning.js";
|
|
16
|
+
export * from "./tokens.js";
|
|
17
|
+
export * from "./utils.js";
|
|
18
|
+
export * from "./virtual/document.js";
|
|
19
|
+
export * from "./connection.js";
|
|
20
|
+
export * from "./lsp.js";
|
|
21
|
+
export * from "./lsp-protocol.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { LibroView } from '@difizen/libro-core';
|
|
2
|
+
import { LibroService } from '@difizen/libro-core';
|
|
3
|
+
import { ServerManager } from '@difizen/libro-kernel';
|
|
4
|
+
import { ApplicationContribution } from '@difizen/mana-app';
|
|
5
|
+
import { ILSPCodeExtractorsManager, ILSPDocumentConnectionManager, ILSPFeatureManager } from './tokens.js';
|
|
6
|
+
export declare class LSPAppContribution implements ApplicationContribution {
|
|
7
|
+
libroService: LibroService;
|
|
8
|
+
serverManager: ServerManager;
|
|
9
|
+
connectionManager: ILSPDocumentConnectionManager;
|
|
10
|
+
featureManager: ILSPFeatureManager;
|
|
11
|
+
codeExtractorManager: ILSPCodeExtractorsManager;
|
|
12
|
+
onStart(): void;
|
|
13
|
+
setupNotebookLanguageServer(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Activate the language server for notebook.
|
|
16
|
+
*/
|
|
17
|
+
activateNotebookLanguageServer(notebook: LibroView): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=lsp-app-contribution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lsp-app-contribution.d.ts","sourceRoot":"","sources":["../src/lsp-app-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAI5D,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB,qBACa,kBAAmB,YAAW,uBAAuB;IAC1C,YAAY,EAAE,YAAY,CAAC;IAC1B,aAAa,EAAE,aAAa,CAAC;IAGpD,iBAAiB,EAAE,6BAA6B,CAAC;IACrB,cAAc,EAAE,kBAAkB,CAAC;IAC5B,oBAAoB,EAAE,yBAAyB,CAAC;IAEnF,OAAO;IAsCP,2BAA2B;IAM3B;;OAEG;IACG,8BAA8B,CAAC,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAYzE"}
|