
Skill
mps-aspect-editor-menus-and-keymaps
author MPS editor menus and keymaps
Description
Use when authoring the **non-layout** parts of the MPS editor aspect — what happens when the user types, presses a key, triggers completion, pastes, or invokes a context action. Covers action maps (`CellActionMapDeclaration`), cell keymaps (`CellKeyMapDeclaration`), transformation menus (`TransformationMenu_Default` / `_Named` / `_Contribution`), substitute menus (`SubstituteMenu_Default` / `SubstituteMenu` / contributions), side transforms (LEFT/RIGHT), legacy cell menus, paste wrappers and copy-paste handlers (in the actions language), completion styling, reference presentation, two-step deletion, and the editor selection API. Trigger terms: `actionMap`, `keyMap`, `delete_action_id`, `transformationMenu`, `substituteMenu`, `Ctrl+Space`, `Ctrl+Alt+B`, side transform, paste wrapper, completion styling, `PasteWrappers`, `CopyPasteHandlers`. For the **layout** side (cells, layouts, style sheets) use `mps-aspect-editor` instead.
SKILL.md
MPS Editor Aspect — Menus, Keymaps and Actions
This skill covers the non-layout parts of the MPS editor aspect: everything that controls user interaction (typing, keystrokes, completion, paste, context actions). Most concepts belong to jetbrains.mps.lang.editor.structure; paste wrappers / node factories / copy-paste handlers live in jetbrains.mps.lang.actions.structure. Roots typically live in <lang>/languageModels/editor.mps or actions.mps.
Where these roots go. Menus / keymaps / action maps live in the same editor aspect model as the layout cell models — there is no separate aspect ID. Paste wrappers, copy-paste handlers and node factories live in the actions aspect model. Both aspect IDs (editor, actions) are case-sensitive and carry no @ suffix — see aspect-model-stereotypes.md.
For the layout side (concept editors, cell models, style sheets, editor components) see mps-mcp-workflow and mps-aspect-editor.
Critical Directives
- Pick the right artefact for the user-visible behaviour. "Change what
Deletedoes" → action map. "AddCtrl+Shift+I" → keymap. "Offer+after a number" → side transform in a transformation menu. "Hide / reorder completion" → substitute menu. "Wrap pasted node" → paste wrapper. Seereferences/landscape.mdfor the full mapping. - Author by convention. Name roots
<Concept>_ActionMap,<Concept>_KeyMap,<Concept>_TransformationMenu,<Concept>_<Position>_SubstituteMenu,<Concept>_Factory,<Concept>Stylingfor automatic discovery. MPS walks the super-concept chain to find them. - Use MPS MCP tools for edits.
mps_mcp_insert_root_node_from_json,mps_mcp_update_node. Resolve concept names withmps_mcp_search_concepts/mps_mcp_get_concept_details— never guess concept IDs. - Define a substitute menu before a transformation menu. The default
BaseConcept_TransformationMenualready includes the substitute menu; for most "make my concept completable" tasks, only a substitute menu is required. - An empty default substitute menu HIDES the concept from completion. Either remove it or fill it. See
references/substitute-menus.md§"Empty default suppresses". - Side-transform items are NOT automatically in
Ctrl+Space. Either listTransformationLocation_CompletionalongsideTransformationLocation_SideTransform, or add a separate completion section. - Use action maps for
DELETE/BACKSPACEinstead of keymaps bound toVK_DELETE. They integrate with two-step deletion and action inheritance. TransformationMenufield name isconceptDeclaration, notapplicableConcept. Real role names:sections,parts,locations,textFunction. Older docs lie.- Contributions must live in a different language from the menu they extend.
TransformationMenuContribution/SubstituteMenu_Contributionare cross-language only. - Write bodies with
mps-model-manipulationidioms.node.replace with(...),node.parent.<role>.set(...),node.children<X>.add new(...). Implicit params:node,editorContext(+model,scope,operationContextdepending on function kind). - After edits run
mps_mcp_check_root_node_problemsand rebuild the language. - Trace missing completion items with
Ctrl+Alt+Bon the offending item — MPS shows the menu → menu-part → action chain.
Common-Path Workflow
For a typical "let the user invoke action X when they do Y" task:
- Pick the artefact from the table in
references/landscape.md. - Pick the attachment concept. Roles:
applicableConcept(action maps, keymaps, copy/paste handlers, paste wrappers source/target);conceptDeclarationviaIMenu_Concept(transformation and substitute menus). - Name by convention so MPS discovers the root automatically. Otherwise wire it explicitly from the cell (
actionMap,keyMap,transformationMenu,substituteMenu, legacymenu). - Draft JSON using a blueprint from
references/json-blueprints.md. Usemps_mcp_insert_root_node_from_json. - Write the function body with smodel + BaseLanguage. For "select the new node afterwards", use the editor selection API (
references/selection-and-deletion.md). - Rebuild the language (
mps_mcp_alter_nodesMAKE) so the editor sees the new concepts. - Validate with
mps_mcp_check_root_node_problemson every touched root. Common error: unresolved action IDs (delete_action_idetc.) or missing imports for shared-concept parameters. - Test interactively in a sample model. For side transforms, verify the item also appears in completion (if intended).
- Diagnose missing items with
Ctrl+Alt+Bon the popup item — that prints the menu chain.
Which Menu Fires Where (Quick Reference)
| User action | Menu consulted |
|---|---|
Ctrl+Space / typing into a concept-completion cell | Default SubstituteMenu for the link's target concept, walking DOWN sub-concepts |
| Context Assistant pops up | Sections with TransformationLocation_ContextAssistant |
| Context Actions Tool | Sections with TransformationLocation_ContextActionsTool |
Typing + right of a cell | Sections with TransformationLocation_SideTransform location, place.side = RIGHT |
Pressing Delete | CellActionMapDeclaration item with actionId = delete_action_id, else default |
| Arbitrary keystroke | CellKeyMapDeclaration items matching keystroke + caret policy |
| Copy (Ctrl+C) | CopyPreProcessors for the concept |
| Paste into incompatible slot | PasteWrappers, then PastePostProcessors |
Related Skills
mps-mcp-workflow— "MPS Concept Editor Workflow" section: scaffold, componentise, refine. Covers the layout side.mps-aspect-editor— overall workflow for creating and changing MPS editor definitions; cell models, layout styles, style inheritance.mps-aspect-actions—NodeFactoryinitialisation of new nodes (in the actions language, often referenced from menus).mps-aspect-intentions— Alt+Enter context actions. Intentions can be surfaced inside a transformation menu via theintentionadapter.mps-model-manipulation— smodel operations used in execute/text/condition bodies.mps-baselanguage— BaseLanguage JSON mechanics.mps-node-editing,mps-mcp-workflow— concept identification / blueprint hygiene.
Reference Index
- Open
references/landscape.mdwhen choosing which artefact to build — the master table of root concepts, attachment-point roles, file conventions, naming conventions, and theBaseConcept_TransformationMenusuper-chain rule. Also covers theTransformationMenu_Default/_Nameddeprecation note (future merge intoTransformationMenuImpl). - Open
references/action-maps.mdwhen overriding standard cell actions (DELETE, BACKSPACE, SELECT_ALL, LEFT_TRANSFORM, RIGHT_TRANSFORM, …) —CellActionMapDeclarationfields, item structure, theNot_ActionMapexample from Kaja,BACKSPACEauto-registration, the keyboard-deletable-annotation pattern (delete a node attribute from its label cell and reselect the host node), importing maps viaCellActionMapImport/wildcard/by-action-id selectors, import rules (transitive, winner, no cycles, cross-language),SELECT_ALLcustomisation. - Open
references/keymaps.mdwhen binding arbitrary keystrokes to a cell —CellKeyMapDeclarationfields,everyModelflag,CellKeyMapItemproperties (keystroke, executeFunction, isApplicableFunction, description, caretPolicy, showInPopup, menuAlwaysShown),CastExpression_KeyMaptemplate,modifiersstring syntax (ctrl alt shift meta), caret-policy semantics, when to prefer an action map. - Open
references/transformation-menus.mdwhen adding items to completion / context assistant / context actions tool / side transforms — section structure withlocations+parts, the fourTransformationLocation_*types, every menu part concept (Action,Group,Super,IncludeMenu,IncludeSubstituteMenu,SubMenu,Parameterized,WrapSubstituteMenu,PropertyMenu,ReferenceMenu,Placeholder), adapter parts (intention,refactoring,plugin Action), theActionblueprint withtextFunction/executeFunction/canExecuteFunction/features(description text), parameterised parts withparameterObject, groups + variables (with the eager-evaluation gotcha),TransformationMenuContributioncross-language extension, cell-level attachment combining legacymenu+transformationMenu. - Open
references/substitute-menus.mdwhen controlling what nodes are creatable at an AST position — default vs named, the five synthesised-default rules (sub-concepts, abstracts filtered, can-be-child, can-be-parent, smart-reference for 1:1), the "empty default suppresses" gotcha, allSubstituteMenuPart_*concepts (AddConcept,Concepts,Subconcepts,Group,IncludeMenu,Parameterized,Action,Wrapper,ReferenceScope,Placeholder), theStatement_SubstituteMenuJSON template, theWrapperexample wrappingExpressionintoExpressionStatement. - Open
references/side-transforms.mdwhen converting1typed+into1 + <hole>— the right-transform JSON template onExpression, LEFT vs RIGHT semantics, the trick to also surface items inCtrl+Space(either combine locations or include the menu from a completion section). - Open
references/legacy-cell-menus.mdwhen dealing with cells that still havemenu/postfixHintdeclarations — property values menu, postfix hints (with the verbatimsplitByCamelsexample), primary replace-child / choose-referent, replace-node (custom node concept), generic items, cell menu reference, ref-presentation cell, and thepresentation query in reference constraintsdeprecation warning. - Open
references/paste-and-copy.mdwhen transforming pasted nodes or pre/post-processing copy/paste —PasteWrappers(in actions language) withsourceConcept/targetConcept/wrapfunction and theExpression → Statementexample;CopyPasteHandlerswithCopyPreProcessor(mutatescopy, notoriginal) andPastePostProcessor(re-resolves references with theLocalVariableReferenceexample); triggering order (handlers → wrappers → graft). - Open
references/completion-styling.mdwhen customising the look or priority of completion items —CompletionStylingselectors (items modifying concept instances vs items creating concept instances), styling attributes (bold/italic/strike/colour/hide/priority), sort order,ReturnStatementStyling/VariableReferencePriorityexamples, the global "Use completion styling" toggle. - Open
references/reference-presentation.mdwhen changing how a reference looks resolved or in completion —ref. presentation cellonCellModel_RefCell,cell menu referenceitems, the recommended modern alternative (override the referenced concept'sInlineEditorComponentor expose agetPresentation()behavior method). - Open
references/selection-and-deletion.mdwhen selecting a node after a mutation or implementing two-step deletion — theselectoperation syntax (in:,cell:,selectionStart,selectionEnd), predefined cell values (FIRST,LAST,LAST_EDITABLE,MOST_RELEVANT), theApproveDelete_Operationhook, the "node not already selected / not already approved" conditions, and the rule that custom delete actions must callnode.approveDelete(editorContext)before mutating. - Open
references/json-blueprints.mdwhen inserting any of these roots through MCP — copy-and-edit JSON for action map, keymap, transformation menu (default + side-transform), substitute menu (default + wrapper), paste wrapper, copy-paste handlers, completion styling. Each blueprint has a comment indicating where to inject BaseLanguage statement lists. - Open
references/wiring-tables.mdwhen understanding the cell-to-aspect wiring — the cellmenu/transformationMenu/substituteMenu/keyMap/actionMapmapping, when both are combined vs replaced, the name-driven discovery convention. - Open
references/real-examples.mdwhen studying canonical implementations —jetbrains.mps.samples.Kaja(compact action-map + substitute menu + side-transform + style sheet),jetbrains.mps.baseLanguage(editor.mps ≈4 MB; actions.mps with paste wrappers; intentions.mps), with themps_mcp_print_nodeworkflow for cross-checking concept and role names. - Open
references/common-failures.mdwhen a feature does not work — concept absent from completion (empty default substitute menu); side transform inserts the character;Deletedoesn't fire (two-step deletion not approved); keymap item never fires; paste wrapper not triggered; transformation-menu action in completion but not Context Assistant; wrong role name in JSON (section/part/location/matchingTextFunction/applicableConcept); stale references after refactor (useFIX_REFERENCES); contribution defined in same language as the menu.
More skills from the MPS repository
View all 31 skillsmps-aspect-accessories
configure JetBrains MPS module dependencies
Jul 17ArchitectureConfigurationEngineeringmps-aspect-actions
define and edit MPS node factories
Jul 17ArchitectureEngineeringmps-aspect-behavior
define and edit MPS concept behavior
Jul 13ArchitectureEngineeringmps-aspect-constraints
define JetBrains MPS language constraints
Jul 23ArchitectureCode Analysismps-aspect-dataflow
define and debug MPS dataflow builders
Jul 13Data Analysismps-aspect-editor
define MPS editor layouts
Jul 23DesignUI Components
More from JetBrains
View publishermps-aspect-generation-plan
modify MPS generation plans
MPS
Jul 13ArchitectureEngineeringmps-aspect-generator
define JetBrains MPS generator rules
MPS
Jul 17ArchitectureCode AnalysisEngineeringmps-aspect-intentions
define and edit MPS intentions
MPS
Jul 23ArchitectureEngineeringmps-aspect-migrations
author and debug MPS migration scripts
MPS
Jul 13DebuggingMigrationmps-aspect-structure-concepts
define concepts in MPS structure aspect
MPS
Jul 23Data Modeling