@finos/legend-extension-dsl-persistence
Version:
Legend extension for Persistence DSL
192 lines • 8.58 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import packageJson from '../../../package.json' with { type: 'json' };
import { MeteorIcon, PuzzlePieceIcon } from '@finos/legend-art';
import { LegendStudioApplicationPlugin, UnsupportedElementEditorState, PACKAGEABLE_ELEMENT_GROUP_BY_CATEGORY, } from '@finos/legend-application-studio';
import { Persistence } from '../../graph/metamodel/pure/model/packageableElements/persistence/DSL_Persistence_Persistence.js';
import { PersistenceContext } from '../../graph/metamodel/pure/model/packageableElements/persistence/DSL_Persistence_PersistenceContext.js';
import { BLANK_PERSISTENCE_CONTEXT_SNIPPET, BLANK_PERSISTENCE_SNIPPET, } from '../../__lib__/studio/DSL_Persistence_LegendStudioCodeSnippet.js';
import { DSL_PERSISTENCE_LEGEND_STUDIO_DOCUMENTATION_KEY } from '../../__lib__/studio/DSL_Persistence_LegendStudioDocumentation.js';
const PERSISTENCE_ELEMENT_TYPE = 'PERSISTENCE';
const PERSISTENCE_CONTEXT_ELEMENT_TYPE = 'PERSISTENCE_CONTEXT';
const PERSISTENCE_ELEMENT_PROJECT_EXPLORER_DND_TYPE = 'PROJECT_EXPLORER_PERSISTENCE';
const PERSISTENCE_CONTEXT_ELEMENT_PROJECT_EXPLORER_DND_TYPE = 'PROJECT_EXPLORER_PERSISTENCE_CONTEXT';
const PURE_GRAMMAR_PERSISTENCE_PARSER_NAME = 'Persistence';
const PURE_GRAMMAR_PERSISTENCE_ELEMENT_TYPE_LABEL = 'Persistence';
const PURE_GRAMMAR_PERSISTENCE_CONTEXT_ELEMENT_TYPE_LABEL = 'PersistenceContext';
export class DSL_Persistence_LegendStudioApplicationPlugin extends LegendStudioApplicationPlugin {
constructor() {
super(packageJson.extensions.applicationStudioPlugin, packageJson.version);
}
getExtraRequiredDocumentationKeys() {
return [
DSL_PERSISTENCE_LEGEND_STUDIO_DOCUMENTATION_KEY.CONCEPT_ELEMENT_PERSISTENCE,
DSL_PERSISTENCE_LEGEND_STUDIO_DOCUMENTATION_KEY.CONCEPT_ELEMENT_PERSISTENCE_CONTEXT,
DSL_PERSISTENCE_LEGEND_STUDIO_DOCUMENTATION_KEY.GRAMMAR_PARSER,
];
}
getExtraPureGrammarKeywords() {
return [
PURE_GRAMMAR_PERSISTENCE_ELEMENT_TYPE_LABEL,
PURE_GRAMMAR_PERSISTENCE_CONTEXT_ELEMENT_TYPE_LABEL,
];
}
getExtraSupportedElementTypes() {
return [PERSISTENCE_ELEMENT_TYPE, PERSISTENCE_CONTEXT_ELEMENT_TYPE];
}
getExtraSupportedElementTypesWithCategory() {
const elementTypesWithCategoryMap = new Map();
elementTypesWithCategoryMap.set(PACKAGEABLE_ELEMENT_GROUP_BY_CATEGORY.OTHER, [PERSISTENCE_ELEMENT_TYPE, PERSISTENCE_CONTEXT_ELEMENT_TYPE]);
return elementTypesWithCategoryMap;
}
getExtraElementClassifiers() {
return [
(element) => {
if (element instanceof Persistence) {
return PERSISTENCE_ELEMENT_TYPE;
}
else if (element instanceof PersistenceContext) {
return PERSISTENCE_CONTEXT_ELEMENT_TYPE;
}
return undefined;
},
];
}
getExtraElementIconGetters() {
return [
(type) => {
if (type === PERSISTENCE_ELEMENT_TYPE) {
return (_jsx("div", { className: "icon icon--persistence", children: _jsx(MeteorIcon, {}) }));
}
else if (type === PERSISTENCE_CONTEXT_ELEMENT_TYPE) {
return (_jsx("div", { className: "icon icon--persistence-context", children: _jsx(PuzzlePieceIcon, {}) }));
}
return undefined;
},
];
}
getExtraNewElementFromStateCreators() {
return [
(type, name, state) => {
if (type === PERSISTENCE_ELEMENT_TYPE) {
return new Persistence(name);
}
else if (type === PERSISTENCE_CONTEXT_ELEMENT_TYPE) {
return new PersistenceContext(name);
}
return undefined;
},
];
}
getExtraElementEditorStateCreators() {
return [
(editorStore, element) => {
if (element instanceof Persistence ||
element instanceof PersistenceContext) {
return new UnsupportedElementEditorState(editorStore, element);
}
return undefined;
},
];
}
getExtraDragElementClassifiers() {
return [
(element) => {
if (element instanceof Persistence) {
return PERSISTENCE_ELEMENT_PROJECT_EXPLORER_DND_TYPE;
}
else if (element instanceof PersistenceContext) {
return PERSISTENCE_CONTEXT_ELEMENT_PROJECT_EXPLORER_DND_TYPE;
}
return undefined;
},
];
}
getExtraPureGrammarTextEditorDragElementTypes() {
return [
PERSISTENCE_ELEMENT_PROJECT_EXPLORER_DND_TYPE,
PERSISTENCE_CONTEXT_ELEMENT_PROJECT_EXPLORER_DND_TYPE,
];
}
getExtraPureGrammarParserElementDocumentationGetters() {
return [
(editorStore, parserKeyword, elementKeyword) => {
if (parserKeyword === PURE_GRAMMAR_PERSISTENCE_PARSER_NAME) {
if (elementKeyword === PURE_GRAMMAR_PERSISTENCE_ELEMENT_TYPE_LABEL) {
return editorStore.applicationStore.documentationService.getDocEntry(DSL_PERSISTENCE_LEGEND_STUDIO_DOCUMENTATION_KEY.CONCEPT_ELEMENT_PERSISTENCE);
}
else if (elementKeyword ===
PURE_GRAMMAR_PERSISTENCE_CONTEXT_ELEMENT_TYPE_LABEL) {
return editorStore.applicationStore.documentationService.getDocEntry(DSL_PERSISTENCE_LEGEND_STUDIO_DOCUMENTATION_KEY.CONCEPT_ELEMENT_PERSISTENCE_CONTEXT);
}
}
return undefined;
},
];
}
getExtraPureGrammarParserDocumentationGetters() {
return [
(editorStore, parserKeyword) => {
if (parserKeyword === PURE_GRAMMAR_PERSISTENCE_PARSER_NAME) {
return editorStore.applicationStore.documentationService.getDocEntry(DSL_PERSISTENCE_LEGEND_STUDIO_DOCUMENTATION_KEY.GRAMMAR_PARSER);
}
return undefined;
},
];
}
getExtraPureGrammarParserKeywordSuggestionGetters() {
return [
(editorStore) => [
{
text: PURE_GRAMMAR_PERSISTENCE_PARSER_NAME,
description: `(dsl)`,
documentation: editorStore.applicationStore.documentationService.getDocEntry(DSL_PERSISTENCE_LEGEND_STUDIO_DOCUMENTATION_KEY.GRAMMAR_PARSER),
insertText: PURE_GRAMMAR_PERSISTENCE_PARSER_NAME,
},
],
];
}
getExtraPureGrammarParserElementSnippetSuggestionsGetters() {
return [
(editorStore, parserKeyword) => parserKeyword === PURE_GRAMMAR_PERSISTENCE_PARSER_NAME
? [
{
text: PURE_GRAMMAR_PERSISTENCE_ELEMENT_TYPE_LABEL,
description: '(blank)',
insertText: BLANK_PERSISTENCE_SNIPPET,
},
{
text: PURE_GRAMMAR_PERSISTENCE_CONTEXT_ELEMENT_TYPE_LABEL,
description: '(blank)',
insertText: BLANK_PERSISTENCE_CONTEXT_SNIPPET,
},
]
: undefined,
];
}
getExtraElementTypeLabelGetters() {
return [
(type) => {
if (type === PERSISTENCE_CONTEXT_ELEMENT_TYPE) {
return 'Persistence Context';
}
return undefined;
},
];
}
}
//# sourceMappingURL=DSL_Persistence_LegendStudioApplicationPlugin.js.map