@finos/legend-application 10.1.0 → 10.2.0

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.
Files changed (42) hide show
  1. package/lib/components/LegendApplicationComponentFrameworkProvider.d.ts.map +1 -1
  2. package/lib/components/LegendApplicationComponentFrameworkProvider.js +10 -6
  3. package/lib/components/LegendApplicationComponentFrameworkProvider.js.map +1 -1
  4. package/lib/components/shared/TabManager.d.ts.map +1 -1
  5. package/lib/components/shared/TabManager.js +20 -4
  6. package/lib/components/shared/TabManager.js.map +1 -1
  7. package/lib/index.css +2 -2
  8. package/lib/index.css.map +1 -1
  9. package/lib/index.d.ts +2 -0
  10. package/lib/index.d.ts.map +1 -1
  11. package/lib/index.js +2 -0
  12. package/lib/index.js.map +1 -1
  13. package/lib/stores/CommandCenter.d.ts +10 -2
  14. package/lib/stores/CommandCenter.d.ts.map +1 -1
  15. package/lib/stores/CommandCenter.js +2 -2
  16. package/lib/stores/CommandCenter.js.map +1 -1
  17. package/lib/stores/KeyboardShortcutsService.d.ts +5 -0
  18. package/lib/stores/KeyboardShortcutsService.d.ts.map +1 -1
  19. package/lib/stores/KeyboardShortcutsService.js +5 -0
  20. package/lib/stores/KeyboardShortcutsService.js.map +1 -1
  21. package/lib/stores/PureLanguageSupport.d.ts +21 -0
  22. package/lib/stores/PureLanguageSupport.d.ts.map +1 -1
  23. package/lib/stores/PureLanguageSupport.js +185 -75
  24. package/lib/stores/PureLanguageSupport.js.map +1 -1
  25. package/lib/stores/PureLanguageTextEditorSupport.d.ts +70 -0
  26. package/lib/stores/PureLanguageTextEditorSupport.d.ts.map +1 -0
  27. package/lib/stores/PureLanguageTextEditorSupport.js +231 -0
  28. package/lib/stores/PureLanguageTextEditorSupport.js.map +1 -0
  29. package/lib/stores/shared/TabManagerState.d.ts +5 -2
  30. package/lib/stores/shared/TabManagerState.d.ts.map +1 -1
  31. package/lib/stores/shared/TabManagerState.js +39 -1
  32. package/lib/stores/shared/TabManagerState.js.map +1 -1
  33. package/package.json +5 -5
  34. package/src/components/LegendApplicationComponentFrameworkProvider.tsx +10 -6
  35. package/src/components/shared/TabManager.tsx +22 -5
  36. package/src/index.ts +2 -0
  37. package/src/stores/CommandCenter.ts +11 -3
  38. package/src/stores/KeyboardShortcutsService.ts +5 -0
  39. package/src/stores/PureLanguageSupport.ts +194 -76
  40. package/src/stores/PureLanguageTextEditorSupport.ts +327 -0
  41. package/src/stores/shared/TabManagerState.ts +50 -3
  42. package/tsconfig.json +1 -0
@@ -30,20 +30,55 @@ import {
30
30
  } from 'monaco-editor';
31
31
  import { EDITOR_LANGUAGE, EDITOR_THEME } from '../const.js';
32
32
 
33
+ /**
34
+ * The postfix to be added to all token types, i.e. identifier.pure, number.pure, etc.
35
+ */
36
+ const PURE_GRAMMAR_TOKEN_POSTFIX = '.pure';
37
+
38
+ export enum PURE_GRAMMAR_TOKEN {
39
+ WHITESPACE = '',
40
+
41
+ KEYWORD = 'keyword',
42
+ IDENTIFIER = 'identifier',
43
+ OPERATOR = 'operator',
44
+ DELIMITER = 'delimiter',
45
+
46
+ PARSER = 'parser',
47
+ NUMBER = 'number',
48
+ DATE = 'date',
49
+ COLOR = 'color',
50
+ PACKAGE = 'package',
51
+ STRING = 'string',
52
+ COMMENT = 'comment',
53
+
54
+ LANGUAGE_STRUCT = 'language-struct',
55
+ MULTIPLICITY = 'multiplicity',
56
+ GENERICS = 'generics',
57
+ PROPERTY = 'property',
58
+ VARIABLE = 'variable',
59
+ TYPE = 'type',
60
+
61
+ INVALID = 'invalid',
62
+ }
63
+
33
64
  const theme: monacoEditorAPI.IStandaloneThemeData = {
34
65
  base: 'vs-dark', // can also be vs-dark or hc-black
35
66
  inherit: true, // can also be false to completely replace the builtin rules
36
67
  colors: {},
37
68
  rules: [
38
69
  // NOTE: unfortunately, `monaco-editor` only accepts HEX values, not CSS variables
39
- { token: 'package', foreground: '808080' },
40
- { token: 'parser-marker', foreground: 'c586c0' },
41
- { token: 'property', foreground: 'dcdcaa' },
42
- { token: 'function', foreground: 'dcdcaa' },
43
- { token: 'language-struct', foreground: 'c586c0' },
44
- { token: 'multiplicity', foreground: '2d796b' },
45
- { token: 'attribute', foreground: '9cdcfe' },
46
- { token: 'cast', foreground: '569cd6' },
70
+ { token: PURE_GRAMMAR_TOKEN.IDENTIFIER, foreground: 'dcdcaa' },
71
+ { token: PURE_GRAMMAR_TOKEN.NUMBER, foreground: 'b5cea8' },
72
+ { token: PURE_GRAMMAR_TOKEN.DATE, foreground: 'b5cea8' },
73
+ { token: PURE_GRAMMAR_TOKEN.COLOR, foreground: 'b5cea8' },
74
+ { token: PURE_GRAMMAR_TOKEN.PACKAGE, foreground: '808080' },
75
+ { token: PURE_GRAMMAR_TOKEN.PARSER, foreground: 'c586c0' },
76
+ { token: PURE_GRAMMAR_TOKEN.LANGUAGE_STRUCT, foreground: 'c586c0' },
77
+ { token: PURE_GRAMMAR_TOKEN.MULTIPLICITY, foreground: '2d796b' },
78
+ { token: PURE_GRAMMAR_TOKEN.GENERICS, foreground: '2d796b' },
79
+ { token: PURE_GRAMMAR_TOKEN.PROPERTY, foreground: '9cdcfe' },
80
+ { token: PURE_GRAMMAR_TOKEN.VARIABLE, foreground: '4fc1ff' },
81
+ { token: PURE_GRAMMAR_TOKEN.TYPE, foreground: '3dc9b0' },
47
82
  ],
48
83
  };
49
84
 
@@ -73,6 +108,7 @@ const configuration: monacoLanguagesAPI.LanguageConfiguration = {
73
108
  { open: '"', close: '"' },
74
109
  { open: "'", close: "'" },
75
110
  { open: '<', close: '>' },
111
+ { open: '<<', close: '>>' },
76
112
  ],
77
113
  folding: {
78
114
  markers: {
@@ -103,7 +139,7 @@ const generateLanguageMonarch = (
103
139
  // TODO: add syntax highlighting for modules/plugins (come up with a plugin mechanism to do this).
104
140
  ({
105
141
  defaultToken: 'invalid',
106
- tokenPostfix: '.pure',
142
+ tokenPostfix: PURE_GRAMMAR_TOKEN_POSTFIX,
107
143
 
108
144
  keywords: [
109
145
  ...extraKeywords,
@@ -118,6 +154,8 @@ const generateLanguageMonarch = (
118
154
  // native
119
155
  'let',
120
156
  'extends',
157
+ 'true',
158
+ 'false',
121
159
  'projects',
122
160
  // elements
123
161
  PURE_ELEMENT_NAME.CLASS,
@@ -182,9 +220,11 @@ const generateLanguageMonarch = (
182
220
  '#{',
183
221
  '}#',
184
222
  '@',
223
+ '<<',
224
+ '>>',
185
225
  ],
186
226
 
187
- languageStructs: ['import', 'native', 'if', 'fold'],
227
+ languageStructs: ['import', 'native'],
188
228
 
189
229
  parsers: (
190
230
  [
@@ -204,6 +244,7 @@ const generateLanguageMonarch = (
204
244
  .map((parser) => `${PARSER_SECTION_MARKER}${parser}`),
205
245
 
206
246
  // common regular expressions to be used in tokenizer
247
+ identifier: /[a-zA-Z_$][\w$]*/,
207
248
  symbols: /[=><!~?:&|+\-*/^%#@]+/,
208
249
  escapes:
209
250
  /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
@@ -213,17 +254,25 @@ const generateLanguageMonarch = (
213
254
  hexdigits: /[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,
214
255
  multiplicity: /\[(?:\d+(?:\.\.(?:\d+|\*|))?|\*)\]/,
215
256
  package: /(?:[\w_]+::)+/,
257
+ generics: /<.+>/,
258
+ date: /%-?\d+(?:-\d+(?:-\d+(?:T(?:\d+(?::\d+(?::\d+(?:.\d+)?)?)?)(?:[+-][0-9]{4})?)))/,
259
+ time: /%\d+(?::\d+(?::\d+(?:.\d+)?)?)?/,
216
260
 
217
261
  tokenizer: {
218
262
  root: [
219
- // packages
220
- { include: '@package' },
263
+ // NOTE: since `monaco-editor` Monarch is only meant for tokenizing
264
+ // and the need to highlight Pure syntax is more than just token-based,
265
+ // but semantic/syntax-based we have to create these complex rules.
266
+ // the things to note here is these are not meant to match multilines
267
+ // and they must be placed before identifier rules since token matching
268
+ // is run in order
269
+ // See https://github.com/microsoft/monaco-editor/issues/316#issuecomment-273555698
270
+ // See https://github.com/microsoft/monaco-editor/issues/571#issuecomment-342555050
271
+ // See https://microsoft.github.io/monaco-editor/monarch.html
272
+ { include: '@pure' },
221
273
 
222
- // properties
223
- [/(\.)([\w_]+)/, ['delimiter', 'property']],
224
-
225
- // functions
226
- { include: '@function' },
274
+ { include: '@date' },
275
+ { include: '@color' },
227
276
 
228
277
  // parser markers
229
278
  [
@@ -231,20 +280,20 @@ const generateLanguageMonarch = (
231
280
  /^\s*###[\w]+/,
232
281
  {
233
282
  cases: {
234
- '@parsers': 'parser-marker',
235
- '@default': 'invalid',
283
+ '@parsers': PURE_GRAMMAR_TOKEN.PARSER,
284
+ '@default': PURE_GRAMMAR_TOKEN.INVALID,
236
285
  },
237
286
  },
238
287
  ],
239
288
 
240
289
  // identifiers and keywords
241
290
  [
242
- /[a-zA-Z_$][\w$]*/,
291
+ /(@identifier)/,
243
292
  {
244
293
  cases: {
245
- '@languageStructs': 'language-struct',
246
- '@keywords': 'keyword.$0',
247
- '@default': 'identifier',
294
+ '@languageStructs': PURE_GRAMMAR_TOKEN.LANGUAGE_STRUCT,
295
+ '@keywords': `${PURE_GRAMMAR_TOKEN.KEYWORD}.$0`,
296
+ '@default': PURE_GRAMMAR_TOKEN.IDENTIFIER,
248
297
  },
249
298
  },
250
299
  ],
@@ -259,97 +308,156 @@ const generateLanguageMonarch = (
259
308
  /@symbols/,
260
309
  {
261
310
  cases: {
262
- '@operators': 'operator',
263
- '@default': '',
311
+ '@operators': PURE_GRAMMAR_TOKEN.OPERATOR,
312
+ '@default': PURE_GRAMMAR_TOKEN.IDENTIFIER,
264
313
  },
265
314
  },
266
315
  ],
267
316
 
268
- // numbers
269
317
  { include: '@number' },
270
318
 
271
319
  // delimiter: after number because of .\d floats
272
- [/[;,.]/, 'delimiter'],
320
+ [/[;,.]/, PURE_GRAMMAR_TOKEN.DELIMITER],
273
321
 
274
322
  // strings
275
323
  // NOTE: including non-teminated string so as people type ', we can start showing them that they're working on a string
276
- [/'([^'\\]|\\.)*$/, 'string.invalid'],
277
- [/'/, 'string', '@string'],
324
+ [/'([^'\\]|\\.)*$/, `${PURE_GRAMMAR_TOKEN.STRING}.invalid`],
325
+ [/'/, PURE_GRAMMAR_TOKEN.STRING, '@string'],
278
326
 
279
- // characters
280
327
  { include: '@characters' },
281
328
  ],
282
329
 
283
- number: [
284
- [/(@digits)[eE]([-+]?(@digits))?[fFdD]?/, 'number.float'],
285
- [/(@digits)\.(@digits)([eE][-+]?(@digits))?[fFdD]?/, 'number.float'],
286
- [/0[xX](@hexdigits)[Ll]?/, 'number.hex'],
287
- [/0(@octaldigits)[Ll]?/, 'number.octal'],
288
- [/0[bB](@binarydigits)[Ll]?/, 'number.binary'],
289
- [/(@digits)[fFdD]/, 'number.float'],
290
- [/(@digits)[lL]?/, 'number'],
291
- ],
330
+ pure: [
331
+ // type
332
+ [/(@package\*)/, [PURE_GRAMMAR_TOKEN.PACKAGE]], // import path
333
+ [
334
+ /(@package?)(@identifier)(@generics?)(\s*)(@multiplicity)/,
335
+ [
336
+ PURE_GRAMMAR_TOKEN.PACKAGE,
337
+ PURE_GRAMMAR_TOKEN.TYPE,
338
+ PURE_GRAMMAR_TOKEN.GENERICS,
339
+ PURE_GRAMMAR_TOKEN.WHITESPACE,
340
+ PURE_GRAMMAR_TOKEN.MULTIPLICITY,
341
+ ],
342
+ ],
343
+ [
344
+ /(@package)(@identifier)(@generics?)/,
345
+ [
346
+ PURE_GRAMMAR_TOKEN.PACKAGE,
347
+ PURE_GRAMMAR_TOKEN.TYPE,
348
+ PURE_GRAMMAR_TOKEN.GENERICS,
349
+ ],
350
+ ],
292
351
 
293
- function: [
294
- [/(cast)(\()(@)/, ['function', '', 'cast']],
295
- [/(->\s*)(cast)(\()(@)/, ['', 'function', '', 'cast']],
296
- [/(->\s*)([\w_]+)(\s*\()/, ['', 'function', '']],
297
- [/([\w_]+)(\s*\()/, ['function', '']],
298
- [/(->\s*)([\w_]+)/, ['', 'function']],
299
- ],
352
+ // special operators that uses type (e.g. constructor, cast)
353
+ [
354
+ /([@^])(?:\s*)(@package?)(@identifier)(@generics?)(@multiplicity?)/,
355
+ [
356
+ `${PURE_GRAMMAR_TOKEN.TYPE}.operator`,
357
+ PURE_GRAMMAR_TOKEN.PACKAGE,
358
+ PURE_GRAMMAR_TOKEN.TYPE,
359
+ PURE_GRAMMAR_TOKEN.GENERICS,
360
+ PURE_GRAMMAR_TOKEN.MULTIPLICITY,
361
+ ],
362
+ ],
363
+
364
+ // property / parameter
365
+ [
366
+ /(\.\s*)(@identifier)/,
367
+ [PURE_GRAMMAR_TOKEN.DELIMITER, PURE_GRAMMAR_TOKEN.PROPERTY],
368
+ ],
369
+ [
370
+ /(@identifier)(\s*[:=])/,
371
+ [PURE_GRAMMAR_TOKEN.PROPERTY, PURE_GRAMMAR_TOKEN.OPERATOR],
372
+ ],
373
+ [
374
+ /(@identifier)(\.)(@identifier)/,
375
+ [
376
+ PURE_GRAMMAR_TOKEN.TYPE,
377
+ PURE_GRAMMAR_TOKEN.OPERATOR,
378
+ PURE_GRAMMAR_TOKEN.PROPERTY,
379
+ ],
380
+ ], // profile tag and stereotype
300
381
 
301
- package: [
302
- [/(@package)(\*)/, ['package', 'tag']],
303
- [/(@package)([\w_]+)/, ['package', 'type']],
382
+ // variables
304
383
  [
305
- /(@package)([\w_]+)(\s*)(@multiplicity)/,
306
- ['package', 'type', '', 'multiplicity'],
384
+ /(let)(\s+)(@identifier)(\s*[:=])/,
385
+ [
386
+ PURE_GRAMMAR_TOKEN.KEYWORD,
387
+ PURE_GRAMMAR_TOKEN.WHITESPACE,
388
+ PURE_GRAMMAR_TOKEN.VARIABLE,
389
+ PURE_GRAMMAR_TOKEN.OPERATOR,
390
+ ],
307
391
  ],
392
+ [/(\$@identifier)/, [PURE_GRAMMAR_TOKEN.VARIABLE]],
393
+ ],
394
+
395
+ date: [
396
+ [/(%latest)/, [`${PURE_GRAMMAR_TOKEN.DATE}.latest`]],
397
+ [/(@date)/, [PURE_GRAMMAR_TOKEN.DATE]],
398
+ [/(@time)/, [`${PURE_GRAMMAR_TOKEN.DATE}.time`]],
399
+ ],
400
+
401
+ color: [[/(#[0-9a-fA-F]{6})/, [PURE_GRAMMAR_TOKEN.COLOR]]],
402
+
403
+ number: [
308
404
  [
309
- /([\w_]+)(\s*:\s*)(@package)([\w_]+)(\s*)(@multiplicity)/,
310
- ['attribute', '', 'package', 'type', '', 'multiplicity'],
405
+ /(@digits)[eE]([-+]?(@digits))?[fFdD]?/,
406
+ `${PURE_GRAMMAR_TOKEN.NUMBER}.float`,
311
407
  ],
312
408
  [
313
- /(:\s*)([\w_]+)(\s*)(@multiplicity)/,
314
- ['', 'type', '', 'multiplicity'],
409
+ /(@digits)\.(@digits)([eE][-+]?(@digits))?[fFdD]?/,
410
+ `${PURE_GRAMMAR_TOKEN.NUMBER}.float`,
315
411
  ],
412
+ [/0[xX](@hexdigits)[Ll]?/, `${PURE_GRAMMAR_TOKEN.NUMBER}.hex`],
413
+ [/0(@octaldigits)[Ll]?/, `${PURE_GRAMMAR_TOKEN.NUMBER}.octal`],
414
+ [/0[bB](@binarydigits)[Ll]?/, `${PURE_GRAMMAR_TOKEN.NUMBER}.binary`],
415
+ [/(@digits)[fFdD]/, `${PURE_GRAMMAR_TOKEN.NUMBER}.float`],
416
+ [/(@digits)[lL]?/, PURE_GRAMMAR_TOKEN.NUMBER],
316
417
  ],
317
418
 
318
419
  whitespace: [
319
- [/[ \t\r\n]+/, ''],
320
- [/\/\*\*(?!\/)/, 'comment.doc', '@doc'],
321
- [/\/\*/, 'comment', '@comment'],
322
- [/\/\/.*$/, 'comment'],
420
+ [/[ \t\r\n]+/, PURE_GRAMMAR_TOKEN.WHITESPACE],
421
+ [/\/\*\*(?!\/)/, `${PURE_GRAMMAR_TOKEN.COMMENT}.doc`, '@doc'],
422
+ [/\/\*/, PURE_GRAMMAR_TOKEN.COMMENT, '@comment'],
423
+ [/\/\/.*$/, PURE_GRAMMAR_TOKEN.COMMENT],
323
424
  ],
324
425
 
325
426
  comment: [
326
- [/[^/*]+/, 'comment'],
327
- // [/\/\*/, 'comment', '@push' ], // nested comment not allowed :-(
328
- // [/\/\*/, 'comment.invalid' ], // this breaks block comments in the shape of /* //*/
329
- [/\*\//, 'comment', '@pop'],
330
- [/[/*]/, 'comment'],
427
+ [/[^/*]+/, PURE_GRAMMAR_TOKEN.COMMENT],
428
+ // [/\/\*/, PURE_GRAMMAR_TOKEN.COMMENT, '@push' ], // nested comment not allowed :-(
429
+ // [/\/\*/, ${PURE_GRAMMAR_TOKEN.COMMENT}.invalid` ], // this breaks block comments in the shape of /* //*/
430
+ [/\*\//, PURE_GRAMMAR_TOKEN.COMMENT, '@pop'],
431
+ [/[/*]/, PURE_GRAMMAR_TOKEN.COMMENT],
331
432
  ],
332
433
 
333
434
  // Identical copy of comment above, except for the addition of .doc
334
435
  doc: [
335
- [/[^/*]+/, 'comment.doc'],
336
- // [/\/\*/, 'comment.doc', '@push' ], // nested comment not allowed :-(
337
- [/\/\*/, 'comment.doc.invalid'],
338
- [/\*\//, 'comment.doc', '@pop'],
339
- [/[/*]/, 'comment.doc'],
436
+ [/[^/*]+/, `${PURE_GRAMMAR_TOKEN.COMMENT}.doc`],
437
+ // [/\/\*/, `${PURE_GRAMMAR_TOKEN.COMMENT}.doc`, '@push' ], // nested comment not allowed :-(
438
+ [/\/\*/, `${PURE_GRAMMAR_TOKEN.COMMENT}.doc.invalid`],
439
+ [/\*\//, `${PURE_GRAMMAR_TOKEN.COMMENT}.doc`, '@pop'],
440
+ [/[/*]/, `${PURE_GRAMMAR_TOKEN.COMMENT}.doc`],
340
441
  ],
341
442
 
342
443
  string: [
343
- [/[^\\']+/, 'string'],
344
- [/@escapes/, 'string.escape'],
345
- [/\\./, 'string.escape.invalid'],
346
- [/'/, 'string', '@pop'],
444
+ [/[^\\']+/, PURE_GRAMMAR_TOKEN.STRING],
445
+ [/@escapes/, `${PURE_GRAMMAR_TOKEN.STRING}.escape`],
446
+ [/\\./, `${PURE_GRAMMAR_TOKEN.STRING}.escape.invalid`],
447
+ [/'/, PURE_GRAMMAR_TOKEN.STRING, '@pop'],
347
448
  ],
348
449
 
349
450
  characters: [
350
- [/'[^\\']'/, 'string'],
351
- [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
352
- [/'/, 'string.invalid'],
451
+ [/'[^\\']'/, PURE_GRAMMAR_TOKEN.STRING],
452
+ [
453
+ /(')(@escapes)(')/,
454
+ [
455
+ PURE_GRAMMAR_TOKEN.STRING,
456
+ `${PURE_GRAMMAR_TOKEN.STRING}.escape`,
457
+ PURE_GRAMMAR_TOKEN.STRING,
458
+ ],
459
+ ],
460
+ [/'/, `${PURE_GRAMMAR_TOKEN.STRING}.invalid`],
353
461
  ],
354
462
  },
355
463
  } as monacoLanguagesAPI.IMonarchLanguage);
@@ -362,6 +470,11 @@ export const setupPureLanguageService = (
362
470
  // Override `monaco-editor` native hotkeys
363
471
  // See https://github.com/microsoft/monaco-editor/issues/102#issuecomment-1282897640
364
472
  monacoEditorAPI.addKeybindingRules([
473
+ {
474
+ // disable cursor move (core command)
475
+ keybinding: KeyMod.WinCtrl | KeyCode.KeyB,
476
+ command: null,
477
+ },
365
478
  {
366
479
  // disable cursor move (core command)
367
480
  keybinding: KeyMod.WinCtrl | KeyCode.KeyO,
@@ -387,6 +500,11 @@ export const setupPureLanguageService = (
387
500
  keybinding: KeyCode.F9,
388
501
  command: null,
389
502
  },
503
+ {
504
+ // disable toggle debugger breakpoint
505
+ keybinding: KeyMod.Shift | KeyCode.F10,
506
+ command: null,
507
+ },
390
508
  ]);
391
509
  monacoLanguagesAPI.register({ id: EDITOR_LANGUAGE.PURE });
392
510
  monacoLanguagesAPI.setLanguageConfiguration(