@finos/legend-lego 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. package/lib/application/DocumentationLink.d.ts +27 -0
  2. package/lib/application/DocumentationLink.d.ts.map +1 -0
  3. package/lib/application/DocumentationLink.js +45 -0
  4. package/lib/application/DocumentationLink.js.map +1 -0
  5. package/lib/application/FuzzySearchAdvancedConfigMenu.d.ts +23 -0
  6. package/lib/application/FuzzySearchAdvancedConfigMenu.d.ts.map +1 -0
  7. package/lib/application/FuzzySearchAdvancedConfigMenu.js +35 -0
  8. package/lib/application/FuzzySearchAdvancedConfigMenu.js.map +1 -0
  9. package/lib/application/TabManager.d.ts +24 -0
  10. package/lib/application/TabManager.d.ts.map +1 -0
  11. package/lib/application/TabManager.js +117 -0
  12. package/lib/application/TabManager.js.map +1 -0
  13. package/lib/application/TabManagerState.d.ts +40 -0
  14. package/lib/application/TabManagerState.d.ts.map +1 -0
  15. package/lib/application/TabManagerState.js +93 -0
  16. package/lib/application/TabManagerState.js.map +1 -0
  17. package/lib/application/index.d.ts +20 -0
  18. package/lib/application/index.d.ts.map +1 -0
  19. package/lib/application/index.js +20 -0
  20. package/lib/application/index.js.map +1 -0
  21. package/lib/code-editor/CodeDiffView.d.ts +35 -0
  22. package/lib/code-editor/CodeDiffView.d.ts.map +1 -0
  23. package/lib/code-editor/CodeDiffView.js +78 -0
  24. package/lib/code-editor/CodeDiffView.js.map +1 -0
  25. package/lib/code-editor/CodeEditor.d.ts +1 -1
  26. package/lib/code-editor/CodeEditor.d.ts.map +1 -1
  27. package/lib/code-editor/CodeEditor.js +5 -3
  28. package/lib/code-editor/CodeEditor.js.map +1 -1
  29. package/lib/code-editor/CodeEditorConfig.d.ts +31 -0
  30. package/lib/code-editor/CodeEditorConfig.d.ts.map +1 -0
  31. package/lib/code-editor/CodeEditorConfig.js +33 -0
  32. package/lib/code-editor/CodeEditorConfig.js.map +1 -0
  33. package/lib/code-editor/CodeEditorUtils.d.ts +2 -0
  34. package/lib/code-editor/CodeEditorUtils.d.ts.map +1 -1
  35. package/lib/code-editor/CodeEditorUtils.js +46 -1
  36. package/lib/code-editor/CodeEditorUtils.js.map +1 -1
  37. package/lib/code-editor/PureLanguageCodeEditorSupport.d.ts +70 -0
  38. package/lib/code-editor/PureLanguageCodeEditorSupport.d.ts.map +1 -0
  39. package/lib/code-editor/PureLanguageCodeEditorSupport.js +237 -0
  40. package/lib/code-editor/PureLanguageCodeEditorSupport.js.map +1 -0
  41. package/lib/code-editor/PureLanguageService.d.ts +42 -0
  42. package/lib/code-editor/PureLanguageService.d.ts.map +1 -0
  43. package/lib/code-editor/PureLanguageService.js +437 -0
  44. package/lib/code-editor/PureLanguageService.js.map +1 -0
  45. package/lib/code-editor/__test-utils__/MockedMonacoEditor.d.ts.map +1 -0
  46. package/lib/code-editor/__test-utils__/MockedMonacoEditor.js.map +1 -0
  47. package/lib/code-editor/__test-utils__/MonacoEditorMockUtils.d.ts.map +1 -0
  48. package/lib/code-editor/{testing → __test-utils__}/MonacoEditorMockUtils.js +1 -1
  49. package/lib/code-editor/__test-utils__/MonacoEditorMockUtils.js.map +1 -0
  50. package/lib/code-editor/__test__.d.ts +17 -0
  51. package/lib/code-editor/__test__.d.ts.map +1 -0
  52. package/lib/code-editor/{testing/index.js → __test__.js} +2 -2
  53. package/lib/code-editor/__test__.js.map +1 -0
  54. package/lib/code-editor/index.d.ts +4 -0
  55. package/lib/code-editor/index.d.ts.map +1 -1
  56. package/lib/code-editor/index.js +4 -0
  57. package/lib/code-editor/index.js.map +1 -1
  58. package/lib/graph-editor/ElementIconUtils.d.ts +18 -0
  59. package/lib/graph-editor/ElementIconUtils.d.ts.map +1 -0
  60. package/lib/graph-editor/ElementIconUtils.js +37 -0
  61. package/lib/graph-editor/ElementIconUtils.js.map +1 -0
  62. package/lib/graph-editor/PackageableElementOption.d.ts +25 -0
  63. package/lib/graph-editor/PackageableElementOption.d.ts.map +1 -0
  64. package/lib/graph-editor/PackageableElementOption.js +46 -0
  65. package/lib/graph-editor/PackageableElementOption.js.map +1 -0
  66. package/lib/graph-editor/index.d.ts +18 -0
  67. package/lib/graph-editor/index.d.ts.map +1 -0
  68. package/lib/graph-editor/index.js +18 -0
  69. package/lib/graph-editor/index.js.map +1 -0
  70. package/lib/index.css +2 -2
  71. package/lib/index.css.map +1 -1
  72. package/package.json +14 -9
  73. package/src/application/DocumentationLink.tsx +82 -0
  74. package/src/application/FuzzySearchAdvancedConfigMenu.tsx +66 -0
  75. package/src/application/TabManager.tsx +285 -0
  76. package/src/application/TabManagerState.ts +124 -0
  77. package/src/application/index.ts +22 -0
  78. package/src/code-editor/CodeDiffView.tsx +128 -0
  79. package/src/code-editor/CodeEditor.tsx +8 -5
  80. package/src/code-editor/CodeEditorConfig.ts +32 -0
  81. package/src/code-editor/CodeEditorUtils.ts +76 -1
  82. package/src/code-editor/PureLanguageCodeEditorSupport.ts +338 -0
  83. package/src/code-editor/PureLanguageService.ts +501 -0
  84. package/src/code-editor/{testing → __test-utils__}/MonacoEditorMockUtils.tsx +1 -1
  85. package/src/code-editor/{testing/index.ts → __test__.ts} +1 -1
  86. package/src/code-editor/index.ts +8 -0
  87. package/src/graph-editor/ElementIconUtils.tsx +47 -0
  88. package/src/graph-editor/PackageableElementOption.tsx +86 -0
  89. package/{lib/code-editor/testing/index.d.ts → src/graph-editor/index.ts} +3 -2
  90. package/tsconfig.json +16 -4
  91. package/lib/code-editor/testing/MockedMonacoEditor.d.ts.map +0 -1
  92. package/lib/code-editor/testing/MockedMonacoEditor.js.map +0 -1
  93. package/lib/code-editor/testing/MonacoEditorMockUtils.d.ts.map +0 -1
  94. package/lib/code-editor/testing/MonacoEditorMockUtils.js.map +0 -1
  95. package/lib/code-editor/testing/index.d.ts.map +0 -1
  96. package/lib/code-editor/testing/index.js.map +0 -1
  97. /package/lib/code-editor/{testing → __test-utils__}/MockedMonacoEditor.d.ts +0 -0
  98. /package/lib/code-editor/{testing → __test-utils__}/MockedMonacoEditor.js +0 -0
  99. /package/lib/code-editor/{testing → __test-utils__}/MonacoEditorMockUtils.d.ts +0 -0
  100. /package/src/code-editor/{testing → __test-utils__}/MockedMonacoEditor.ts +0 -0
@@ -15,7 +15,7 @@
15
15
  */
16
16
  /// <reference types="react" resolution-mode="require"/>
17
17
  import { editor as monacoEditorAPI } from 'monaco-editor';
18
- import { type CODE_EDITOR_LANGUAGE } from '@finos/legend-application';
18
+ import { type CODE_EDITOR_LANGUAGE } from './CodeEditorConfig.js';
19
19
  export declare const CodeEditor: React.FC<{
20
20
  inputValue: string;
21
21
  isReadOnly?: boolean | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../src/code-editor/CodeEditor.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAGH,OAAO,EAAoB,MAAM,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AAS5E,OAAO,EACL,KAAK,oBAAoB,EAI1B,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,kBAAkB,CAAC,EACf,CAAC,eAAe,CAAC,cAAc,GAAG,eAAe,CAAC,oBAAoB,CAAC,GACvE,SAAS,CAAC;IACd,WAAW,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACnD,CAiHA,CAAC"}
1
+ {"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../src/code-editor/CodeEditor.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;AAGH,OAAO,EAAoB,MAAM,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AAa5E,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,WAAW,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,kBAAkB,CAAC,EACf,CAAC,eAAe,CAAC,cAAc,GAAG,eAAe,CAAC,oBAAoB,CAAC,GACvE,SAAS,CAAC;IACd,WAAW,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACnD,CAkHA,CAAC"}
@@ -18,7 +18,8 @@ import { useState, useRef, useEffect } from 'react';
18
18
  import { editor as monacoEditorAPI } from 'monaco-editor';
19
19
  import { disposeCodeEditor, getBaseCodeEditorOptions, resetLineNumberGutterWidth, getCodeEditorValue, normalizeLineEnding, } from './CodeEditorUtils.js';
20
20
  import { useResizeDetector } from '@finos/legend-art';
21
- import { CODE_EDITOR_THEME, TAB_SIZE, useApplicationStore, } from '@finos/legend-application';
21
+ import { DEFAULT_TAB_SIZE, useApplicationStore, } from '@finos/legend-application';
22
+ import { CODE_EDITOR_THEME, } from './CodeEditorConfig.js';
22
23
  export const CodeEditor = (props) => {
23
24
  const { inputValue, updateInput, language, isReadOnly, showMiniMap, hideGutter, extraEditorOptions, } = props;
24
25
  const applicationStore = useApplicationStore();
@@ -97,13 +98,14 @@ export const CodeEditor = (props) => {
97
98
  ...(extraEditorOptions ?? {}),
98
99
  });
99
100
  const model = editor.getModel();
100
- model?.updateOptions({ tabSize: TAB_SIZE });
101
+ model?.updateOptions({ tabSize: DEFAULT_TAB_SIZE });
101
102
  }
103
+ // dispose editor
102
104
  useEffect(() => () => {
103
105
  if (editor) {
104
106
  disposeCodeEditor(editor);
105
107
  }
106
- }, [editor]); // dispose editor
108
+ }, [editor]);
107
109
  return (_jsx("div", { ref: ref, className: "code-editor__container", children: _jsx("div", { className: "code-editor__body", ref: textInputRef }) }));
108
110
  };
109
111
  //# sourceMappingURL=CodeEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditor.js","sourceRoot":"","sources":["../../src/code-editor/CodeEditor.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAoB,MAAM,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAEL,iBAAiB,EACjB,QAAQ,EACR,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,CAAC,MAAM,UAAU,GAUlB,CAAC,KAAK,EAAE,EAAE;IACb,MAAM,EACJ,UAAU,EACV,WAAW,EACX,QAAQ,EACR,UAAU,EACV,WAAW,EACX,UAAU,EACV,kBAAkB,GACnB,GAAG,KAAK,CAAC;IACV,MAAM,gBAAgB,GAAG,mBAAmB,EAAE,CAAC;IAC/C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,EAEjC,CAAC;IACJ,MAAM,oCAAoC,GAAG,MAAM,CACjD,SAAS,CACV,CAAC;IAEF;;;;;;;OAOG;IACH,MAAM,KAAK,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC9C,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAClD,MAAM,EAAE,GAAG,EAAE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@ -0,0 +1,31 @@
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 enum CODE_EDITOR_THEME {
17
+ LEGEND = "legend",
18
+ TEMPORARY__VSCODE_LIGHT = "vs"
19
+ }
20
+ export declare enum CODE_EDITOR_LANGUAGE {
21
+ TEXT = "plaintext",
22
+ PURE = "pure",
23
+ JSON = "json",
24
+ JAVA = "java",
25
+ MARKDOWN = "markdown",
26
+ SQL = "sql",
27
+ XML = "xml",
28
+ YAML = "yaml",
29
+ GRAPHQL = "graphql"
30
+ }
31
+ //# sourceMappingURL=CodeEditorConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeEditorConfig.d.ts","sourceRoot":"","sources":["../../src/code-editor/CodeEditorConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,oBAAY,iBAAiB;IAC3B,MAAM,WAAW;IACjB,uBAAuB,OAAO;CAC/B;AAED,oBAAY,oBAAoB;IAC9B,IAAI,cAAc;IAClB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,OAAO,YAAY;CACpB"}
@@ -0,0 +1,33 @@
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 var CODE_EDITOR_THEME;
17
+ (function (CODE_EDITOR_THEME) {
18
+ CODE_EDITOR_THEME["LEGEND"] = "legend";
19
+ CODE_EDITOR_THEME["TEMPORARY__VSCODE_LIGHT"] = "vs";
20
+ })(CODE_EDITOR_THEME = CODE_EDITOR_THEME || (CODE_EDITOR_THEME = {}));
21
+ export var CODE_EDITOR_LANGUAGE;
22
+ (function (CODE_EDITOR_LANGUAGE) {
23
+ CODE_EDITOR_LANGUAGE["TEXT"] = "plaintext";
24
+ CODE_EDITOR_LANGUAGE["PURE"] = "pure";
25
+ CODE_EDITOR_LANGUAGE["JSON"] = "json";
26
+ CODE_EDITOR_LANGUAGE["JAVA"] = "java";
27
+ CODE_EDITOR_LANGUAGE["MARKDOWN"] = "markdown";
28
+ CODE_EDITOR_LANGUAGE["SQL"] = "sql";
29
+ CODE_EDITOR_LANGUAGE["XML"] = "xml";
30
+ CODE_EDITOR_LANGUAGE["YAML"] = "yaml";
31
+ CODE_EDITOR_LANGUAGE["GRAPHQL"] = "graphql";
32
+ })(CODE_EDITOR_LANGUAGE = CODE_EDITOR_LANGUAGE || (CODE_EDITOR_LANGUAGE = {}));
33
+ //# sourceMappingURL=CodeEditorConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeEditorConfig.js","sourceRoot":"","sources":["../../src/code-editor/CodeEditorConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAN,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,mDAA8B,CAAA;AAChC,CAAC,EAHW,iBAAiB,GAAjB,iBAAiB,KAAjB,iBAAiB,QAG5B;AAED,MAAM,CAAN,IAAY,oBAUX;AAVD,WAAY,oBAAoB;IAC9B,0CAAkB,CAAA;IAClB,qCAAa,CAAA;IACb,qCAAa,CAAA;IACb,qCAAa,CAAA;IACb,6CAAqB,CAAA;IACrB,mCAAW,CAAA;IACX,mCAAW,CAAA;IACX,qCAAa,CAAA;IACb,2CAAmB,CAAA;AACrB,CAAC,EAVW,oBAAoB,GAApB,oBAAoB,KAApB,oBAAoB,QAU/B"}
@@ -13,6 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ import { type GenericLegendApplicationStore } from '@finos/legend-application';
16
17
  import { editor as monacoEditorAPI } from 'monaco-editor';
17
18
  export type CodeEditorPosition = {
18
19
  lineNumber: number;
@@ -58,4 +59,5 @@ export declare const clearMarkers: (ownerId?: string) => void;
58
59
  */
59
60
  export declare const normalizeLineEnding: (val: string) => string;
60
61
  export declare const resetLineNumberGutterWidth: (editor: monacoEditorAPI.ICodeEditor) => void;
62
+ export declare const configureCodeEditorComponent: (applicationStore: GenericLegendApplicationStore) => Promise<void>;
61
63
  //# sourceMappingURL=CodeEditorUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditorUtils.d.ts","sourceRoot":"","sources":["../../src/code-editor/CodeEditorUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,IAAI,eAAe,EAAkB,MAAM,eAAe,CAAC;AAE1E,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,WACpB,gBAAgB,qBAAqB,KAC5C,IAIF,CAAC;AAEF,eAAO,MAAM,qBAAqB,WACxB,gBAAgB,qBAAqB,KAC5C,IAIF,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBA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@@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { editor as monacoEditorAPI, MarkerSeverity } from 'monaco-editor';
16
+ import { APPLICATION_EVENT, DEFAULT_MONOSPACED_FONT_FAMILY, } from '@finos/legend-application';
17
+ import { LogEvent } from '@finos/legend-shared';
18
+ import { editor as monacoEditorAPI, KeyCode, KeyMod, MarkerSeverity, } from 'monaco-editor';
17
19
  /**
18
20
  * Normally `monaco-editor` worker disposes after 5 minutes staying idle, but we fasten
19
21
  * this pace just in case the usage of the editor causes memory-leak somehow
@@ -131,4 +133,47 @@ export const resetLineNumberGutterWidth = (editor) => {
131
133
  lineNumbersMinChars: Math.max(Math.floor(Math.log10(currentValue.split(/\r\n|\r|\n/g).length)) + 3, 5),
132
134
  });
133
135
  };
136
+ export const configureCodeEditorComponent = async (applicationStore) => {
137
+ /**
138
+ * Since we use a custom fonts for text-editor, we want to make sure the font is loaded before any text-editor is opened
139
+ * this is to ensure
140
+ */
141
+ const fontLoadFailureErrorMessage = `Monospaced font '${DEFAULT_MONOSPACED_FONT_FAMILY}' has not been loaded properly, code editor might not display properly`;
142
+ await Promise.all([400, 700].map((weight) => document.fonts.load(`${weight} 1em ${DEFAULT_MONOSPACED_FONT_FAMILY}`)))
143
+ .then(() => {
144
+ if (document.fonts.check(`1em ${DEFAULT_MONOSPACED_FONT_FAMILY}`)) {
145
+ monacoEditorAPI.remeasureFonts();
146
+ }
147
+ else {
148
+ applicationStore.logService.error(LogEvent.create(APPLICATION_EVENT.APPLICATION_SETUP__FAILURE), fontLoadFailureErrorMessage);
149
+ }
150
+ })
151
+ .catch(() => applicationStore.logService.error(LogEvent.create(APPLICATION_EVENT.APPLICATION_SETUP__FAILURE), fontLoadFailureErrorMessage));
152
+ // override native hotkeys supported by monaco-editor
153
+ // here we map these keys to a dummy command that would just dispatch the key combination
154
+ // to the application keyboard shortcut service, effectively bypassing the command associated
155
+ // with the native keybinding
156
+ const OVERRIDE_DEFAULT_KEYBINDING_COMMAND = 'legend.code-editor.override-default-keybinding';
157
+ monacoEditorAPI.registerCommand(OVERRIDE_DEFAULT_KEYBINDING_COMMAND, (accessor, ...args) => {
158
+ applicationStore.keyboardShortcutsService.dispatch(args[0]);
159
+ });
160
+ const hotkeyMapping = [
161
+ [KeyCode.F1, 'F1'],
162
+ [KeyCode.F8, 'F8'],
163
+ [KeyCode.F9, 'F9'],
164
+ [KeyMod.WinCtrl | KeyCode.KeyG, 'Control+KeyG'],
165
+ [KeyMod.WinCtrl | KeyCode.KeyB, 'Control+KeyB'],
166
+ [KeyMod.WinCtrl | KeyCode.KeyO, 'Control+KeyO'],
167
+ [KeyMod.WinCtrl | KeyCode.KeyD, 'Control+KeyD'],
168
+ [KeyMod.WinCtrl | KeyCode.KeyP, 'Control+KeyP'],
169
+ [KeyMod.Shift | KeyCode.F10, 'Shift+F10'],
170
+ [KeyMod.WinCtrl | KeyCode.F2, 'Control+F2'],
171
+ [KeyMod.WinCtrl | KeyCode.F12, 'Control+F12'], // go-to definition
172
+ ];
173
+ monacoEditorAPI.addKeybindingRules(hotkeyMapping.map(([nativeCodeEditorKeyBinding, keyCombination]) => ({
174
+ keybinding: nativeCodeEditorKeyBinding,
175
+ command: OVERRIDE_DEFAULT_KEYBINDING_COMMAND,
176
+ commandArgs: keyCombination,
177
+ })));
178
+ };
134
179
  //# sourceMappingURL=CodeEditorUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditorUtils.js","sourceRoot":"","sources":["../../src/code-editor/CodeEditorUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAO1E;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,MAA6C,EACvC,EAAE;IACR,MAAM,CAAC,OAAO,EAAE,CAAC;IACjB,yEAAyE;IACzE,MAAM,CAAC,QAAQ,EAAE,EAAE,O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mBAAmB;KACnE,CAAC;IACF,eAAe,CAAC,kBAAkB,CAChC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,0BAA0B,EAAE,cAAc,CAAC,EAAE,EAAE,CAAC,CAAC;QACnE,UAAU,EAAE,0BAA0B;QACtC,OAAO,EAAE,mCAAmC;QAC5C,WAAW,EAAE,cAAc;KAC5B,CAAC,CAAC,CACJ,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,70 @@
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 type { DocumentationEntry } from '@finos/legend-application';
17
+ import { type editor as monacoEditorAPI, languages as monacoLanguagesAPI, type IPosition } from 'monaco-editor';
18
+ /**
19
+ * This snippet suggestion is meant for an embedded content of an element
20
+ * In other words, it is used to construct element snippet suggestions
21
+ *
22
+ * Because of that, it is expected that there are text content wrapping around
23
+ * this snippet, so the first suggestion might not start from index 1.
24
+ */
25
+ export interface ElementEmbeddedContentSnippetSuggestion {
26
+ /**
27
+ * Brief description about the suggestion item to enable the users to quickly
28
+ * differentiate between one suggestions from another
29
+ */
30
+ description?: string | undefined;
31
+ /**
32
+ * The snippet text to be embedded in the full snippet suggestion text for the element
33
+ *
34
+ * NOTE: The snippet syntax follows that of `monaco-editor`
35
+ * See https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets
36
+ */
37
+ text: string;
38
+ }
39
+ /**
40
+ * This mirrors `monaco-editor` completion item structure
41
+ * See https://microsoft.github.io/monaco-editor/api/interfaces/monaco.languages.CompletionItem.html
42
+ */
43
+ export interface PureGrammarTextSuggestion {
44
+ /**
45
+ * The text label of the suggestion.
46
+ */
47
+ text: string;
48
+ /**
49
+ * Brief description about the suggestion item to enable the users to quickly
50
+ * differentiate between one suggestions from another
51
+ */
52
+ description?: string | undefined;
53
+ /**
54
+ * Detailed documentation that explains/elaborates the suggestion item.
55
+ */
56
+ documentation?: DocumentationEntry | undefined;
57
+ /**
58
+ * A string or snippet that should be inserted when selecting this suggestion.
59
+ *
60
+ * NOTE: The snippet syntax follows that of `monaco-editor`
61
+ * See https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets
62
+ */
63
+ insertText: string;
64
+ }
65
+ export declare const getParserKeywordSuggestions: (position: IPosition, model: monacoEditorAPI.ITextModel, suggestions: PureGrammarTextSuggestion[]) => monacoLanguagesAPI.CompletionItem[];
66
+ export declare const getSectionParserNameFromLineText: (lineText: string) => string | undefined;
67
+ export declare const getParserElementSnippetSuggestions: (position: IPosition, model: monacoEditorAPI.ITextModel, suggestionsGetter: (parserName: string) => PureGrammarTextSuggestion[]) => monacoLanguagesAPI.CompletionItem[];
68
+ export declare const getInlineSnippetSuggestions: (position: IPosition, model: monacoEditorAPI.ITextModel, extraSnippetSuggestions?: PureGrammarTextSuggestion[]) => monacoLanguagesAPI.CompletionItem[];
69
+ export declare const isTokenOneOf: (token: string, baseTokens: string[], exact?: boolean) => boolean;
70
+ //# sourceMappingURL=PureLanguageCodeEditorSupport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PureLanguageCodeEditorSupport.d.ts","sourceRoot":"","sources":["../../src/code-editor/PureLanguageCodeEditorSupport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAOpE,OAAO,EACL,KAAK,MAAM,IAAI,eAAe,EAC9B,SAAS,IAAI,kBAAkB,EAC/B,KAAK,SAAS,EACf,MAAM,eAAe,CAAC;AAEvB;;;;;;GAMG;AACH,MAAM,WAAW,uCAAuC;IACtD;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC;;OAEG;IACH,aAAa,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAC/C;;;;;OAKG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,2BAA2B,aAC5B,SAAS,SACZ,gBAAgB,UAAU,eACpB,yBAAyB,EAAE,KACvC,mBAAmB,cAAc,EAuCnC,CAAC;AAEF,eAAO,MAAM,gCAAgC,aACjC,MAAM,KACf,MAAM,GAAG,SAMX,CAAC;AAEF,eAAO,MAAM,kCAAkC,aACnC,SAAS,SACZ,gBAAgB,UAAU,kCACD,MAAM,KAAK,yBAAyB,EAAE,KACrE,mBAAmB,cAAc,EAiDnC,CAAC;AAEF,eAAO,MAAM,2BAA2B,aAC5B,SAAS,SACZ,gBAAgB,UAAU,4BACR,yBAAyB,EAAE,KACnD,mBAAmB,cAAc,EAmInC,CAAC;AAEF,eAAO,MAAM,YAAY,UAChB,MAAM,cACD,MAAM,EAAE,sBAEnB,OAQF,CAAC"}
@@ -0,0 +1,237 @@
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 { getNullableFirstElement, 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(getNullableFirstElement(token.split('.')));
235
+ return baseTokens.includes(baseToken);
236
+ };
237
+ //# sourceMappingURL=PureLanguageCodeEditorSupport.js.map
@@ -0,0 +1 @@
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,uBAAuB,EACvB,oBAAoB,EACpB,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,SAAS,IAAI,kBAAkB,GAEhC,MAAM,eAAe,CAAC;AAmDvB,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,QAAmB,EACnB,KAAiC,EACjC,WAAwC,EACH,EAAE;IACvC,MAAM,OAAO,GAAwC,EAAE,CAAC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1,42 @@
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 enum PURE_GRAMMAR_TOKEN {
17
+ WHITESPACE = "",
18
+ KEYWORD = "keyword",
19
+ IDENTIFIER = "identifier",
20
+ OPERATOR = "operator",
21
+ DELIMITER = "delimiter",
22
+ PARSER = "parser",
23
+ NUMBER = "number",
24
+ DATE = "date",
25
+ COLOR = "color",
26
+ PACKAGE = "package",
27
+ STRING = "string",
28
+ COMMENT = "comment",
29
+ LANGUAGE_STRUCT = "language-struct",
30
+ MULTIPLICITY = "multiplicity",
31
+ GENERICS = "generics",
32
+ PROPERTY = "property",
33
+ PARAMETER = "property",
34
+ VARIABLE = "variable",
35
+ TYPE = "type",
36
+ INVALID = "invalid"
37
+ }
38
+ export declare function setupPureLanguageService(options?: {
39
+ extraKeywords?: string[] | undefined;
40
+ extraParserKeywords?: string[] | undefined;
41
+ }): void;
42
+ //# sourceMappingURL=PureLanguageService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PureLanguageService.d.ts","sourceRoot":"","sources":["../../src/code-editor/PureLanguageService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAoBH,oBAAY,kBAAkB;IAC5B,UAAU,KAAK;IAEf,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,QAAQ,aAAa;IACrB,SAAS,cAAc;IAEvB,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,OAAO,YAAY;IAEnB,eAAe,oBAAoB;IACnC,YAAY,iBAAiB;IAC7B,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,SAAS,aAAa;IACtB,QAAQ,aAAa;IACrB,IAAI,SAAS;IAEb,OAAO,YAAY;CACpB;AAwaD,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE;IACjD,aAAa,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACrC,mBAAmB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CAC5C,GAAG,IAAI,CAcP"}