@finos/legend-application 14.0.4 → 15.0.1
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/lib/__lib__/LegendApplicationDocumentation.d.ts.map +1 -0
- package/lib/__lib__/LegendApplicationDocumentation.js.map +1 -0
- package/lib/{application → __lib__}/LegendApplicationEvent.d.ts +0 -1
- package/lib/__lib__/LegendApplicationEvent.d.ts.map +1 -0
- package/lib/{application → __lib__}/LegendApplicationEvent.js +0 -1
- package/lib/__lib__/LegendApplicationEvent.js.map +1 -0
- package/lib/__lib__/LegendApplicationNavigation.d.ts +19 -0
- package/lib/__lib__/LegendApplicationNavigation.d.ts.map +1 -0
- package/lib/__lib__/LegendApplicationNavigation.js +20 -0
- package/lib/__lib__/LegendApplicationNavigation.js.map +1 -0
- package/lib/__lib__/LegendApplicationSetting.d.ts.map +1 -0
- package/lib/__lib__/LegendApplicationSetting.js.map +1 -0
- package/lib/{application → __lib__}/LegendApplicationTelemetry.d.ts +0 -11
- package/lib/__lib__/LegendApplicationTelemetry.d.ts.map +1 -0
- package/lib/{application → __lib__}/LegendApplicationTelemetry.js +0 -4
- package/lib/__lib__/LegendApplicationTelemetry.js.map +1 -0
- package/lib/__lib__/LegendApplicationTheme.d.ts.map +1 -0
- package/lib/__lib__/LegendApplicationTheme.js.map +1 -0
- package/lib/__test__.d.ts +18 -0
- package/lib/__test__.d.ts.map +1 -0
- package/lib/__test__.js +18 -0
- package/lib/__test__.js.map +1 -0
- package/lib/application/LegendApplication.d.ts +7 -4
- package/lib/application/LegendApplication.d.ts.map +1 -1
- package/lib/application/LegendApplication.js +28 -11
- package/lib/application/LegendApplication.js.map +1 -1
- package/lib/application/LegendApplicationConfig.d.ts +8 -1
- package/lib/application/LegendApplicationConfig.d.ts.map +1 -1
- package/lib/application/LegendApplicationConfig.js +6 -2
- package/lib/application/LegendApplicationConfig.js.map +1 -1
- package/lib/browser.d.ts +19 -0
- package/lib/browser.d.ts.map +1 -0
- package/lib/browser.js +19 -0
- package/lib/browser.js.map +1 -0
- package/lib/components/{LegendApplicationComponentFrameworkProvider.d.ts → ApplicationComponentFrameworkProvider.d.ts} +2 -2
- package/lib/components/ApplicationComponentFrameworkProvider.d.ts.map +1 -0
- package/lib/components/{LegendApplicationComponentFrameworkProvider.js → ApplicationComponentFrameworkProvider.js} +3 -3
- package/lib/components/ApplicationComponentFrameworkProvider.js.map +1 -0
- package/lib/components/ApplicationFrameworkProvider.d.ts +21 -0
- package/lib/components/ApplicationFrameworkProvider.d.ts.map +1 -0
- package/lib/components/ApplicationFrameworkProvider.js +39 -0
- package/lib/components/ApplicationFrameworkProvider.js.map +1 -0
- package/lib/components/{shared/DocumentationLink.d.ts → ApplicationPlatformProvider.d.ts} +4 -10
- package/lib/components/ApplicationPlatformProvider.d.ts.map +1 -0
- package/lib/components/{WebApplicationNavigatorProviderTestUtils.d.ts → ApplicationPlatformProvider.js} +5 -7
- package/lib/components/ApplicationPlatformProvider.js.map +1 -0
- package/lib/components/ApplicationStoreProvider.d.ts +3 -4
- package/lib/components/ApplicationStoreProvider.d.ts.map +1 -1
- package/lib/components/ApplicationStoreProvider.js +6 -23
- package/lib/components/ApplicationStoreProvider.js.map +1 -1
- package/lib/components/{WebApplicationNavigatorProvider.d.ts → BrowserEnvironmentProvider.d.ts} +3 -4
- package/lib/components/BrowserEnvironmentProvider.d.ts.map +1 -0
- package/lib/components/BrowserEnvironmentProvider.js +31 -0
- package/lib/components/BrowserEnvironmentProvider.js.map +1 -0
- package/lib/components/VirtualAssistant.d.ts.map +1 -1
- package/lib/components/VirtualAssistant.js +17 -9
- package/lib/components/VirtualAssistant.js.map +1 -1
- package/lib/components/{shared/FuzzySearchAdvancedConfigMenu.d.ts → __test-utils__/BrowserEnvironmentTestUtils.d.ts} +13 -7
- package/lib/components/__test-utils__/BrowserEnvironmentTestUtils.d.ts.map +1 -0
- package/lib/components/__test-utils__/BrowserEnvironmentTestUtils.js +42 -0
- package/lib/components/__test-utils__/BrowserEnvironmentTestUtils.js.map +1 -0
- package/lib/index.css +2 -2
- package/lib/index.css.map +1 -1
- package/lib/index.d.ts +8 -16
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -18
- package/lib/index.js.map +1 -1
- package/lib/package.json +4 -6
- package/lib/stores/{shared/PackageableElementOption.d.ts → ApplicationConfig.d.ts} +6 -7
- package/lib/stores/ApplicationConfig.d.ts.map +1 -0
- package/lib/stores/ApplicationConfig.js +21 -0
- package/lib/stores/ApplicationConfig.js.map +1 -0
- package/lib/stores/ApplicationNavigationContextService.js +1 -1
- package/lib/stores/ApplicationNavigationContextService.js.map +1 -1
- package/lib/stores/ApplicationStore.d.ts +4 -8
- package/lib/stores/ApplicationStore.d.ts.map +1 -1
- package/lib/stores/ApplicationStore.js +14 -14
- package/lib/stores/ApplicationStore.js.map +1 -1
- package/lib/stores/AssistantService.d.ts +3 -3
- package/lib/stores/AssistantService.d.ts.map +1 -1
- package/lib/stores/AssistantService.js +18 -10
- package/lib/stores/AssistantService.js.map +1 -1
- package/lib/stores/CommandService.js +1 -1
- package/lib/stores/CommandService.js.map +1 -1
- package/lib/stores/Core_LegendApplicationPlugin.d.ts.map +1 -1
- package/lib/stores/Core_LegendApplicationPlugin.js +2 -52
- package/lib/stores/Core_LegendApplicationPlugin.js.map +1 -1
- package/lib/stores/DocumentationService.d.ts +1 -1
- package/lib/stores/DocumentationService.d.ts.map +1 -1
- package/lib/stores/DocumentationService.js +4 -5
- package/lib/stores/DocumentationService.js.map +1 -1
- package/lib/stores/LayoutService.js +3 -3
- package/lib/stores/LayoutService.js.map +1 -1
- package/lib/stores/LegendApplicationPlugin.d.ts +1 -15
- package/lib/stores/LegendApplicationPlugin.d.ts.map +1 -1
- package/lib/stores/LegendApplicationPlugin.js +0 -5
- package/lib/stores/LegendApplicationPlugin.js.map +1 -1
- package/lib/stores/SettingService.d.ts +1 -0
- package/lib/stores/SettingService.d.ts.map +1 -1
- package/lib/stores/SettingService.js +1 -1
- package/lib/stores/SettingService.js.map +1 -1
- package/lib/stores/__test-utils__/ApplicationStoreTestUtils.d.ts +18 -0
- package/lib/stores/__test-utils__/ApplicationStoreTestUtils.d.ts.map +1 -0
- package/lib/stores/__test-utils__/ApplicationStoreTestUtils.js +21 -0
- package/lib/stores/__test-utils__/ApplicationStoreTestUtils.js.map +1 -0
- package/lib/stores/navigation/BrowserNavigator.d.ts +64 -0
- package/lib/stores/navigation/BrowserNavigator.d.ts.map +1 -0
- package/lib/stores/navigation/{WebApplicationNavigator.js → BrowserNavigator.js} +22 -3
- package/lib/stores/navigation/BrowserNavigator.js.map +1 -0
- package/lib/stores/navigation/{WebApplicationNavigator.d.ts → DefaultNavigator.d.ts} +3 -12
- package/lib/stores/navigation/DefaultNavigator.d.ts.map +1 -0
- package/lib/stores/navigation/DefaultNavigator.js +74 -0
- package/lib/stores/navigation/DefaultNavigator.js.map +1 -0
- package/lib/stores/navigation/NavigationService.d.ts +7 -0
- package/lib/stores/navigation/NavigationService.d.ts.map +1 -1
- package/lib/stores/navigation/NavigationService.js.map +1 -1
- package/lib/stores/platform/ApplicationPlatform.d.ts +24 -0
- package/lib/stores/platform/ApplicationPlatform.d.ts.map +1 -0
- package/lib/stores/platform/ApplicationPlatform.js +25 -0
- package/lib/stores/platform/ApplicationPlatform.js.map +1 -0
- package/lib/stores/platform/BrowserPlatform.d.ts +29 -0
- package/lib/stores/platform/BrowserPlatform.d.ts.map +1 -0
- package/lib/stores/platform/BrowserPlatform.js +39 -0
- package/lib/stores/platform/BrowserPlatform.js.map +1 -0
- package/lib/stores/storage/StorageService.d.ts +5 -2
- package/lib/stores/storage/StorageService.d.ts.map +1 -1
- package/lib/stores/storage/StorageService.js +20 -10
- package/lib/stores/storage/StorageService.js.map +1 -1
- package/lib/stores/terminal/XTerm.d.ts.map +1 -1
- package/lib/stores/terminal/XTerm.js +5 -5
- package/lib/stores/terminal/XTerm.js.map +1 -1
- package/package.json +7 -9
- package/src/{application → __lib__}/LegendApplicationEvent.ts +1 -1
- package/{lib/stores/shared/PackageableElementOption.js → src/__lib__/LegendApplicationNavigation.ts} +4 -5
- package/src/{application → __lib__}/LegendApplicationTelemetry.ts +0 -24
- package/src/{components.ts → __test__.ts} +2 -7
- package/src/application/LegendApplication.ts +45 -16
- package/src/application/LegendApplicationConfig.ts +13 -2
- package/src/browser.ts +19 -0
- package/src/components/{LegendApplicationComponentFrameworkProvider.tsx → ApplicationComponentFrameworkProvider.tsx} +2 -2
- package/src/components/ApplicationFrameworkProvider.tsx +47 -0
- package/src/components/ApplicationPlatformProvider.tsx +29 -0
- package/src/components/ApplicationStoreProvider.tsx +8 -33
- package/src/components/BrowserEnvironmentProvider.tsx +48 -0
- package/src/components/VirtualAssistant.tsx +53 -11
- package/src/components/__test-utils__/BrowserEnvironmentTestUtils.tsx +63 -0
- package/src/index.ts +12 -24
- package/src/stores/ApplicationConfig.ts +22 -0
- package/src/stores/ApplicationNavigationContextService.ts +1 -1
- package/src/stores/ApplicationStore.ts +18 -19
- package/src/stores/AssistantService.ts +20 -9
- package/src/stores/CommandService.ts +1 -1
- package/src/stores/Core_LegendApplicationPlugin.ts +2 -78
- package/src/stores/DocumentationService.ts +4 -5
- package/src/stores/LayoutService.ts +3 -3
- package/src/stores/LegendApplicationPlugin.ts +1 -21
- package/src/stores/SettingService.ts +2 -1
- package/src/stores/__test-utils__/ApplicationStoreTestUtils.ts +24 -0
- package/src/stores/navigation/{WebApplicationNavigator.ts → BrowserNavigator.ts} +41 -2
- package/src/stores/navigation/DefaultNavigator.ts +150 -0
- package/src/stores/navigation/NavigationService.ts +8 -0
- package/src/stores/{shared/PackageableElementOption.ts → platform/ApplicationPlatform.ts} +14 -11
- package/src/stores/platform/BrowserPlatform.ts +54 -0
- package/src/stores/storage/StorageService.ts +32 -14
- package/src/stores/terminal/XTerm.ts +8 -5
- package/tsconfig.json +19 -23
- package/lib/application/LegendApplicationDocumentation.d.ts.map +0 -1
- package/lib/application/LegendApplicationDocumentation.js.map +0 -1
- package/lib/application/LegendApplicationEvent.d.ts.map +0 -1
- package/lib/application/LegendApplicationEvent.js.map +0 -1
- package/lib/application/LegendApplicationSetting.d.ts.map +0 -1
- package/lib/application/LegendApplicationSetting.js.map +0 -1
- package/lib/application/LegendApplicationTelemetry.d.ts.map +0 -1
- package/lib/application/LegendApplicationTelemetry.js.map +0 -1
- package/lib/application/LegendApplicationTheme.d.ts.map +0 -1
- package/lib/application/LegendApplicationTheme.js.map +0 -1
- package/lib/components/ApplicationStoreProviderTestUtils.d.ts +0 -31
- package/lib/components/ApplicationStoreProviderTestUtils.d.ts.map +0 -1
- package/lib/components/ApplicationStoreProviderTestUtils.js +0 -32
- package/lib/components/ApplicationStoreProviderTestUtils.js.map +0 -1
- package/lib/components/LegendApplicationComponentFrameworkProvider.d.ts.map +0 -1
- package/lib/components/LegendApplicationComponentFrameworkProvider.js.map +0 -1
- package/lib/components/WebApplicationNavigatorProvider.d.ts.map +0 -1
- package/lib/components/WebApplicationNavigatorProvider.js +0 -29
- package/lib/components/WebApplicationNavigatorProvider.js.map +0 -1
- package/lib/components/WebApplicationNavigatorProviderTestUtils.d.ts.map +0 -1
- package/lib/components/WebApplicationNavigatorProviderTestUtils.js +0 -28
- package/lib/components/WebApplicationNavigatorProviderTestUtils.js.map +0 -1
- package/lib/components/shared/DocumentationLink.d.ts.map +0 -1
- package/lib/components/shared/DocumentationLink.js +0 -53
- package/lib/components/shared/DocumentationLink.js.map +0 -1
- package/lib/components/shared/FuzzySearchAdvancedConfigMenu.d.ts.map +0 -1
- package/lib/components/shared/FuzzySearchAdvancedConfigMenu.js +0 -37
- package/lib/components/shared/FuzzySearchAdvancedConfigMenu.js.map +0 -1
- package/lib/components/shared/PackageableElementOptionLabel.d.ts +0 -22
- package/lib/components/shared/PackageableElementOptionLabel.d.ts.map +0 -1
- package/lib/components/shared/PackageableElementOptionLabel.js +0 -46
- package/lib/components/shared/PackageableElementOptionLabel.js.map +0 -1
- package/lib/components/shared/TabManager.d.ts +0 -24
- package/lib/components/shared/TabManager.d.ts.map +0 -1
- package/lib/components/shared/TabManager.js +0 -117
- package/lib/components/shared/TabManager.js.map +0 -1
- package/lib/components.d.ts +0 -21
- package/lib/components.d.ts.map +0 -1
- package/lib/components.js +0 -21
- package/lib/components.js.map +0 -1
- package/lib/const.d.ts +0 -35
- package/lib/const.d.ts.map +0 -1
- package/lib/const.js +0 -39
- package/lib/const.js.map +0 -1
- package/lib/stores/ApplicationStoreTestUtils.d.ts +0 -41
- package/lib/stores/ApplicationStoreTestUtils.d.ts.map +0 -1
- package/lib/stores/ApplicationStoreTestUtils.js +0 -70
- package/lib/stores/ApplicationStoreTestUtils.js.map +0 -1
- package/lib/stores/navigation/WebApplicationNavigator.d.ts.map +0 -1
- package/lib/stores/navigation/WebApplicationNavigator.js.map +0 -1
- package/lib/stores/navigation/WebApplicationRouter.d.ts +0 -22
- package/lib/stores/navigation/WebApplicationRouter.d.ts.map +0 -1
- package/lib/stores/navigation/WebApplicationRouter.js +0 -25
- package/lib/stores/navigation/WebApplicationRouter.js.map +0 -1
- package/lib/stores/pure-language/PureLanguageCodeEditorSupport.d.ts +0 -70
- package/lib/stores/pure-language/PureLanguageCodeEditorSupport.d.ts.map +0 -1
- package/lib/stores/pure-language/PureLanguageCodeEditorSupport.js +0 -237
- package/lib/stores/pure-language/PureLanguageCodeEditorSupport.js.map +0 -1
- package/lib/stores/pure-language/PureLanguageSupport.d.ts +0 -39
- package/lib/stores/pure-language/PureLanguageSupport.d.ts.map +0 -1
- package/lib/stores/pure-language/PureLanguageSupport.js +0 -437
- package/lib/stores/pure-language/PureLanguageSupport.js.map +0 -1
- package/lib/stores/shared/FuzzySearchAdvancedConfigState.d.ts +0 -30
- package/lib/stores/shared/FuzzySearchAdvancedConfigState.d.ts.map +0 -1
- package/lib/stores/shared/FuzzySearchAdvancedConfigState.js +0 -59
- package/lib/stores/shared/FuzzySearchAdvancedConfigState.js.map +0 -1
- package/lib/stores/shared/PackageableElementOption.d.ts.map +0 -1
- package/lib/stores/shared/PackageableElementOption.js.map +0 -1
- package/lib/stores/shared/TabManagerState.d.ts +0 -40
- package/lib/stores/shared/TabManagerState.d.ts.map +0 -1
- package/lib/stores/shared/TabManagerState.js +0 -93
- package/lib/stores/shared/TabManagerState.js.map +0 -1
- package/src/components/ApplicationStoreProviderTestUtils.tsx +0 -59
- package/src/components/WebApplicationNavigatorProvider.tsx +0 -46
- package/src/components/WebApplicationNavigatorProviderTestUtils.tsx +0 -37
- package/src/components/shared/DocumentationLink.tsx +0 -87
- package/src/components/shared/FuzzySearchAdvancedConfigMenu.tsx +0 -73
- package/src/components/shared/PackageableElementOptionLabel.tsx +0 -85
- package/src/components/shared/TabManager.tsx +0 -288
- package/src/const.ts +0 -40
- package/src/stores/ApplicationStoreTestUtils.ts +0 -107
- package/src/stores/navigation/WebApplicationRouter.ts +0 -49
- package/src/stores/pure-language/PureLanguageCodeEditorSupport.ts +0 -338
- package/src/stores/pure-language/PureLanguageSupport.ts +0 -498
- package/src/stores/shared/FuzzySearchAdvancedConfigState.ts +0 -65
- package/src/stores/shared/TabManagerState.ts +0 -124
- /package/lib/{application → __lib__}/LegendApplicationDocumentation.d.ts +0 -0
- /package/lib/{application → __lib__}/LegendApplicationDocumentation.js +0 -0
- /package/lib/{application → __lib__}/LegendApplicationSetting.d.ts +0 -0
- /package/lib/{application → __lib__}/LegendApplicationSetting.js +0 -0
- /package/lib/{application → __lib__}/LegendApplicationTheme.d.ts +0 -0
- /package/lib/{application → __lib__}/LegendApplicationTheme.js +0 -0
- /package/src/{application → __lib__}/LegendApplicationDocumentation.ts +0 -0
- /package/src/{application → __lib__}/LegendApplicationSetting.ts +0 -0
- /package/src/{application → __lib__}/LegendApplicationTheme.ts +0 -0
|
@@ -1,338 +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
|
-
|
|
17
|
-
import { PARSER_SECTION_MARKER, PURE_PARSER } from '@finos/legend-graph';
|
|
18
|
-
import {
|
|
19
|
-
getNullableFirstElement,
|
|
20
|
-
guaranteeNonNullable,
|
|
21
|
-
hasWhiteSpace,
|
|
22
|
-
} from '@finos/legend-shared';
|
|
23
|
-
import {
|
|
24
|
-
type editor as monacoEditorAPI,
|
|
25
|
-
languages as monacoLanguagesAPI,
|
|
26
|
-
type IPosition,
|
|
27
|
-
} from 'monaco-editor';
|
|
28
|
-
import type { DocumentationEntry } from '../DocumentationService.js';
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* This snippet suggestion is meant for an embedded content of an element
|
|
32
|
-
* In other words, it is used to construct element snippet suggestions
|
|
33
|
-
*
|
|
34
|
-
* Because of that, it is expected that there are text content wrapping around
|
|
35
|
-
* this snippet, so the first suggestion might not start from index 1.
|
|
36
|
-
*/
|
|
37
|
-
export interface ElementEmbeddedContentSnippetSuggestion {
|
|
38
|
-
/**
|
|
39
|
-
* Brief description about the suggestion item to enable the users to quickly
|
|
40
|
-
* differentiate between one suggestions from another
|
|
41
|
-
*/
|
|
42
|
-
description?: string | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* The snippet text to be embedded in the full snippet suggestion text for the element
|
|
45
|
-
*
|
|
46
|
-
* NOTE: The snippet syntax follows that of `monaco-editor`
|
|
47
|
-
* See https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets
|
|
48
|
-
*/
|
|
49
|
-
text: string;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* This mirrors `monaco-editor` completion item structure
|
|
54
|
-
* See https://microsoft.github.io/monaco-editor/api/interfaces/monaco.languages.CompletionItem.html
|
|
55
|
-
*/
|
|
56
|
-
export interface PureGrammarTextSuggestion {
|
|
57
|
-
/**
|
|
58
|
-
* The text label of the suggestion.
|
|
59
|
-
*/
|
|
60
|
-
text: string;
|
|
61
|
-
/**
|
|
62
|
-
* Brief description about the suggestion item to enable the users to quickly
|
|
63
|
-
* differentiate between one suggestions from another
|
|
64
|
-
*/
|
|
65
|
-
description?: string | undefined;
|
|
66
|
-
/**
|
|
67
|
-
* Detailed documentation that explains/elaborates the suggestion item.
|
|
68
|
-
*/
|
|
69
|
-
documentation?: DocumentationEntry | undefined;
|
|
70
|
-
/**
|
|
71
|
-
* A string or snippet that should be inserted when selecting this suggestion.
|
|
72
|
-
*
|
|
73
|
-
* NOTE: The snippet syntax follows that of `monaco-editor`
|
|
74
|
-
* See https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets
|
|
75
|
-
*/
|
|
76
|
-
insertText: string;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export const getParserKeywordSuggestions = (
|
|
80
|
-
position: IPosition,
|
|
81
|
-
model: monacoEditorAPI.ITextModel,
|
|
82
|
-
suggestions: PureGrammarTextSuggestion[],
|
|
83
|
-
): monacoLanguagesAPI.CompletionItem[] => {
|
|
84
|
-
const results: monacoLanguagesAPI.CompletionItem[] = [];
|
|
85
|
-
const currentWord = model.getWordUntilPosition(position);
|
|
86
|
-
|
|
87
|
-
// suggestions for parser keyword
|
|
88
|
-
const lineTextIncludingWordRange = {
|
|
89
|
-
startLineNumber: position.lineNumber,
|
|
90
|
-
startColumn: 1,
|
|
91
|
-
endLineNumber: position.lineNumber,
|
|
92
|
-
endColumn: currentWord.endColumn,
|
|
93
|
-
};
|
|
94
|
-
const lineTextIncludingWord = model.getValueInRange(
|
|
95
|
-
lineTextIncludingWordRange,
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
// NOTE: make sure parser keyword suggestions only show up when the current word is the
|
|
99
|
-
// the first word of the line since parser section header must not be preceded by anything
|
|
100
|
-
if (!hasWhiteSpace(lineTextIncludingWord.trim())) {
|
|
101
|
-
suggestions.forEach((suggestion) => {
|
|
102
|
-
results.push({
|
|
103
|
-
label: {
|
|
104
|
-
label: `${PARSER_SECTION_MARKER}${suggestion.text}`,
|
|
105
|
-
description: suggestion.description,
|
|
106
|
-
},
|
|
107
|
-
kind: monacoLanguagesAPI.CompletionItemKind.Keyword,
|
|
108
|
-
insertText: `${PARSER_SECTION_MARKER}${suggestion.insertText}\n`,
|
|
109
|
-
range: lineTextIncludingWordRange,
|
|
110
|
-
documentation: suggestion.documentation
|
|
111
|
-
? suggestion.documentation.markdownText
|
|
112
|
-
? {
|
|
113
|
-
value: suggestion.documentation.markdownText.value,
|
|
114
|
-
}
|
|
115
|
-
: suggestion.documentation.text
|
|
116
|
-
: undefined,
|
|
117
|
-
} as monacoLanguagesAPI.CompletionItem);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return results;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export const getSectionParserNameFromLineText = (
|
|
125
|
-
lineText: string,
|
|
126
|
-
): string | undefined => {
|
|
127
|
-
if (lineText.startsWith(PARSER_SECTION_MARKER)) {
|
|
128
|
-
return lineText.substring(PARSER_SECTION_MARKER.length).split(' ')[0];
|
|
129
|
-
}
|
|
130
|
-
// NOTE: since leading whitespace to parser name is considered invalid, we will return `undefined`
|
|
131
|
-
return undefined;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export const getParserElementSnippetSuggestions = (
|
|
135
|
-
position: IPosition,
|
|
136
|
-
model: monacoEditorAPI.ITextModel,
|
|
137
|
-
suggestionsGetter: (parserName: string) => PureGrammarTextSuggestion[],
|
|
138
|
-
): monacoLanguagesAPI.CompletionItem[] => {
|
|
139
|
-
const results: monacoLanguagesAPI.CompletionItem[] = [];
|
|
140
|
-
const currentWord = model.getWordUntilPosition(position);
|
|
141
|
-
|
|
142
|
-
// suggestions for parser element snippets
|
|
143
|
-
const textUntilPosition = model.getValueInRange({
|
|
144
|
-
startLineNumber: 1,
|
|
145
|
-
startColumn: 1,
|
|
146
|
-
endLineNumber: position.lineNumber,
|
|
147
|
-
endColumn: position.column,
|
|
148
|
-
});
|
|
149
|
-
const allParserSectionHeaders =
|
|
150
|
-
// NOTE: since `###Pure` is implicitly considered as the first section, we prepend it to the text
|
|
151
|
-
`${PARSER_SECTION_MARKER}${PURE_PARSER.PURE}\n${textUntilPosition}`
|
|
152
|
-
.split('\n')
|
|
153
|
-
.filter((line) => line.startsWith(PARSER_SECTION_MARKER));
|
|
154
|
-
const currentParserName = getSectionParserNameFromLineText(
|
|
155
|
-
allParserSectionHeaders[allParserSectionHeaders.length - 1] ?? '',
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
if (currentParserName) {
|
|
159
|
-
suggestionsGetter(currentParserName).forEach((snippetSuggestion) => {
|
|
160
|
-
results.push({
|
|
161
|
-
label: {
|
|
162
|
-
label: snippetSuggestion.text,
|
|
163
|
-
description: snippetSuggestion.description,
|
|
164
|
-
},
|
|
165
|
-
kind: monacoLanguagesAPI.CompletionItemKind.Snippet,
|
|
166
|
-
insertTextRules:
|
|
167
|
-
monacoLanguagesAPI.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
168
|
-
insertText: `${snippetSuggestion.insertText}\n`,
|
|
169
|
-
range: {
|
|
170
|
-
startLineNumber: position.lineNumber,
|
|
171
|
-
startColumn: currentWord.startColumn,
|
|
172
|
-
endLineNumber: position.lineNumber,
|
|
173
|
-
endColumn: currentWord.endColumn,
|
|
174
|
-
},
|
|
175
|
-
documentation: snippetSuggestion.documentation
|
|
176
|
-
? snippetSuggestion.documentation.markdownText
|
|
177
|
-
? {
|
|
178
|
-
value: snippetSuggestion.documentation.markdownText.value,
|
|
179
|
-
}
|
|
180
|
-
: snippetSuggestion.documentation.text
|
|
181
|
-
: undefined,
|
|
182
|
-
} as monacoLanguagesAPI.CompletionItem);
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return results;
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
export const getInlineSnippetSuggestions = (
|
|
190
|
-
position: IPosition,
|
|
191
|
-
model: monacoEditorAPI.ITextModel,
|
|
192
|
-
extraSnippetSuggestions: PureGrammarTextSuggestion[] = [],
|
|
193
|
-
): monacoLanguagesAPI.CompletionItem[] => {
|
|
194
|
-
const currentWord = model.getWordUntilPosition(position);
|
|
195
|
-
|
|
196
|
-
return (
|
|
197
|
-
[
|
|
198
|
-
{
|
|
199
|
-
text: 'let',
|
|
200
|
-
description: 'new variable',
|
|
201
|
-
insertText: `let \${1:} = \${2:};`,
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
text: 'let',
|
|
205
|
-
description: 'new collection',
|
|
206
|
-
insertText: `let \${1:} = [\${2:}];`,
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
text: 'cast',
|
|
210
|
-
description: 'type casting',
|
|
211
|
-
insertText: `cast(@\${1:model::SomeClass})`,
|
|
212
|
-
},
|
|
213
|
-
// conditionals
|
|
214
|
-
{
|
|
215
|
-
text: 'if',
|
|
216
|
-
description: '(conditional)',
|
|
217
|
-
insertText: `if(\${1:'true'}, | \${2:/* if true do this */}, | \${3:/* if false do this */})`,
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
text: 'case',
|
|
221
|
-
description: '(conditional)',
|
|
222
|
-
insertText: `case(\${1:}, \${2:'true'}, \${3:'false'})`,
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
text: 'match',
|
|
226
|
-
description: '(conditional)',
|
|
227
|
-
insertText: `match([x:\${1:String[1]}, \${2:''}])`,
|
|
228
|
-
},
|
|
229
|
-
// collection
|
|
230
|
-
{
|
|
231
|
-
text: 'map',
|
|
232
|
-
description: '(collection)',
|
|
233
|
-
insertText: `map(x|\${1:})`,
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
text: 'filter',
|
|
237
|
-
description: '(collection)',
|
|
238
|
-
insertText: `filter(x|\${1:})`,
|
|
239
|
-
},
|
|
240
|
-
{
|
|
241
|
-
text: 'fold',
|
|
242
|
-
description: '(collection)',
|
|
243
|
-
insertText: `fold({a, b| \${1:$a + $b}}, \${2:0})`,
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
text: 'filter',
|
|
247
|
-
description: '(collection)',
|
|
248
|
-
insertText: `filter(x|\${1:})`,
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
text: 'sort',
|
|
252
|
-
description: '(collection)',
|
|
253
|
-
insertText: `sort()`,
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
text: 'in',
|
|
257
|
-
description: '(collection)',
|
|
258
|
-
insertText: `in()`,
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
text: 'slice',
|
|
262
|
-
description: '(collection)',
|
|
263
|
-
insertText: `slice(\${1:1},$\{2:2})`,
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
text: 'removeDuplicates',
|
|
267
|
-
description: '(collection)',
|
|
268
|
-
insertText: `removeDuplicates()`,
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
text: 'toOne',
|
|
272
|
-
description: '(collection)',
|
|
273
|
-
insertText: `toOne(\${1:})`,
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
text: 'toOneMany',
|
|
277
|
-
description: '(collection)',
|
|
278
|
-
insertText: `toOneMany(\${1:})`,
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
text: 'isEmpty',
|
|
282
|
-
description: '(collection)',
|
|
283
|
-
insertText: `isEmpty()`,
|
|
284
|
-
},
|
|
285
|
-
// string
|
|
286
|
-
{
|
|
287
|
-
text: 'endsWith',
|
|
288
|
-
description: '(string)',
|
|
289
|
-
insertText: `endsWith()`,
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
text: 'startsWith',
|
|
293
|
-
description: '(string)',
|
|
294
|
-
insertText: `startsWith()`,
|
|
295
|
-
},
|
|
296
|
-
...extraSnippetSuggestions,
|
|
297
|
-
] as PureGrammarTextSuggestion[]
|
|
298
|
-
).map(
|
|
299
|
-
(snippetSuggestion) =>
|
|
300
|
-
({
|
|
301
|
-
label: {
|
|
302
|
-
label: snippetSuggestion.text,
|
|
303
|
-
description: snippetSuggestion.description,
|
|
304
|
-
},
|
|
305
|
-
kind: monacoLanguagesAPI.CompletionItemKind.Snippet,
|
|
306
|
-
insertTextRules:
|
|
307
|
-
monacoLanguagesAPI.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
308
|
-
insertText: snippetSuggestion.insertText,
|
|
309
|
-
range: {
|
|
310
|
-
startLineNumber: position.lineNumber,
|
|
311
|
-
startColumn: currentWord.startColumn,
|
|
312
|
-
endLineNumber: position.lineNumber,
|
|
313
|
-
endColumn: currentWord.endColumn,
|
|
314
|
-
},
|
|
315
|
-
documentation: snippetSuggestion.documentation
|
|
316
|
-
? snippetSuggestion.documentation.markdownText
|
|
317
|
-
? {
|
|
318
|
-
value: snippetSuggestion.documentation.markdownText.value,
|
|
319
|
-
}
|
|
320
|
-
: snippetSuggestion.documentation.text
|
|
321
|
-
: undefined,
|
|
322
|
-
} as monacoLanguagesAPI.CompletionItem),
|
|
323
|
-
);
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
export const isTokenOneOf = (
|
|
327
|
-
token: string,
|
|
328
|
-
baseTokens: string[],
|
|
329
|
-
exact = false,
|
|
330
|
-
): boolean => {
|
|
331
|
-
if (exact) {
|
|
332
|
-
return baseTokens.map((baseToken) => `${baseToken}.pure`).includes(token);
|
|
333
|
-
}
|
|
334
|
-
const baseToken = guaranteeNonNullable(
|
|
335
|
-
getNullableFirstElement(token.split('.')),
|
|
336
|
-
);
|
|
337
|
-
return baseTokens.includes(baseToken);
|
|
338
|
-
};
|