| |
| |
| |
| <!doctype html> |
| <html lang="en" class="no-js"> |
| <head> |
| |
| <meta charset="utf-8"> |
| <meta name="viewport" content="width=device-width,initial-scale=1"> |
| |
| |
| |
| <link rel="shortcut icon" href="assets/images/favicon.png"> |
| <meta name="generator" content="mkdocs-1.1.2, mkdocs-material-5.4.0"> |
| |
| |
| |
| <title>Emfatic</title> |
| |
| |
| |
| <link rel="stylesheet" href="assets/stylesheets/main.fe0cca5b.min.css"> |
| |
| |
| |
| |
| |
| |
| <link href="https://fonts.gstatic.com" rel="preconnect" crossorigin> |
| <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700%7CRoboto+Mono&display=fallback"> |
| <style>body,input{font-family:"Roboto",-apple-system,BlinkMacSystemFont,Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono",SFMono-Regular,Consolas,Menlo,monospace}</style> |
| |
| |
| |
| |
| <link rel="stylesheet" href="assets/stylesheets/extra.css"> |
| |
| <link rel="stylesheet" href="assets/stylesheets/mermaid.css"> |
| |
| <link rel="stylesheet" href="assets/javascript/google-code-prettify/prettify.css"> |
| |
| <link rel="stylesheet" href="https://unpkg.com/mermaid@8.5.1/dist/mermaid.css"> |
| |
| |
| |
| |
| <script>window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)},ga.l=+new Date,ga("create","UA-184785655-1","auto"),ga("set","anonymizeIp",!0),ga("send","pageview"),document.addEventListener("DOMContentLoaded",function(){document.forms.search&&document.forms.search.query.addEventListener("blur",function(){if(this.value){var e=document.location.pathname;ga("send","pageview",e+"?q="+this.value)}})}),document.addEventListener("DOMContentSwitch",function(){ga("send","pageview")})</script> |
| <script async src="https://www.google-analytics.com/analytics.js"></script> |
| |
| |
| |
| </head> |
| |
| |
| <body dir="ltr"> |
| |
| |
| <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off"> |
| <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off"> |
| <label class="md-overlay" for="__drawer"></label> |
| <div data-md-component="skip"> |
| |
| |
| <a href="#eclipse-emfatic" class="md-skip"> |
| Skip to content |
| </a> |
| |
| </div> |
| <div data-md-component="announce"> |
| |
| </div> |
| |
| <header class="md-header" data-md-component="header"> |
| <nav class="md-header-nav md-grid" aria-label="Header"> |
| <a href="." title="Emfatic" class="md-header-nav__button md-logo" aria-label="Emfatic"> |
| |
| |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 003-3 3 3 0 00-3-3 3 3 0 00-3 3 3 3 0 003 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54z"/></svg> |
| |
| </a> |
| <label class="md-header-nav__button md-icon" for="__drawer"> |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2z"/></svg> |
| </label> |
| <div class="md-header-nav__title" data-md-component="header-title"> |
| |
| <div class="md-header-nav__ellipsis"> |
| <span class="md-header-nav__topic md-ellipsis"> |
| Emfatic |
| </span> |
| <span class="md-header-nav__topic md-ellipsis"> |
| |
| Home |
| |
| </span> |
| </div> |
| |
| </div> |
| |
| <label class="md-header-nav__button md-icon" for="__search"> |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"/></svg> |
| </label> |
| |
| <div class="md-search" data-md-component="search" role="dialog"> |
| <label class="md-search__overlay" for="__search"></label> |
| <div class="md-search__inner" role="search"> |
| <form class="md-search__form" name="search"> |
| <input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" data-md-state="active"> |
| <label class="md-search__icon md-icon" for="__search"> |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0116 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 019.5 16 6.5 6.5 0 013 9.5 6.5 6.5 0 019.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"/></svg> |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg> |
| </label> |
| <button type="reset" class="md-search__icon md-icon" aria-label="Clear" data-md-component="search-reset" tabindex="-1"> |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"/></svg> |
| </button> |
| </form> |
| <div class="md-search__output"> |
| <div class="md-search__scrollwrap" data-md-scrollfix> |
| <div class="md-search-result" data-md-component="search-result"> |
| <div class="md-search-result__meta"> |
| Initializing search |
| </div> |
| <ol class="md-search-result__list"></ol> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| |
| |
| <div class="md-header-nav__source"> |
| |
| <a href="https://git.eclipse.org/c/emfatic/org.eclipse.emfatic.git/" title="Go to repository" class="md-source"> |
| <div class="md-source__icon md-icon"> |
| |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M439.55 236.05L244 40.45a28.87 28.87 0 00-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 01-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 000 40.81l195.61 195.6a28.86 28.86 0 0040.8 0l194.69-194.69a28.86 28.86 0 000-40.81z"/></svg> |
| </div> |
| <div class="md-source__repository"> |
| Git repository @ Eclipse |
| </div> |
| </a> |
| </div> |
| |
| </nav> |
| </header> |
| |
| <div class="md-container" data-md-component="container"> |
| |
| |
| |
| |
| |
| |
| <main class="md-main" data-md-component="main"> |
| <div class="md-main__inner md-grid"> |
| |
| |
| <div class="md-sidebar md-sidebar--primary" data-md-component="navigation"> |
| <div class="md-sidebar__scrollwrap"> |
| <div class="md-sidebar__inner"> |
| <nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0"> |
| <label class="md-nav__title" for="__drawer"> |
| <a href="." title="Emfatic" class="md-nav__button md-logo" aria-label="Emfatic"> |
| |
| |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a3 3 0 003-3 3 3 0 00-3-3 3 3 0 00-3 3 3 3 0 003 3m0 3.54C9.64 9.35 6.5 8 3 8v11c3.5 0 6.64 1.35 9 3.54 2.36-2.19 5.5-3.54 9-3.54V8c-3.5 0-6.64 1.35-9 3.54z"/></svg> |
| |
| </a> |
| Emfatic |
| </label> |
| |
| <div class="md-nav__source"> |
| |
| <a href="https://git.eclipse.org/c/emfatic/org.eclipse.emfatic.git/" title="Go to repository" class="md-source"> |
| <div class="md-source__icon md-icon"> |
| |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M439.55 236.05L244 40.45a28.87 28.87 0 00-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 01-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 000 40.81l195.61 195.6a28.86 28.86 0 0040.8 0l194.69-194.69a28.86 28.86 0 000-40.81z"/></svg> |
| </div> |
| <div class="md-source__repository"> |
| Git repository @ Eclipse |
| </div> |
| </a> |
| </div> |
| |
| <ul class="md-nav__list" data-md-scrollfix> |
| |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item md-nav__item--active"> |
| |
| <input class="md-nav__toggle md-toggle" data-md-toggle="toc" type="checkbox" id="__toc"> |
| |
| |
| |
| |
| <label class="md-nav__link md-nav__link--active" for="__toc"> |
| Home |
| <span class="md-nav__icon md-icon"> |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 9h14V7H3v2m0 4h14v-2H3v2m0 4h14v-2H3v2m16 0h2v-2h-2v2m0-10v2h2V7h-2m0 6h2v-2h-2v2z"/></svg> |
| </span> |
| </label> |
| |
| <a href="." title="Home" class="md-nav__link md-nav__link--active"> |
| Home |
| </a> |
| |
| |
| <nav class="md-nav md-nav--secondary" aria-label="Table of contents"> |
| |
| |
| |
| |
| |
| <label class="md-nav__title" for="__toc"> |
| <span class="md-nav__icon md-icon"> |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg> |
| </span> |
| Table of contents |
| </label> |
| <ul class="md-nav__list" data-md-scrollfix> |
| |
| <li class="md-nav__item"> |
| <a href="#packages" class="md-nav__link"> |
| Packages |
| </a> |
| |
| <nav class="md-nav" aria-label="Packages"> |
| <ul class="md-nav__list"> |
| |
| <li class="md-nav__item"> |
| <a href="#main-package" class="md-nav__link"> |
| Main Package |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#sub-packages" class="md-nav__link"> |
| Sub-Packages |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#main-package-imports" class="md-nav__link"> |
| Main Package Imports |
| </a> |
| |
| </li> |
| |
| </ul> |
| </nav> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#classifiers" class="md-nav__link"> |
| Classifiers |
| </a> |
| |
| <nav class="md-nav" aria-label="Classifiers"> |
| <ul class="md-nav__list"> |
| |
| <li class="md-nav__item"> |
| <a href="#classes" class="md-nav__link"> |
| Classes |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#data-types" class="md-nav__link"> |
| Data Types |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#enumerated-types" class="md-nav__link"> |
| Enumerated Types |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#map-entries" class="md-nav__link"> |
| Map Entries |
| </a> |
| |
| </li> |
| |
| </ul> |
| </nav> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#type-expressions" class="md-nav__link"> |
| Type Expressions |
| </a> |
| |
| <nav class="md-nav" aria-label="Type Expressions"> |
| <ul class="md-nav__list"> |
| |
| <li class="md-nav__item"> |
| <a href="#basic-types" class="md-nav__link"> |
| Basic Types |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#multiplicity-expressions" class="md-nav__link"> |
| Multiplicity Expressions |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#escaping-keywords" class="md-nav__link"> |
| Escaping Keywords |
| </a> |
| |
| </li> |
| |
| </ul> |
| </nav> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#structural-and-behavioral-features" class="md-nav__link"> |
| Structural and Behavioral Features |
| </a> |
| |
| <nav class="md-nav" aria-label="Structural and Behavioral Features"> |
| <ul class="md-nav__list"> |
| |
| <li class="md-nav__item"> |
| <a href="#modifiers" class="md-nav__link"> |
| Modifiers |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#attributes" class="md-nav__link"> |
| Attributes |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#references" class="md-nav__link"> |
| References |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#operations" class="md-nav__link"> |
| Operations |
| </a> |
| |
| </li> |
| |
| </ul> |
| </nav> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#annotations" class="md-nav__link"> |
| Annotations |
| </a> |
| |
| <nav class="md-nav" aria-label="Annotations"> |
| <ul class="md-nav__list"> |
| |
| <li class="md-nav__item"> |
| <a href="#annotation-labels" class="md-nav__link"> |
| Annotation Labels |
| </a> |
| |
| </li> |
| |
| </ul> |
| </nav> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#about" class="md-nav__link"> |
| About |
| </a> |
| |
| </li> |
| |
| </ul> |
| |
| </nav> |
| |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="download/" title="Download" class="md-nav__link"> |
| Download |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item md-nav__item--nested"> |
| |
| <input class="md-nav__toggle md-toggle" data-md-toggle="nav-3" type="checkbox" id="nav-3"> |
| |
| <label class="md-nav__link" for="nav-3"> |
| Community |
| <span class="md-nav__icon md-icon"> |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8.59 16.58L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.42z"/></svg> |
| </span> |
| </label> |
| <nav class="md-nav" aria-label="Community" data-md-level="1"> |
| <label class="md-nav__title" for="nav-3"> |
| <span class="md-nav__icon md-icon"> |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg> |
| </span> |
| Community |
| </label> |
| <ul class="md-nav__list" data-md-scrollfix> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="https://projects.eclipse.org/projects/modeling.emft.emfatic/who" title="Who is developing Emfatic?" class="md-nav__link"> |
| Who is developing Emfatic? |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="https://www.eclipse.org/forums/index.php/f/19/" title="Forum" class="md-nav__link"> |
| Forum |
| </a> |
| </li> |
| |
| |
| </ul> |
| </nav> |
| </li> |
| |
| |
| </ul> |
| </nav> |
| </div> |
| </div> |
| </div> |
| |
| |
| <div class="md-sidebar md-sidebar--secondary" data-md-component="toc"> |
| <div class="md-sidebar__scrollwrap"> |
| <div class="md-sidebar__inner"> |
| |
| <nav class="md-nav md-nav--secondary" aria-label="Table of contents"> |
| |
| |
| |
| |
| |
| <label class="md-nav__title" for="__toc"> |
| <span class="md-nav__icon md-icon"> |
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg> |
| </span> |
| Table of contents |
| </label> |
| <ul class="md-nav__list" data-md-scrollfix> |
| |
| <li class="md-nav__item"> |
| <a href="#packages" class="md-nav__link"> |
| Packages |
| </a> |
| |
| <nav class="md-nav" aria-label="Packages"> |
| <ul class="md-nav__list"> |
| |
| <li class="md-nav__item"> |
| <a href="#main-package" class="md-nav__link"> |
| Main Package |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#sub-packages" class="md-nav__link"> |
| Sub-Packages |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#main-package-imports" class="md-nav__link"> |
| Main Package Imports |
| </a> |
| |
| </li> |
| |
| </ul> |
| </nav> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#classifiers" class="md-nav__link"> |
| Classifiers |
| </a> |
| |
| <nav class="md-nav" aria-label="Classifiers"> |
| <ul class="md-nav__list"> |
| |
| <li class="md-nav__item"> |
| <a href="#classes" class="md-nav__link"> |
| Classes |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#data-types" class="md-nav__link"> |
| Data Types |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#enumerated-types" class="md-nav__link"> |
| Enumerated Types |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#map-entries" class="md-nav__link"> |
| Map Entries |
| </a> |
| |
| </li> |
| |
| </ul> |
| </nav> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#type-expressions" class="md-nav__link"> |
| Type Expressions |
| </a> |
| |
| <nav class="md-nav" aria-label="Type Expressions"> |
| <ul class="md-nav__list"> |
| |
| <li class="md-nav__item"> |
| <a href="#basic-types" class="md-nav__link"> |
| Basic Types |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#multiplicity-expressions" class="md-nav__link"> |
| Multiplicity Expressions |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#escaping-keywords" class="md-nav__link"> |
| Escaping Keywords |
| </a> |
| |
| </li> |
| |
| </ul> |
| </nav> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#structural-and-behavioral-features" class="md-nav__link"> |
| Structural and Behavioral Features |
| </a> |
| |
| <nav class="md-nav" aria-label="Structural and Behavioral Features"> |
| <ul class="md-nav__list"> |
| |
| <li class="md-nav__item"> |
| <a href="#modifiers" class="md-nav__link"> |
| Modifiers |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#attributes" class="md-nav__link"> |
| Attributes |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#references" class="md-nav__link"> |
| References |
| </a> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#operations" class="md-nav__link"> |
| Operations |
| </a> |
| |
| </li> |
| |
| </ul> |
| </nav> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#annotations" class="md-nav__link"> |
| Annotations |
| </a> |
| |
| <nav class="md-nav" aria-label="Annotations"> |
| <ul class="md-nav__list"> |
| |
| <li class="md-nav__item"> |
| <a href="#annotation-labels" class="md-nav__link"> |
| Annotation Labels |
| </a> |
| |
| </li> |
| |
| </ul> |
| </nav> |
| |
| </li> |
| |
| <li class="md-nav__item"> |
| <a href="#about" class="md-nav__link"> |
| About |
| </a> |
| |
| </li> |
| |
| </ul> |
| |
| </nav> |
| </div> |
| </div> |
| </div> |
| |
| |
| <div class="md-content"> |
| <article class="md-content__inner md-typeset"> |
| |
| |
| |
| |
| |
| |
| <h1 id="eclipse-emfatic">Eclipse Emfatic<a class="headerlink" href="#eclipse-emfatic" title="Permanent link">¶</a></h1> |
| <p>Emfatic is a textual syntax for <a href="http://www.eclipse.org/emf">EMF Ecore</a> |
| (meta-)models. This page details the syntax of Emfatic and the mapping between |
| Emfatic declarations and the corresponding Ecore constructs.</p> |
| <h2 id="packages">Packages<a class="headerlink" href="#packages" title="Permanent link">¶</a></h2> |
| <p>Emfatic programs are shown in boxes as in the example |
| below:</p> |
| <pre class="prettyprint lang-emf"><code>package test; |
| class Foo { }</code></pre> |
| |
| <p>When compiled, the program above will produce a model with an <code>EPackage</code> |
| named "test" containing a single <code>EClass</code> named "Foo".</p> |
| <p>As is probably clear from the first Emfatic program above, the keyword |
| package introduces an Ecore <code>EPackage</code> and the identifier following it |
| maps to the <code>name</code> attribute of the generated <code>EPackage</code>.</p> |
| <h3 id="main-package">Main Package<a class="headerlink" href="#main-package" title="Permanent link">¶</a></h3> |
| <p>The only thing required in an Emfatic source file is a package |
| declaration. This required element is called the main package |
| declaration and the <code>EPackage</code> it defines will contain (directly or |
| indirectly) all of the other elements of the generated Ecore model. |
| Thus the simplest possible Emfatic program would look something like |
| this:</p> |
| <pre class="prettyprint lang-emf"><code>package p;</code></pre> |
| |
| <p>Specifying values for the <code>EPackage</code> attributes <code>nsURI</code> and <code>nsPrefix</code> |
| is done like this:</p> |
| <pre class="prettyprint lang-emf"><code>@namespace(uri="http://www.eclipse.org/emf/2002/Ecore", prefix="ecore") |
| package ecore;</code></pre> |
| |
| <p>Note that Emfatic is case-sensitive in most contexts (reflecting the |
| underlying case-sensitivity of Ecore), however the identifiers |
| namespace, uri and prefix in the text above could be written in any |
| case. Also note that the order of declaration for uri and prefix is not |
| important. The syntax of the @namespace declaration is actually a |
| special case of the more general syntax for declaring EAnnotations, |
| which will be described in full detail in section 5 below.</p> |
| <h3 id="sub-packages">Sub-Packages<a class="headerlink" href="#sub-packages" title="Permanent link">¶</a></h3> |
| <p>Ecore allows packages to be nested inside packages. In Emfatic, the |
| syntax for nested packages differs from that of the main package. |
| Nested package declarations are followed by a curly-brace bracketed |
| region which encloses the nested package contents. The example below |
| demonstrates package nesting.</p> |
| <pre class="prettyprint lang-emf"><code>package main; |
| |
| package sub1 { |
| } |
| |
| package sub2 { |
| package sub2_1 { } |
| package sub2_2 { } |
| }</code></pre> |
| |
| <p>In the Ecore model generated from the above program, the top-level |
| package named "main" will contain two packages, "sub1" and "sub2", |
| and package sub2 will contain the packages "sub2_1" and "sub2_2".</p> |
| <h3 id="main-package-imports">Main Package Imports<a class="headerlink" href="#main-package-imports" title="Permanent link">¶</a></h3> |
| <p>Import statements allow for types defined in external Ecore models to be |
| referenced. All import statements must immediately follow the main |
| package declaration. The example below demonstrates the basic syntax of |
| import statements. The double-quoted string literal following the |
| import keyword must contain the URI of an Ecore model.</p> |
| <pre class="prettyprint lang-emf"><code>package main; |
| import "platform:/resource/proj1/foo.ecore"; |
| import "http://www.eclipse.org/emf/2002/Ecore"; |
| |
| package sub { }</code></pre> |
| |
| <p>Note that Ecore.ecore is automatically imported, so the second import in |
| the program above is not really necessary.</p> |
| <h2 id="classifiers">Classifiers<a class="headerlink" href="#classifiers" title="Permanent link">¶</a></h2> |
| <h3 id="classes">Classes<a class="headerlink" href="#classes" title="Permanent link">¶</a></h3> |
| <p>The Emfatic syntax for class declarations is very similar to Java, |
| however a few quirks are required to allow for all of the possibilities |
| of Ecore. The example below containing four simple class declarations |
| demonstrates the use of the keywords <code>class</code>, <code>interface</code> and <code>abstract</code> |
| and also introduces Emfatic comments (Emfatic allows both styles of Java |
| comments). The comments detail the mapping from Emfatic to the <code>EClass</code> |
| attributes <code>interface</code> and <code>abstract</code>.</p> |
| <pre class="prettyprint lang-emf"><code>package main; |
| class C1 { |
| } |
| // isInterface=false, isAbstract=false |
| |
| abstract class C2 { } // isInterface=false, isAbstract=true |
| interface I1 { } // isInterface=true, isAbstract=false |
| abstract interface I2 { } // isInterface=true, isAbstract=true</code></pre> |
| |
| <p>Inheritance is specified with the keyword <code>extends</code>. Unlike Java, there |
| is no <code>implements</code> keyword to distinguish inheritance from interface |
| implementation. The example below defines an inheritance hierarchy.</p> |
| <pre class="prettyprint lang-emf"><code>package main; |
| class A { } |
| class B { } |
| class C extends A, B { } |
| class D extends C { }</code></pre> |
| |
| <p>If necessary, the value of the <code>EClassifier</code> attribute |
| <code>instanceClassName</code> can be specified. The class |
| <code>EStringToStringMapEntry</code> from Ecore.ecore provides an example of this:</p> |
| <pre class="prettyprint lang-emf"><code>class EStringToStringMapEntry : java.util.Map$Entry { |
| // ... contents omitted ... |
| }</code></pre> |
| |
| <p>Note that if the class both extends other classes and specifies a value |
| for <code>instanceClassName</code>, the extends clause must precede the <code>instanceClassName</code> clause.</p> |
| <h3 id="data-types">Data Types<a class="headerlink" href="#data-types" title="Permanent link">¶</a></h3> |
| <p>Declaring an <code>EDataType</code> is fairly simple. Here are some familiar |
| examples from Ecore.ecore:</p> |
| <pre class="prettyprint lang-emf"><code>datatype EInt : int; |
| datatype EIntegerObject : java.lang.Integer; |
| transient datatype EJavaObject : java.lang.Object; |
| |
| datatype EFeatureMapEntry : org.eclipse.emf.ecore.util.FeatureMap$Entry; |
| datatype EByteArray : "byte[]"; // Note: [ and ] are not legal |
| identifier characters and must be in quotes</code></pre> |
| |
| <p>First note that as with classes, the value of the <code>EClassifier</code> |
| attribute <code>instanceClassName</code> follows the colon after the name of the |
| datatype. However specifying <code>instanceClassName</code> is required for |
| datatypes (while it is optional for classes).</p> |
| <p>The keyword <code>transient</code> in the third datatype declaration above |
| indicates that the value of the <code>EDataType</code> <code>serializable</code> attribute |
| should be set to false. This is a good time to point out that the |
| modifier keywords introduced so far (<code>abstract</code> and <code>interface</code>) are |
| applied to reverse the default Ecore attribute values (by default |
| <code>EClass</code> attributes <code>abstract</code> and <code>interface</code> are both false). In the |
| case of the <code>EDataType</code> attribute <code>serializable</code>, the default value is |
| true so Emfatic uses a keyword, <code>transient</code>, that means the opposite of |
| serializable.</p> |
| <p>The last two datatypes illustrate a subtle syntactic point. The value |
| specified for the <code>instanceClassName</code> attribute must either be a valid |
| qualified identifier (a dot or dollar-sign separated list of identifiers |
| such as <code>java.lang.Object</code> in the third datatype above) or it must be |
| enclosed in double quotes. The datatype EFeatureMapEntry contains the |
| character '<code>$</code>' which, following Java syntactic rules, is a legal |
| qualified identifier separator. The datatype EByteArray contains the |
| characters '<code>[</code>' and '<code>]</code>' which are not legal in a qualified |
| identifier.</p> |
| <p>The overall point to make about qualified identifier versus |
| double-quoted syntax for <code>instanceClassName</code> is that the typical |
| datatype declaration can use the former and thus should be easier to |
| read and edit, while the latter is available when needed and allows for |
| arbitrary string text to be placed in the generated Ecore model. There |
| are some other contexts where the Emfatic programmer has the option to |
| use either a qualified identifier or double-quoted string (see the |
| section on Annotations below for another example of this).</p> |
| <h3 id="enumerated-types">Enumerated Types<a class="headerlink" href="#enumerated-types" title="Permanent link">¶</a></h3> |
| <p>The example below demonstrates the Emfatic syntax that maps to <code>EEnum</code> |
| and <code>EEnumLiteral</code>. Note that the simple assignment expressions specify |
| the <code>value</code> attribute of each generated <code>EEnumLiteral</code>.</p> |
| <pre class="prettyprint lang-emf"><code>enum E { |
| A=1; |
| B=2; |
| C=3; |
| }</code></pre> |
| |
| <p>In fact, specifying enumeration literal values is optional and Emfatic |
| generates reasonable values when they are left unspecified. The code |
| and comments below describe the rules for this.</p> |
| <pre class="prettyprint lang-emf"><code>enum E { |
| A; // = 0 (if not specified, first literal has value 0) |
| |
| B = 3; |
| C; // = 4 (in general, unspecified values are 1 greater than previous value) |
| D; // = 5 |
| }</code></pre> |
| |
| <h3 id="map-entries">Map Entries<a class="headerlink" href="#map-entries" title="Permanent link">¶</a></h3> |
| <p>MapEntry classes (such as <code>EStringToStringMapEntry</code> in Ecore.ecore) can |
| be specified in either of two ways. The "longhand" way is to declare |
| a class with features named <code>key</code> and <code>value</code> and with |
| <code>[instanceClass=java.util.Map$Entry]</code> as suggested at the end of section |
| 2.1 above. But there is a convienent shorthand notation which achieves |
| the same result:</p> |
| <pre class="prettyprint lang-emf"><code>mapentry EStringToStringMapEntry : String -> String;</code></pre> |
| |
| <p>The expression following the colon gives the type of the MapEntry <code>key</code> |
| structural feature followed by the <code>-></code> operator, followed by the type |
| of the <code>value</code> structural feature. Type expressions can be more complex |
| than shown in the example above and are detailed fully in the next |
| section.</p> |
| <h2 id="type-expressions">Type Expressions<a class="headerlink" href="#type-expressions" title="Permanent link">¶</a></h2> |
| <p>The most basic Ecore elements that haven't yet been explored in Emfatic |
| are the structural and behavioral class features represented by the |
| Ecore classes <code>EAttribute</code>, <code>EReference</code>, <code>EOperation</code> and |
| <code>EParameter</code>. These four Ecore classes are all derived from |
| <code>ETypedElement</code> which means that instances of them have some type (which |
| is an <code>EClassifier</code>) and inherit the other characteristics of |
| <code>ETypedElement</code>, like multiplicity. Before we can describe each |
| specific kind of class feature, we need to show how types are |
| represented syntactically, because that applies (more or less) to all of |
| them.</p> |
| <p>Type expressions have two parts. First is a simple identifier or a |
| qualified identifier (a dot-separated list of simple identifiers like |
| "a.b.c") that identifies some <code>EClassifier</code>. The <code>EClassifier</code> |
| identified may be defined in the same Emfatic source file as the type |
| expression, or it may be in one of the imported Ecore models (specified |
| in import statements).</p> |
| <p>Let's skip ahead a little by looking at some attribute declarations so |
| that we can talk about their type expressions:</p> |
| <pre class="prettyprint lang-emf"><code>package test; |
| |
| datatype D1 : int; |
| |
| package P { |
| datatype D2 : int; |
| } |
| |
| class C { |
| attr D1 d1; |
| attr P.D2 d2; |
| attr ecore.EString s1; |
| attr String s2; |
| }</code></pre> |
| |
| <p>The class named "C" above declares four attributes with the names |
| "d1", "d2", "s1" and "s2". Note that Emfatic follows Java |
| syntactic style in placing type expression before the name. However |
| unlike Java field declarations, Emfatic uses a keyword - <code>attr</code> - to |
| introduce an attribute. (The keyword <code>attr</code> and similar keywords to |
| introduce references and operations will explained in more detail in the |
| following sub-sections).</p> |
| <p>The type expression for d1 is "D1" which identifies the datatype D1. |
| Because C and D1 are in the same package (test), this simple expression |
| is fine.</p> |
| <p>The type expression for d2 is "P.D2". In this case a qualified |
| identifier expression is necessary to identify datatype D2 inside |
| package P.</p> |
| <p>The type expression for s1 is "ecore.EString". This identifies the |
| datatype EString in package ecore (recall that model Ecore.ecore is |
| implicitly imported in all Emfatic programs).</p> |
| <p>The type expression for s2 is "String". The identifier String is |
| actually a special shorthand for ecore.EString, so s1 and s2 have the |
| same type.</p> |
| <h3 id="basic-types">Basic Types<a class="headerlink" href="#basic-types" title="Permanent link">¶</a></h3> |
| <p>A number of the types defined in Ecore.ecore have shorthand notation in |
| Emfatic. The table below lists the Emfatic shorthand and the |
| corresponding Ecore.ecore type name for each of these basic types as |
| well as the corresponding Java type or class.</p> |
| <table> |
| <thead> |
| <tr> |
| <th>Emfatic Keyword</th> |
| <th>Ecore EClassifier name</th> |
| <th>Java type name</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>boolean</td> |
| <td>EBoolean</td> |
| <td>boolean</td> |
| </tr> |
| <tr> |
| <td>Boolean</td> |
| <td>EBooleanObject</td> |
| <td>java.lang.Boolean</td> |
| </tr> |
| <tr> |
| <td>byte</td> |
| <td>EByte</td> |
| <td>byte</td> |
| </tr> |
| <tr> |
| <td>Byte</td> |
| <td>EByteObject</td> |
| <td>java.lang.Byte</td> |
| </tr> |
| <tr> |
| <td>char</td> |
| <td>EChar</td> |
| <td>char</td> |
| </tr> |
| <tr> |
| <td>Character</td> |
| <td>ECharacterObject</td> |
| <td>java.lang.Character</td> |
| </tr> |
| <tr> |
| <td>double</td> |
| <td>EDouble</td> |
| <td>double</td> |
| </tr> |
| <tr> |
| <td>Double</td> |
| <td>EDoubleObject</td> |
| <td>java.lang.Double</td> |
| </tr> |
| <tr> |
| <td>float</td> |
| <td>EFloat</td> |
| <td>float</td> |
| </tr> |
| <tr> |
| <td>Float</td> |
| <td>EFloatObject</td> |
| <td>java.lang.Float</td> |
| </tr> |
| <tr> |
| <td>int</td> |
| <td>EInt</td> |
| <td>int</td> |
| </tr> |
| <tr> |
| <td>Integer</td> |
| <td>EIntegerObject</td> |
| <td>java.lang.Integer</td> |
| </tr> |
| <tr> |
| <td>long</td> |
| <td>ELong</td> |
| <td>long</td> |
| </tr> |
| <tr> |
| <td>Long</td> |
| <td>ELongObject</td> |
| <td>java.lang.Long</td> |
| </tr> |
| <tr> |
| <td>short</td> |
| <td>EShort</td> |
| <td>short</td> |
| </tr> |
| <tr> |
| <td>Short</td> |
| <td>EShortObject</td> |
| <td>java.lang.Short</td> |
| </tr> |
| <tr> |
| <td>Date</td> |
| <td>EDate</td> |
| <td>java.util.Date</td> |
| </tr> |
| <tr> |
| <td>String</td> |
| <td>EString</td> |
| <td>java.lang.String</td> |
| </tr> |
| <tr> |
| <td>Object</td> |
| <td>EJavaObject</td> |
| <td>java.lang.Object</td> |
| </tr> |
| <tr> |
| <td>Class</td> |
| <td>EJavaClass</td> |
| <td>java.lang.Class</td> |
| </tr> |
| <tr> |
| <td>EObject</td> |
| <td>EObject</td> |
| <td>org.eclipse.emf.ecore.EObject</td> |
| </tr> |
| <tr> |
| <td>EClass</td> |
| <td>EClass</td> |
| <td>org.eclipse.emf.ecore.EClass</td> |
| </tr> |
| </tbody> |
| </table> |
| <p>Remember that you can always reference these types, and the rest of the |
| types in Ecore.ecore, by using their fully qualified name which begins |
| with the package prefix "ecore". For example <code>ecore.EOperation</code> and |
| <code>ecore.EBigInteger</code> are also legal references to types in Ecore.ecore.</p> |
| <h3 id="multiplicity-expressions">Multiplicity Expressions<a class="headerlink" href="#multiplicity-expressions" title="Permanent link">¶</a></h3> |
| <p>The second part of a type expression is the multiplicity expression. |
| This maps to the <code>lowerBound</code> and <code>upperBound</code> attributes of |
| <code>ETypedElement</code>. Multiplicity expressions are optional, but when |
| omitted the generated <code>ETypedElement</code> gets the defaults (<code>lowerBound</code> = |
| 0 and <code>upperBound</code> = 1). The example below shows some attribute |
| declarations with multiplicity expressions:</p> |
| <pre class="prettyprint lang-emf"><code>class C { |
| attr String[1] s1; |
| attr String[0..3] s2; |
| attr String[*] s3; |
| attr String[+] s4; |
| }</code></pre> |
| |
| <p>The mapping between various multiplicity expressions and the |
| <code>lowerBound</code> and <code>upperBound</code> attributes of the generated |
| <code>ETypedElement</code> is detailed more fully in the following table.</p> |
| <table> |
| <thead> |
| <tr> |
| <th>Emfatic multiplicity expression</th> |
| <th>ETypedElement lowerBound</th> |
| <th>ETypedElement upperBound</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>none</td> |
| <td>0</td> |
| <td>1</td> |
| </tr> |
| <tr> |
| <td>[?]</td> |
| <td>0</td> |
| <td>1</td> |
| </tr> |
| <tr> |
| <td>[]</td> |
| <td>0</td> |
| <td>unbounded (-1)</td> |
| </tr> |
| <tr> |
| <td>[*]</td> |
| <td>0</td> |
| <td>unbounded (-1)</td> |
| </tr> |
| <tr> |
| <td>[+]</td> |
| <td>1</td> |
| <td>unbounded (-1)</td> |
| </tr> |
| <tr> |
| <td>[1]</td> |
| <td>1</td> |
| <td>1</td> |
| </tr> |
| <tr> |
| <td>[n]</td> |
| <td>n</td> |
| <td>n</td> |
| </tr> |
| <tr> |
| <td>[0..4]</td> |
| <td>0</td> |
| <td>4</td> |
| </tr> |
| <tr> |
| <td>[m..n]</td> |
| <td>m</td> |
| <td>n</td> |
| </tr> |
| <tr> |
| <td>[5..*]</td> |
| <td>5</td> |
| <td>unbounded (-1)</td> |
| </tr> |
| <tr> |
| <td>[1..?]</td> |
| <td>1</td> |
| <td>unspecified (-2)</td> |
| </tr> |
| </tbody> |
| </table> |
| <h3 id="escaping-keywords">Escaping Keywords<a class="headerlink" href="#escaping-keywords" title="Permanent link">¶</a></h3> |
| <p>Sometimes it's necessary or desirable to use a keyword as the name for |
| some model element. This can be acheived by prefixing the name |
| identifier with the '<code>~</code>' symbol. This ability was added primarily to |
| make it possible to represent Ecore.ecore in Emfatic, so we'll show |
| another example from Ecore.ecore here to illustrate:</p> |
| <pre class="prettyprint lang-emf"><code>class EClass extends EClassifier |
| { |
| // ... |
| ~abstract : EBoolean; |
| ~interface : EBoolean; |
| // ... |
| }</code></pre> |
| |
| <p>Recall that the <code>abstract</code> and <code>interface</code> keywords are used in class |
| declarations. The code above shows how they can be used as attribute |
| names. Emfatic removes the '<code>~</code>' symbol so names in the generated |
| Ecore model do not contain it.</p> |
| <h2 id="structural-and-behavioral-features">Structural and Behavioral Features<a class="headerlink" href="#structural-and-behavioral-features" title="Permanent link">¶</a></h2> |
| <p>Now we are ready to show how the Ecore class features <code>EAttribute</code>, |
| <code>EReference</code>, <code>EOperation</code> and <code>EParameter</code> are represented in Emfatic. |
| The example below is the class <code>EPackage</code> from Ecore.ecore and it was |
| chosen to give a feel for the feature syntax because it contains a |
| sample of each kind of class feature. </p> |
| <pre class="prettyprint lang-emf"><code>class EPackage extends ENamedElement { |
| op EClassifier getEClassifier(EString name); |
| attr EString nsURI; |
| attr EString nsPrefix; |
| transient !resolve ref EFactory[1]#ePackage eFactoryInstance; |
| val EClassifier[*]#ePackage eClassifiers; |
| val EPackage[*]#eSuperPackage eSubpackages; |
| readonly transient ref EPackage#eSubpackages eSuperPackage; |
| }</code></pre> |
| |
| <p>For now we just want to point out that the syntax for class features is |
| based on the syntax of Java with one key difference. In Java some |
| elements are introduced with special keywords like <code>class</code> and |
| <code>interface</code>, but type members like fields and methods have no such |
| keywords to introduce them. This works for Java because fields and |
| methods can be distinguished by looking at other syntactic featues |
| (methods have parenthesis and fields do not). However the distinction |
| between what EMF calls attributes and references doesn't really exist |
| in Java, so there is no distinguishing syntax. Because of this and |
| because class features are such an essential element of EMF, a decision |
| was made to use keywords to introduce and differentiate attributes, |
| references and operations. Thus in Emfatic the basic syntax for a class |
| feature looks like this: </p> |
| <div class="highlight"><pre><span></span><code>modifiers featureKind typeExpression name ';' |
| </code></pre></div> |
| |
| <p>Where <code>featureKind</code> is one of the four keywords in the following table.</p> |
| <table> |
| <thead> |
| <tr> |
| <th>Emfatic keyword</th> |
| <th>introduces</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>attr</td> |
| <td>EAttribute</td> |
| </tr> |
| <tr> |
| <td>op</td> |
| <td>EOperation</td> |
| </tr> |
| <tr> |
| <td>ref</td> |
| <td>normal EReference (EReference.containment = false)</td> |
| </tr> |
| <tr> |
| <td>val</td> |
| <td>"by value" EReference (EReference.containment = true)</td> |
| </tr> |
| </tbody> |
| </table> |
| <h3 id="modifiers">Modifiers<a class="headerlink" href="#modifiers" title="Permanent link">¶</a></h3> |
| <p>Look again at the Emfatic code above for <code>EPackage</code> and note in the last |
| class feature declaration the keyword <code>ref</code> is preceded by the words |
| <code>readonly</code> and <code>transient</code>. These are modifiers similar in spirit to |
| Java's modifiers such as <code>public</code>, <code>private</code> and <code>abstract</code>. However |
| these modifiers map to boolean attributes on the Ecore classes involved |
| in defining structural and behavioral features. These modifiers must |
| appear directly before the feature's type expression. The table below |
| describes each modifier.</p> |
| <table> |
| <thead> |
| <tr> |
| <th>modifier</th> |
| <th>means</th> |
| <th>applies to</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>readonly</td> |
| <td>EStructuralFeature.changeable = false</td> |
| <td>attribute, reference</td> |
| </tr> |
| <tr> |
| <td>volatile</td> |
| <td>EStructuralFeature.volatile = true</td> |
| <td>attribute, reference</td> |
| </tr> |
| <tr> |
| <td>transient</td> |
| <td>EStructuralFeature.transient = true</td> |
| <td>attribute, reference</td> |
| </tr> |
| <tr> |
| <td>unsettable</td> |
| <td>EStructuralFeature.unsettable = true</td> |
| <td>attribute, reference</td> |
| </tr> |
| <tr> |
| <td>derived</td> |
| <td>EStructuralFeature.derived = true</td> |
| <td>attribute, reference</td> |
| </tr> |
| <tr> |
| <td>unique</td> |
| <td>ETypedElement.unique = true</td> |
| <td>attribute, reference, operation, parameter</td> |
| </tr> |
| <tr> |
| <td>ordered</td> |
| <td>ETypedElement.ordered = true</td> |
| <td>attribute, reference, operation, parameter</td> |
| </tr> |
| <tr> |
| <td>resolve</td> |
| <td>EReference.resolveProxies = true</td> |
| <td>reference</td> |
| </tr> |
| <tr> |
| <td>id</td> |
| <td>EAttribute.iD = true</td> |
| <td>attribute</td> |
| </tr> |
| </tbody> |
| </table> |
| <p>Note that the meaning of a modifier may be negated by prefixing the <code>!</code> |
| operator. The example below demonstrates this with an non-ordered |
| attribute:</p> |
| <pre class="prettyprint lang-emf"><code>class X { |
| !ordered attr String[*] s; |
| }</code></pre> |
| |
| <p>Normally the only modifiers that you should see negated with <code>!</code> are |
| <code>unique</code>, <code>ordered</code> and <code>resolve</code>. This is because these three are true |
| by default, so reversing the Ecore default means using the <code>!</code> |
| operator. Note also that <code>EStructuralFeature.changeable</code> is true by |
| default, but the modifier keyword <code>readonly</code> means the opposite |
| (<code>EStructuralFeature.changeable</code> = false).</p> |
| <h3 id="attributes">Attributes<a class="headerlink" href="#attributes" title="Permanent link">¶</a></h3> |
| <p>We've now seen attribute naming and type expressions. Attributes may |
| also be assigned default value expressions. Below is an example showing |
| the various forms of attribute syntax.</p> |
| <pre class="prettyprint lang-emf"><code>class C { |
| attr String s; |
| attr int i = 1; |
| attr ecore.EBoolean b = true; |
| }</code></pre> |
| |
| <p>Again note that the declaration of attributes is basically identical to |
| declaring fields in Java except for the presence of the <code>attr</code> keyword.</p> |
| <h3 id="references">References<a class="headerlink" href="#references" title="Permanent link">¶</a></h3> |
| <p>The type expression syntax for references is slightly complicated by the |
| fact that we need some way to identify the opposite of a reference. |
| Let's return again to the code for <code>EPackage</code>, but we'll just look at |
| the last two feature declarations:</p> |
| <pre class="prettyprint lang-emf"><code>class EPackage extends ENamedElement { |
| // ... |
| val EPackage[*]#eSuperPackage eSubpackages; |
| readonly transient ref EPackage#eSubpackages eSuperPackage; |
| }</code></pre> |
| |
| <p>Notice that the type expressions are followed by a <code>#</code> symbol and an |
| identifier. This identifier names the <code>EReference</code> which is the |
| <code>opposite</code> of the reference being declared. If a reference doesn't |
| need to specify its opposite then that part (including the <code>#</code> symbol) |
| is omitted.</p> |
| <h3 id="operations">Operations<a class="headerlink" href="#operations" title="Permanent link">¶</a></h3> |
| <p>The declaration syntax for operations is Java-like as described above, |
| including use of the keyword <code>void</code> to identify operations which don't |
| return a value. Also a Java-like <code>throws</code> clause allows for the |
| declaration of exception types:</p> |
| <pre class="prettyprint lang-emf"><code>class X { |
| op String getFullName(); |
| op void returnsNothing(); |
| op int add(int a, int b); |
| op EObject doSomething(int a, ecore.EBoolean b) throws ExceptionA, ExceptionB; |
| }</code></pre> |
| |
| <h2 id="annotations">Annotations<a class="headerlink" href="#annotations" title="Permanent link">¶</a></h2> |
| <p>Annotations can be attached to every kind of EMF element, however only |
| the <code>source</code> and <code>details</code> features of the resulting <code>EAnnotation</code> can |
| be specified in Emfatic. The Emfatic syntax for representing EMF |
| annotations was inspired by the syntax being introduced for Java |
| annotations in Java 1.5 ("Tiger"). The <code>@</code> symbol is followed by the |
| value of the <code>EAnnotation</code> <code>source</code> attribute. Key/value pairs for the |
| annotation <code>details</code> may appear in parenthesis following the <code>source</code> |
| value. Multiple annotations can be attached to each element. Usually |
| the annotation appears just before its containing element (parameter and |
| enum literal annotations may appear just after the declaration). The |
| example below gives some examples of annotations.</p> |
| <pre class="prettyprint lang-emf"><code>@"http://source/uri"("key1"="value1", "key2"="value2") |
| @sourceLabel(key.a="value1", key.b="value2") |
| @simpleAttr |
| package test; |
| |
| @"http://class/annotation"(k="v") |
| class C { |
| @"http://attribute/annotation"(k="v") |
| attr int a; |
| |
| op int Op( |
| |
| @before(k=v) int a, |
| int b @after(k=v) |
| ); |
| } |
| |
| enum E { |
| @"http://before"(k=v) |
| A=1; |
| B=2 @"http://after"(k=v); |
| }</code></pre> |
| |
| <p>One subtle point to note is that double quotes are only required around |
| the string value if it is not a valid simple or qualified identifier. |
| So an identifier like <code>key</code> or <code>key.a.b.c</code> need not be quoted, but most |
| complex strings (such as urls) will need to be.</p> |
| <h3 id="annotation-labels">Annotation Labels<a class="headerlink" href="#annotation-labels" title="Permanent link">¶</a></h3> |
| <p>Emfatic allows for short labels to be defined that map to longer URI |
| values for the <code>source</code> attribute of an <code>EAnnotation</code>. The purpose of |
| this feature is to simplify the Emfatic code, making it easier to read |
| and edit. Several annotation labels are available by default, as shown |
| in the following table:</p> |
| <table> |
| <thead> |
| <tr> |
| <th>Emfatic annotation label</th> |
| <th>maps to EAnnotation.source value</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td>Ecore</td> |
| <td>http://www.eclipse.org/emf/2002/Ecore</td> |
| </tr> |
| <tr> |
| <td>GenModel</td> |
| <td>http://www.eclipse.org/emf/2002/GenModel</td> |
| </tr> |
| <tr> |
| <td>ExtendedMetaData</td> |
| <td>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</td> |
| </tr> |
| <tr> |
| <td>EmfaticAnnotationMap</td> |
| <td>http://www.eclipse.org/emf/2004/EmfaticAnnotationMap</td> |
| </tr> |
| </tbody> |
| </table> |
| <p>The code below shows some examples:</p> |
| <pre class="prettyprint lang-emf"><code>@EmfaticAnnotationMap(myLabel="http://foo/bar") |
| @genmodel(documentation="model documentation") |
| package test; |
| |
| @ecore(constraints="constraintA constraintB") |
| @myLabel(key="value") |
| class C { |
| }</code></pre> |
| |
| <p>There are several details to elaborate on in the example above. First |
| note that labels are not case sensitive (so <code>Ecore</code> and <code>ecore</code> and |
| <code>ECORE</code> all work the same way).</p> |
| <p>Second, note that declaring an annotation using the label |
| <code>EmfaticAnnotationMap</code> has the side effect of creating a new label which |
| can be used later in the program. So the second annotation on class |
| "C" will get the <code>source</code> value of <code>"http://foo/bar"</code>.</p> |
| <p>Finally, note that the code above shows how to introduce model |
| documentation and constraints in a way that will later flow into |
| generated Java code when working with an EMF genmodel.</p> |
| <h2 id="about">About<a class="headerlink" href="#about" title="Permanent link">¶</a></h2> |
| <p>This article was originally written by Chris Daly (cjdaly@us.ibm.com) |
| (Copyright IBM Corp. 2004) and was hosted under IBM alphaWorks.</p> |
| |
| |
| |
| |
| |
| |
| |
| </article> |
| </div> |
| </div> |
| </main> |
| |
| |
| <footer class="md-footer"> |
| |
| <div class="md-footer-nav"> |
| <nav class="md-footer-nav__inner md-grid"> |
| |
| |
| <a href="download/" title="Download" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next"> |
| <div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title"> |
| <span class="md-flex__ellipsis"> |
| <span class="md-footer-nav__direction"> |
| Next |
| </span> |
| Download |
| </span> |
| </div> |
| <div class="md-flex__cell md-flex__cell--shrink"> |
| <i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i> |
| </div> |
| </a> |
| |
| </nav> |
| </div> |
| |
| <div class="md-footer-meta md-typeset"> |
| <div class="md-footer-meta__inner md-grid"> |
| <div class="md-footer-copyright"> |
| |
| <div class="md-footer-copyright__highlight"> |
| Copyright © Eclipse Foundation, Inc. All Rights Reserved. |
| </div> |
| |
| powered by |
| <a href="https://www.mkdocs.org">MkDocs</a> |
| and |
| <a href="https://squidfunk.github.io/mkdocs-material/">Material for MkDocs</a> |
| </div> |
| <div class="md-footer-copyright epsilon-eclipse-links"> |
| <ul> |
| <li><a href="https://www.eclipse.org/legal/privacy.php">Privacy Policy</a></li> |
| <li><a href="https://www.eclipse.org/legal/termsofuse.php">Terms of Use</a></li> |
| <li><a href="https://www.eclipse.org/legal/copyright.php">Copyright Agent</a></li> |
| </ul> |
| </div> |
| |
| </div> |
| </div> |
| </footer> |
| |
| </div> |
| |
| <script src="assets/javascripts/vendor.d710d30a.min.js"></script> |
| <script src="assets/javascripts/bundle.b39636ac.min.js"></script><script id="__lang" type="application/json">{"clipboard.copy": "Copy to clipboard", "clipboard.copied": "Copied to clipboard", "search.config.lang": "en", "search.config.pipeline": "trimmer, stopWordFilter", "search.config.separator": "[\\s\\-]+", "search.result.placeholder": "Type to start searching", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents"}</script> |
| |
| <script> |
| app = initialize({ |
| base: ".", |
| features: [], |
| search: Object.assign({ |
| worker: "assets/javascripts/worker/search.a68abb33.min.js" |
| }, typeof search !== "undefined" && search) |
| }) |
| </script> |
| |
| <script src="https://unpkg.com/mermaid@8.5.1/dist/mermaid.min.js"></script> |
| |
| <script src="assets/javascript/mermaid.js"></script> |
| |
| <script src="assets/javascript/jquery.js"></script> |
| |
| <script src="assets/javascript/google-code-prettify/prettify.js"></script> |
| |
| <script src="assets/javascript/google-code-prettify/lang-emfatic.js"></script> |
| |
| <script src="assets/javascript/google-code-prettify/lang-epsilon.js"></script> |
| |
| <script src="assets/javascript/google-code-prettify/prettyprint.js"></script> |
| |
| |
| </body> |
| </html> |