OCL Documentation
Total Page:16
File Type:pdf, Size:1020Kb
OCL Documentation OCL Documentation Christian Damus, Adolfo Sánchez-Barbudo Herrera, Axel Uhl, Edward Willink and contributors Copyright 2002 - 2018 Eclipse OCL 6.6.0 1 1. Overview and Getting Started ....................................................................................... 1 1.1. What is OCL? .................................................................................................... 1 1.2. How Does It Work? ............................................................................................ 1 1.2.1. Editing ................................................................................................... 1 1.2.2. Execution ................................................................................................ 1 1.2.3. Debugging .............................................................................................. 2 1.2.4. Testing ................................................................................................... 2 1.3. Eclipse OCL is Extensible .................................................................................... 2 1.4. Who Uses OCL and Eclipse OCL? ........................................................................ 2 1.5. Who is Behind Eclipse OCL? ............................................................................... 3 1.6. Getting Started ................................................................................................... 3 2. Users Guide ................................................................................................................ 5 2.1. The two Eclipse OCLs ......................................................................................... 5 2.1.1. The Classic Eclipse OCL metamodels .......................................................... 5 2.1.2. The Unified or Pivot Eclipse OCL metamodel ............................................... 5 2.1.3. The transition .......................................................................................... 6 2.1.4. Migration ................................................................................................ 7 2.1.5. APIs ...................................................................................................... 8 2.2. The Essential OCL Language ................................................................................ 9 2.2.1. Syntax .................................................................................................... 9 2.3. The OCLinEcore Language ................................................................................. 19 2.3.1. Syntax .................................................................................................. 19 2.3.2. Limitations ............................................................................................ 31 2.4. The Complete OCL Language ............................................................................. 31 2.4.1. Syntax .................................................................................................. 31 2.5. The OCL Standard Library Language ................................................................... 37 2.5.1. Syntax .................................................................................................. 37 2.6. Editors ............................................................................................................ 41 2.6.1. Syntax coloring ...................................................................................... 41 2.6.2. Validation ............................................................................................. 42 2.6.3. Hover Text ............................................................................................ 42 2.6.4. Content Assist ........................................................................................ 42 2.6.5. Code Templates ...................................................................................... 42 2.6.6. Open Declaration .................................................................................... 42 2.7. OCL Nature and Builder Auto-Validation .............................................................. 43 2.7.1. Configuring the OCL Nature and Builder .................................................... 43 2.7.2. Ecore and UML Auto-Validation ............................................................... 43 2.7.3. Building on pre-Photon / 2018 releases ....................................................... 44 2.8. Console ........................................................................................................... 44 2.8.1. Context Object Selection .......................................................................... 45 2.8.2. Editing .................................................................................................. 45 2.8.3. Editor Keys ........................................................................................... 45 2.8.4. Results .................................................................................................. 45 2.8.5. Tool Bar ............................................................................................... 45 2.9. Validity View (new in Luna) ............................................................................... 46 2.9.1. View Tool Bar ....................................................................................... 47 2.9.2. Model Elements Pane .............................................................................. 48 2.9.3. Metamodel Constraints Pane ..................................................................... 49 2.9.4. Constraint Locators ................................................................................. 50 2.10. Debugger (new in Luna) ................................................................................... 51 2.10.1. Launching ............................................................................................ 51 2.10.2. Stepping .............................................................................................. 53 2.10.3. Variables View ..................................................................................... 54 2.10.4. Breakpoints View .................................................................................. 54 2.10.5. Outline View ........................................................................................ 54 2.11. OCL Integration .............................................................................................. 54 2.11.1. OCL execution in Ecore / EMF Delegates .................................................. 54 2.11.2. Custom Validation Messages ................................................................... 54 Eclipse OCL 6.6.0 ii OCL Documentation 2.11.3. CompleteOCL Validation ....................................................................... 55 2.11.4. OCLinEcore for Xtext Validation ............................................................. 56 2.11.5. Complete OCL for Xtext Validation ......................................................... 56 2.12. OCL in UML (using Papyrus) ........................................................................... 56 2.12.1. UML Integration ................................................................................... 56 2.12.2. Class Diagram ...................................................................................... 57 2.12.3. State Machine Diagram .......................................................................... 61 2.13. OCL Constraint Examples for UML (using Papyrus) .............................................. 62 2.13.1. Model Constraints ................................................................................. 63 2.13.2. Profile Constraints ................................................................................. 66 2.14. User Interface ................................................................................................. 70 2.14.1. Project Property Pages ........................................................................... 70 2.14.2. Workspace Preference Pages ................................................................... 71 2.14.3. Overall Options .................................................................................... 71 2.14.4. Ecore and UML Options ........................................................................ 72 2.14.5. UML Options ....................................................................................... 73 2.14.6. Model Registry ..................................................................................... 73 2.14.7. Syntax Coloring .................................................................................... 73 2.14.8. Editor Templates ................................................................................... 73 2.14.9. OCLinEcore Options ............................................................................. 74 3. The OCL Standard Library ........................................................................................ 75 3.1. Precedences .................................................................................................... 75 3.2. Bag(T) ....................................................................................................... 75 3.3. Boolean ..................................................................................................... 76 3.4. Class .......................................................................................................