JjScript Reference
JjScript is an imperative, command-based scripting language for direct metamodel manipulation. While JjEL evaluates expressions without side effects and JjTL produces new models declaratively, JjScript modifies the metamodel in place: it creates, renames, moves, and deletes elements as immediate operations.
Command syntax
Section titled “Command syntax”Every JjScript statement begins with a verb followed by its arguments:
create class Personcreate attribute name in Person type EString [1]rename class Person to Customerdelete attribute ageAll value expressions inside commands are delegated to JjEL. The same expression syntax works across all Jjodel languages.
Structural commands
Section titled “Structural commands”| Command | Syntax | Description |
|---|---|---|
| create | create <type> <name> [in <parent>] [options] | Create a metamodel element |
| delete | delete [<type>] <target> [cascade|force] | Remove an element |
| rename | rename [<type>] <target> to <name> | Rename an element |
| set | set <target>.<prop> [=|+=|-=] <value> | Set a property |
| add | add <type> <name> to <target> | Create with parent context |
| remove | remove <target> from <parent> | Remove from a collection |
| move | move <target> to <destination> | Relocate an element |
| copy | copy <target> to <dest> [as <name>] [deep] | Duplicate an element |
| extends | <Child> extends <Parent> | Set inheritance |
Element types
Section titled “Element types”JjScript supports 15 element types: class, abstract class, interface, attribute, reference, containment, composition, operation, parameter, package, enum, literal, annotation, model, metamodel.
Create options
Section titled “Create options”The create command accepts element-specific options:
create class Personcreate abstract class BaseEntitycreate interface Nameablecreate attribute name in Person type EString [1]create attribute age in Person type EInt default 0create reference friends in Person type Person [*]create enum VisibilityKindcreate literal PUBLIC in VisibilityKindSet operators
Section titled “Set operators”The set command supports three operators:
=replaces the value+=appends to a collection-=removes from a collection
set Person.isAbstract = trueset Person.attributes += newAttrInspection commands
Section titled “Inspection commands”| Command | Syntax | Description |
|---|---|---|
| list | list [<type>] [in <scope>] | List elements |
| show | show <target> [brief|full|tree] | Display element details |
| validate | validate [<target>|all] | Check model correctness |
list classshow Person fullvalidate allControl commands
Section titled “Control commands”| Command | Syntax | Description |
|---|---|---|
| undo / redo | undo [n] / redo [n] | Undo/redo up to 20 actions |
| clear | clear [history|console|selection] | Reset state |
| help | help [<topic>] | Context-sensitive help |
Advanced commands
Section titled “Advanced commands”Evaluates a JjEL expression in the current metamodel context:
eval forall c in classes such that c.isAbstract: c.nameeval exists a in Person.attributes such that a.type == "EString"If the input starts with a JjEL keyword (forall, exists, with), the eval prefix is optional.
forall
Section titled “forall”Iterates over a collection and executes a command per element:
forall a in attributes such that a.type == "EString"do set a.readonly = trueBinds values to variables, including interactive prompts:
let $name = prompt('New class name', EString) inrename class Person to $name
let $ok = confirm('Delete all derived attributes?') inforall a in attributes such that a.isDeriveddo delete aElement resolution
Section titled “Element resolution”JjScript locates elements by qualified name using three strategies:
- Metamodel-scoped (preferred): searches within the target metamodel
- Project-wide: searches all metamodels in the project
- Name-only: case-insensitive lookup by last segment
Qualified names use :: for package paths (com::model::Person) and . for member access (Person.name).
Autocompletion
Section titled “Autocompletion”JjScript provides context-sensitive suggestions as you type, combining:
- Command names and keywords
- Class and attribute names from the current metamodel
- Primitive types and user-defined types
Integration with Jjodie
Section titled “Integration with Jjodie”JjScript is the execution target for the Jjodie AI assistant. When you type a natural-language request in the chat (“add a name attribute of type String to Person”), Jjodie generates JjScript commands and executes them.
Complete example
Section titled “Complete example”Building a metamodel from scratch:
# Create typescreate class Personcreate abstract class BaseEntitycreate interface Nameable
# Set inheritancePerson extends BaseEntityPerson extends Nameable
# Add featurescreate attribute name in Person type EString [1]create attribute age in Person type EInt default 0create reference friends in Person type Person [*]
# Create an enumerationcreate enum VisibilityKindcreate literal PUBLIC in VisibilityKindcreate literal PRIVATE in VisibilityKindcreate literal PROTECTED in VisibilityKind
# Create a packagecreate package com.examplemove Person to com.example
# Validatevalidate allGrammar summary
Section titled “Grammar summary”Command = CreateCmd | DeleteCmd | RenameCmd | SetCmd | AddCmd | RemoveCmd | MoveCmd | CopyCmd | ExtendsCmd | ListCmd | ShowCmd | ValidateCmd | HelpCmd | UndoCmd | RedoCmd | ClearCmd | EvalCmd | LetCmd | ForallCmd
CreateCmd = 'create' ElementType IDENTIFIER ('in' QualifiedName)? CreateOptions*
DeleteCmd = 'delete' ElementType? QualifiedName ('cascade' | 'force')?
ForallCmd = 'forall' IDENT 'in' JjELExpr ('such' 'that' JjELExpr)? 'do' Command
LetCmd = 'let' '$' IDENT '=' Expr (',' '$' IDENT '=' Expr)* 'in' Command