Changes for page Textual Modeling with Xtext
Last modified by Richard Kreissig on 2025/01/30 12:03
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -57,6 +57,52 @@ 57 57 58 58 Xtext supports automatic formatting, which is available in the text editor with right-click → //Format// or ctrl+shift+F. However, the formatter must be configured in order to generate good results. Write a formatter configuration that fits well to your syntax by editing the generated file {{code language="none"}}TuringFormatter{{/code}} in the {{code language="none"}}formatting{{/code}} subpackage. Learn how this is done by reading the Xtext reference documentation → Runtime Concepts → Formatting. 59 59 60 += Validation = 61 + 62 +The generated code includes some automatic validation of models with respect to syntactic issues. If the token sequence in a text file does not conform to the grammar, error markers are shown at appropriate points in the text. However, this should be augmented by semantic validation by checking high-level properties of the model. Implement such a semantic validation by editing the generated file {{code language="none"}}TuringJavaValidator{{/code}} in the {{code language="none"}}validation{{/code}} subpackage. Learn how this is done by reading the Xtext reference documentation → Runtime Concepts → Validation → Custom Validation. You should implement at least the following checks: 63 + 64 +* Is there exactly one initial state? 65 +* Are all states reachable through transitions starting from the initial state? 66 + 60 60 = Parsing = 61 61 62 - 69 +The generated code includes a parser for text files in your syntax. This parser is simply used with the same interface as for any other EMF models: resource sets. Your final task for this tutorial is to reuse the Turing controller you implemented in the EMF tutorial for simulating Turing Machine models, this time applying it to {{code language="none"}}.tuxt{{/code}} text files. However, instead of using a fixed path to your model file, we will now use a //menu contribution// in order to set the file path dynamically. 70 + 71 +1. Go to the plugin where you created and registered {{code language="none"}}TuringHeadController{{/code}}, the Turing Machine simulator. Open {{code language="none"}}plugin.xml{{/code}} → //Dependencies// and add org.eclipse.ui if not on the list yet. Go to //Extensions// and add org.eclipse.ui.menus. 72 +1. Add a //menuContribution// element to the new extension and set "popup:org.eclipse.ui.popup.any?after=additions" as //locationURI// (without quotation marks). 73 +1. Add a //command// element to the //menuContribution// with the following attributes:\\ 74 +1*. //commandId: //de.cau.cs.rtprak.login.setSimFile 75 +1*. //label: //Set Simulation File 76 +1. Add a //visibleWhen// element to the //command//, and add an //iterate// element to the //visibleWhen// with the following attributes:\\ 77 +1*. //operator~:// and 78 +1*. //ifEmpty~:// false 79 +1. Add an //adapt// element to the //iterate// with the following attribute:\\ 80 +1*. //type~:// org.eclipse.core.resources.IResource 81 +1. Add a //test// element to the //adapt// with the following attributes:\\ 82 +1*. //property~:// org.eclipse.core.resources.extension 83 +1*. //value~:// tuxt 84 +1. Add a new extension org.eclipse.ui.commands and add a //command// element to it with the following attributes:\\ 85 +1*. //id~://de.cau.cs.rtprak.login.setSimFile 86 +1*. //name~://Set Simulation File 87 +1*. Click on //defaultHandler// to open a dialog for creation of a new handler class. Name the new class {{code language="none"}}SetFileHandler{{/code}} and put it into some package of that plugin. Remove the suggested interface and set {{code language="none"}}org.eclipse.core.commands.AbstractHandler{{/code}} as superclass instead. 88 +1. ((( 89 +Use the following method stub for SetFileHandler{{code language="none"}}{{/code}}: 90 + 91 +{{code theme="Eclipse" language="java"}} 92 + /** 93 + * {@inheritDoc} 94 + */ 95 + @Override 96 + public Object execute(ExecutionEvent event) throws ExecutionException { 97 + ISelection selection = HandlerUtil.getCurrentSelection(event); 98 + if (selection instanceof IStructuredSelection) { 99 + Object element = ((IStructuredSelection) selection).getFirstElement(); 100 + if (element instanceof IFile) { 101 + IFile file = (IFile) element; 102 + // TODO update the static reference to the simulation file 103 + } 104 + } 105 + return null; 106 + } 107 +{{/code}} 108 +)))
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 -298242 21 +2982426 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/WS12EclPract/pages/298242 2/Textual Modeling with Xtext1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/WS12EclPract/pages/2982426/Textual Modeling with Xtext