MPS BaseLanguage (Java) Authoring
SkillDev toolsAuthor and edit MPS `jetbrains.mps.baseLanguage` (Java) nodes — choose between the Java parser and JSON AST blueprints, map Java syntax to baseLanguage concepts/roles, harvest persistent member references, and validate. Use when writing class/method bodies, fields, expressions, statements, or any Java/BaseLanguage code inside MPS models, especially when BaseLanguage extensions (smodel, closures, collections) are involved.
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the MPS BaseLanguage (Java) Authoring skill
What this skill tells your AI
The instructions your AI receives, as published by jetbrains/mps in .agents/skills/mps-baselanguage/SKILL.md and read by ahel’s review.
jetbrains.mps.baseLanguage is MPS's Java-equivalent language. You edit it as an AST, not as text. Two authoring paths exist: the Java parser (mps_mcp_parse_java_and_insert) for plain Java, and JSON AST blueprints (mps_mcp_insert_root_node_from_json / mps_mcp_update_root_node_from_json / mps_mcp_update_node) for everything else — especially code that uses BaseLanguage extensions (jetbrains.mps.lang.smodel, jetbrains.mps.baseLanguage.closures, jetbrains.mps.baseLanguage.collections) or needs stable persistent member references.
Critical Directives
- Node equality: always use
:eq:and:ne:(conceptsNPEEqualsExpression/NPENotEqualsExpression). Never==or.equals()between SNode references. - Constructor return type:
ConstructorDeclaration.returnTypeMUST be aVoidTypenode. Leaving it empty fails validation. ClassCreatorwiring:ClassCreator.baseMethodDeclarationpoints at the constructor declaration, not the class.InstanceMethodCallOperation.baseMethodDeclarationpoints at the method declaration.- Inherited methods: use the declaring class ref for
baseMethodDeclaration, not the subclass that calls the method. E.g.addActionListeneris declared onAbstractButton, so use theAbstractButtonclass ref. - Expressions in statement lists: any
Expressionmust be wrapped inExpressionStatementto be valid inside aStatementList. - Variable declarations: in method bodies wrap
LocalVariableDeclarationinLocalVariableDeclarationStatement. InForStatement.variableuseLocalVariableDeclarationdirectly, no wrapper. - Prefer primitives: use
string(StringType) overString(ClassifierType) where possible; same forint,boolean, etc. - Compatibility: BaseLanguage core is Java 7 (including generics). When building AST directly (JSON blueprints), there is no lambda/record syntax — use the
jetbrains.mps.baseLanguage.closuresextension for closures. The Java parser (mps_mcp_parse_java_and_insert) additionally accepts the Java 8+ syntax MPS recognizes — most notably lambdas, which it maps toclosuresClosureLiterals (auto-imported whenpostProcess.importUsedLanguagesis on); a lambda only type-checks against a matching functional-type target. Constructs the parser does not recognize (e.g. records) still fail to parse. Seereferences/parse-java-tips.md. - Surgical edits: when a single child changes prefer
mps_mcp_update_nodeover rewriting the whole root — full-root rewrites churn persistent IDs and break incoming refs.
Choose Your Path
Pick the right authoring tool before you start:
mps_mcp_parse_java_and_insert— use for plain Java skeletons or bodies (classes, methods, statements, expressions), including the current MPS Console input (insert.mode: "console"to replace the console command, ormode: "child"/"replace"with aparentRef/targetRefinside the current console command for nested edits). Fastest path when no BaseLanguage extension is required.- JSON AST blueprints — use when the parser is unavailable, when the code uses BaseLanguage extensions (smodel, closures, collections), or when stable persistent references to members are required for downstream consumers.
- Mixed — use the parser for the skeleton with placeholders (e.g.
IntegerConstant,StringLiteral,IntegerType,StringType), then JSON-edit the placeholders to swap in extension-specific subtrees.
Common Workflow
- Scope: call
mps_mcp_get_current_editor_root_nodeto know where you are inserting (method body, field initializer, root, …). - Resolve dependencies: confirm the containing model imports the right languages (
jetbrains.mps.baseLanguageplus any extensions). Models for referenced nodes must also be imported. - Skeleton first: for any non-trivial root, insert a placeholder skeleton (
mps_mcp_create_root_node+mps_mcp_update_root_node_from_jsonor the parser) before filling member bodies. - Harvest references: for own members, run
mps_mcp_print_nodeon the skeleton to read persistent refs of constructors, methods, and fields. For JDK / library stubs, derive refs from the class ref using the URL-encoded signature formula (see references). - Apply bodies: edit one subtree at a time with
mps_mcp_update_node, or bulk-rewrite viamps_mcp_update_root_node_from_json. - Auto-resolution: for unambiguous local refs (a parameter, a local variable, a unique method name), pass the plain name as
target— MPS resolves it after insertion. For overloaded or stub members, use a persistent ref. - Validate in three gates:
dryRun: trueon insert tools — catches structural / assignability errors before mutationmps_mcp_check_root_node_problems— semantic checkingmps_mcp_alter_nodes MAKE— generation + compilation
- Repair: if a few refs are broken after insert, run
mps_mcp_alter_nodes FIX_REFERENCESrather than re-harvesting all of them.
Related Skills
mps-node-editing— general node mutation tools (mps_mcp_update_node, etc.). Load first if you have not seen them.mps-aspect-structure-concepts— defines what concepts exist and what roles they expose. Read when authoring a brand-new language whose concepts extend BaseLanguage.mps-quotations— light/quoted SNode literals embedded in BaseLanguage code (e.g. inside behavior or generator bodies).mps-model-manipulation—smodel+collections+closurespatterns layered on top of BaseLanguage; load when manipulating MPS nodes from BaseLanguage.mps-aspect-behavior,mps-aspect-typesystem,mps-aspect-constraints— each owns a language whose function bodies are BaseLanguage; reach for those skills when the surrounding aspect matters.
Reference Index
- Open
references/concept-mapping.mdwhen you need the Java-syntax → MPS-concept lookup table and the key role names (statements, expressions, types, declarations). - Open
references/json-patterns.mdwhen you need ready-to-paste JSON blueprints for common constructs (local variable, node-equality, instance-method call, anonymous class, array creation, super-constructor call, empty class template). - Open
references/critical-rules.mdwhen something fails validation and you want the rulebook onExpressionStatement,ClassCreator, anonymous classes, mandatory bodies,FieldReferenceOperation, etc. - Open
references/parse-java-tips.mdwhen usingmps_mcp_parse_java_and_insertand you need binary-expression priority handling, placeholder strategy, or post-insert verification steps. - Open
references/stub-references.mdwhen you need to point abaseMethodDeclarationat a JDK or library member — covers ref derivation, URL encoding, inherited-method handling, and the GET_ASSIGNABLE_REFERENCES fallback. - Open
references/json-ast-workflow.mdwhen authoring a non-trivial BaseLanguage root via JSON AST — covers staged skeleton → harvest → patch → validate, plus theClassCreatorvsInstanceMethodCallOperationref distinction. - Open
references/troubleshooting.mdwhen you hitdryRunerrors, broken-ref symptoms in generated Java (new (),???()), stale-ref errors, or "model checks pass but MAKE fails".
Signals
- GitHub stars
- 2k
- Forks
- 309
- Last commit
- Sep 2026
Advanced
- Catalog kind
- skill
- Gateway key
mps-baselanguage- Source
- github.com/jetbrains/mps