forked from jupyter-lsp/jupyterlab-lsp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.ts
59 lines (55 loc) · 1.82 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { CodeEditor } from '@jupyterlab/codeeditor';
export interface IExtractedCode {
/**
* Foreign code (may be empty, for example line of '%R') or null if none.
*/
foreign_code: string | null;
/**
* Range of the foreign code relative to the original source.
*/
range: CodeEditor.IRange;
/**
* Code to be retained in the virtual document of the host.
*/
host_code: string | null;
}
/**
* Foreign code extractor makes it possible to analyze code of language X embedded in code (or notebook) of language Y.
*
* The typical examples are:
* - (X=CSS< Y=HTML), or
* - (X=JavaScrip, Y=HTML),
*
* while in the data analysis realm, examples include:
* - (X=R, Y=IPython),
* - (X=LATEX Y=IPython),
* - (X=SQL, Y=IPython)
*
* This extension does not aim to provide comprehensive abilities for foreign code extraction,
* but it does intend to provide stable interface for other extensions to build on it.
*
* A simple, regular expression based, configurable foreign extractor is implemented
* to provide a good reference and a good initial experience for the users.
*/
export interface IForeignCodeExtractor {
/**
* The foreign language.
*/
language: string;
/**
* Split the code into the host and foreign code (if any foreign code was detected)
*/
extract_foreign_code(code: string): IExtractedCode[];
/**
* Does the extractor produce code which should be appended to the previously established virtual document (False)
* of the same language, or does it produce standalone snippets which require separate connections (True)?
*/
standalone: boolean;
/**
* Test if there is any foreign code in provided code snippet.
*/
has_foreign_code(code: string): boolean;
}
export interface IForeignCodeExtractorsRegistry {
[host_language: string]: IForeignCodeExtractor[];
}