syntaxNodes = getNodesFor(transitionNodes, syntax);
39 | acceptNodes(getLastNavigableState(), syntaxNodes);
40 | }
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src-gen/org/eclipse/xtext/example/fowlerdsl/statemachine/Command.java:
--------------------------------------------------------------------------------
1 | /**
2 | */
3 | package org.eclipse.xtext.example.fowlerdsl.statemachine;
4 |
5 | import org.eclipse.emf.ecore.EObject;
6 |
7 | /**
8 | *
9 | * A representation of the model object 'Command'.
10 | *
11 | *
12 | *
13 | * The following features are supported:
14 | *
15 | *
16 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.Command#getName Name}
17 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.Command#getCode Code}
18 | *
19 | *
20 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getCommand()
21 | * @model
22 | * @generated
23 | */
24 | public interface Command extends EObject
25 | {
26 | /**
27 | * Returns the value of the 'Name' attribute.
28 | *
29 | *
30 | * If the meaning of the 'Name' attribute isn't clear,
31 | * there really should be more of a description here...
32 | *
33 | *
34 | * @return the value of the 'Name' attribute.
35 | * @see #setName(String)
36 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getCommand_Name()
37 | * @model
38 | * @generated
39 | */
40 | String getName();
41 |
42 | /**
43 | * Sets the value of the '{@link org.eclipse.xtext.example.fowlerdsl.statemachine.Command#getName Name}' attribute.
44 | *
45 | *
46 | * @param value the new value of the 'Name' attribute.
47 | * @see #getName()
48 | * @generated
49 | */
50 | void setName(String value);
51 |
52 | /**
53 | * Returns the value of the 'Code' attribute.
54 | *
55 | *
56 | * If the meaning of the 'Code' attribute isn't clear,
57 | * there really should be more of a description here...
58 | *
59 | *
60 | * @return the value of the 'Code' attribute.
61 | * @see #setCode(String)
62 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getCommand_Code()
63 | * @model
64 | * @generated
65 | */
66 | String getCode();
67 |
68 | /**
69 | * Sets the value of the '{@link org.eclipse.xtext.example.fowlerdsl.statemachine.Command#getCode Code}' attribute.
70 | *
71 | *
72 | * @param value the new value of the 'Code' attribute.
73 | * @see #getCode()
74 | * @generated
75 | */
76 | void setCode(String value);
77 |
78 | } // Command
79 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src-gen/org/eclipse/xtext/example/fowlerdsl/statemachine/Event.java:
--------------------------------------------------------------------------------
1 | /**
2 | */
3 | package org.eclipse.xtext.example.fowlerdsl.statemachine;
4 |
5 | import org.eclipse.emf.ecore.EObject;
6 |
7 | /**
8 | *
9 | * A representation of the model object 'Event'.
10 | *
11 | *
12 | *
13 | * The following features are supported:
14 | *
15 | *
16 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.Event#getName Name}
17 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.Event#getCode Code}
18 | *
19 | *
20 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getEvent()
21 | * @model
22 | * @generated
23 | */
24 | public interface Event extends EObject
25 | {
26 | /**
27 | * Returns the value of the 'Name' attribute.
28 | *
29 | *
30 | * If the meaning of the 'Name' attribute isn't clear,
31 | * there really should be more of a description here...
32 | *
33 | *
34 | * @return the value of the 'Name' attribute.
35 | * @see #setName(String)
36 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getEvent_Name()
37 | * @model
38 | * @generated
39 | */
40 | String getName();
41 |
42 | /**
43 | * Sets the value of the '{@link org.eclipse.xtext.example.fowlerdsl.statemachine.Event#getName Name}' attribute.
44 | *
45 | *
46 | * @param value the new value of the 'Name' attribute.
47 | * @see #getName()
48 | * @generated
49 | */
50 | void setName(String value);
51 |
52 | /**
53 | * Returns the value of the 'Code' attribute.
54 | *
55 | *
56 | * If the meaning of the 'Code' attribute isn't clear,
57 | * there really should be more of a description here...
58 | *
59 | *
60 | * @return the value of the 'Code' attribute.
61 | * @see #setCode(String)
62 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getEvent_Code()
63 | * @model
64 | * @generated
65 | */
66 | String getCode();
67 |
68 | /**
69 | * Sets the value of the '{@link org.eclipse.xtext.example.fowlerdsl.statemachine.Event#getCode Code}' attribute.
70 | *
71 | *
72 | * @param value the new value of the 'Code' attribute.
73 | * @see #getCode()
74 | * @generated
75 | */
76 | void setCode(String value);
77 |
78 | } // Event
79 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src-gen/org/eclipse/xtext/example/fowlerdsl/statemachine/State.java:
--------------------------------------------------------------------------------
1 | /**
2 | */
3 | package org.eclipse.xtext.example.fowlerdsl.statemachine;
4 |
5 | import org.eclipse.emf.common.util.EList;
6 |
7 | import org.eclipse.emf.ecore.EObject;
8 |
9 | /**
10 | *
11 | * A representation of the model object 'State'.
12 | *
13 | *
14 | *
15 | * The following features are supported:
16 | *
17 | *
18 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.State#getName Name}
19 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.State#getActions Actions}
20 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.State#getTransitions Transitions}
21 | *
22 | *
23 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getState()
24 | * @model
25 | * @generated
26 | */
27 | public interface State extends EObject
28 | {
29 | /**
30 | * Returns the value of the 'Name' attribute.
31 | *
32 | *
33 | * If the meaning of the 'Name' attribute isn't clear,
34 | * there really should be more of a description here...
35 | *
36 | *
37 | * @return the value of the 'Name' attribute.
38 | * @see #setName(String)
39 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getState_Name()
40 | * @model
41 | * @generated
42 | */
43 | String getName();
44 |
45 | /**
46 | * Sets the value of the '{@link org.eclipse.xtext.example.fowlerdsl.statemachine.State#getName Name}' attribute.
47 | *
48 | *
49 | * @param value the new value of the 'Name' attribute.
50 | * @see #getName()
51 | * @generated
52 | */
53 | void setName(String value);
54 |
55 | /**
56 | * Returns the value of the 'Actions' reference list.
57 | * The list contents are of type {@link org.eclipse.xtext.example.fowlerdsl.statemachine.Command}.
58 | *
59 | *
60 | * If the meaning of the 'Actions' reference list isn't clear,
61 | * there really should be more of a description here...
62 | *
63 | *
64 | * @return the value of the 'Actions' reference list.
65 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getState_Actions()
66 | * @model
67 | * @generated
68 | */
69 | EList getActions();
70 |
71 | /**
72 | * Returns the value of the 'Transitions' containment reference list.
73 | * The list contents are of type {@link org.eclipse.xtext.example.fowlerdsl.statemachine.Transition}.
74 | *
75 | *
76 | * If the meaning of the 'Transitions' containment reference list isn't clear,
77 | * there really should be more of a description here...
78 | *
79 | *
80 | * @return the value of the 'Transitions' containment reference list.
81 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getState_Transitions()
82 | * @model containment="true"
83 | * @generated
84 | */
85 | EList getTransitions();
86 |
87 | } // State
88 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src-gen/org/eclipse/xtext/example/fowlerdsl/statemachine/Statemachine.java:
--------------------------------------------------------------------------------
1 | /**
2 | */
3 | package org.eclipse.xtext.example.fowlerdsl.statemachine;
4 |
5 | import org.eclipse.emf.common.util.EList;
6 |
7 | import org.eclipse.emf.ecore.EObject;
8 |
9 | /**
10 | *
11 | * A representation of the model object 'Statemachine'.
12 | *
13 | *
14 | *
15 | * The following features are supported:
16 | *
17 | *
18 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.Statemachine#getEvents Events}
19 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.Statemachine#getResetEvents Reset Events}
20 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.Statemachine#getCommands Commands}
21 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.Statemachine#getStates States}
22 | *
23 | *
24 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getStatemachine()
25 | * @model
26 | * @generated
27 | */
28 | public interface Statemachine extends EObject
29 | {
30 | /**
31 | * Returns the value of the 'Events' containment reference list.
32 | * The list contents are of type {@link org.eclipse.xtext.example.fowlerdsl.statemachine.Event}.
33 | *
34 | *
35 | * If the meaning of the 'Events' containment reference list isn't clear,
36 | * there really should be more of a description here...
37 | *
38 | *
39 | * @return the value of the 'Events' containment reference list.
40 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getStatemachine_Events()
41 | * @model containment="true"
42 | * @generated
43 | */
44 | EList getEvents();
45 |
46 | /**
47 | * Returns the value of the 'Reset Events' reference list.
48 | * The list contents are of type {@link org.eclipse.xtext.example.fowlerdsl.statemachine.Event}.
49 | *
50 | *
51 | * If the meaning of the 'Reset Events' reference list isn't clear,
52 | * there really should be more of a description here...
53 | *
54 | *
55 | * @return the value of the 'Reset Events' reference list.
56 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getStatemachine_ResetEvents()
57 | * @model
58 | * @generated
59 | */
60 | EList getResetEvents();
61 |
62 | /**
63 | * Returns the value of the 'Commands' containment reference list.
64 | * The list contents are of type {@link org.eclipse.xtext.example.fowlerdsl.statemachine.Command}.
65 | *
66 | *
67 | * If the meaning of the 'Commands' containment reference list isn't clear,
68 | * there really should be more of a description here...
69 | *
70 | *
71 | * @return the value of the 'Commands' containment reference list.
72 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getStatemachine_Commands()
73 | * @model containment="true"
74 | * @generated
75 | */
76 | EList getCommands();
77 |
78 | /**
79 | * Returns the value of the 'States' containment reference list.
80 | * The list contents are of type {@link org.eclipse.xtext.example.fowlerdsl.statemachine.State}.
81 | *
82 | *
83 | * If the meaning of the 'States' containment reference list isn't clear,
84 | * there really should be more of a description here...
85 | *
86 | *
87 | * @return the value of the 'States' containment reference list.
88 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getStatemachine_States()
89 | * @model containment="true"
90 | * @generated
91 | */
92 | EList getStates();
93 |
94 | } // Statemachine
95 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src-gen/org/eclipse/xtext/example/fowlerdsl/statemachine/StatemachineFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | */
3 | package org.eclipse.xtext.example.fowlerdsl.statemachine;
4 |
5 | import org.eclipse.emf.ecore.EFactory;
6 |
7 | /**
8 | *
9 | * The Factory for the model.
10 | * It provides a create method for each non-abstract class of the model.
11 | *
12 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage
13 | * @generated
14 | */
15 | public interface StatemachineFactory extends EFactory
16 | {
17 | /**
18 | * The singleton instance of the factory.
19 | *
20 | *
21 | * @generated
22 | */
23 | StatemachineFactory eINSTANCE = org.eclipse.xtext.example.fowlerdsl.statemachine.impl.StatemachineFactoryImpl.init();
24 |
25 | /**
26 | * Returns a new object of class 'Statemachine'.
27 | *
28 | *
29 | * @return a new object of class 'Statemachine'.
30 | * @generated
31 | */
32 | Statemachine createStatemachine();
33 |
34 | /**
35 | * Returns a new object of class 'Event'.
36 | *
37 | *
38 | * @return a new object of class 'Event'.
39 | * @generated
40 | */
41 | Event createEvent();
42 |
43 | /**
44 | * Returns a new object of class 'Command'.
45 | *
46 | *
47 | * @return a new object of class 'Command'.
48 | * @generated
49 | */
50 | Command createCommand();
51 |
52 | /**
53 | * Returns a new object of class 'State'.
54 | *
55 | *
56 | * @return a new object of class 'State'.
57 | * @generated
58 | */
59 | State createState();
60 |
61 | /**
62 | * Returns a new object of class 'Transition'.
63 | *
64 | *
65 | * @return a new object of class 'Transition'.
66 | * @generated
67 | */
68 | Transition createTransition();
69 |
70 | /**
71 | * Returns the package supported by this factory.
72 | *
73 | *
74 | * @return the package supported by this factory.
75 | * @generated
76 | */
77 | StatemachinePackage getStatemachinePackage();
78 |
79 | } //StatemachineFactory
80 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src-gen/org/eclipse/xtext/example/fowlerdsl/statemachine/Transition.java:
--------------------------------------------------------------------------------
1 | /**
2 | */
3 | package org.eclipse.xtext.example.fowlerdsl.statemachine;
4 |
5 | import org.eclipse.emf.ecore.EObject;
6 |
7 | /**
8 | *
9 | * A representation of the model object 'Transition'.
10 | *
11 | *
12 | *
13 | * The following features are supported:
14 | *
15 | *
16 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.Transition#getEvent Event}
17 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.Transition#getState State}
18 | *
19 | *
20 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getTransition()
21 | * @model
22 | * @generated
23 | */
24 | public interface Transition extends EObject
25 | {
26 | /**
27 | * Returns the value of the 'Event' reference.
28 | *
29 | *
30 | * If the meaning of the 'Event' reference isn't clear,
31 | * there really should be more of a description here...
32 | *
33 | *
34 | * @return the value of the 'Event' reference.
35 | * @see #setEvent(Event)
36 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getTransition_Event()
37 | * @model
38 | * @generated
39 | */
40 | Event getEvent();
41 |
42 | /**
43 | * Sets the value of the '{@link org.eclipse.xtext.example.fowlerdsl.statemachine.Transition#getEvent Event}' reference.
44 | *
45 | *
46 | * @param value the new value of the 'Event' reference.
47 | * @see #getEvent()
48 | * @generated
49 | */
50 | void setEvent(Event value);
51 |
52 | /**
53 | * Returns the value of the 'State' reference.
54 | *
55 | *
56 | * If the meaning of the 'State' reference isn't clear,
57 | * there really should be more of a description here...
58 | *
59 | *
60 | * @return the value of the 'State' reference.
61 | * @see #setState(State)
62 | * @see org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage#getTransition_State()
63 | * @model
64 | * @generated
65 | */
66 | State getState();
67 |
68 | /**
69 | * Sets the value of the '{@link org.eclipse.xtext.example.fowlerdsl.statemachine.Transition#getState State}' reference.
70 | *
71 | *
72 | * @param value the new value of the 'State' reference.
73 | * @see #getState()
74 | * @generated
75 | */
76 | void setState(State value);
77 |
78 | } // Transition
79 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src-gen/org/eclipse/xtext/example/fowlerdsl/statemachine/impl/CommandImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | */
3 | package org.eclipse.xtext.example.fowlerdsl.statemachine.impl;
4 |
5 | import org.eclipse.emf.common.notify.Notification;
6 |
7 | import org.eclipse.emf.ecore.EClass;
8 |
9 | import org.eclipse.emf.ecore.impl.ENotificationImpl;
10 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
11 |
12 | import org.eclipse.xtext.example.fowlerdsl.statemachine.Command;
13 | import org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage;
14 |
15 | /**
16 | *
17 | * An implementation of the model object 'Command'.
18 | *
19 | *
20 | * The following features are implemented:
21 | *
22 | *
23 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.impl.CommandImpl#getName Name}
24 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.impl.CommandImpl#getCode Code}
25 | *
26 | *
27 | * @generated
28 | */
29 | public class CommandImpl extends MinimalEObjectImpl.Container implements Command
30 | {
31 | /**
32 | * The default value of the '{@link #getName() Name}' attribute.
33 | *
34 | *
35 | * @see #getName()
36 | * @generated
37 | * @ordered
38 | */
39 | protected static final String NAME_EDEFAULT = null;
40 |
41 | /**
42 | * The cached value of the '{@link #getName() Name}' attribute.
43 | *
44 | *
45 | * @see #getName()
46 | * @generated
47 | * @ordered
48 | */
49 | protected String name = NAME_EDEFAULT;
50 |
51 | /**
52 | * The default value of the '{@link #getCode() Code}' attribute.
53 | *
54 | *
55 | * @see #getCode()
56 | * @generated
57 | * @ordered
58 | */
59 | protected static final String CODE_EDEFAULT = null;
60 |
61 | /**
62 | * The cached value of the '{@link #getCode() Code}' attribute.
63 | *
64 | *
65 | * @see #getCode()
66 | * @generated
67 | * @ordered
68 | */
69 | protected String code = CODE_EDEFAULT;
70 |
71 | /**
72 | *
73 | *
74 | * @generated
75 | */
76 | protected CommandImpl()
77 | {
78 | super();
79 | }
80 |
81 | /**
82 | *
83 | *
84 | * @generated
85 | */
86 | @Override
87 | protected EClass eStaticClass()
88 | {
89 | return StatemachinePackage.Literals.COMMAND;
90 | }
91 |
92 | /**
93 | *
94 | *
95 | * @generated
96 | */
97 | public String getName()
98 | {
99 | return name;
100 | }
101 |
102 | /**
103 | *
104 | *
105 | * @generated
106 | */
107 | public void setName(String newName)
108 | {
109 | String oldName = name;
110 | name = newName;
111 | if (eNotificationRequired())
112 | eNotify(new ENotificationImpl(this, Notification.SET, StatemachinePackage.COMMAND__NAME, oldName, name));
113 | }
114 |
115 | /**
116 | *
117 | *
118 | * @generated
119 | */
120 | public String getCode()
121 | {
122 | return code;
123 | }
124 |
125 | /**
126 | *
127 | *
128 | * @generated
129 | */
130 | public void setCode(String newCode)
131 | {
132 | String oldCode = code;
133 | code = newCode;
134 | if (eNotificationRequired())
135 | eNotify(new ENotificationImpl(this, Notification.SET, StatemachinePackage.COMMAND__CODE, oldCode, code));
136 | }
137 |
138 | /**
139 | *
140 | *
141 | * @generated
142 | */
143 | @Override
144 | public Object eGet(int featureID, boolean resolve, boolean coreType)
145 | {
146 | switch (featureID)
147 | {
148 | case StatemachinePackage.COMMAND__NAME:
149 | return getName();
150 | case StatemachinePackage.COMMAND__CODE:
151 | return getCode();
152 | }
153 | return super.eGet(featureID, resolve, coreType);
154 | }
155 |
156 | /**
157 | *
158 | *
159 | * @generated
160 | */
161 | @Override
162 | public void eSet(int featureID, Object newValue)
163 | {
164 | switch (featureID)
165 | {
166 | case StatemachinePackage.COMMAND__NAME:
167 | setName((String)newValue);
168 | return;
169 | case StatemachinePackage.COMMAND__CODE:
170 | setCode((String)newValue);
171 | return;
172 | }
173 | super.eSet(featureID, newValue);
174 | }
175 |
176 | /**
177 | *
178 | *
179 | * @generated
180 | */
181 | @Override
182 | public void eUnset(int featureID)
183 | {
184 | switch (featureID)
185 | {
186 | case StatemachinePackage.COMMAND__NAME:
187 | setName(NAME_EDEFAULT);
188 | return;
189 | case StatemachinePackage.COMMAND__CODE:
190 | setCode(CODE_EDEFAULT);
191 | return;
192 | }
193 | super.eUnset(featureID);
194 | }
195 |
196 | /**
197 | *
198 | *
199 | * @generated
200 | */
201 | @Override
202 | public boolean eIsSet(int featureID)
203 | {
204 | switch (featureID)
205 | {
206 | case StatemachinePackage.COMMAND__NAME:
207 | return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
208 | case StatemachinePackage.COMMAND__CODE:
209 | return CODE_EDEFAULT == null ? code != null : !CODE_EDEFAULT.equals(code);
210 | }
211 | return super.eIsSet(featureID);
212 | }
213 |
214 | /**
215 | *
216 | *
217 | * @generated
218 | */
219 | @Override
220 | public String toString()
221 | {
222 | if (eIsProxy()) return super.toString();
223 |
224 | StringBuffer result = new StringBuffer(super.toString());
225 | result.append(" (name: ");
226 | result.append(name);
227 | result.append(", code: ");
228 | result.append(code);
229 | result.append(')');
230 | return result.toString();
231 | }
232 |
233 | } //CommandImpl
234 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src-gen/org/eclipse/xtext/example/fowlerdsl/statemachine/impl/EventImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | */
3 | package org.eclipse.xtext.example.fowlerdsl.statemachine.impl;
4 |
5 | import org.eclipse.emf.common.notify.Notification;
6 |
7 | import org.eclipse.emf.ecore.EClass;
8 |
9 | import org.eclipse.emf.ecore.impl.ENotificationImpl;
10 | import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
11 |
12 | import org.eclipse.xtext.example.fowlerdsl.statemachine.Event;
13 | import org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage;
14 |
15 | /**
16 | *
17 | * An implementation of the model object 'Event'.
18 | *
19 | *
20 | * The following features are implemented:
21 | *
22 | *
23 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.impl.EventImpl#getName Name}
24 | * - {@link org.eclipse.xtext.example.fowlerdsl.statemachine.impl.EventImpl#getCode Code}
25 | *
26 | *
27 | * @generated
28 | */
29 | public class EventImpl extends MinimalEObjectImpl.Container implements Event
30 | {
31 | /**
32 | * The default value of the '{@link #getName() Name}' attribute.
33 | *
34 | *
35 | * @see #getName()
36 | * @generated
37 | * @ordered
38 | */
39 | protected static final String NAME_EDEFAULT = null;
40 |
41 | /**
42 | * The cached value of the '{@link #getName() Name}' attribute.
43 | *
44 | *
45 | * @see #getName()
46 | * @generated
47 | * @ordered
48 | */
49 | protected String name = NAME_EDEFAULT;
50 |
51 | /**
52 | * The default value of the '{@link #getCode() Code}' attribute.
53 | *
54 | *
55 | * @see #getCode()
56 | * @generated
57 | * @ordered
58 | */
59 | protected static final String CODE_EDEFAULT = null;
60 |
61 | /**
62 | * The cached value of the '{@link #getCode() Code}' attribute.
63 | *
64 | *
65 | * @see #getCode()
66 | * @generated
67 | * @ordered
68 | */
69 | protected String code = CODE_EDEFAULT;
70 |
71 | /**
72 | *
73 | *
74 | * @generated
75 | */
76 | protected EventImpl()
77 | {
78 | super();
79 | }
80 |
81 | /**
82 | *
83 | *
84 | * @generated
85 | */
86 | @Override
87 | protected EClass eStaticClass()
88 | {
89 | return StatemachinePackage.Literals.EVENT;
90 | }
91 |
92 | /**
93 | *
94 | *
95 | * @generated
96 | */
97 | public String getName()
98 | {
99 | return name;
100 | }
101 |
102 | /**
103 | *
104 | *
105 | * @generated
106 | */
107 | public void setName(String newName)
108 | {
109 | String oldName = name;
110 | name = newName;
111 | if (eNotificationRequired())
112 | eNotify(new ENotificationImpl(this, Notification.SET, StatemachinePackage.EVENT__NAME, oldName, name));
113 | }
114 |
115 | /**
116 | *
117 | *
118 | * @generated
119 | */
120 | public String getCode()
121 | {
122 | return code;
123 | }
124 |
125 | /**
126 | *
127 | *
128 | * @generated
129 | */
130 | public void setCode(String newCode)
131 | {
132 | String oldCode = code;
133 | code = newCode;
134 | if (eNotificationRequired())
135 | eNotify(new ENotificationImpl(this, Notification.SET, StatemachinePackage.EVENT__CODE, oldCode, code));
136 | }
137 |
138 | /**
139 | *
140 | *
141 | * @generated
142 | */
143 | @Override
144 | public Object eGet(int featureID, boolean resolve, boolean coreType)
145 | {
146 | switch (featureID)
147 | {
148 | case StatemachinePackage.EVENT__NAME:
149 | return getName();
150 | case StatemachinePackage.EVENT__CODE:
151 | return getCode();
152 | }
153 | return super.eGet(featureID, resolve, coreType);
154 | }
155 |
156 | /**
157 | *
158 | *
159 | * @generated
160 | */
161 | @Override
162 | public void eSet(int featureID, Object newValue)
163 | {
164 | switch (featureID)
165 | {
166 | case StatemachinePackage.EVENT__NAME:
167 | setName((String)newValue);
168 | return;
169 | case StatemachinePackage.EVENT__CODE:
170 | setCode((String)newValue);
171 | return;
172 | }
173 | super.eSet(featureID, newValue);
174 | }
175 |
176 | /**
177 | *
178 | *
179 | * @generated
180 | */
181 | @Override
182 | public void eUnset(int featureID)
183 | {
184 | switch (featureID)
185 | {
186 | case StatemachinePackage.EVENT__NAME:
187 | setName(NAME_EDEFAULT);
188 | return;
189 | case StatemachinePackage.EVENT__CODE:
190 | setCode(CODE_EDEFAULT);
191 | return;
192 | }
193 | super.eUnset(featureID);
194 | }
195 |
196 | /**
197 | *
198 | *
199 | * @generated
200 | */
201 | @Override
202 | public boolean eIsSet(int featureID)
203 | {
204 | switch (featureID)
205 | {
206 | case StatemachinePackage.EVENT__NAME:
207 | return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
208 | case StatemachinePackage.EVENT__CODE:
209 | return CODE_EDEFAULT == null ? code != null : !CODE_EDEFAULT.equals(code);
210 | }
211 | return super.eIsSet(featureID);
212 | }
213 |
214 | /**
215 | *
216 | *
217 | * @generated
218 | */
219 | @Override
220 | public String toString()
221 | {
222 | if (eIsProxy()) return super.toString();
223 |
224 | StringBuffer result = new StringBuffer(super.toString());
225 | result.append(" (name: ");
226 | result.append(name);
227 | result.append(", code: ");
228 | result.append(code);
229 | result.append(')');
230 | return result.toString();
231 | }
232 |
233 | } //EventImpl
234 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src-gen/org/eclipse/xtext/example/fowlerdsl/statemachine/impl/StatemachineFactoryImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | */
3 | package org.eclipse.xtext.example.fowlerdsl.statemachine.impl;
4 |
5 | import org.eclipse.emf.ecore.EClass;
6 | import org.eclipse.emf.ecore.EObject;
7 | import org.eclipse.emf.ecore.EPackage;
8 |
9 | import org.eclipse.emf.ecore.impl.EFactoryImpl;
10 |
11 | import org.eclipse.emf.ecore.plugin.EcorePlugin;
12 |
13 | import org.eclipse.xtext.example.fowlerdsl.statemachine.*;
14 |
15 | /**
16 | *
17 | * An implementation of the model Factory.
18 | *
19 | * @generated
20 | */
21 | public class StatemachineFactoryImpl extends EFactoryImpl implements StatemachineFactory
22 | {
23 | /**
24 | * Creates the default factory implementation.
25 | *
26 | *
27 | * @generated
28 | */
29 | public static StatemachineFactory init()
30 | {
31 | try
32 | {
33 | StatemachineFactory theStatemachineFactory = (StatemachineFactory)EPackage.Registry.INSTANCE.getEFactory(StatemachinePackage.eNS_URI);
34 | if (theStatemachineFactory != null)
35 | {
36 | return theStatemachineFactory;
37 | }
38 | }
39 | catch (Exception exception)
40 | {
41 | EcorePlugin.INSTANCE.log(exception);
42 | }
43 | return new StatemachineFactoryImpl();
44 | }
45 |
46 | /**
47 | * Creates an instance of the factory.
48 | *
49 | *
50 | * @generated
51 | */
52 | public StatemachineFactoryImpl()
53 | {
54 | super();
55 | }
56 |
57 | /**
58 | *
59 | *
60 | * @generated
61 | */
62 | @Override
63 | public EObject create(EClass eClass)
64 | {
65 | switch (eClass.getClassifierID())
66 | {
67 | case StatemachinePackage.STATEMACHINE: return createStatemachine();
68 | case StatemachinePackage.EVENT: return createEvent();
69 | case StatemachinePackage.COMMAND: return createCommand();
70 | case StatemachinePackage.STATE: return createState();
71 | case StatemachinePackage.TRANSITION: return createTransition();
72 | default:
73 | throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
74 | }
75 | }
76 |
77 | /**
78 | *
79 | *
80 | * @generated
81 | */
82 | public Statemachine createStatemachine()
83 | {
84 | StatemachineImpl statemachine = new StatemachineImpl();
85 | return statemachine;
86 | }
87 |
88 | /**
89 | *
90 | *
91 | * @generated
92 | */
93 | public Event createEvent()
94 | {
95 | EventImpl event = new EventImpl();
96 | return event;
97 | }
98 |
99 | /**
100 | *
101 | *
102 | * @generated
103 | */
104 | public Command createCommand()
105 | {
106 | CommandImpl command = new CommandImpl();
107 | return command;
108 | }
109 |
110 | /**
111 | *
112 | *
113 | * @generated
114 | */
115 | public State createState()
116 | {
117 | StateImpl state = new StateImpl();
118 | return state;
119 | }
120 |
121 | /**
122 | *
123 | *
124 | * @generated
125 | */
126 | public Transition createTransition()
127 | {
128 | TransitionImpl transition = new TransitionImpl();
129 | return transition;
130 | }
131 |
132 | /**
133 | *
134 | *
135 | * @generated
136 | */
137 | public StatemachinePackage getStatemachinePackage()
138 | {
139 | return (StatemachinePackage)getEPackage();
140 | }
141 |
142 | /**
143 | *
144 | *
145 | * @deprecated
146 | * @generated
147 | */
148 | @Deprecated
149 | public static StatemachinePackage getPackage()
150 | {
151 | return StatemachinePackage.eINSTANCE;
152 | }
153 |
154 | } //StatemachineFactoryImpl
155 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src-gen/org/eclipse/xtext/example/fowlerdsl/validation/AbstractStatemachineValidator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * generated by Xtext
3 | */
4 | package org.eclipse.xtext.example.fowlerdsl.validation;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 | import org.eclipse.emf.ecore.EPackage;
9 |
10 | public class AbstractStatemachineValidator extends org.eclipse.xtext.validation.AbstractDeclarativeValidator {
11 |
12 | @Override
13 | protected List getEPackages() {
14 | List result = new ArrayList();
15 | result.add(org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage.eINSTANCE);
16 | return result;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/fowlerdsl/GenerateStatemachine.mwe2:
--------------------------------------------------------------------------------
1 | module org.eclipse.xtext.example.fowlerdsl.GenerateStatemachine
2 |
3 | import org.eclipse.emf.mwe.utils.*
4 | import org.eclipse.xtext.generator.*
5 | import org.eclipse.xtext.ui.generator.*
6 |
7 | var grammarURI = "classpath:/org/eclipse/xtext/example/fowlerdsl/Statemachine.xtext"
8 | var fileExtensions = "statemachine"
9 | var projectName = "org.eclipse.xtext.example.fowlerdsl"
10 | var runtimeProject = "../${projectName}"
11 | var generateXtendStub = true
12 | var encoding = "UTF-8"
13 | var lineDelimiter = '\n'
14 |
15 | Workflow {
16 | bean = StandaloneSetup {
17 | scanClassPath = true
18 | platformUri = "${runtimeProject}/.."
19 | // The following two lines can be removed, if Xbase is not used.
20 | registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
21 | registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
22 | }
23 |
24 | component = DirectoryCleaner {
25 | directory = "${runtimeProject}/src-gen"
26 | }
27 |
28 | component = DirectoryCleaner {
29 | directory = "${runtimeProject}/model"
30 | }
31 |
32 | component = DirectoryCleaner {
33 | directory = "${runtimeProject}.ui/src-gen"
34 | }
35 |
36 | // component = DirectoryCleaner {
37 | // directory = "${runtimeProject}.tests/src-gen"
38 | // }
39 |
40 | component = Generator auto-inject {
41 | pathRtProject = runtimeProject
42 | pathUiProject = "${runtimeProject}.ui"
43 | // pathTestProject = "${runtimeProject}.tests"
44 | projectNameRt = projectName
45 | projectNameUi = "${projectName}.ui"
46 | encoding = encoding
47 | language = auto-inject {
48 | uri = grammarURI
49 |
50 | // Java API to access grammar elements (required by several other fragments)
51 | fragment = grammarAccess.GrammarAccessFragment auto-inject {}
52 |
53 | // generates Java API for the generated EPackages
54 | fragment = ecore.EMFGeneratorFragment auto-inject {}
55 |
56 | // the old serialization component
57 | // fragment = parseTreeConstructor.ParseTreeConstructorFragment auto-inject {}
58 |
59 | // serializer 2.0
60 | fragment = serializer.SerializerFragment auto-inject {
61 | generateStub = false
62 | }
63 |
64 | // a custom ResourceFactory for use with EMF
65 | fragment = resourceFactory.ResourceFactoryFragment auto-inject {}
66 |
67 | // The antlr parser generator fragment.
68 | fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject {
69 | // options = {
70 | // backtrack = true
71 | // }
72 | }
73 |
74 | // Xtend-based API for validation
75 | fragment = validation.ValidatorFragment auto-inject {
76 | // composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
77 | // composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
78 | }
79 |
80 | // old scoping and exporting API
81 | // fragment = scoping.ImportURIScopingFragment auto-inject {}
82 | // fragment = exporting.SimpleNamesFragment auto-inject {}
83 |
84 | // scoping and exporting API
85 | fragment = scoping.ImportNamespacesScopingFragment auto-inject {}
86 | fragment = exporting.QualifiedNamesFragment auto-inject {}
87 | fragment = builder.BuilderIntegrationFragment auto-inject {}
88 |
89 | // generator API
90 | fragment = generator.GeneratorFragment auto-inject {}
91 |
92 | // formatter API
93 | fragment = formatting2.Formatter2Fragment auto-inject {}
94 |
95 | // labeling API
96 | fragment = labeling.LabelProviderFragment auto-inject {}
97 |
98 | // outline API
99 | fragment = outline.OutlineTreeProviderFragment auto-inject {}
100 | fragment = outline.QuickOutlineFragment auto-inject {}
101 |
102 | // quickfix API
103 | fragment = quickfix.QuickfixProviderFragment auto-inject {}
104 |
105 | // content assist API
106 | fragment = contentAssist.ContentAssistFragment auto-inject {}
107 |
108 | // generates a more lightweight Antlr parser and lexer tailored for content assist
109 | fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject {
110 | partialParsing = true
111 | }
112 |
113 | // generates junit test support classes into Generator#pathTestProject
114 | // fragment = junit.Junit4Fragment auto-inject {}
115 |
116 | // rename refactoring
117 | fragment = refactoring.RefactorElementNameFragment auto-inject {}
118 |
119 | // provides the necessary bindings for java types integration
120 | fragment = types.TypesGeneratorFragment auto-inject {}
121 |
122 | // generates the required bindings only if the grammar inherits from Xbase
123 | fragment = xbase.XbaseGeneratorFragment auto-inject {}
124 |
125 | // provides a preference page for template proposals
126 | fragment = templates.CodetemplatesGeneratorFragment auto-inject {}
127 |
128 | // provides a compare view
129 | fragment = compare.CompareFragment auto-inject {}
130 | }
131 | }
132 | }
133 |
134 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/fowlerdsl/Statemachine.xtext:
--------------------------------------------------------------------------------
1 | grammar org.eclipse.xtext.example.fowlerdsl.Statemachine with org.eclipse.xtext.common.Terminals
2 |
3 | generate statemachine "http://www.eclipse.org/xtext/example/fowlerdsl/Statemachine"
4 |
5 | Statemachine :
6 | {Statemachine}
7 | ('events'
8 | events+=Event+
9 | 'end')?
10 | ('resetEvents'
11 | resetEvents+=[Event]+
12 | 'end')?
13 | ('commands'
14 | commands+=Command+
15 | 'end')?
16 | states+=State*
17 | ;
18 |
19 | Event:
20 | name=ID code=ID
21 | ;
22 |
23 | Command:
24 | name=ID code=ID
25 | ;
26 |
27 | State:
28 | 'state' name=ID
29 | ('actions' '{' actions+=[Command]+ '}')?
30 | transitions+=Transition*
31 | 'end'
32 | ;
33 |
34 | Transition:
35 | event=[Event] '=>' state=[State]
36 | ;
37 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/fowlerdsl/StatemachineRuntimeModule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * generated by Xtext
3 | */
4 | package org.eclipse.xtext.example.fowlerdsl;
5 |
6 | import org.eclipse.xtext.example.fowlerdsl.resource.StatemachineFragmentProvider;
7 | import org.eclipse.xtext.example.fowlerdsl.resource.StatemachineResourceDescriptionStrategy;
8 | import org.eclipse.xtext.resource.IDefaultResourceDescriptionStrategy;
9 | import org.eclipse.xtext.resource.IFragmentProvider;
10 |
11 | /**
12 | * Use this class to register components to be used at runtime / without the Equinox extension registry.
13 | */
14 | public class StatemachineRuntimeModule extends org.eclipse.xtext.example.fowlerdsl.AbstractStatemachineRuntimeModule {
15 |
16 |
17 | public Class extends IFragmentProvider> bindIFragmentProvider() {
18 | return StatemachineFragmentProvider.class;
19 | }
20 |
21 | public Class extends IDefaultResourceDescriptionStrategy> bindIDefaultResourceDescriptionStrategy(){
22 | return StatemachineResourceDescriptionStrategy.class;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/fowlerdsl/StatemachineStandaloneSetup.java:
--------------------------------------------------------------------------------
1 | /*
2 | * generated by Xtext
3 | */
4 | package org.eclipse.xtext.example.fowlerdsl;
5 |
6 | /**
7 | * Initialization support for running Xtext languages
8 | * without equinox extension registry
9 | */
10 | public class StatemachineStandaloneSetup extends StatemachineStandaloneSetupGenerated{
11 |
12 | public static void doSetup() {
13 | new StatemachineStandaloneSetup().createInjectorAndDoEMFRegistration();
14 | }
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/fowlerdsl/formatting2/StatemachineFormatter.xtend:
--------------------------------------------------------------------------------
1 | /*
2 | * generated by Xtext
3 | */
4 | package org.eclipse.xtext.example.fowlerdsl.formatting2;
5 |
6 | import com.google.inject.Inject
7 | import org.eclipse.xtext.example.fowlerdsl.services.StatemachineGrammarAccess
8 | import org.eclipse.xtext.example.fowlerdsl.statemachine.Command
9 | import org.eclipse.xtext.example.fowlerdsl.statemachine.Event
10 | import org.eclipse.xtext.example.fowlerdsl.statemachine.State
11 | import org.eclipse.xtext.example.fowlerdsl.statemachine.Statemachine
12 | import org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage
13 | import org.eclipse.xtext.example.fowlerdsl.statemachine.Transition
14 | import org.eclipse.xtext.formatting2.AbstractFormatter2
15 | import org.eclipse.xtext.formatting2.IFormattableDocument
16 |
17 | class StatemachineFormatter extends AbstractFormatter2 {
18 |
19 | @Inject extension StatemachineGrammarAccess
20 |
21 | def dispatch void format(Statemachine statemachine, extension IFormattableDocument document) {
22 | // TODO: format HiddenRegions around keywords, attributes, cross references, etc.
23 | for (Event events : statemachine.getEvents()) {
24 | format(events, document);
25 | }
26 | for (Command commands : statemachine.getCommands()) {
27 | format(commands, document);
28 | }
29 | for (State states : statemachine.getStates()) {
30 | format(states, document);
31 | }
32 | }
33 |
34 |
35 | def dispatch void format(State state, extension IFormattableDocument document) {
36 | interior(
37 | state.regionFor.keyword('state').append[oneSpace],
38 | state.regionFor.keyword('end'),
39 | [indent]
40 | )
41 | if (state.name !== null) {
42 | state.regionFor.feature(StatemachinePackage.Literals.STATE__NAME).prepend[oneSpace]
43 | }
44 | state.regionFor.keyword('actions').prepend[newLine].append[oneSpace]
45 | interior(
46 | state.regionFor.keyword('{').append[newLine],
47 | state.regionFor.keyword('}').append[newLine],
48 | [indent]
49 | )
50 | state.append[setNewLines(1, 1, 2)]
51 | for (command : state.actions) {
52 | command.format
53 | }
54 | for (Transition transitions : state.getTransitions()) {
55 | format(transitions, document);
56 | }
57 | }
58 |
59 | def dispatch void format(Transition transition, extension IFormattableDocument document) {
60 | transition.regionFor.keywords('=>', '(', ')').forEach [
61 | surround[oneSpace]
62 | ]
63 | transition.append[setNewLines(1, 1, 2)]
64 | transition.event.format
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/fowlerdsl/generator/StatemachineGenerator.xtend:
--------------------------------------------------------------------------------
1 | /*
2 | * generated by Xtext
3 | */
4 | package org.eclipse.xtext.example.fowlerdsl.generator
5 |
6 | import org.eclipse.emf.ecore.resource.Resource
7 | import org.eclipse.xtext.example.fowlerdsl.statemachine.Command
8 | import org.eclipse.xtext.example.fowlerdsl.statemachine.State
9 | import org.eclipse.xtext.example.fowlerdsl.statemachine.Statemachine
10 | import org.eclipse.xtext.generator.IFileSystemAccess
11 | import org.eclipse.xtext.generator.IGenerator
12 |
13 | /**
14 | * Generates code from your model files on save.
15 | *
16 | * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation
17 | */
18 | class StatemachineGenerator implements IGenerator {
19 |
20 | override void doGenerate(Resource resource, IFileSystemAccess fsa) {
21 | fsa.generateFile(resource.className+".java", toJavaCode(resource.contents.head as Statemachine))
22 | }
23 |
24 | def className(Resource res) {
25 | var name = res.URI.lastSegment
26 | return name.substring(0, name.indexOf('.'))
27 | }
28 |
29 | def toJavaCode(Statemachine sm) '''
30 | import java.io.BufferedReader;
31 | import java.io.IOException;
32 | import java.io.InputStreamReader;
33 |
34 | public class «sm.eResource.className» {
35 |
36 | public static void main(String[] args) {
37 | new «sm.eResource.className»().run();
38 | }
39 |
40 | «FOR c : sm.commands»
41 | «c.declareCommand»
42 | «ENDFOR»
43 |
44 | protected void run() {
45 | boolean executeActions = true;
46 | String currentState = "«sm.states.head?.name»";
47 | String lastEvent = null;
48 | while (true) {
49 | «FOR state : sm.states»
50 | «state.generateCode»
51 | «ENDFOR»
52 | «FOR resetEvent : sm.resetEvents»
53 | if ("«resetEvent.name»".equals(lastEvent)) {
54 | System.out.println("Resetting state machine.");
55 | currentState = "«sm.states.head?.name»";
56 | executeActions = true;
57 | }
58 | «ENDFOR»
59 |
60 | }
61 | }
62 |
63 | private String receiveEvent() {
64 | System.out.flush();
65 | BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
66 | try {
67 | return br.readLine();
68 | } catch (IOException ioe) {
69 | System.out.println("Problem reading input");
70 | return "";
71 | }
72 | }
73 | }
74 | '''
75 |
76 | def declareCommand(Command command) '''
77 | protected void do«command.name.toFirstUpper»() {
78 | System.out.println("Executing command «command.name» («command.code»)");
79 | }
80 | '''
81 |
82 | def generateCode(State state) '''
83 | if (currentState.equals("«state.name»")) {
84 | if (executeActions) {
85 | «FOR c : state.actions»
86 | do«c.name.toFirstUpper»();
87 | «ENDFOR»
88 | executeActions = false;
89 | }
90 | System.out.println("Your are now in state '«state.name»'. Possible events are [«
91 | state.transitions.map(t | t.event.name).join(', ')»].");
92 | lastEvent = receiveEvent();
93 | «FOR t : state.transitions»
94 | if ("«t.event.name»".equals(lastEvent)) {
95 | currentState = "«t.state.name»";
96 | executeActions = true;
97 | }
98 | «ENDFOR»
99 | }
100 | '''
101 |
102 | }
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/fowlerdsl/resource/PathURIFragmentProvider.xtend:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 TypeFox and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package org.eclipse.xtext.example.fowlerdsl.resource
9 |
10 | import org.eclipse.emf.common.util.SegmentSequence
11 | import org.eclipse.emf.common.util.URI
12 | import org.eclipse.emf.ecore.EObject
13 | import org.eclipse.emf.ecore.InternalEObject
14 | import org.eclipse.emf.ecore.resource.impl.ResourceImpl
15 | import org.eclipse.xtext.EcoreUtil2
16 |
17 | /**
18 | * Calculates the standard EMF path URI fragment.
19 | * Temporary workaround for https://github.com/eclipse/xtext-eclipse/issues/284
20 | *
21 | * @author koehnlein
22 | */
23 | class PathURIFragmentProvider {
24 |
25 | /**
26 | * inspired by {@link ResourceImpl#getURIFragment()}
27 | */
28 | static def String getPathURIFragment(EObject element) {
29 | val builder = SegmentSequence.newBuilder("/")
30 | var internalEObject = element as InternalEObject
31 | var isContained = internalEObject.eDirectResource !== null
32 | for (var container = internalEObject.eInternalContainer();
33 | container !== null && !isContained;
34 | container = internalEObject.eInternalContainer()) {
35 | builder.append(container.eURIFragmentSegment(internalEObject.eContainingFeature(), internalEObject))
36 | internalEObject = container
37 | if (container.eDirectResource() !== null) {
38 | isContained = true
39 | }
40 | }
41 | if (!isContained) {
42 | return "/-1"
43 | }
44 | builder.append(getURIFragmentRootSegment(internalEObject))
45 | builder.append("")
46 | builder.reverse()
47 | return builder.toSegmentSequence().toString()
48 | }
49 |
50 | static def URI getPathURI(EObject object) {
51 | val resource = object.eResource
52 | if(resource !== null) {
53 | val fragment = object.pathURIFragment
54 | val resourceURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(resource)
55 | return resourceURI.appendFragment(fragment)
56 | } else {
57 | return EcoreUtil2.getPlatformResourceOrNormalizedURI(object)
58 | }
59 | }
60 |
61 | protected static def String getURIFragmentRootSegment(EObject eObject) {
62 | var contents = eObject.eResource.contents
63 | if (contents.size > 1)
64 | return Integer.toString(contents.indexOf(eObject))
65 | else
66 | return ''
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/fowlerdsl/resource/StatemachineFragmentProvider.java:
--------------------------------------------------------------------------------
1 | package org.eclipse.xtext.example.fowlerdsl.resource;
2 |
3 | import java.util.Iterator;
4 |
5 | import org.eclipse.emf.ecore.EObject;
6 | import org.eclipse.emf.ecore.InternalEObject;
7 | import org.eclipse.emf.ecore.resource.Resource;
8 | import org.eclipse.emf.ecore.util.EcoreUtil;
9 | import org.eclipse.xtext.example.fowlerdsl.statemachine.State;
10 | import org.eclipse.xtext.example.fowlerdsl.statemachine.Transition;
11 | import org.eclipse.xtext.naming.IQualifiedNameProvider;
12 | import org.eclipse.xtext.naming.QualifiedName;
13 | import org.eclipse.xtext.naming.SimpleNameProvider;
14 | import org.eclipse.xtext.resource.IFragmentProvider;
15 |
16 | import com.google.inject.Inject;
17 |
18 | public class StatemachineFragmentProvider implements IFragmentProvider {
19 |
20 | @Inject
21 | private IQualifiedNameProvider qualifiedNameProvider = new SimpleNameProvider();
22 |
23 | public String getFragment(EObject obj, Fallback fallback) {
24 | QualifiedName qName = qualifiedNameProvider.getFullyQualifiedName(obj);
25 | if (obj instanceof Transition && obj.eContainer() instanceof State) {
26 | String r = ((State) obj.eContainer()).getName();
27 | if (r == null) {
28 | r = "";
29 | }
30 | r += "-|";
31 | if (((Transition) obj).getEvent() != null && ((Transition) obj).getEvent().getCode() != null) {
32 | r += ((Transition) obj).getEvent().getCode();
33 | }
34 | r += "|";
35 | return r;
36 |
37 | } else {
38 |
39 | return qName != null ? qName.toString() : fallback.getFragment(obj);
40 | }
41 | }
42 |
43 | public EObject getEObject(Resource resource, String fragment, Fallback fallback) {
44 | if (fragment != null) {
45 | Iterator i = EcoreUtil.getAllContents(resource, false);
46 | while (i.hasNext()) {
47 | EObject eObject = i.next();
48 | String candidateFragment = (eObject.eIsProxy()) ? ((InternalEObject) eObject).eProxyURI().fragment()
49 | : getFragment(eObject, fallback);
50 | if (fragment.equals(candidateFragment))
51 | return eObject;
52 | }
53 | }
54 | return fallback.getEObject(fragment);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/fowlerdsl/resource/StatemachineResourceDescriptionStrategy.xtend:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 TypeFox and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package org.eclipse.xtext.example.fowlerdsl.resource
9 |
10 | import org.eclipse.emf.common.util.URI
11 | import org.eclipse.emf.ecore.EObject
12 | import org.eclipse.emf.ecore.EReference
13 | import org.eclipse.xtext.resource.impl.DefaultReferenceDescription
14 | import org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy
15 |
16 | import static extension org.eclipse.xtext.example.fowlerdsl.resource.PathURIFragmentProvider.*
17 |
18 | class StatemachineResourceDescriptionStrategy extends DefaultResourceDescriptionStrategy {
19 |
20 | override protected createReferenceDescription(EObject owner, URI exportedContainerURI, EReference eReference, int indexInList, EObject target) {
21 | val ownerURI = owner.pathURI
22 | val targetURI = target.pathURI
23 | return new DefaultReferenceDescription(ownerURI, targetURI, eReference, indexInList, exportedContainerURI)
24 | }
25 |
26 | }
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/fowlerdsl/scoping/StatemachineScopeProvider.xtend:
--------------------------------------------------------------------------------
1 | /*
2 | * generated by Xtext
3 | */
4 | package org.eclipse.xtext.example.fowlerdsl.scoping
5 |
6 | /**
7 | * This class contains custom scoping description.
8 | *
9 | * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#scoping
10 | * on how and when to use it.
11 | *
12 | */
13 | class StatemachineScopeProvider extends org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/src/org/eclipse/xtext/example/fowlerdsl/validation/StatemachineValidator.xtend:
--------------------------------------------------------------------------------
1 | /*
2 | * generated by Xtext
3 | */
4 | package org.eclipse.xtext.example.fowlerdsl.validation
5 |
6 | import org.eclipse.xtext.example.fowlerdsl.statemachine.StatemachinePackage
7 | import org.eclipse.xtext.validation.Check
8 |
9 | /**
10 | * Custom validation rules.
11 | *
12 | * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation
13 | */
14 | class StatemachineValidator extends AbstractStatemachineValidator {
15 |
16 | public static val INVALID_NAME = 'invalidName'
17 |
18 | @Check
19 | def checkStateNameStartsWithLowerCase(org.eclipse.xtext.example.fowlerdsl.statemachine.State state) {
20 | if (Character.isUpperCase(state.name.charAt(0))) {
21 | warning('Name should start with a lower case letter',
22 | StatemachinePackage.Literals.STATE__NAME,
23 | INVALID_NAME, state.name)
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/formatting/.gitignore:
--------------------------------------------------------------------------------
1 | /.StatemachineFormatter.java._trace
2 | /.StatemachineFormatter.xtendbin
3 | /StatemachineFormatter.java
4 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/formatting2/.StatemachineFormatter.java._trace:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ObeoNetwork/Xtext-Sirius-integration/098f5c4777ff5b443785d69fef8387d14c61e131/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/formatting2/.StatemachineFormatter.java._trace
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/formatting2/.StatemachineFormatter.xtendbin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ObeoNetwork/Xtext-Sirius-integration/098f5c4777ff5b443785d69fef8387d14c61e131/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/formatting2/.StatemachineFormatter.xtendbin
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/generator/.gitignore:
--------------------------------------------------------------------------------
1 | /.StatemachineGenerator.java._trace
2 | /.StatemachineGenerator.xtendbin
3 | /StatemachineGenerator.java
4 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/resource/.PathURIFragmentProvider.java._trace:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ObeoNetwork/Xtext-Sirius-integration/098f5c4777ff5b443785d69fef8387d14c61e131/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/resource/.PathURIFragmentProvider.java._trace
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/resource/.PathURIFragmentProvider.xtendbin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ObeoNetwork/Xtext-Sirius-integration/098f5c4777ff5b443785d69fef8387d14c61e131/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/resource/.PathURIFragmentProvider.xtendbin
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/resource/.StatemachineResourceDescriptionStrategy.java._trace:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ObeoNetwork/Xtext-Sirius-integration/098f5c4777ff5b443785d69fef8387d14c61e131/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/resource/.StatemachineResourceDescriptionStrategy.java._trace
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/resource/.StatemachineResourceDescriptionStrategy.xtendbin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ObeoNetwork/Xtext-Sirius-integration/098f5c4777ff5b443785d69fef8387d14c61e131/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/resource/.StatemachineResourceDescriptionStrategy.xtendbin
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/resource/PathURIFragmentProvider.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2017 TypeFox and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | */
8 | package org.eclipse.xtext.example.fowlerdsl.resource;
9 |
10 | import org.eclipse.emf.common.util.EList;
11 | import org.eclipse.emf.common.util.SegmentSequence;
12 | import org.eclipse.emf.common.util.URI;
13 | import org.eclipse.emf.ecore.EObject;
14 | import org.eclipse.emf.ecore.InternalEObject;
15 | import org.eclipse.emf.ecore.resource.Resource;
16 | import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
17 | import org.eclipse.xtext.EcoreUtil2;
18 |
19 | /**
20 | * Calculates the standard EMF path URI fragment.
21 | * Temporary workaround for https://github.com/eclipse/xtext-eclipse/issues/284
22 | *
23 | * @author koehnlein
24 | */
25 | @SuppressWarnings("all")
26 | public class PathURIFragmentProvider {
27 | /**
28 | * inspired by {@link ResourceImpl#getURIFragment()}
29 | */
30 | public static String getPathURIFragment(final EObject element) {
31 | final SegmentSequence.Builder builder = SegmentSequence.newBuilder("/");
32 | InternalEObject internalEObject = ((InternalEObject) element);
33 | Resource.Internal _eDirectResource = internalEObject.eDirectResource();
34 | boolean isContained = (_eDirectResource != null);
35 | for (InternalEObject container = internalEObject.eInternalContainer(); ((container != null) && (!isContained)); container = internalEObject.eInternalContainer()) {
36 | {
37 | builder.append(container.eURIFragmentSegment(internalEObject.eContainingFeature(), internalEObject));
38 | internalEObject = container;
39 | Resource.Internal _eDirectResource_1 = container.eDirectResource();
40 | boolean _tripleNotEquals = (_eDirectResource_1 != null);
41 | if (_tripleNotEquals) {
42 | isContained = true;
43 | }
44 | }
45 | }
46 | if ((!isContained)) {
47 | return "/-1";
48 | }
49 | builder.append(PathURIFragmentProvider.getURIFragmentRootSegment(internalEObject));
50 | builder.append("");
51 | builder.reverse();
52 | return builder.toSegmentSequence().toString();
53 | }
54 |
55 | public static URI getPathURI(final EObject object) {
56 | final Resource resource = object.eResource();
57 | if ((resource != null)) {
58 | final String fragment = PathURIFragmentProvider.getPathURIFragment(object);
59 | final URI resourceURI = EcoreUtil2.getPlatformResourceOrNormalizedURI(resource);
60 | return resourceURI.appendFragment(fragment);
61 | } else {
62 | return EcoreUtil2.getPlatformResourceOrNormalizedURI(object);
63 | }
64 | }
65 |
66 | protected static String getURIFragmentRootSegment(final EObject eObject) {
67 | EList contents = eObject.eResource().getContents();
68 | int _size = contents.size();
69 | boolean _greaterThan = (_size > 1);
70 | if (_greaterThan) {
71 | return Integer.toString(contents.indexOf(eObject));
72 | } else {
73 | return "";
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/resource/StatemachineResourceDescriptionStrategy.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2017 TypeFox and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | */
8 | package org.eclipse.xtext.example.fowlerdsl.resource;
9 |
10 | import org.eclipse.emf.common.util.URI;
11 | import org.eclipse.emf.ecore.EObject;
12 | import org.eclipse.emf.ecore.EReference;
13 | import org.eclipse.xtext.example.fowlerdsl.resource.PathURIFragmentProvider;
14 | import org.eclipse.xtext.resource.IReferenceDescription;
15 | import org.eclipse.xtext.resource.impl.DefaultReferenceDescription;
16 | import org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy;
17 |
18 | @SuppressWarnings("all")
19 | public class StatemachineResourceDescriptionStrategy extends DefaultResourceDescriptionStrategy {
20 | @Override
21 | protected IReferenceDescription createReferenceDescription(final EObject owner, final URI exportedContainerURI, final EReference eReference, final int indexInList, final EObject target) {
22 | final URI ownerURI = PathURIFragmentProvider.getPathURI(owner);
23 | final URI targetURI = PathURIFragmentProvider.getPathURI(target);
24 | return new DefaultReferenceDescription(ownerURI, targetURI, eReference, indexInList, exportedContainerURI);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/scoping/.gitignore:
--------------------------------------------------------------------------------
1 | /.StatemachineScopeProvider.java._trace
2 | /.StatemachineScopeProvider.xtendbin
3 | /StatemachineScopeProvider.java
4 |
--------------------------------------------------------------------------------
/xtext-support-parent/examples/org.eclipse.xtext.example.fowlerdsl/xtend-gen/org/eclipse/xtext/example/fowlerdsl/validation/.gitignore:
--------------------------------------------------------------------------------
1 | /.StatemachineValidator.java._trace
2 | /.StatemachineValidator.xtendbin
3 | /StatemachineValidator.java
4 |
--------------------------------------------------------------------------------
/xtext-support-parent/features/org.obeonetwork.dsl.viewpoint.feature.xtext.support/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.obeonetwork.dsl.viewpoint.feature.xtext.support
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.pde.FeatureBuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.m2e.core.maven2Nature
21 | org.eclipse.pde.FeatureNature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/xtext-support-parent/features/org.obeonetwork.dsl.viewpoint.feature.xtext.support/build.properties:
--------------------------------------------------------------------------------
1 | bin.includes = feature.xml
2 |
--------------------------------------------------------------------------------
/xtext-support-parent/features/org.obeonetwork.dsl.viewpoint.feature.xtext.support/feature.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 | [Enter Feature Description here.]
9 |
10 |
11 |
12 | [Enter Copyright Description here.]
13 |
14 |
15 |
16 | [Enter License Description here.]
17 |
18 |
19 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/xtext-support-parent/features/org.obeonetwork.dsl.viewpoint.feature.xtext.support/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 |
6 | ../..
7 | org.obeonetwork.dsl.viewpoint.xtext.support
8 | xtext-support-parent
9 | 1.0.0-SNAPSHOT
10 |
11 |
12 | org.obeonetwork.dsl.viewpoint.feature.xtext.support
13 | eclipse-feature
14 |
15 |
--------------------------------------------------------------------------------
/xtext-support-parent/features/org.obeonetwork.dsl.viewpoint.xtext.support.update/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.obeonetwork.dsl.viewpoint.xtext.support.update
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.pde.UpdateSiteBuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.pde.UpdateSiteNature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/xtext-support-parent/features/org.obeonetwork.dsl.viewpoint.xtext.support.update/category.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Viewpoint
5 |
6 |
7 |
8 |
9 |
10 |
11 | The Obeo Network.
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/xtext-support-parent/features/org.obeonetwork.dsl.viewpoint.xtext.support.update/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 |
6 | ../..
7 | org.obeonetwork.dsl.viewpoint.xtext.support
8 | xtext-support-parent
9 | 1.0.0-SNAPSHOT
10 |
11 |
12 | org.obeonetwork.dsl.viewpoint.xtext.support.update
13 | eclipse-repository
14 |
15 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/io.typefox.xtext.sirius.aird/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/io.typefox.xtext.sirius.aird/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | io.typefox.xtext.sirius.aird
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.pde.ManifestBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.pde.SchemaBuilder
20 |
21 |
22 |
23 |
24 |
25 | org.eclipse.pde.PluginNature
26 | org.eclipse.jdt.core.javanature
27 |
28 |
29 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/io.typefox.xtext.sirius.aird/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4 | org.eclipse.jdt.core.compiler.compliance=1.8
5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7 | org.eclipse.jdt.core.compiler.source=1.8
8 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/io.typefox.xtext.sirius.aird/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: Xtext integration for Sirius aird files
4 | Bundle-SymbolicName: io.typefox.xtext.sirius.aird;singleton:=true
5 | Bundle-Version: 1.0.0.qualifier
6 | Bundle-Vendor: TypeFox
7 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8
8 | Require-Bundle: org.eclipse.xtext,
9 | org.eclipse.core.runtime,
10 | org.eclipse.xtext.ui,
11 | org.eclipse.emf.ecore.editor,
12 | org.eclipse.xtext.ui.shared
13 | Import-Package: org.apache.log4j
14 | Bundle-ActivationPolicy: lazy
15 | Bundle-Activator: io.typefox.xtext.sirius.aird.ui.Activator
16 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/io.typefox.xtext.sirius.aird/build.properties:
--------------------------------------------------------------------------------
1 | source.. = src/
2 | output.. = bin/
3 | bin.includes = META-INF/,\
4 | .,\
5 | plugin.xml
6 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/io.typefox.xtext.sirius.aird/plugin.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/io.typefox.xtext.sirius.aird/src/io/typefox/xtext/sirius/aird/AirdRuntimeModule.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 TypeFox and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package io.typefox.xtext.sirius.aird;
9 |
10 | import org.eclipse.xtext.resource.generic.AbstractGenericResourceRuntimeModule;
11 | import org.eclipse.xtext.validation.IResourceValidator;
12 |
13 | /**
14 | * The DI module to configure the Xtext language services for aird models.
15 | *
16 | * @author koehnlein
17 | */
18 | public class AirdRuntimeModule extends AbstractGenericResourceRuntimeModule {
19 |
20 | @Override
21 | protected String getLanguageName() {
22 | return "io.typefox.xtext.sirius.aird";
23 | }
24 |
25 | @Override
26 | protected String getFileExtensions() {
27 | return "aird";
28 | }
29 |
30 | public IResourceValidator bindIResourceValidator() {
31 | return IResourceValidator.NULL;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/io.typefox.xtext.sirius.aird/src/io/typefox/xtext/sirius/aird/ui/Activator.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 TypeFox and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package io.typefox.xtext.sirius.aird.ui;
9 |
10 | import org.apache.log4j.Logger;
11 | import org.eclipse.ui.plugin.AbstractUIPlugin;
12 | import org.eclipse.xtext.ui.shared.SharedStateModule;
13 | import org.osgi.framework.BundleContext;
14 |
15 | import com.google.inject.Guice;
16 | import com.google.inject.Injector;
17 | import com.google.inject.util.Modules;
18 |
19 | import io.typefox.xtext.sirius.aird.AirdRuntimeModule;
20 |
21 | public class Activator extends AbstractUIPlugin {
22 |
23 | private static final Logger logger = Logger.getLogger(Activator.class);
24 |
25 | // The plug-in ID
26 | public static final String PLUGIN_ID = "io.typefox.xtext.sirius.aird"; //$NON-NLS-1$
27 |
28 | // The shared instance
29 | private static Activator plugin;
30 |
31 | private Injector injector;
32 |
33 | /**
34 | * The constructor
35 | */
36 | public Activator() {
37 | }
38 |
39 | public Injector getInjector() {
40 | return injector;
41 | }
42 |
43 | private void initializeEcoreInjector() {
44 | injector = Guice.createInjector(
45 | Modules.override(Modules.override(new AirdRuntimeModule())
46 | .with(new AirdUiModule(plugin)))
47 | .with(new SharedStateModule()));
48 | }
49 |
50 | @Override
51 | public void start(BundleContext context) throws Exception {
52 | super.start(context);
53 | plugin = this;
54 | try {
55 | initializeEcoreInjector();
56 | } catch(Exception e) {
57 | logger.error(e.getMessage(), e);
58 | throw e;
59 | }
60 | }
61 |
62 | @Override
63 | public void stop(BundleContext context) throws Exception {
64 | plugin = null;
65 | injector = null;
66 | super.stop(context);
67 | }
68 |
69 | /**
70 | * Returns the shared instance
71 | *
72 | * @return the shared instance
73 | */
74 | public static Activator getDefault() {
75 | return plugin;
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/io.typefox.xtext.sirius.aird/src/io/typefox/xtext/sirius/aird/ui/AirdUiModule.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 TypeFox and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package io.typefox.xtext.sirius.aird.ui;
9 |
10 | import org.eclipse.ui.plugin.AbstractUIPlugin;
11 | import org.eclipse.xtext.ui.LanguageSpecific;
12 | import org.eclipse.xtext.ui.editor.IURIEditorOpener;
13 | import org.eclipse.xtext.ui.resource.generic.EmfUiModule;
14 |
15 | /**
16 | * The DI module to configure the Xtext UI language services for aird models.
17 | *
18 | * @author koehnlein
19 | */
20 | public class AirdUiModule extends EmfUiModule {
21 |
22 | public AirdUiModule(AbstractUIPlugin plugin) {
23 | super(plugin);
24 | }
25 |
26 | @Override
27 | public void configureLanguageSpecificURIEditorOpener(com.google.inject.Binder binder) {
28 | binder.bind(IURIEditorOpener.class).annotatedWith(LanguageSpecific.class).to(EcoreEditorOpener.class);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/io.typefox.xtext.sirius.aird/src/io/typefox/xtext/sirius/aird/ui/EcoreEditorOpener.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 TypeFox and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package io.typefox.xtext.sirius.aird.ui;
9 |
10 | import java.util.Collections;
11 |
12 | import org.eclipse.emf.common.util.URI;
13 | import org.eclipse.emf.ecore.EObject;
14 | import org.eclipse.emf.ecore.EReference;
15 | import org.eclipse.emf.ecore.presentation.EcoreEditor;
16 | import org.eclipse.ui.IEditorPart;
17 | import org.eclipse.xtext.ui.editor.LanguageSpecificURIEditorOpener;
18 |
19 | /**
20 | * @author koehnlein
21 | */
22 | public class EcoreEditorOpener extends LanguageSpecificURIEditorOpener {
23 |
24 | @Override
25 | protected void selectAndReveal(IEditorPart openEditor, URI uri,
26 | EReference crossReference, int indexInList, boolean select) {
27 | if (uri.fragment() != null) {
28 | EcoreEditor ecoreEditor = (EcoreEditor) openEditor.getAdapter(EcoreEditor.class);
29 | if (ecoreEditor != null) {
30 | EObject eObject = ecoreEditor.getEditingDomain().getResourceSet().getEObject(uri, true);
31 | ecoreEditor.setSelectionToViewer(Collections.singletonList(eObject));
32 | }
33 | }
34 | }
35 |
36 | @Override
37 | protected String getEditorId() {
38 | return "fr.obeo.dsl.designer.sample.flow.presentation.FlowEditorID";
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/io.typefox.xtext.sirius.aird/src/io/typefox/xtext/sirius/aird/ui/ExecutableExtensionFactory.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 TypeFox and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package io.typefox.xtext.sirius.aird.ui;
9 |
10 | import org.eclipse.xtext.ui.guice.AbstractGuiceAwareExecutableExtensionFactory;
11 | import org.osgi.framework.Bundle;
12 |
13 | import com.google.inject.Injector;
14 |
15 | /**
16 | * Instantiates classes declared in the plugin.xml using the DI container.
17 | *
18 | * @author koehnlein
19 | */
20 | public class ExecutableExtensionFactory extends AbstractGuiceAwareExecutableExtensionFactory {
21 |
22 | @Override
23 | protected Bundle getBundle() {
24 | return Activator.getDefault().getBundle();
25 | }
26 |
27 | @Override
28 | protected Injector getInjector() {
29 | return Activator.getDefault().getInjector();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/org.obeonetwork.dsl.viewpoint.xtext.support/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/org.obeonetwork.dsl.viewpoint.xtext.support/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.obeonetwork.dsl.viewpoint.xtext.support
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.pde.ManifestBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.pde.SchemaBuilder
20 |
21 |
22 |
23 |
24 | org.eclipse.m2e.core.maven2Builder
25 |
26 |
27 |
28 |
29 |
30 | org.eclipse.m2e.core.maven2Nature
31 | org.eclipse.pde.PluginNature
32 | org.eclipse.jdt.core.javanature
33 |
34 |
35 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/org.obeonetwork.dsl.viewpoint.xtext.support/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: org.obeonetwork.dsl.viewpoint.xtext.support
4 | Bundle-SymbolicName: org.obeonetwork.dsl.viewpoint.xtext.support
5 | Bundle-Version: 1.0.0.qualifier
6 | Bundle-Activator: org.obeonetwork.dsl.viewpoint.xtext.support.Activator
7 | Require-Bundle: org.eclipse.ui,
8 | org.eclipse.core.runtime,
9 | org.eclipse.emf.common;bundle-version="2.5.0",
10 | org.eclipse.xtext;bundle-version="2.0.0",
11 | org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.2.1",
12 | org.eclipse.ui.ide;bundle-version="3.5.0",
13 | org.eclipse.xtext.ui;bundle-version="2.0.0",
14 | org.eclipse.core.expressions;bundle-version="3.4.100",
15 | org.eclipse.xtext.ui.shared;bundle-version="0.8.0",
16 | org.eclipse.emf.compare,
17 | org.eclipse.sirius;bundle-version="1.0.0",
18 | org.eclipse.emf.compare.rcp;bundle-version="2.2.0"
19 | Bundle-ActivationPolicy: lazy
20 | Bundle-RequiredExecutionEnvironment: J2SE-1.5
21 | Export-Package: org.obeonetwork.dsl.viewpoint.xtext.support,
22 | org.obeonetwork.dsl.viewpoint.xtext.support.action
23 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/org.obeonetwork.dsl.viewpoint.xtext.support/build.properties:
--------------------------------------------------------------------------------
1 | source.. = src/
2 | output.. = bin/
3 | bin.includes = META-INF/,\
4 | .
5 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/org.obeonetwork.dsl.viewpoint.xtext.support/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 |
6 | ../..
7 | org.obeonetwork.dsl.viewpoint.xtext.support
8 | xtext-support-parent
9 | 1.0.0-SNAPSHOT
10 |
11 |
12 | org.obeonetwork.dsl.viewpoint.xtext.support
13 | eclipse-plugin
14 |
15 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/org.obeonetwork.dsl.viewpoint.xtext.support/src/org/obeonetwork/dsl/viewpoint/xtext/support/Activator.java:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright (c) 2011 Obeo and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Obeo - initial API and implementation
10 | ****************************************************************************/
11 |
12 | package org.obeonetwork.dsl.viewpoint.xtext.support;
13 |
14 | import org.eclipse.core.runtime.IStatus;
15 | import org.eclipse.core.runtime.Status;
16 | import org.eclipse.ui.plugin.AbstractUIPlugin;
17 | import org.osgi.framework.BundleContext;
18 |
19 | /**
20 | * The activator class controls the plug-in life cycle
21 | */
22 | public class Activator extends AbstractUIPlugin {
23 |
24 | // The plug-in ID
25 | public static final String PLUGIN_ID = "org.obeonetwork.dsl.viewpoint.xtext.support";
26 |
27 | // The shared instance
28 | private static Activator plugin;
29 |
30 | /**
31 | * The constructor
32 | */
33 | public Activator() {
34 | }
35 |
36 | /*
37 | * (non-Javadoc)
38 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
39 | */
40 | public void start(BundleContext context) throws Exception {
41 | super.start(context);
42 | plugin = this;
43 | }
44 |
45 | /*
46 | * (non-Javadoc)
47 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
48 | */
49 | public void stop(BundleContext context) throws Exception {
50 | plugin = null;
51 | super.stop(context);
52 | }
53 |
54 | /**
55 | * Returns the shared instance
56 | *
57 | * @return the shared instance
58 | */
59 | public static Activator getDefault() {
60 | return plugin;
61 | }
62 |
63 | public static void logError(Throwable t) {
64 | getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, t.getMessage(), t));
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/org.obeonetwork.dsl.viewpoint.xtext.support/src/org/obeonetwork/dsl/viewpoint/xtext/support/StringUtil.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2009 itemis AG (http://www.itemis.eu) and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *******************************************************************************/
8 | package org.obeonetwork.dsl.viewpoint.xtext.support;
9 |
10 | /**
11 | * @author koehnlein
12 | */
13 | public class StringUtil {
14 |
15 | public static int getNumLines(String s) {
16 | int numLines = 1;
17 | for (char c : s.toCharArray()) {
18 | if (c == '\n') {
19 | ++numLines;
20 | }
21 | }
22 | return numLines;
23 | }
24 |
25 | public static int getMaxColumns(String s) {
26 | int maxColumns = 0;
27 | int currentColumns = 0;
28 | for (char c : s.toCharArray()) {
29 | if (c == '\n') {
30 | maxColumns = Math.max(maxColumns, currentColumns);
31 | currentColumns = 0;
32 | } else {
33 | ++currentColumns;
34 | }
35 | }
36 | return Math.max(currentColumns, maxColumns);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/xtext-support-parent/plugins/org.obeonetwork.dsl.viewpoint.xtext.support/src/org/obeonetwork/dsl/viewpoint/xtext/support/action/OpenXtextEmbeddedEditor.java:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * Copyright (c) 2011 Obeo and others.
3 | * All rights reserved. This program and the accompanying materials
4 | * are made available under the terms of the Eclipse Public License v1.0
5 | * which accompanies this distribution, and is available at
6 | * http://www.eclipse.org/legal/epl-v10.html
7 | *
8 | * Contributors:
9 | * Obeo - initial API and implementation
10 | ****************************************************************************/
11 |
12 | package org.obeonetwork.dsl.viewpoint.xtext.support.action;
13 |
14 | import java.util.Collection;
15 | import java.util.Map;
16 |
17 | import org.eclipse.emf.ecore.EObject;
18 | import org.eclipse.gef.EditPart;
19 | import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
20 | import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
21 | import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
22 | import org.eclipse.sirius.tools.api.ui.IExternalJavaAction;
23 | import org.eclipse.ui.IEditorPart;
24 | import org.eclipse.ui.IWorkbench;
25 | import org.eclipse.ui.IWorkbenchPage;
26 | import org.eclipse.ui.PlatformUI;
27 | import org.obeonetwork.dsl.viewpoint.xtext.support.XtextEmbeddedEditor;
28 |
29 | import com.google.inject.Injector;
30 |
31 | public abstract class OpenXtextEmbeddedEditor implements IExternalJavaAction {
32 |
33 | public boolean canExecute(Collection extends EObject> arg0) {
34 | return true;
35 | }
36 |
37 | public void execute(Collection extends EObject> context,
38 | Map parameters) {
39 | DiagramEditPart diagramEditPart = ((DiagramEditor) getActiveEditor())
40 | .getDiagramEditPart();
41 | for (EObject o : context) {
42 | EditPart editPart = diagramEditPart
43 | .findEditPart(diagramEditPart, o);
44 | if (editPart != null && (editPart instanceof IGraphicalEditPart)) {
45 | openEmbeddedEditor((IGraphicalEditPart) editPart);
46 | break;
47 | }
48 | }
49 |
50 | }
51 |
52 | protected void openEmbeddedEditor(IGraphicalEditPart graphicalEditPart) {
53 | XtextEmbeddedEditor embeddedEditor = new XtextEmbeddedEditor(graphicalEditPart, getInjector());
54 | embeddedEditor.showEditor();
55 | }
56 |
57 | /**
58 | * Return the injector associated to you domain model plug-in.
59 | * @return
60 | */
61 | protected abstract Injector getInjector();
62 |
63 | protected IEditorPart getActiveEditor() {
64 | IWorkbench workbench = PlatformUI.getWorkbench();
65 | IWorkbenchPage page = workbench.getActiveWorkbenchWindow()
66 | .getActivePage();
67 | return page.getActiveEditor();
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/xtext-support-parent/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | org.obeonetwork.dsl.viewpoint.xtext.support
6 | xtext-support-parent
7 | 1.0.0-SNAPSHOT
8 | pom
9 |
10 |
11 | plugins/org.obeonetwork.dsl.viewpoint.xtext.support
12 | features/org.obeonetwork.dsl.viewpoint.feature.xtext.support
13 | features/org.obeonetwork.dsl.viewpoint.xtext.support.update
14 |
15 |
16 |
17 | 0.14.1
18 |
19 |
20 |
21 |
22 | juno
23 | p2
24 | http://download.eclipse.org/releases/juno
25 |
26 |
27 | xtext
28 | p2
29 | http://download.itemis.com/updates
30 |
31 |
32 | obeodesigner
33 | p2
34 | http://www.obeo.fr/download/release/designer/6.1/latest/juno3/update
35 |
36 |
37 | acceleo
38 | p2
39 | http://download.eclipse.org/modeling/m2t/acceleo/updates/releases/3.2
40 |
41 |
42 | Indigo Release
43 | http://www.obeo.fr/download/acceleo/maven/releases/indigo
44 |
45 |
46 | Snapshots
47 | http://www.obeo.fr/download/acceleo/maven/snapshots
48 |
49 |
50 |
51 |
52 |
53 | Indigo Release
54 | http://www.obeo.fr/download/acceleo/maven/releases/indigo
55 |
56 |
57 | Snapshots
58 | http://www.obeo.fr/download/acceleo/maven/snapshots
59 |
60 |
61 |
62 |
63 |
64 |
65 | org.eclipse.tycho
66 | tycho-maven-plugin
67 | ${tycho-version}
68 | true
69 |
70 |
71 |
72 | org.eclipse.tycho
73 | tycho-p2-director-plugin
74 | ${tycho-version}
75 |
76 |
77 | materialize-products
78 |
79 | materialize-products
80 |
81 |
82 |
83 | archive-products
84 |
85 | archive-products
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------