-
Notifications
You must be signed in to change notification settings - Fork 317
/
MultiRuleEnumTestLanguageGrammarAccess.java
301 lines (240 loc) · 11.2 KB
/
MultiRuleEnumTestLanguageGrammarAccess.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
/*******************************************************************************
* Copyright (c) 2011, 2024 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.xtext.enumrules.services;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.List;
import org.eclipse.xtext.Alternatives;
import org.eclipse.xtext.Assignment;
import org.eclipse.xtext.EnumLiteralDeclaration;
import org.eclipse.xtext.EnumRule;
import org.eclipse.xtext.Grammar;
import org.eclipse.xtext.GrammarUtil;
import org.eclipse.xtext.Group;
import org.eclipse.xtext.Keyword;
import org.eclipse.xtext.ParserRule;
import org.eclipse.xtext.RuleCall;
import org.eclipse.xtext.TerminalRule;
import org.eclipse.xtext.common.services.TerminalsGrammarAccess;
import org.eclipse.xtext.service.AbstractElementFinder;
import org.eclipse.xtext.service.GrammarProvider;
@Singleton
public class MultiRuleEnumTestLanguageGrammarAccess extends AbstractElementFinder.AbstractGrammarElementFinder {
public class ModelElements extends AbstractParserRuleElementFinder {
private final ParserRule rule = (ParserRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.xtext.enumrules.MultiRuleEnumTestLanguage.Model");
private final Group cGroup = (Group)rule.eContents().get(1);
private final Keyword cSomeEnumKeyword_0 = (Keyword)cGroup.eContents().get(0);
private final Assignment cAAssignment_1 = (Assignment)cGroup.eContents().get(1);
private final RuleCall cAEnumRuleAEnumRuleCall_1_0 = (RuleCall)cAAssignment_1.eContents().get(0);
private final Assignment cBAssignment_2 = (Assignment)cGroup.eContents().get(2);
private final RuleCall cBEnumRuleBEnumRuleCall_2_0 = (RuleCall)cBAssignment_2.eContents().get(0);
private final Assignment cCAssignment_3 = (Assignment)cGroup.eContents().get(3);
private final RuleCall cCEnumRuleCEnumRuleCall_3_0 = (RuleCall)cCAssignment_3.eContents().get(0);
//Model:
// 'someEnum' a=EnumRuleA b=EnumRuleB c=EnumRuleC
//;
@Override public ParserRule getRule() { return rule; }
//'someEnum' a=EnumRuleA b=EnumRuleB c=EnumRuleC
public Group getGroup() { return cGroup; }
//'someEnum'
public Keyword getSomeEnumKeyword_0() { return cSomeEnumKeyword_0; }
//a=EnumRuleA
public Assignment getAAssignment_1() { return cAAssignment_1; }
//EnumRuleA
public RuleCall getAEnumRuleAEnumRuleCall_1_0() { return cAEnumRuleAEnumRuleCall_1_0; }
//b=EnumRuleB
public Assignment getBAssignment_2() { return cBAssignment_2; }
//EnumRuleB
public RuleCall getBEnumRuleBEnumRuleCall_2_0() { return cBEnumRuleBEnumRuleCall_2_0; }
//c=EnumRuleC
public Assignment getCAssignment_3() { return cCAssignment_3; }
//EnumRuleC
public RuleCall getCEnumRuleCEnumRuleCall_3_0() { return cCEnumRuleCEnumRuleCall_3_0; }
}
public class EnumRuleAElements extends AbstractElementFinder.AbstractEnumRuleElementFinder {
private final EnumRule rule = (EnumRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.xtext.enumrules.MultiRuleEnumTestLanguage.EnumRuleA");
private final Alternatives cAlternatives = (Alternatives)rule.eContents().get(1);
private final EnumLiteralDeclaration cAEnumLiteralDeclaration_0 = (EnumLiteralDeclaration)cAlternatives.eContents().get(0);
private final Keyword cAAKeyword_0_0 = (Keyword)cAEnumLiteralDeclaration_0.eContents().get(0);
private final EnumLiteralDeclaration cBEnumLiteralDeclaration_1 = (EnumLiteralDeclaration)cAlternatives.eContents().get(1);
private final Keyword cBBKeyword_1_0 = (Keyword)cBEnumLiteralDeclaration_1.eContents().get(0);
private final EnumLiteralDeclaration cCEnumLiteralDeclaration_2 = (EnumLiteralDeclaration)cAlternatives.eContents().get(2);
private final Keyword cCCKeyword_2_0 = (Keyword)cCEnumLiteralDeclaration_2.eContents().get(0);
//enum EnumRuleA returns MyEnum:
// A | B | C
//;
public EnumRule getRule() { return rule; }
//A | B | C
public Alternatives getAlternatives() { return cAlternatives; }
//A
public EnumLiteralDeclaration getAEnumLiteralDeclaration_0() { return cAEnumLiteralDeclaration_0; }
public Keyword getAAKeyword_0_0() { return cAAKeyword_0_0; }
//B
public EnumLiteralDeclaration getBEnumLiteralDeclaration_1() { return cBEnumLiteralDeclaration_1; }
public Keyword getBBKeyword_1_0() { return cBBKeyword_1_0; }
//C
public EnumLiteralDeclaration getCEnumLiteralDeclaration_2() { return cCEnumLiteralDeclaration_2; }
public Keyword getCCKeyword_2_0() { return cCCKeyword_2_0; }
}
public class EnumRuleBElements extends AbstractElementFinder.AbstractEnumRuleElementFinder {
private final EnumRule rule = (EnumRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.xtext.enumrules.MultiRuleEnumTestLanguage.EnumRuleB");
private final Alternatives cAlternatives = (Alternatives)rule.eContents().get(1);
private final EnumLiteralDeclaration cCEnumLiteralDeclaration_0 = (EnumLiteralDeclaration)cAlternatives.eContents().get(0);
private final Keyword cCCKeyword_0_0 = (Keyword)cCEnumLiteralDeclaration_0.eContents().get(0);
private final EnumLiteralDeclaration cDEnumLiteralDeclaration_1 = (EnumLiteralDeclaration)cAlternatives.eContents().get(1);
private final Keyword cDDKeyword_1_0 = (Keyword)cDEnumLiteralDeclaration_1.eContents().get(0);
private final EnumLiteralDeclaration cEEnumLiteralDeclaration_2 = (EnumLiteralDeclaration)cAlternatives.eContents().get(2);
private final Keyword cEEKeyword_2_0 = (Keyword)cEEnumLiteralDeclaration_2.eContents().get(0);
//enum EnumRuleB returns MyEnum:
// C | D | E
//;
public EnumRule getRule() { return rule; }
//C | D | E
public Alternatives getAlternatives() { return cAlternatives; }
//C
public EnumLiteralDeclaration getCEnumLiteralDeclaration_0() { return cCEnumLiteralDeclaration_0; }
public Keyword getCCKeyword_0_0() { return cCCKeyword_0_0; }
//D
public EnumLiteralDeclaration getDEnumLiteralDeclaration_1() { return cDEnumLiteralDeclaration_1; }
public Keyword getDDKeyword_1_0() { return cDDKeyword_1_0; }
//E
public EnumLiteralDeclaration getEEnumLiteralDeclaration_2() { return cEEnumLiteralDeclaration_2; }
public Keyword getEEKeyword_2_0() { return cEEKeyword_2_0; }
}
public class EnumRuleCElements extends AbstractElementFinder.AbstractEnumRuleElementFinder {
private final EnumRule rule = (EnumRule) GrammarUtil.findRuleForName(getGrammar(), "org.eclipse.xtext.enumrules.MultiRuleEnumTestLanguage.EnumRuleC");
private final Alternatives cAlternatives = (Alternatives)rule.eContents().get(1);
private final EnumLiteralDeclaration cAEnumLiteralDeclaration_0 = (EnumLiteralDeclaration)cAlternatives.eContents().get(0);
private final Keyword cAAKeyword_0_0 = (Keyword)cAEnumLiteralDeclaration_0.eContents().get(0);
private final EnumLiteralDeclaration cDEnumLiteralDeclaration_1 = (EnumLiteralDeclaration)cAlternatives.eContents().get(1);
private final Keyword cDDKeyword_1_0 = (Keyword)cDEnumLiteralDeclaration_1.eContents().get(0);
private final EnumLiteralDeclaration cBEnumLiteralDeclaration_2 = (EnumLiteralDeclaration)cAlternatives.eContents().get(2);
private final Keyword cBBKeyword_2_0 = (Keyword)cBEnumLiteralDeclaration_2.eContents().get(0);
//enum EnumRuleC returns MyEnum:
// A | D | B
//;
public EnumRule getRule() { return rule; }
//A | D | B
public Alternatives getAlternatives() { return cAlternatives; }
//A
public EnumLiteralDeclaration getAEnumLiteralDeclaration_0() { return cAEnumLiteralDeclaration_0; }
public Keyword getAAKeyword_0_0() { return cAAKeyword_0_0; }
//D
public EnumLiteralDeclaration getDEnumLiteralDeclaration_1() { return cDEnumLiteralDeclaration_1; }
public Keyword getDDKeyword_1_0() { return cDDKeyword_1_0; }
//B
public EnumLiteralDeclaration getBEnumLiteralDeclaration_2() { return cBEnumLiteralDeclaration_2; }
public Keyword getBBKeyword_2_0() { return cBBKeyword_2_0; }
}
private final ModelElements pModel;
private final EnumRuleAElements eEnumRuleA;
private final EnumRuleBElements eEnumRuleB;
private final EnumRuleCElements eEnumRuleC;
private final Grammar grammar;
private final TerminalsGrammarAccess gaTerminals;
@Inject
public MultiRuleEnumTestLanguageGrammarAccess(GrammarProvider grammarProvider,
TerminalsGrammarAccess gaTerminals) {
this.grammar = internalFindGrammar(grammarProvider);
this.gaTerminals = gaTerminals;
this.pModel = new ModelElements();
this.eEnumRuleA = new EnumRuleAElements();
this.eEnumRuleB = new EnumRuleBElements();
this.eEnumRuleC = new EnumRuleCElements();
}
protected Grammar internalFindGrammar(GrammarProvider grammarProvider) {
Grammar grammar = grammarProvider.getGrammar(this);
while (grammar != null) {
if ("org.eclipse.xtext.enumrules.MultiRuleEnumTestLanguage".equals(grammar.getName())) {
return grammar;
}
List<Grammar> grammars = grammar.getUsedGrammars();
if (!grammars.isEmpty()) {
grammar = grammars.iterator().next();
} else {
return null;
}
}
return grammar;
}
@Override
public Grammar getGrammar() {
return grammar;
}
public TerminalsGrammarAccess getTerminalsGrammarAccess() {
return gaTerminals;
}
//Model:
// 'someEnum' a=EnumRuleA b=EnumRuleB c=EnumRuleC
//;
public ModelElements getModelAccess() {
return pModel;
}
public ParserRule getModelRule() {
return getModelAccess().getRule();
}
//enum EnumRuleA returns MyEnum:
// A | B | C
//;
public EnumRuleAElements getEnumRuleAAccess() {
return eEnumRuleA;
}
public EnumRule getEnumRuleARule() {
return getEnumRuleAAccess().getRule();
}
//enum EnumRuleB returns MyEnum:
// C | D | E
//;
public EnumRuleBElements getEnumRuleBAccess() {
return eEnumRuleB;
}
public EnumRule getEnumRuleBRule() {
return getEnumRuleBAccess().getRule();
}
//enum EnumRuleC returns MyEnum:
// A | D | B
//;
public EnumRuleCElements getEnumRuleCAccess() {
return eEnumRuleC;
}
public EnumRule getEnumRuleCRule() {
return getEnumRuleCAccess().getRule();
}
//terminal ID: '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
public TerminalRule getIDRule() {
return gaTerminals.getIDRule();
}
//terminal INT returns ecore::EInt: ('0'..'9')+;
public TerminalRule getINTRule() {
return gaTerminals.getINTRule();
}
//terminal STRING:
// '"' ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|'"') )* '"' |
// "'" ( '\\' . /* 'b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\' */ | !('\\'|"'") )* "'"
// ;
public TerminalRule getSTRINGRule() {
return gaTerminals.getSTRINGRule();
}
//terminal ML_COMMENT : '/*' -> '*/';
public TerminalRule getML_COMMENTRule() {
return gaTerminals.getML_COMMENTRule();
}
//terminal SL_COMMENT : '//' !('\n'|'\r')* ('\r'? '\n')?;
public TerminalRule getSL_COMMENTRule() {
return gaTerminals.getSL_COMMENTRule();
}
//terminal WS : (' '|'\t'|'\r'|'\n')+;
public TerminalRule getWSRule() {
return gaTerminals.getWSRule();
}
//terminal ANY_OTHER: .;
public TerminalRule getANY_OTHERRule() {
return gaTerminals.getANY_OTHERRule();
}
}