How to add/create a new Concept using the Open API?
Hi folks,
I've read a lot about creating nodes using the Open API (which works very well). Now I need to create a new concept instead of a node. So, is it possible to define a new concept and editor using Java?
Thanks in advance!
Cheers,
Dennis
I've read a lot about creating nodes using the Open API (which works very well). Now I need to create a new concept instead of a node. So, is it possible to define a new concept and editor using Java?
Thanks in advance!
Cheers,
Dennis
Please sign in to leave a comment.
execute(node)->void { node<ConceptDeclaration> declaration = node : ConceptDeclaration; string name = declaration.name; string virtualPackage = declaration.virtualPackage; node<ConceptDeclaration> stub = declaration.model.new root node(ConceptDeclaration); stub.name = "Stub" + name; stub.virtualPackage = virtualPackage; stub.extends.set(declaration); node<InterfaceConceptReference> ref1 = new node<InterfaceConceptReference>(); ref1.intfc.set(concept/IDontSubstituteByDefault/.asNode); stub.implements.add(ref1); node<InterfaceConceptReference> ref2 = new node<InterfaceConceptReference>(); ref2.intfc.set(concept/IStubForAnotherConcept/.asNode); stub.implements.add(ref2); SModel model = declaration/.getModel(); if (model == null) { return; } SModule language = model.getModule(); SModel editorModel = LanguageAspect.EDITOR.get((Language) language); if (editorModel == null) { return; } node<ConceptEditorDeclaration> editor = new node<ConceptEditorDeclaration>(); editor.conceptDeclaration.set(stub); editor.virtualPackage = virtualPackage; node<CellModel_Component> component = new node<CellModel_Component>(); component.editorComponent.set(node/ImplementationRemovedInStubMessage/); editor.cellModel.set(component); editorModel.addRootNode(editor); }I'm not able to import the jetbrains.mps.lang.editor.structure.ConceptEditorDeclaration into my Action. What dependencies and languages do I have to import, in order to make it work?
I tried the following dependencies and languages:
Dependencies:
jetbrains.mps.lang.structure.editor@java_stub
jetbrains.mps.openapi.editor@java_stub
jetbrains.mps.baselanguage.editor
Used Languages:
jetbrains.mps.baselanguage
jetbrains.mps.lang.editor
jetbrains.mps.lang.structure
Unfortunately most of these imports are grayed out, so I figured they are not being used..?
FYI my action is contained in a Plugin Aspect in my language. Perhaps this has something to do with the issue?
Vaclav
Yo may also try to add the import by Control/Cmd + R and typing "ConceptEditorDeclaration". This should import both the language and the model dependencies.