monaco-yql-languages 1.0.5 → 1.0.6
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/build/_.contribution.d.ts +88 -0
- package/build/_.contribution.js +113 -0
- package/build/clickhouse/clickhouse.contribution.d.ts +3 -0
- package/build/clickhouse/clickhouse.contribution.js +16 -0
- package/build/clickhouse/clickhouse.d.ts +4 -0
- package/{src/clickhouse/clickhouse.ts → build/clickhouse/clickhouse.js} +52 -84
- package/build/clickhouse/clickhouse.keywords.d.ts +11 -0
- package/{src/clickhouse/clickhouse.keywords.ts → build/clickhouse/clickhouse.keywords.js} +2 -16
- package/build/completion.d.ts +9 -0
- package/build/completion.js +87 -0
- package/build/fillers/monaco-editor-core.js +1 -0
- package/build/monaco.contribution.js +5 -0
- package/build/s-expressions/s-expressions.contribution.d.ts +1 -0
- package/{src/s-expressions/s-expressions.contribution.ts → build/s-expressions/s-expressions.contribution.js} +1 -3
- package/build/s-expressions/s-expressions.d.ts +4 -0
- package/{src/s-expressions/s-expressions.ts → build/s-expressions/s-expressions.js} +23 -34
- package/build/s-expressions/s-expressions.keywords.d.ts +3 -0
- package/build/s-expressions/s-expressions.keywords.js +3 -0
- package/build/themes/themes.contribution.d.ts +1 -0
- package/build/themes/themes.contribution.js +47 -0
- package/build/yql/yql.contribution.d.ts +1 -0
- package/build/yql/yql.contribution.js +12 -0
- package/build/yql/yql.d.ts +7 -0
- package/{src/yql/yql.ts → build/yql/yql.js} +41 -57
- package/build/yql/yql.keywords.d.ts +3 -0
- package/build/yql/yql.keywords.js +3 -0
- package/build/yql/yql_ansi.contribution.d.ts +1 -0
- package/build/yql/yql_ansi.contribution.js +12 -0
- package/package.json +5 -2
- package/.editorconfig +0 -17
- package/.eslintignore +0 -1
- package/.eslintrc +0 -7
- package/.github/workflows/ci.yml +0 -44
- package/.github/workflows/release.yml +0 -16
- package/.husky/commit-msg +0 -4
- package/.husky/pre-commit +0 -4
- package/.nvmrc +0 -1
- package/.prettierignore +0 -3
- package/.prettierignore copy +0 -2
- package/.prettierrc.js +0 -1
- package/.stylelintrc +0 -3
- package/AUTHORS +0 -5
- package/CHANGELOG.md +0 -53
- package/CODEOWNERS +0 -1
- package/CONTRIBUTING.md +0 -36
- package/commitlint.config.js +0 -1
- package/src/_.contribution.ts +0 -246
- package/src/clickhouse/clickhouse.contribution.ts +0 -31
- package/src/completion.ts +0 -124
- package/src/s-expressions/s-expressions.keywords.ts +0 -14
- package/src/themes/themes.contribution.ts +0 -49
- package/src/yql/yql.contribution.ts +0 -15
- package/src/yql/yql.keywords.ts +0 -13
- package/src/yql/yql_ansi.contribution.ts +0 -15
- package/tsconfig.json +0 -12
- /package/{src/fillers/monaco-editor-core.ts → build/fillers/monaco-editor-core.d.ts} +0 -0
- /package/{src/monaco.contribution.ts → build/monaco.contribution.d.ts} +0 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { CompletionLists } from './completion';
|
|
2
|
+
import { IEvent, languages } from './fillers/monaco-editor-core';
|
|
3
|
+
interface ILang extends languages.ILanguageExtensionPoint {
|
|
4
|
+
loader: () => Promise<ILangImpl>;
|
|
5
|
+
}
|
|
6
|
+
interface ILangImpl {
|
|
7
|
+
conf: languages.LanguageConfiguration;
|
|
8
|
+
language: languages.IMonarchLanguage;
|
|
9
|
+
completions?: CompletionLists;
|
|
10
|
+
}
|
|
11
|
+
export declare function loadLanguage(languageId: string): Promise<ILangImpl>;
|
|
12
|
+
export declare function registerLanguage(def: ILang): void;
|
|
13
|
+
export interface ICreateData {
|
|
14
|
+
languageId: string;
|
|
15
|
+
}
|
|
16
|
+
export interface ModeConfiguration {
|
|
17
|
+
/**
|
|
18
|
+
* Defines whether the built-in completionItemProvider is enabled.
|
|
19
|
+
*/
|
|
20
|
+
readonly completionItems?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Defines whether the built-in hoverProvider is enabled.
|
|
23
|
+
*/
|
|
24
|
+
readonly hovers?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Defines whether the built-in documentSymbolProvider is enabled.
|
|
27
|
+
*/
|
|
28
|
+
readonly documentSymbols?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Defines whether the built-in definitions provider is enabled.
|
|
31
|
+
*/
|
|
32
|
+
readonly definitions?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Defines whether the built-in references provider is enabled.
|
|
35
|
+
*/
|
|
36
|
+
readonly references?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Defines whether the built-in references provider is enabled.
|
|
39
|
+
*/
|
|
40
|
+
readonly documentHighlights?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Defines whether the built-in rename provider is enabled.
|
|
43
|
+
*/
|
|
44
|
+
readonly rename?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Defines whether the built-in color provider is enabled.
|
|
47
|
+
*/
|
|
48
|
+
readonly colors?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Defines whether the built-in foldingRange provider is enabled.
|
|
51
|
+
*/
|
|
52
|
+
readonly foldingRanges?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Defines whether the built-in diagnostic provider is enabled.
|
|
55
|
+
*/
|
|
56
|
+
readonly diagnostics?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Defines whether the built-in selection range provider is enabled.
|
|
59
|
+
*/
|
|
60
|
+
readonly selectionRanges?: boolean;
|
|
61
|
+
}
|
|
62
|
+
export interface DiagnosticsOptions {
|
|
63
|
+
readonly validate?: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface LanguageServiceDefaults {
|
|
66
|
+
readonly languageId: string;
|
|
67
|
+
readonly onDidChange: IEvent<LanguageServiceDefaults>;
|
|
68
|
+
readonly diagnosticsOptions: DiagnosticsOptions;
|
|
69
|
+
readonly modeConfiguration: ModeConfiguration;
|
|
70
|
+
setDiagnosticsOptions(options: DiagnosticsOptions): void;
|
|
71
|
+
setModeConfiguration(modeConfiguration: ModeConfiguration): void;
|
|
72
|
+
}
|
|
73
|
+
export declare class LanguageServiceDefaultsImpl implements LanguageServiceDefaults {
|
|
74
|
+
private _onDidChange;
|
|
75
|
+
private _diagnosticsOptions;
|
|
76
|
+
private _modeConfiguration;
|
|
77
|
+
private _languageId;
|
|
78
|
+
constructor(languageId: string, diagnosticsOptions: DiagnosticsOptions, modeConfiguration: ModeConfiguration);
|
|
79
|
+
get onDidChange(): IEvent<LanguageServiceDefaults>;
|
|
80
|
+
get languageId(): string;
|
|
81
|
+
get modeConfiguration(): ModeConfiguration;
|
|
82
|
+
get diagnosticsOptions(): DiagnosticsOptions;
|
|
83
|
+
setDiagnosticsOptions(options: DiagnosticsOptions): void;
|
|
84
|
+
setModeConfiguration(modeConfiguration: ModeConfiguration): void;
|
|
85
|
+
}
|
|
86
|
+
export declare const modeConfigurationDefault: Required<ModeConfiguration>;
|
|
87
|
+
export declare const diagnosticDefault: Required<DiagnosticsOptions>;
|
|
88
|
+
export {};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { getCompletionItemsProvider } from './completion';
|
|
2
|
+
import { Emitter, languages } from './fillers/monaco-editor-core';
|
|
3
|
+
const languageDefinitions = {};
|
|
4
|
+
const lazyLanguageLoaders = {};
|
|
5
|
+
class LazyLanguageLoader {
|
|
6
|
+
static getOrCreate(languageId) {
|
|
7
|
+
if (!lazyLanguageLoaders[languageId]) {
|
|
8
|
+
lazyLanguageLoaders[languageId] = new LazyLanguageLoader(languageId);
|
|
9
|
+
}
|
|
10
|
+
return lazyLanguageLoaders[languageId];
|
|
11
|
+
}
|
|
12
|
+
constructor(languageId) {
|
|
13
|
+
this._languageId = languageId;
|
|
14
|
+
this._loadingTriggered = false;
|
|
15
|
+
this._lazyLoadPromise = new Promise((resolve, reject) => {
|
|
16
|
+
this._lazyLoadPromiseResolve = resolve;
|
|
17
|
+
this._lazyLoadPromiseReject = reject;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
whenLoaded() {
|
|
21
|
+
return this._lazyLoadPromise;
|
|
22
|
+
}
|
|
23
|
+
load() {
|
|
24
|
+
if (!this._loadingTriggered) {
|
|
25
|
+
this._loadingTriggered = true;
|
|
26
|
+
languageDefinitions[this._languageId].loader().then((mod) => this._lazyLoadPromiseResolve(mod), (err) => this._lazyLoadPromiseReject(err));
|
|
27
|
+
}
|
|
28
|
+
return this._lazyLoadPromise;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function loadLanguage(languageId) {
|
|
32
|
+
return LazyLanguageLoader.getOrCreate(languageId).load();
|
|
33
|
+
}
|
|
34
|
+
export function registerLanguage(def) {
|
|
35
|
+
const languageId = def.id;
|
|
36
|
+
languageDefinitions[languageId] = def;
|
|
37
|
+
languages.register(def);
|
|
38
|
+
const lazyLanguageLoader = LazyLanguageLoader.getOrCreate(languageId);
|
|
39
|
+
languages.setMonarchTokensProvider(languageId, lazyLanguageLoader.whenLoaded().then((mod) => mod.language));
|
|
40
|
+
languages.onLanguage(languageId, () => {
|
|
41
|
+
lazyLanguageLoader.load().then((mod) => {
|
|
42
|
+
languages.setLanguageConfiguration(languageId, mod.conf);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
lazyLanguageLoader.whenLoaded().then((mod) => {
|
|
46
|
+
if (mod.completions) {
|
|
47
|
+
registerCompletionItemProvider(languageId, mod.completions);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function registerCompletionItemProvider(languageId, completions) {
|
|
52
|
+
const disposables = [];
|
|
53
|
+
function unregister() {
|
|
54
|
+
var _a;
|
|
55
|
+
while (disposables.length > 0) {
|
|
56
|
+
(_a = disposables.pop()) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const defaults = languages[languageId];
|
|
60
|
+
if (!defaults || defaults.modeConfiguration.completionItems) {
|
|
61
|
+
disposables.push(languages.registerCompletionItemProvider(languageId, getCompletionItemsProvider(completions, languages.CompletionItemKind)));
|
|
62
|
+
}
|
|
63
|
+
if (defaults) {
|
|
64
|
+
disposables.push(defaults.onDidChange(() => {
|
|
65
|
+
unregister();
|
|
66
|
+
registerCompletionItemProvider(languageId, completions);
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export class LanguageServiceDefaultsImpl {
|
|
71
|
+
constructor(languageId, diagnosticsOptions, modeConfiguration) {
|
|
72
|
+
this._onDidChange = new Emitter();
|
|
73
|
+
this._languageId = languageId;
|
|
74
|
+
this.setDiagnosticsOptions(diagnosticsOptions);
|
|
75
|
+
this.setModeConfiguration(modeConfiguration);
|
|
76
|
+
}
|
|
77
|
+
get onDidChange() {
|
|
78
|
+
return this._onDidChange.event;
|
|
79
|
+
}
|
|
80
|
+
get languageId() {
|
|
81
|
+
return this._languageId;
|
|
82
|
+
}
|
|
83
|
+
get modeConfiguration() {
|
|
84
|
+
return this._modeConfiguration;
|
|
85
|
+
}
|
|
86
|
+
get diagnosticsOptions() {
|
|
87
|
+
return this._diagnosticsOptions;
|
|
88
|
+
}
|
|
89
|
+
setDiagnosticsOptions(options) {
|
|
90
|
+
this._diagnosticsOptions = options || Object.create(null);
|
|
91
|
+
this._onDidChange.fire(this);
|
|
92
|
+
}
|
|
93
|
+
setModeConfiguration(modeConfiguration) {
|
|
94
|
+
this._modeConfiguration = modeConfiguration || Object.create(null);
|
|
95
|
+
this._onDidChange.fire(this);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export const modeConfigurationDefault = {
|
|
99
|
+
completionItems: true,
|
|
100
|
+
hovers: true,
|
|
101
|
+
documentSymbols: true,
|
|
102
|
+
definitions: true,
|
|
103
|
+
references: true,
|
|
104
|
+
documentHighlights: true,
|
|
105
|
+
rename: true,
|
|
106
|
+
colors: true,
|
|
107
|
+
foldingRanges: true,
|
|
108
|
+
diagnostics: true,
|
|
109
|
+
selectionRanges: true,
|
|
110
|
+
};
|
|
111
|
+
export const diagnosticDefault = {
|
|
112
|
+
validate: true,
|
|
113
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LanguageServiceDefaultsImpl, diagnosticDefault, modeConfigurationDefault, registerLanguage, } from '../_.contribution';
|
|
2
|
+
import { languages } from '../fillers/monaco-editor-core';
|
|
3
|
+
export const LANGUAGE_ID = 'clickhouse';
|
|
4
|
+
registerLanguage({
|
|
5
|
+
id: LANGUAGE_ID,
|
|
6
|
+
extensions: [],
|
|
7
|
+
loader: () => import('./clickhouse').then((module) => {
|
|
8
|
+
return {
|
|
9
|
+
conf: module.conf,
|
|
10
|
+
language: module.language,
|
|
11
|
+
completions: module.completionLists,
|
|
12
|
+
};
|
|
13
|
+
}),
|
|
14
|
+
});
|
|
15
|
+
export const clickhouseDefaults = new LanguageServiceDefaultsImpl(LANGUAGE_ID, diagnosticDefault, modeConfigurationDefault);
|
|
16
|
+
languages[LANGUAGE_ID] = clickhouseDefaults;
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
constants,
|
|
5
|
-
dataTypeFamiliesCaseInsensitive,
|
|
6
|
-
dataTypeFamiliesCaseSensitive,
|
|
7
|
-
functionsCaseInsensitive,
|
|
8
|
-
functionsCaseSensitive,
|
|
9
|
-
keywords,
|
|
10
|
-
tableEngines,
|
|
11
|
-
tableFunctions,
|
|
12
|
-
} from './clickhouse.keywords';
|
|
13
|
-
|
|
14
|
-
export {completionLists} from './clickhouse.keywords';
|
|
15
|
-
|
|
16
|
-
export const conf: languages.LanguageConfiguration = {
|
|
1
|
+
import { constants, dataTypeFamiliesCaseInsensitive, dataTypeFamiliesCaseSensitive, functionsCaseInsensitive, functionsCaseSensitive, keywords, tableEngines, tableFunctions, } from './clickhouse.keywords';
|
|
2
|
+
export { completionLists } from './clickhouse.keywords';
|
|
3
|
+
export const conf = {
|
|
17
4
|
comments: {
|
|
18
5
|
lineComment: '--',
|
|
19
6
|
blockComment: ['```', '```'],
|
|
@@ -24,40 +11,33 @@ export const conf: languages.LanguageConfiguration = {
|
|
|
24
11
|
['(', ')'],
|
|
25
12
|
],
|
|
26
13
|
autoClosingPairs: [
|
|
27
|
-
{open: '{', close: '}'},
|
|
28
|
-
{open: '[', close: ']'},
|
|
29
|
-
{open: '(', close: ')'},
|
|
30
|
-
{open: '"', close: '"'},
|
|
31
|
-
{open: "'", close: "'"},
|
|
32
|
-
{open: '`', close: '`'},
|
|
14
|
+
{ open: '{', close: '}' },
|
|
15
|
+
{ open: '[', close: ']' },
|
|
16
|
+
{ open: '(', close: ')' },
|
|
17
|
+
{ open: '"', close: '"' },
|
|
18
|
+
{ open: "'", close: "'" },
|
|
19
|
+
{ open: '`', close: '`' },
|
|
33
20
|
],
|
|
34
21
|
surroundingPairs: [
|
|
35
|
-
{open: '{', close: '}'},
|
|
36
|
-
{open: '[', close: ']'},
|
|
37
|
-
{open: '(', close: ')'},
|
|
38
|
-
{open: '"', close: '"'},
|
|
39
|
-
{open: "'", close: "'"},
|
|
40
|
-
{open: '`', close: '`'},
|
|
22
|
+
{ open: '{', close: '}' },
|
|
23
|
+
{ open: '[', close: ']' },
|
|
24
|
+
{ open: '(', close: ')' },
|
|
25
|
+
{ open: '"', close: '"' },
|
|
26
|
+
{ open: "'", close: "'" },
|
|
27
|
+
{ open: '`', close: '`' },
|
|
41
28
|
],
|
|
42
29
|
};
|
|
43
|
-
|
|
44
30
|
const keywordsCaseInsensitive = getCaseInsensitiveRegExp(keywords);
|
|
45
|
-
const typeKeywordsCaseInsensitive = getCaseInsensitiveRegExp(
|
|
46
|
-
oneWordPatterns(dataTypeFamiliesCaseInsensitive),
|
|
47
|
-
);
|
|
31
|
+
const typeKeywordsCaseInsensitive = getCaseInsensitiveRegExp(oneWordPatterns(dataTypeFamiliesCaseInsensitive));
|
|
48
32
|
const builtinFunctionsCaseInsensitive = getCaseInsensitiveRegExp(functionsCaseInsensitive);
|
|
49
|
-
|
|
50
|
-
export const language: languages.IMonarchLanguage & Record<string, unknown> = {
|
|
33
|
+
export const language = {
|
|
51
34
|
defaultToken: 'text',
|
|
52
|
-
|
|
53
35
|
brackets: [
|
|
54
|
-
{open: '[', close: ']', token: 'delimiter.square'},
|
|
55
|
-
{open: '(', close: ')', token: 'delimiter.parenthesis'},
|
|
56
|
-
{open: '{', close: '}', token: 'delimiter.curly'},
|
|
36
|
+
{ open: '[', close: ']', token: 'delimiter.square' },
|
|
37
|
+
{ open: '(', close: ')', token: 'delimiter.parenthesis' },
|
|
38
|
+
{ open: '{', close: '}', token: 'delimiter.curly' },
|
|
57
39
|
],
|
|
58
|
-
|
|
59
40
|
keywords,
|
|
60
|
-
|
|
61
41
|
keywordsDouble: [
|
|
62
42
|
`${caseInsensitiveRegExp('GROUP')}\\W+${caseInsensitiveRegExp('BY')}`,
|
|
63
43
|
`${caseInsensitiveRegExp('ON')}\\W+${caseInsensitiveRegExp('CLUSTER')}`,
|
|
@@ -81,18 +61,12 @@ export const language: languages.IMonarchLanguage & Record<string, unknown> = {
|
|
|
81
61
|
`${caseInsensitiveRegExp('FORMAT')}\\W+JSON`,
|
|
82
62
|
`${caseInsensitiveRegExp('FORMAT')}\\W+TabSeparated`,
|
|
83
63
|
].join('|'),
|
|
84
|
-
|
|
85
64
|
typeKeywords: dataTypeFamiliesCaseSensitive,
|
|
86
|
-
typeKeywordsDouble: getCaseInsensitiveRegExp(
|
|
87
|
-
manyWordsPatterns(dataTypeFamiliesCaseInsensitive),
|
|
88
|
-
),
|
|
65
|
+
typeKeywordsDouble: getCaseInsensitiveRegExp(manyWordsPatterns(dataTypeFamiliesCaseInsensitive)),
|
|
89
66
|
constants,
|
|
90
|
-
|
|
91
67
|
builtinFunctions: functionsCaseSensitive,
|
|
92
|
-
|
|
93
68
|
tableFunctions,
|
|
94
69
|
tableEngines,
|
|
95
|
-
|
|
96
70
|
operators: [
|
|
97
71
|
'+',
|
|
98
72
|
'-',
|
|
@@ -114,18 +88,16 @@ export const language: languages.IMonarchLanguage & Record<string, unknown> = {
|
|
|
114
88
|
'<>',
|
|
115
89
|
'=',
|
|
116
90
|
],
|
|
117
|
-
|
|
118
91
|
symbols: /[=><!~?:&|+\-*/^%]+/,
|
|
119
92
|
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
|
120
93
|
// TODO: FIX ME
|
|
121
94
|
variables: /[\w]+(?:\[[\w\]+]|[=-]>\w+)?/,
|
|
122
|
-
|
|
123
95
|
tokenizer: {
|
|
124
96
|
root: [
|
|
125
|
-
{include: '@whitespace'},
|
|
126
|
-
{include: '@comments'},
|
|
127
|
-
{include: '@numbers'},
|
|
128
|
-
{include: '@strings'},
|
|
97
|
+
{ include: '@whitespace' },
|
|
98
|
+
{ include: '@comments' },
|
|
99
|
+
{ include: '@numbers' },
|
|
100
|
+
{ include: '@strings' },
|
|
129
101
|
// variables
|
|
130
102
|
[/[$@:](@variables)/, 'variable'],
|
|
131
103
|
[/{(@variables)}/, 'variable'],
|
|
@@ -138,14 +110,14 @@ export const language: languages.IMonarchLanguage & Record<string, unknown> = {
|
|
|
138
110
|
/[a-zA-Z_$][\w$]*/,
|
|
139
111
|
{
|
|
140
112
|
cases: {
|
|
141
|
-
[keywordsCaseInsensitive]: {token: 'keyword'},
|
|
142
|
-
'@constants': {token: 'constant'},
|
|
143
|
-
'@builtinFunctions': {token: 'constant.other.color'},
|
|
144
|
-
[builtinFunctionsCaseInsensitive]: {token: 'constant.other.color'},
|
|
145
|
-
'@tableFunctions': {token: 'constant.other.color'},
|
|
146
|
-
'@tableEngines': {token: 'constant.other.color'},
|
|
147
|
-
'@typeKeywords': {token: 'keyword.type'},
|
|
148
|
-
[typeKeywordsCaseInsensitive]: {token: 'keyword.type'},
|
|
113
|
+
[keywordsCaseInsensitive]: { token: 'keyword' },
|
|
114
|
+
'@constants': { token: 'constant' },
|
|
115
|
+
'@builtinFunctions': { token: 'constant.other.color' },
|
|
116
|
+
[builtinFunctionsCaseInsensitive]: { token: 'constant.other.color' },
|
|
117
|
+
'@tableFunctions': { token: 'constant.other.color' },
|
|
118
|
+
'@tableEngines': { token: 'constant.other.color' },
|
|
119
|
+
'@typeKeywords': { token: 'keyword.type' },
|
|
120
|
+
[typeKeywordsCaseInsensitive]: { token: 'keyword.type' },
|
|
149
121
|
'@default': 'identifier',
|
|
150
122
|
},
|
|
151
123
|
},
|
|
@@ -163,66 +135,62 @@ export const language: languages.IMonarchLanguage & Record<string, unknown> = {
|
|
|
163
135
|
whitespace: [[/\s+/, 'white']],
|
|
164
136
|
comments: [
|
|
165
137
|
[/--+.*/, 'comment'],
|
|
166
|
-
[/```/, {token: 'comment.quote', next: '@comment'}],
|
|
167
|
-
[/\/\*/, {token: 'comment.quote', next: '@cppComment'}],
|
|
138
|
+
[/```/, { token: 'comment.quote', next: '@comment' }],
|
|
139
|
+
[/\/\*/, { token: 'comment.quote', next: '@cppComment' }],
|
|
168
140
|
],
|
|
169
141
|
comment: [
|
|
170
142
|
[/[^`]+/, 'comment'],
|
|
171
|
-
[/```/, {token: 'comment.quote', next: '@pop'}],
|
|
143
|
+
[/```/, { token: 'comment.quote', next: '@pop' }],
|
|
172
144
|
[/./, 'comment'],
|
|
173
145
|
],
|
|
174
146
|
cppComment: [
|
|
175
147
|
[/[^*/]+/, 'comment'],
|
|
176
|
-
[/\*\//, {token: 'comment.quote', next: '@pop'}],
|
|
148
|
+
[/\*\//, { token: 'comment.quote', next: '@pop' }],
|
|
177
149
|
[/./, 'comment'],
|
|
178
150
|
],
|
|
179
151
|
numbers: [[/[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/, 'number']],
|
|
180
152
|
strings: [
|
|
181
|
-
[/'/, {token: 'string', next: '@stringSingle'}],
|
|
182
|
-
[/"/, {token: 'string.tablepath', next: '@stringDouble'}],
|
|
183
|
-
[/`/, {token: 'string.tablepath', next: '@stringBacktick'}],
|
|
153
|
+
[/'/, { token: 'string', next: '@stringSingle' }],
|
|
154
|
+
[/"/, { token: 'string.tablepath', next: '@stringDouble' }],
|
|
155
|
+
[/`/, { token: 'string.tablepath', next: '@stringBacktick' }],
|
|
184
156
|
],
|
|
185
157
|
stringSingle: [
|
|
186
158
|
[/[^\\']/, 'string'],
|
|
187
159
|
[/@escapes/, 'string.escape'],
|
|
188
160
|
[/\\./, 'string.escape.invalid'],
|
|
189
|
-
[/'/, {token: 'string', next: '@pop'}],
|
|
161
|
+
[/'/, { token: 'string', next: '@pop' }],
|
|
190
162
|
],
|
|
191
163
|
stringDouble: [
|
|
192
164
|
[/[^\\"]/, 'string.tablepath'],
|
|
193
165
|
[/@escapes/, 'string.tablepath'],
|
|
194
166
|
[/\\./, 'string.tablepath'],
|
|
195
|
-
[/"/, {token: 'string.tablepath', next: '@pop'}],
|
|
167
|
+
[/"/, { token: 'string.tablepath', next: '@pop' }],
|
|
196
168
|
],
|
|
197
169
|
stringBacktick: [
|
|
198
170
|
[/[^\\`]/, 'string.tablepath'],
|
|
199
171
|
[/@escapes/, 'string.tablepath'],
|
|
200
172
|
[/\\./, 'string.tablepath'],
|
|
201
|
-
[/`/, {token: 'string.tablepath', next: '@pop'}],
|
|
173
|
+
[/`/, { token: 'string.tablepath', next: '@pop' }],
|
|
202
174
|
],
|
|
203
175
|
},
|
|
204
176
|
};
|
|
205
|
-
|
|
206
|
-
function caseInsensitiveRegExp(pattern: string) {
|
|
177
|
+
function caseInsensitiveRegExp(pattern) {
|
|
207
178
|
return pattern
|
|
208
179
|
.split('')
|
|
209
180
|
.map((char) => {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
181
|
+
if (/[a-zA-Z]/.test(char)) {
|
|
182
|
+
return `[${char.toLowerCase()}${char.toUpperCase()}]`;
|
|
183
|
+
}
|
|
184
|
+
return char;
|
|
185
|
+
})
|
|
215
186
|
.join('');
|
|
216
187
|
}
|
|
217
|
-
|
|
218
|
-
function getCaseInsensitiveRegExp(patterns: string[]) {
|
|
188
|
+
function getCaseInsensitiveRegExp(patterns) {
|
|
219
189
|
return `(${patterns.map((pattern) => caseInsensitiveRegExp(pattern).replace(/\s+/g, '\\s')).join('|')})`;
|
|
220
190
|
}
|
|
221
|
-
|
|
222
|
-
function oneWordPatterns(patterns: string[]) {
|
|
191
|
+
function oneWordPatterns(patterns) {
|
|
223
192
|
return patterns.filter((pattern) => /^\S*$/.test(pattern));
|
|
224
193
|
}
|
|
225
|
-
|
|
226
|
-
function manyWordsPatterns(patterns: string[]) {
|
|
194
|
+
function manyWordsPatterns(patterns) {
|
|
227
195
|
return patterns.filter((pattern) => /\s/.test(pattern)).sort((a, b) => b.localeCompare(a));
|
|
228
196
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CompletionLists } from '../completion';
|
|
2
|
+
export declare const keywords: string[];
|
|
3
|
+
export declare const keywordsDouble: string[];
|
|
4
|
+
export declare const constants: string[];
|
|
5
|
+
export declare const functionsCaseSensitive: string[];
|
|
6
|
+
export declare const functionsCaseInsensitive: string[];
|
|
7
|
+
export declare const tableFunctions: string[];
|
|
8
|
+
export declare const tableEngines: string[];
|
|
9
|
+
export declare const dataTypeFamiliesCaseSensitive: string[];
|
|
10
|
+
export declare const dataTypeFamiliesCaseInsensitive: string[];
|
|
11
|
+
export declare const completionLists: CompletionLists;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type {CompletionLists} from '../completion';
|
|
2
|
-
|
|
3
1
|
export const keywords = [
|
|
4
2
|
'AND',
|
|
5
3
|
'ANY',
|
|
@@ -58,7 +56,6 @@ export const keywords = [
|
|
|
58
56
|
'WHERE',
|
|
59
57
|
'WITH',
|
|
60
58
|
];
|
|
61
|
-
|
|
62
59
|
export const keywordsDouble = [
|
|
63
60
|
'GROUP BY',
|
|
64
61
|
'ON CLUSTER',
|
|
@@ -80,9 +77,7 @@ export const keywordsDouble = [
|
|
|
80
77
|
'FORMAT JSON',
|
|
81
78
|
'FORMAT TabSeparated',
|
|
82
79
|
];
|
|
83
|
-
|
|
84
80
|
export const constants = ['true', 'false', 'NULL'];
|
|
85
|
-
|
|
86
81
|
export const functionsCaseSensitive = [
|
|
87
82
|
'__bitBoolMaskAnd',
|
|
88
83
|
'__bitBoolMaskOr',
|
|
@@ -1016,7 +1011,6 @@ export const functionsCaseSensitive = [
|
|
|
1016
1011
|
'YSONLength',
|
|
1017
1012
|
'YSONType',
|
|
1018
1013
|
];
|
|
1019
|
-
|
|
1020
1014
|
export const functionsCaseInsensitive = [
|
|
1021
1015
|
'_CAST',
|
|
1022
1016
|
'abs',
|
|
@@ -1138,7 +1132,6 @@ export const functionsCaseInsensitive = [
|
|
|
1138
1132
|
'YEAR',
|
|
1139
1133
|
'yearweek',
|
|
1140
1134
|
];
|
|
1141
|
-
|
|
1142
1135
|
export const tableFunctions = [
|
|
1143
1136
|
'cluster',
|
|
1144
1137
|
'clusterAllReplicas',
|
|
@@ -1166,9 +1159,7 @@ export const tableFunctions = [
|
|
|
1166
1159
|
'zeros',
|
|
1167
1160
|
'zeros_mt',
|
|
1168
1161
|
];
|
|
1169
|
-
|
|
1170
1162
|
export const tableEngines = ['Buffer', 'Memory', 'YtTable'];
|
|
1171
|
-
|
|
1172
1163
|
export const dataTypeFamiliesCaseSensitive = [
|
|
1173
1164
|
'AggregateFunction',
|
|
1174
1165
|
'Array',
|
|
@@ -1214,7 +1205,6 @@ export const dataTypeFamiliesCaseSensitive = [
|
|
|
1214
1205
|
'UUID',
|
|
1215
1206
|
'YtBoolean',
|
|
1216
1207
|
];
|
|
1217
|
-
|
|
1218
1208
|
export const dataTypeFamiliesCaseInsensitive = [
|
|
1219
1209
|
'BIGINT',
|
|
1220
1210
|
'BIGINT SIGNED',
|
|
@@ -1294,13 +1284,9 @@ export const dataTypeFamiliesCaseInsensitive = [
|
|
|
1294
1284
|
'VARCHAR',
|
|
1295
1285
|
'VARCHAR2',
|
|
1296
1286
|
];
|
|
1297
|
-
|
|
1298
|
-
export const completionLists: CompletionLists = {
|
|
1287
|
+
export const completionLists = {
|
|
1299
1288
|
keywordList: keywords.concat(keywordsDouble),
|
|
1300
1289
|
constantList: constants,
|
|
1301
|
-
typeParameterList: dataTypeFamiliesCaseSensitive.concat(
|
|
1302
|
-
dataTypeFamiliesCaseInsensitive,
|
|
1303
|
-
tableEngines,
|
|
1304
|
-
),
|
|
1290
|
+
typeParameterList: dataTypeFamiliesCaseSensitive.concat(dataTypeFamiliesCaseInsensitive, tableEngines),
|
|
1305
1291
|
functionList: functionsCaseSensitive.concat(functionsCaseInsensitive, tableFunctions),
|
|
1306
1292
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CancellationToken, Position, editor, languages } from './fillers/monaco-editor-core';
|
|
2
|
+
export type CompletionListProvider = {
|
|
3
|
+
(content: string, offset: number, signal?: AbortSignal | null): Promise<string[]>;
|
|
4
|
+
};
|
|
5
|
+
export declare function provideCompletionItems(getCompletionList: CompletionListProvider): (model: editor.ITextModel, position: Position, context: languages.CompletionContext, token: CancellationToken) => languages.ProviderResult<languages.CompletionList>;
|
|
6
|
+
export type CompletionLists = Partial<Record<`${Uncapitalize<keyof typeof languages.CompletionItemKind>}List`, Readonly<string[]>>>;
|
|
7
|
+
export declare function getCompletionItemsProvider(completions: CompletionLists, completionItemKind: typeof languages.CompletionItemKind): {
|
|
8
|
+
provideCompletionItems(model: editor.ITextModel, position: Position, _context: languages.CompletionContext, _token: CancellationToken): languages.CompletionList | undefined;
|
|
9
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const allUpperCaseRe = new RegExp('^[$A-Z_\\s]+$');
|
|
2
|
+
export function provideCompletionItems(getCompletionList) {
|
|
3
|
+
return (model, position, context, token) => {
|
|
4
|
+
const controller = new AbortController();
|
|
5
|
+
const signal = controller.signal;
|
|
6
|
+
token.onCancellationRequested(() => {
|
|
7
|
+
controller.abort();
|
|
8
|
+
});
|
|
9
|
+
const prevText = model
|
|
10
|
+
.getLineContent(position.lineNumber)
|
|
11
|
+
.slice(0, position.column - 1)
|
|
12
|
+
.toLowerCase();
|
|
13
|
+
if (context.triggerCharacter === ':' && prevText.slice(-2) !== '::') {
|
|
14
|
+
return { suggestions: [] };
|
|
15
|
+
}
|
|
16
|
+
else if (context.triggerCharacter === '`' && /[^\s.]`$/.test(prevText)) {
|
|
17
|
+
return { suggestions: [] };
|
|
18
|
+
}
|
|
19
|
+
return getCompletionList(model.getValue(), model.getOffsetAt(position), signal).then(async (data) => {
|
|
20
|
+
const suggestions = [];
|
|
21
|
+
for (const label of data) {
|
|
22
|
+
const suggest = label.length > 1
|
|
23
|
+
? label.slice(0, -1).replace(/[/[]/g, '\\\\$&') + label.slice(-1)
|
|
24
|
+
: label;
|
|
25
|
+
let range;
|
|
26
|
+
if (/[`~!@#%^&*()-=+[{\]}|;:'",.<>/?]/.test(suggest)) {
|
|
27
|
+
for (let i = 0; i < label.length; i++) {
|
|
28
|
+
const prefix = (i === 0 ? suggest : suggest.slice(0, -i)).toLowerCase();
|
|
29
|
+
if (prevText.endsWith(prefix)) {
|
|
30
|
+
range = {
|
|
31
|
+
startLineNumber: position.lineNumber,
|
|
32
|
+
startColumn: position.column - prefix.length,
|
|
33
|
+
endLineNumber: position.lineNumber,
|
|
34
|
+
endColumn: position.column,
|
|
35
|
+
};
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
suggestions.push({
|
|
41
|
+
label,
|
|
42
|
+
filterText: allUpperCaseRe.test(label) ? label.toLowerCase() : label,
|
|
43
|
+
kind: 18, // languages.CompletionItemKind.Text,
|
|
44
|
+
insertText: suggest,
|
|
45
|
+
command: label.endsWith('/') || label.endsWith('.`') || label.endsWith('::')
|
|
46
|
+
? { id: 'editor.action.triggerSuggest', title: '' }
|
|
47
|
+
: undefined,
|
|
48
|
+
//@ts-ignore
|
|
49
|
+
range,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return { suggestions, incomplete: suggestions.length > 0 };
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function getCompletionItemsProvider(completions, completionItemKind) {
|
|
57
|
+
const suggestions = [];
|
|
58
|
+
for (const value in completionItemKind) {
|
|
59
|
+
if (!isNaN(Number(value))) {
|
|
60
|
+
const name = `${completionItemKind[value].toLowerCase()}List`;
|
|
61
|
+
if (name in completions) {
|
|
62
|
+
for (const label of completions[name]) {
|
|
63
|
+
suggestions.push({
|
|
64
|
+
label,
|
|
65
|
+
filterText: allUpperCaseRe.test(label) ? label.toLowerCase() : label,
|
|
66
|
+
insertText: label,
|
|
67
|
+
kind: Number(value),
|
|
68
|
+
range: { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 },
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
suggestions.sort((a, b) => a.filterText.localeCompare(b.filterText));
|
|
75
|
+
return {
|
|
76
|
+
provideCompletionItems(model, position, _context, _token) {
|
|
77
|
+
const word = model.getWordUntilPosition(position);
|
|
78
|
+
const range = {
|
|
79
|
+
startLineNumber: position.lineNumber,
|
|
80
|
+
startColumn: word.startColumn,
|
|
81
|
+
endLineNumber: position.lineNumber,
|
|
82
|
+
endColumn: word.endColumn,
|
|
83
|
+
};
|
|
84
|
+
return { suggestions: suggestions.map((s) => (Object.assign(Object.assign({}, s), { range }))) };
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'monaco-editor/esm/vs/editor/editor.api';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LANGUAGE_ID = "s-expression";
|