@finos/legend-lego 1.2.71 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/code-editor/CodeDiffView.d.ts +3 -1
- package/lib/code-editor/CodeDiffView.d.ts.map +1 -1
- package/lib/code-editor/CodeDiffView.js +6 -2
- package/lib/code-editor/CodeDiffView.js.map +1 -1
- package/lib/code-editor/CodeEditor.d.ts +8 -2
- package/lib/code-editor/CodeEditor.d.ts.map +1 -1
- package/lib/code-editor/CodeEditor.js +42 -4
- package/lib/code-editor/CodeEditor.js.map +1 -1
- package/lib/code-editor/index.d.ts +0 -5
- package/lib/code-editor/index.d.ts.map +1 -1
- package/lib/code-editor/index.js +0 -5
- package/lib/code-editor/index.js.map +1 -1
- package/lib/index.css +1 -1
- package/package.json +29 -29
- package/src/code-editor/CodeDiffView.tsx +10 -3
- package/src/code-editor/CodeEditor.tsx +69 -4
- package/src/code-editor/index.ts +0 -6
- package/tsconfig.json +1 -15
- package/lib/code-editor/CodeEditorTheme.d.ts +0 -41
- package/lib/code-editor/CodeEditorTheme.d.ts.map +0 -1
- package/lib/code-editor/CodeEditorTheme.js +0 -99
- package/lib/code-editor/CodeEditorTheme.js.map +0 -1
- package/lib/code-editor/CodeEditorUtils.d.ts +0 -74
- package/lib/code-editor/CodeEditorUtils.d.ts.map +0 -1
- package/lib/code-editor/CodeEditorUtils.js +0 -203
- package/lib/code-editor/CodeEditorUtils.js.map +0 -1
- package/lib/code-editor/PureLanguage.d.ts +0 -38
- package/lib/code-editor/PureLanguage.d.ts.map +0 -1
- package/lib/code-editor/PureLanguage.js +0 -39
- package/lib/code-editor/PureLanguage.js.map +0 -1
- package/lib/code-editor/PureLanguageCodeEditorSupport.d.ts +0 -71
- package/lib/code-editor/PureLanguageCodeEditorSupport.d.ts.map +0 -1
- package/lib/code-editor/PureLanguageCodeEditorSupport.js +0 -238
- package/lib/code-editor/PureLanguageCodeEditorSupport.js.map +0 -1
- package/lib/code-editor/PureLanguageService.d.ts +0 -19
- package/lib/code-editor/PureLanguageService.d.ts.map +0 -1
- package/lib/code-editor/PureLanguageService.js +0 -373
- package/lib/code-editor/PureLanguageService.js.map +0 -1
- package/lib/code-editor/themes/Github-Theme-dark-dimmed.json +0 -613
- package/lib/code-editor/themes/Github-Theme-dark.json +0 -513
- package/lib/code-editor/themes/Github-Theme-light.json +0 -598
- package/lib/code-editor/themes/Material-Theme-Darker.json +0 -816
- package/lib/code-editor/themes/Material-Theme-Default.json +0 -816
- package/lib/code-editor/themes/MonacoEditorThemeUtils.d.ts +0 -31
- package/lib/code-editor/themes/MonacoEditorThemeUtils.d.ts.map +0 -1
- package/lib/code-editor/themes/MonacoEditorThemeUtils.js +0 -88
- package/lib/code-editor/themes/MonacoEditorThemeUtils.js.map +0 -1
- package/lib/code-editor/themes/OneDark-Pro-darker.json +0 -2061
- package/lib/code-editor/themes/OneDark-Pro.json +0 -2090
- package/lib/code-editor/themes/solarized-dark-color-theme.json +0 -398
- package/src/code-editor/CodeEditorTheme.ts +0 -151
- package/src/code-editor/CodeEditorUtils.ts +0 -336
- package/src/code-editor/PureLanguage.ts +0 -42
- package/src/code-editor/PureLanguageCodeEditorSupport.ts +0 -341
- package/src/code-editor/PureLanguageService.ts +0 -416
- package/src/code-editor/themes/Github-Theme-dark-dimmed.json +0 -613
- package/src/code-editor/themes/Github-Theme-dark.json +0 -513
- package/src/code-editor/themes/Github-Theme-light.json +0 -598
- package/src/code-editor/themes/Material-Theme-Darker.json +0 -816
- package/src/code-editor/themes/Material-Theme-Default.json +0 -816
- package/src/code-editor/themes/MonacoEditorThemeUtils.ts +0 -128
- package/src/code-editor/themes/OneDark-Pro-darker.json +0 -2061
- package/src/code-editor/themes/OneDark-Pro.json +0 -2090
- package/src/code-editor/themes/README.md +0 -8
- package/src/code-editor/themes/solarized-dark-color-theme.json +0 -423
@@ -1,238 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2020-present, Goldman Sachs
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
*/
|
16
|
-
import { PARSER_SECTION_MARKER, PURE_PARSER } from '@finos/legend-graph';
|
17
|
-
import { getNullableFirstEntry, guaranteeNonNullable, hasWhiteSpace, } from '@finos/legend-shared';
|
18
|
-
import { languages as monacoLanguagesAPI, } from 'monaco-editor';
|
19
|
-
export const getParserKeywordSuggestions = (position, model, suggestions) => {
|
20
|
-
const results = [];
|
21
|
-
const currentWord = model.getWordUntilPosition(position);
|
22
|
-
// suggestions for parser keyword
|
23
|
-
const lineTextIncludingWordRange = {
|
24
|
-
startLineNumber: position.lineNumber,
|
25
|
-
startColumn: 1,
|
26
|
-
endLineNumber: position.lineNumber,
|
27
|
-
endColumn: currentWord.endColumn,
|
28
|
-
};
|
29
|
-
const lineTextIncludingWord = model.getValueInRange(lineTextIncludingWordRange);
|
30
|
-
// NOTE: make sure parser keyword suggestions only show up when the current word is the
|
31
|
-
// the first word of the line since parser section header must not be preceded by anything
|
32
|
-
if (!hasWhiteSpace(lineTextIncludingWord.trim())) {
|
33
|
-
suggestions.forEach((suggestion) => {
|
34
|
-
results.push({
|
35
|
-
label: {
|
36
|
-
label: `${PARSER_SECTION_MARKER}${suggestion.text}`,
|
37
|
-
description: suggestion.description,
|
38
|
-
},
|
39
|
-
kind: monacoLanguagesAPI.CompletionItemKind.Keyword,
|
40
|
-
insertText: `${PARSER_SECTION_MARKER}${suggestion.insertText}\n`,
|
41
|
-
range: lineTextIncludingWordRange,
|
42
|
-
documentation: suggestion.documentation
|
43
|
-
? suggestion.documentation.markdownText
|
44
|
-
? {
|
45
|
-
value: suggestion.documentation.markdownText.value,
|
46
|
-
}
|
47
|
-
: suggestion.documentation.text
|
48
|
-
: undefined,
|
49
|
-
});
|
50
|
-
});
|
51
|
-
}
|
52
|
-
return results;
|
53
|
-
};
|
54
|
-
export const getSectionParserNameFromLineText = (lineText) => {
|
55
|
-
if (lineText.startsWith(PARSER_SECTION_MARKER)) {
|
56
|
-
return lineText.substring(PARSER_SECTION_MARKER.length).split(' ')[0];
|
57
|
-
}
|
58
|
-
// NOTE: since leading whitespace to parser name is considered invalid, we will return `undefined`
|
59
|
-
return undefined;
|
60
|
-
};
|
61
|
-
export const getParserElementSnippetSuggestions = (position, model, suggestionsGetter) => {
|
62
|
-
const results = [];
|
63
|
-
const currentWord = model.getWordUntilPosition(position);
|
64
|
-
// suggestions for parser element snippets
|
65
|
-
const textUntilPosition = model.getValueInRange({
|
66
|
-
startLineNumber: 1,
|
67
|
-
startColumn: 1,
|
68
|
-
endLineNumber: position.lineNumber,
|
69
|
-
endColumn: position.column,
|
70
|
-
});
|
71
|
-
const allParserSectionHeaders =
|
72
|
-
// NOTE: since `###Pure` is implicitly considered as the first section, we prepend it to the text
|
73
|
-
`${PARSER_SECTION_MARKER}${PURE_PARSER.PURE}\n${textUntilPosition}`
|
74
|
-
.split('\n')
|
75
|
-
.filter((line) => line.startsWith(PARSER_SECTION_MARKER));
|
76
|
-
const currentParserName = getSectionParserNameFromLineText(allParserSectionHeaders[allParserSectionHeaders.length - 1] ?? '');
|
77
|
-
if (currentParserName) {
|
78
|
-
suggestionsGetter(currentParserName).forEach((snippetSuggestion) => {
|
79
|
-
results.push({
|
80
|
-
label: {
|
81
|
-
label: snippetSuggestion.text,
|
82
|
-
description: snippetSuggestion.description,
|
83
|
-
},
|
84
|
-
kind: monacoLanguagesAPI.CompletionItemKind.Snippet,
|
85
|
-
insertTextRules: monacoLanguagesAPI.CompletionItemInsertTextRule.InsertAsSnippet,
|
86
|
-
insertText: `${snippetSuggestion.insertText}\n`,
|
87
|
-
range: {
|
88
|
-
startLineNumber: position.lineNumber,
|
89
|
-
startColumn: currentWord.startColumn,
|
90
|
-
endLineNumber: position.lineNumber,
|
91
|
-
endColumn: currentWord.endColumn,
|
92
|
-
},
|
93
|
-
documentation: snippetSuggestion.documentation
|
94
|
-
? snippetSuggestion.documentation.markdownText
|
95
|
-
? {
|
96
|
-
value: snippetSuggestion.documentation.markdownText.value,
|
97
|
-
}
|
98
|
-
: snippetSuggestion.documentation.text
|
99
|
-
: undefined,
|
100
|
-
});
|
101
|
-
});
|
102
|
-
}
|
103
|
-
return results;
|
104
|
-
};
|
105
|
-
export const getInlineSnippetSuggestions = (position, model, extraSnippetSuggestions = []) => {
|
106
|
-
const currentWord = model.getWordUntilPosition(position);
|
107
|
-
return [
|
108
|
-
{
|
109
|
-
text: 'let',
|
110
|
-
description: 'new variable',
|
111
|
-
insertText: `let \${1:} = \${2:};`,
|
112
|
-
},
|
113
|
-
{
|
114
|
-
text: 'let',
|
115
|
-
description: 'new collection',
|
116
|
-
insertText: `let \${1:} = [\${2:}];`,
|
117
|
-
},
|
118
|
-
{
|
119
|
-
text: 'cast',
|
120
|
-
description: 'type casting',
|
121
|
-
insertText: `cast(@\${1:model::SomeClass})`,
|
122
|
-
},
|
123
|
-
// conditionals
|
124
|
-
{
|
125
|
-
text: 'if',
|
126
|
-
description: '(conditional)',
|
127
|
-
insertText: `if(\${1:'true'}, | \${2:/* if true do this */}, | \${3:/* if false do this */})`,
|
128
|
-
},
|
129
|
-
{
|
130
|
-
text: 'case',
|
131
|
-
description: '(conditional)',
|
132
|
-
insertText: `case(\${1:}, \${2:'true'}, \${3:'false'})`,
|
133
|
-
},
|
134
|
-
{
|
135
|
-
text: 'match',
|
136
|
-
description: '(conditional)',
|
137
|
-
insertText: `match([x:\${1:String[1]}, \${2:''}])`,
|
138
|
-
},
|
139
|
-
// collection
|
140
|
-
{
|
141
|
-
text: 'map',
|
142
|
-
description: '(collection)',
|
143
|
-
insertText: `map(x|\${1:})`,
|
144
|
-
},
|
145
|
-
{
|
146
|
-
text: 'filter',
|
147
|
-
description: '(collection)',
|
148
|
-
insertText: `filter(x|\${1:})`,
|
149
|
-
},
|
150
|
-
{
|
151
|
-
text: 'fold',
|
152
|
-
description: '(collection)',
|
153
|
-
insertText: `fold({a, b| \${1:$a + $b}}, \${2:0})`,
|
154
|
-
},
|
155
|
-
{
|
156
|
-
text: 'filter',
|
157
|
-
description: '(collection)',
|
158
|
-
insertText: `filter(x|\${1:})`,
|
159
|
-
},
|
160
|
-
{
|
161
|
-
text: 'sort',
|
162
|
-
description: '(collection)',
|
163
|
-
insertText: `sort()`,
|
164
|
-
},
|
165
|
-
{
|
166
|
-
text: 'in',
|
167
|
-
description: '(collection)',
|
168
|
-
insertText: `in()`,
|
169
|
-
},
|
170
|
-
{
|
171
|
-
text: 'slice',
|
172
|
-
description: '(collection)',
|
173
|
-
insertText: `slice(\${1:1},$\{2:2})`,
|
174
|
-
},
|
175
|
-
{
|
176
|
-
text: 'removeDuplicates',
|
177
|
-
description: '(collection)',
|
178
|
-
insertText: `removeDuplicates()`,
|
179
|
-
},
|
180
|
-
{
|
181
|
-
text: 'toOne',
|
182
|
-
description: '(collection)',
|
183
|
-
insertText: `toOne(\${1:})`,
|
184
|
-
},
|
185
|
-
{
|
186
|
-
text: 'toOneMany',
|
187
|
-
description: '(collection)',
|
188
|
-
insertText: `toOneMany(\${1:})`,
|
189
|
-
},
|
190
|
-
{
|
191
|
-
text: 'isEmpty',
|
192
|
-
description: '(collection)',
|
193
|
-
insertText: `isEmpty()`,
|
194
|
-
},
|
195
|
-
// string
|
196
|
-
{
|
197
|
-
text: 'endsWith',
|
198
|
-
description: '(string)',
|
199
|
-
insertText: `endsWith()`,
|
200
|
-
},
|
201
|
-
{
|
202
|
-
text: 'startsWith',
|
203
|
-
description: '(string)',
|
204
|
-
insertText: `startsWith()`,
|
205
|
-
},
|
206
|
-
...extraSnippetSuggestions,
|
207
|
-
].map((snippetSuggestion) => ({
|
208
|
-
label: {
|
209
|
-
label: snippetSuggestion.text,
|
210
|
-
description: snippetSuggestion.description,
|
211
|
-
},
|
212
|
-
kind: monacoLanguagesAPI.CompletionItemKind.Snippet,
|
213
|
-
insertTextRules: monacoLanguagesAPI.CompletionItemInsertTextRule.InsertAsSnippet,
|
214
|
-
insertText: snippetSuggestion.insertText,
|
215
|
-
range: {
|
216
|
-
startLineNumber: position.lineNumber,
|
217
|
-
startColumn: currentWord.startColumn,
|
218
|
-
endLineNumber: position.lineNumber,
|
219
|
-
endColumn: currentWord.endColumn,
|
220
|
-
},
|
221
|
-
documentation: snippetSuggestion.documentation
|
222
|
-
? snippetSuggestion.documentation.markdownText
|
223
|
-
? {
|
224
|
-
value: snippetSuggestion.documentation.markdownText.value,
|
225
|
-
}
|
226
|
-
: snippetSuggestion.documentation.text
|
227
|
-
: undefined,
|
228
|
-
}));
|
229
|
-
};
|
230
|
-
export const isTokenOneOf = (token, baseTokens, exact = false) => {
|
231
|
-
if (exact) {
|
232
|
-
return baseTokens.map((baseToken) => `${baseToken}.pure`).includes(token);
|
233
|
-
}
|
234
|
-
const baseToken = guaranteeNonNullable(getNullableFirstEntry(token.split('.')));
|
235
|
-
return baseTokens.includes(baseToken);
|
236
|
-
};
|
237
|
-
export const PURE_CODE_EDITOR_WORD_SEPARATORS = '`~!@#%^&*()-=+[{]}\\|;:\'",.<>/?'; // omit $ from default word separators
|
238
|
-
//# sourceMappingURL=PureLanguageCodeEditorSupport.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"PureLanguageCodeEditorSupport.js","sourceRoot":"","sources":["../../src/code-editor/PureLanguageCodeEditorSupport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,GACd,MAAM,sBAAsB,CA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AAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5E,CAAC;IACD,MAAM,SAAS,GAAG,oBAAoB,CACpC,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CACxC,CAAC;IACF,OAAO,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gCAAgC,GAC3C,kCAAkC,CAAC,CAAC,sCAAsC"}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2020-present, Goldman Sachs
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
*/
|
16
|
-
export declare function setupPureLanguageService(options?: {
|
17
|
-
extraKeywords?: string[] | undefined;
|
18
|
-
}): void;
|
19
|
-
//# sourceMappingURL=PureLanguageService.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"PureLanguageService.d.ts","sourceRoot":"","sources":["../../src/code-editor/PureLanguageService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAqYH,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE;IACjD,aAAa,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACtC,GAAG,IAAI,CAUP"}
|
@@ -1,373 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2020-present, Goldman Sachs
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
*/
|
16
|
-
/* eslint-disable prefer-named-capture-group */
|
17
|
-
import { PURE_ELEMENT_NAME, PURE_CONNECTION_NAME } from '@finos/legend-graph';
|
18
|
-
import { languages as monacoLanguagesAPI } from 'monaco-editor';
|
19
|
-
import { PURE_GRAMMAR_TOKEN } from './PureLanguage.js';
|
20
|
-
import { CODE_EDITOR_LANGUAGE } from './CodeEditorUtils.js';
|
21
|
-
/**
|
22
|
-
* The postfix to be added to all token types, i.e. identifier.pure, number.pure, etc.
|
23
|
-
*/
|
24
|
-
const PURE_GRAMMAR_TOKEN_POSTFIX = '.pure';
|
25
|
-
// Taken from `monaco-languages` configuration for Java in order to do propert brace matching
|
26
|
-
// See https://github.com/microsoft/monaco-languages/blob/master/src/java/java.ts
|
27
|
-
const configuration = {
|
28
|
-
// NOTE: Pure identifier includes $ but not in the first position (as that is parsed as a variable)
|
29
|
-
wordPattern: /(-?\d*\.\d\w*)|([^`~!@#%^$&*()\-=+[{\]}\\|;:'",.<>/?\s][^`~!@#%^&*()\-=+[{\]}\\|;:'",.<>/?\s]*)/,
|
30
|
-
comments: {
|
31
|
-
lineComment: '//',
|
32
|
-
blockComment: ['/*', '*/'],
|
33
|
-
},
|
34
|
-
brackets: [
|
35
|
-
['{', '}'],
|
36
|
-
['[', ']'],
|
37
|
-
['(', ')'],
|
38
|
-
],
|
39
|
-
autoClosingPairs: [
|
40
|
-
{ open: '{', close: '}' },
|
41
|
-
{ open: '[', close: ']' },
|
42
|
-
{ open: '(', close: ')' },
|
43
|
-
{ open: '"', close: '"' },
|
44
|
-
{ open: "'", close: "'" },
|
45
|
-
],
|
46
|
-
surroundingPairs: [
|
47
|
-
{ open: '{', close: '}' },
|
48
|
-
{ open: '[', close: ']' },
|
49
|
-
{ open: '(', close: ')' },
|
50
|
-
{ open: '"', close: '"' },
|
51
|
-
{ open: "'", close: "'" },
|
52
|
-
{ open: '<', close: '>' },
|
53
|
-
{ open: '<<', close: '>>' },
|
54
|
-
],
|
55
|
-
folding: {
|
56
|
-
markers: {
|
57
|
-
start: new RegExp('^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))'),
|
58
|
-
end: new RegExp('^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))'),
|
59
|
-
},
|
60
|
-
},
|
61
|
-
};
|
62
|
-
/**
|
63
|
-
* Create new monarch definition to support syntax-highlighting
|
64
|
-
* See https://microsoft.github.io/monaco-editor/monarch.html
|
65
|
-
*
|
66
|
-
* The way SQL monarch definition is organized is good and worth learning from
|
67
|
-
* See https://github.com/microsoft/monaco-languages/blob/master/src/sql/sql.ts
|
68
|
-
*
|
69
|
-
* NOTE: using `monarch` only allows fairly very basic syntax-highlighting
|
70
|
-
* to actually do full AST analysis, we might need something more serious like
|
71
|
-
* using TextMate grammar which is used by VSCode itself
|
72
|
-
* See https://github.com/microsoft/monaco-editor#faq
|
73
|
-
* See https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide
|
74
|
-
*/
|
75
|
-
const generateLanguageMonarch = (extraKeywords) =>
|
76
|
-
// TODO: complete syntax-highlighter for core features like constraint, derived properties, etc.
|
77
|
-
// TODO: add syntax highlighting for modules/plugins (come up with a plugin mechanism to do this).
|
78
|
-
({
|
79
|
-
defaultToken: 'invalid',
|
80
|
-
tokenPostfix: PURE_GRAMMAR_TOKEN_POSTFIX,
|
81
|
-
keywords: [
|
82
|
-
...extraKeywords,
|
83
|
-
// relational
|
84
|
-
'Schema',
|
85
|
-
'Table',
|
86
|
-
'Join',
|
87
|
-
'View',
|
88
|
-
'primaryKey',
|
89
|
-
'groupBy',
|
90
|
-
'mainTable',
|
91
|
-
// native
|
92
|
-
'let',
|
93
|
-
'extends',
|
94
|
-
'true',
|
95
|
-
'false',
|
96
|
-
'projects',
|
97
|
-
// elements
|
98
|
-
PURE_ELEMENT_NAME.CLASS,
|
99
|
-
PURE_ELEMENT_NAME.ASSOCIATION,
|
100
|
-
PURE_ELEMENT_NAME.ENUMERATION,
|
101
|
-
PURE_ELEMENT_NAME.MEASURE,
|
102
|
-
PURE_ELEMENT_NAME.PROFILE,
|
103
|
-
PURE_ELEMENT_NAME.FUNCTION,
|
104
|
-
PURE_ELEMENT_NAME.MAPPING,
|
105
|
-
PURE_ELEMENT_NAME.RUNTIME,
|
106
|
-
PURE_ELEMENT_NAME.CONNECTION,
|
107
|
-
PURE_ELEMENT_NAME.FILE_GENERATION,
|
108
|
-
PURE_ELEMENT_NAME.GENERATION_SPECIFICATION,
|
109
|
-
PURE_ELEMENT_NAME.DATA_ELEMENT,
|
110
|
-
// connections
|
111
|
-
PURE_CONNECTION_NAME.JSON_MODEL_CONNECTION,
|
112
|
-
PURE_CONNECTION_NAME.MODEL_CHAIN_CONNECTION,
|
113
|
-
PURE_CONNECTION_NAME.XML_MODEL_CONNECTION,
|
114
|
-
// mapping
|
115
|
-
'include',
|
116
|
-
'EnumerationMapping',
|
117
|
-
'Pure',
|
118
|
-
'AssociationMapping',
|
119
|
-
'XStore',
|
120
|
-
'AggregationAware',
|
121
|
-
/**
|
122
|
-
* @modularize
|
123
|
-
* See https://github.com/finos/legend-studio/issues/65
|
124
|
-
*/
|
125
|
-
PURE_ELEMENT_NAME.SERVICE,
|
126
|
-
PURE_ELEMENT_NAME.FLAT_DATA,
|
127
|
-
PURE_ELEMENT_NAME.DATABASE,
|
128
|
-
PURE_CONNECTION_NAME.FLAT_DATA_CONNECTION,
|
129
|
-
PURE_CONNECTION_NAME.RELATIONAL_DATABASE_CONNECTION,
|
130
|
-
'Relational',
|
131
|
-
],
|
132
|
-
operators: [
|
133
|
-
'=',
|
134
|
-
'>',
|
135
|
-
'<',
|
136
|
-
'!',
|
137
|
-
'~',
|
138
|
-
'?',
|
139
|
-
':',
|
140
|
-
'==',
|
141
|
-
'<=',
|
142
|
-
'>=',
|
143
|
-
'&&',
|
144
|
-
'||',
|
145
|
-
'++',
|
146
|
-
'--',
|
147
|
-
'+',
|
148
|
-
'-',
|
149
|
-
'*',
|
150
|
-
'/',
|
151
|
-
'&',
|
152
|
-
'|',
|
153
|
-
'^',
|
154
|
-
'%',
|
155
|
-
'->',
|
156
|
-
'#{',
|
157
|
-
'}#',
|
158
|
-
'@',
|
159
|
-
'<<',
|
160
|
-
'>>',
|
161
|
-
],
|
162
|
-
languageStructs: ['import', 'native'],
|
163
|
-
// common regular expressions to be used in tokenizer
|
164
|
-
identifier: /[a-zA-Z_$][\w$]*/,
|
165
|
-
symbols: /[=><!~?:&|+\-*/^%#@]+/,
|
166
|
-
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
|
167
|
-
digits: /\d+(_+\d+)*/,
|
168
|
-
octaldigits: /[0-7]+(_+[0-7]+)*/,
|
169
|
-
binarydigits: /[0-1]+(_+[0-1]+)*/,
|
170
|
-
hexdigits: /[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,
|
171
|
-
multiplicity: /\[(?:[a-zA-Z0-9]+(?:\.\.(?:[a-zA-Z0-9]+|\*|))?|\*)\]/,
|
172
|
-
package: /(?:[\w_]+::)+/,
|
173
|
-
// NOTE: generics is a little tricky because in order to do it right, we have to
|
174
|
-
// do some sort of bracket matching, but we just can use a simple tokenizer here
|
175
|
-
// so to account for cases like `<Nil,Any|*>)->` `Function<{T[1]->Boolean[1]}>[1]`
|
176
|
-
// we have to make sure the content does not contain any `:` or `.` characters
|
177
|
-
// in order to avoid the accidental greedy match with inputs like
|
178
|
-
// `function doSomething<T>(a: Function<T[1]->Boolean[1]>)`
|
179
|
-
// nor we want to make sure the last character of the content is not `-` to avoid
|
180
|
-
// accidentally matching `->` as the end of the generics
|
181
|
-
generics: /(?:(?:<\w+>)|(?:<[^:.@^()]+[^-]>))/,
|
182
|
-
date: /%-?\d+(?:-\d+(?:-\d+(?:T(?:\d+(?::\d+(?::\d+(?:.\d+)?)?)?)(?:[+-][0-9]{4})?)))/,
|
183
|
-
time: /%\d+(?::\d+(?::\d+(?:.\d+)?)?)?/,
|
184
|
-
tokenizer: {
|
185
|
-
root: [
|
186
|
-
// NOTE: since `monaco-editor` Monarch is only meant for tokenizing
|
187
|
-
// and the need to highlight Pure syntax is more than just token-based,
|
188
|
-
// but semantic/syntax-based we have to create these complex rules.
|
189
|
-
// the things to note here is these are not meant to match multilines
|
190
|
-
// and they must be placed before identifier rules since token matching
|
191
|
-
// is run in order
|
192
|
-
// See https://github.com/microsoft/monaco-editor/issues/316#issuecomment-273555698
|
193
|
-
// See https://github.com/microsoft/monaco-editor/issues/571#issuecomment-342555050
|
194
|
-
// See https://microsoft.github.io/monaco-editor/monarch.html
|
195
|
-
{ include: '@pure' },
|
196
|
-
{ include: '@date' },
|
197
|
-
{ include: '@color' },
|
198
|
-
// parser markers
|
199
|
-
[
|
200
|
-
// NOTE: any leading whitespace to the section header is considered invalid syntax
|
201
|
-
/^\s*###[\w]+/,
|
202
|
-
PURE_GRAMMAR_TOKEN.PARSER,
|
203
|
-
],
|
204
|
-
// identifiers and keywords
|
205
|
-
[
|
206
|
-
/(@identifier)/,
|
207
|
-
{
|
208
|
-
cases: {
|
209
|
-
'@languageStructs': PURE_GRAMMAR_TOKEN.LANGUAGE_STRUCT,
|
210
|
-
'@keywords': `${PURE_GRAMMAR_TOKEN.KEYWORD}.$0`,
|
211
|
-
// function descriptor
|
212
|
-
'([a-zA-Z_$][\\w$]*)_((\\w+_(([a-zA-Z0-9]+)|(\\$[a-zA-Z0-9]+_[a-zA-Z0-9]+\\$)))__)*(\\w+_(([a-zA-Z0-9]+)|(\\$[a-zA-Z0-9]+_[a-zA-Z0-9]+\\$)))_': PURE_GRAMMAR_TOKEN.TYPE,
|
213
|
-
'@default': PURE_GRAMMAR_TOKEN.IDENTIFIER,
|
214
|
-
},
|
215
|
-
},
|
216
|
-
],
|
217
|
-
// whitespace
|
218
|
-
{ include: '@whitespace' },
|
219
|
-
// delimiters and operators
|
220
|
-
[/[{}()[\]]/, '@brackets'],
|
221
|
-
[/[<>](?!@symbols)/, '@brackets'],
|
222
|
-
[
|
223
|
-
/@symbols/,
|
224
|
-
{
|
225
|
-
cases: {
|
226
|
-
'@operators': PURE_GRAMMAR_TOKEN.OPERATOR,
|
227
|
-
'@default': PURE_GRAMMAR_TOKEN.IDENTIFIER,
|
228
|
-
},
|
229
|
-
},
|
230
|
-
],
|
231
|
-
{ include: '@number' },
|
232
|
-
// delimiter: after number because of .\d floats
|
233
|
-
[/[;,.]/, PURE_GRAMMAR_TOKEN.DELIMITER],
|
234
|
-
// strings
|
235
|
-
// NOTE: including non-teminated string so as people type ', we can start showing them that they're working on a string
|
236
|
-
[/'([^'\\]|\\.)*$/, `${PURE_GRAMMAR_TOKEN.STRING}.invalid`],
|
237
|
-
[/'/, PURE_GRAMMAR_TOKEN.STRING, '@string'],
|
238
|
-
{ include: '@characters' },
|
239
|
-
],
|
240
|
-
pure: [
|
241
|
-
// type
|
242
|
-
[/(@package\*)/, [PURE_GRAMMAR_TOKEN.PACKAGE]], // import path
|
243
|
-
[
|
244
|
-
/(@package?)(@identifier)(@generics?)(\s*)(@multiplicity)/,
|
245
|
-
[
|
246
|
-
PURE_GRAMMAR_TOKEN.PACKAGE,
|
247
|
-
PURE_GRAMMAR_TOKEN.TYPE,
|
248
|
-
PURE_GRAMMAR_TOKEN.GENERICS,
|
249
|
-
PURE_GRAMMAR_TOKEN.WHITESPACE,
|
250
|
-
PURE_GRAMMAR_TOKEN.MULTIPLICITY,
|
251
|
-
],
|
252
|
-
],
|
253
|
-
[
|
254
|
-
/(@package)(@identifier)(@generics?)/,
|
255
|
-
[
|
256
|
-
PURE_GRAMMAR_TOKEN.PACKAGE,
|
257
|
-
PURE_GRAMMAR_TOKEN.TYPE,
|
258
|
-
PURE_GRAMMAR_TOKEN.GENERICS,
|
259
|
-
],
|
260
|
-
],
|
261
|
-
// special operators that uses type (e.g. constructor, cast)
|
262
|
-
[
|
263
|
-
/([@^])(\s*)(@package?)(@identifier)(@generics?)(@multiplicity?)/,
|
264
|
-
[
|
265
|
-
`${PURE_GRAMMAR_TOKEN.TYPE}.operator`,
|
266
|
-
PURE_GRAMMAR_TOKEN.WHITESPACE,
|
267
|
-
PURE_GRAMMAR_TOKEN.PACKAGE,
|
268
|
-
PURE_GRAMMAR_TOKEN.TYPE,
|
269
|
-
PURE_GRAMMAR_TOKEN.GENERICS,
|
270
|
-
PURE_GRAMMAR_TOKEN.MULTIPLICITY,
|
271
|
-
],
|
272
|
-
],
|
273
|
-
// property / parameter
|
274
|
-
[
|
275
|
-
/(\.\s*)(@identifier)/,
|
276
|
-
[PURE_GRAMMAR_TOKEN.DELIMITER, PURE_GRAMMAR_TOKEN.PROPERTY],
|
277
|
-
],
|
278
|
-
[
|
279
|
-
/(@identifier)(\s*=)/,
|
280
|
-
[PURE_GRAMMAR_TOKEN.PROPERTY, PURE_GRAMMAR_TOKEN.OPERATOR],
|
281
|
-
],
|
282
|
-
[
|
283
|
-
/(@identifier)(\.)(@identifier)/,
|
284
|
-
[
|
285
|
-
PURE_GRAMMAR_TOKEN.TYPE,
|
286
|
-
PURE_GRAMMAR_TOKEN.OPERATOR,
|
287
|
-
PURE_GRAMMAR_TOKEN.PROPERTY,
|
288
|
-
],
|
289
|
-
], // could be: property chain, profile tag, and stereotype
|
290
|
-
[
|
291
|
-
/(@identifier)(\s*:)/,
|
292
|
-
[PURE_GRAMMAR_TOKEN.PARAMETER, PURE_GRAMMAR_TOKEN.OPERATOR],
|
293
|
-
],
|
294
|
-
// variables
|
295
|
-
[
|
296
|
-
/(let)(\s+)(@identifier)(\s*=)/,
|
297
|
-
[
|
298
|
-
PURE_GRAMMAR_TOKEN.KEYWORD,
|
299
|
-
PURE_GRAMMAR_TOKEN.WHITESPACE,
|
300
|
-
PURE_GRAMMAR_TOKEN.VARIABLE,
|
301
|
-
PURE_GRAMMAR_TOKEN.OPERATOR,
|
302
|
-
],
|
303
|
-
],
|
304
|
-
[/(\$@identifier)/, [`${PURE_GRAMMAR_TOKEN.VARIABLE}.reference`]],
|
305
|
-
],
|
306
|
-
date: [
|
307
|
-
[/(%latest)/, [`${PURE_GRAMMAR_TOKEN.DATE}.latest`]],
|
308
|
-
[/(@date)/, [PURE_GRAMMAR_TOKEN.DATE]],
|
309
|
-
[/(@time)/, [`${PURE_GRAMMAR_TOKEN.DATE}.time`]],
|
310
|
-
],
|
311
|
-
color: [[/(#[0-9a-fA-F]{6})/, [PURE_GRAMMAR_TOKEN.COLOR]]],
|
312
|
-
number: [
|
313
|
-
[
|
314
|
-
/(@digits)[eE]([-+]?(@digits))?[fFdD]?/,
|
315
|
-
`${PURE_GRAMMAR_TOKEN.NUMBER}.float`,
|
316
|
-
],
|
317
|
-
[
|
318
|
-
/(@digits)\.(@digits)([eE][-+]?(@digits))?[fFdD]?/,
|
319
|
-
`${PURE_GRAMMAR_TOKEN.NUMBER}.float`,
|
320
|
-
],
|
321
|
-
[/0[xX](@hexdigits)[Ll]?/, `${PURE_GRAMMAR_TOKEN.NUMBER}.hex`],
|
322
|
-
[/0(@octaldigits)[Ll]?/, `${PURE_GRAMMAR_TOKEN.NUMBER}.octal`],
|
323
|
-
[/0[bB](@binarydigits)[Ll]?/, `${PURE_GRAMMAR_TOKEN.NUMBER}.binary`],
|
324
|
-
[/(@digits)[fFdD]/, `${PURE_GRAMMAR_TOKEN.NUMBER}.float`],
|
325
|
-
[/(@digits)[lL]?/, PURE_GRAMMAR_TOKEN.NUMBER],
|
326
|
-
],
|
327
|
-
whitespace: [
|
328
|
-
[/[ \t\r\n]+/, PURE_GRAMMAR_TOKEN.WHITESPACE],
|
329
|
-
[/\/\*\*(?!\/)/, `${PURE_GRAMMAR_TOKEN.COMMENT}.doc`, '@doc'],
|
330
|
-
[/\/\*/, PURE_GRAMMAR_TOKEN.COMMENT, '@comment'],
|
331
|
-
[/\/\/.*$/, PURE_GRAMMAR_TOKEN.COMMENT],
|
332
|
-
],
|
333
|
-
comment: [
|
334
|
-
[/[^/*]+/, PURE_GRAMMAR_TOKEN.COMMENT],
|
335
|
-
// [/\/\*/, PURE_GRAMMAR_TOKEN.COMMENT, '@push' ], // nested comment not allowed :-(
|
336
|
-
// [/\/\*/, ${PURE_GRAMMAR_TOKEN.COMMENT}.invalid` ], // this breaks block comments in the shape of /* //*/
|
337
|
-
[/\*\//, PURE_GRAMMAR_TOKEN.COMMENT, '@pop'],
|
338
|
-
[/[/*]/, PURE_GRAMMAR_TOKEN.COMMENT],
|
339
|
-
],
|
340
|
-
// Identical copy of comment above, except for the addition of .doc
|
341
|
-
doc: [
|
342
|
-
[/[^/*]+/, `${PURE_GRAMMAR_TOKEN.COMMENT}.doc`],
|
343
|
-
// [/\/\*/, `${PURE_GRAMMAR_TOKEN.COMMENT}.doc`, '@push' ], // nested comment not allowed :-(
|
344
|
-
[/\/\*/, `${PURE_GRAMMAR_TOKEN.COMMENT}.doc.invalid`],
|
345
|
-
[/\*\//, `${PURE_GRAMMAR_TOKEN.COMMENT}.doc`, '@pop'],
|
346
|
-
[/[/*]/, `${PURE_GRAMMAR_TOKEN.COMMENT}.doc`],
|
347
|
-
],
|
348
|
-
string: [
|
349
|
-
[/[^\\']+/, PURE_GRAMMAR_TOKEN.STRING],
|
350
|
-
[/@escapes/, `${PURE_GRAMMAR_TOKEN.STRING}.escape`],
|
351
|
-
[/\\./, `${PURE_GRAMMAR_TOKEN.STRING}.escape.invalid`],
|
352
|
-
[/'/, PURE_GRAMMAR_TOKEN.STRING, '@pop'],
|
353
|
-
],
|
354
|
-
characters: [
|
355
|
-
[/'[^\\']'/, PURE_GRAMMAR_TOKEN.STRING],
|
356
|
-
[
|
357
|
-
/(')(@escapes)(')/,
|
358
|
-
[
|
359
|
-
PURE_GRAMMAR_TOKEN.STRING,
|
360
|
-
`${PURE_GRAMMAR_TOKEN.STRING}.escape`,
|
361
|
-
PURE_GRAMMAR_TOKEN.STRING,
|
362
|
-
],
|
363
|
-
],
|
364
|
-
[/'/, `${PURE_GRAMMAR_TOKEN.STRING}.invalid`],
|
365
|
-
],
|
366
|
-
},
|
367
|
-
});
|
368
|
-
export function setupPureLanguageService(options) {
|
369
|
-
monacoLanguagesAPI.register({ id: CODE_EDITOR_LANGUAGE.PURE });
|
370
|
-
monacoLanguagesAPI.setLanguageConfiguration(CODE_EDITOR_LANGUAGE.PURE, configuration);
|
371
|
-
monacoLanguagesAPI.setMonarchTokensProvider(CODE_EDITOR_LANGUAGE.PURE, generateLanguageMonarch(options?.extraKeywords ?? []));
|
372
|
-
}
|
373
|
-
//# sourceMappingURL=PureLanguageService.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"PureLanguageService.js","sourceRoot":"","sources":["../../src/code-editor/PureLanguageService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,+CAA+C;AAC/C,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,SAAS,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AACH,MAAM,0BAA0B,GAAG,OAAO,CAAC;AAE3C,6FAA6F;AAC7F,iFAAiF;AACjF,MAAM,aAAa,GAA6C;IAC9D,mGAAmG;IACnG,WAAW,EACT,iGAAiG;IACnG,QAAQ,EAAE;QACR,WAAW,EAAE,IAAI;QACjB,YAAY,EAAE,CAAC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