diff options
Diffstat (limited to 'Domains/github-graph/src-gen/queries/ConsecutiveClosesWithoutReopen.java')
-rw-r--r-- | Domains/github-graph/src-gen/queries/ConsecutiveClosesWithoutReopen.java | 602 |
1 files changed, 602 insertions, 0 deletions
diff --git a/Domains/github-graph/src-gen/queries/ConsecutiveClosesWithoutReopen.java b/Domains/github-graph/src-gen/queries/ConsecutiveClosesWithoutReopen.java new file mode 100644 index 00000000..9072feaf --- /dev/null +++ b/Domains/github-graph/src-gen/queries/ConsecutiveClosesWithoutReopen.java | |||
@@ -0,0 +1,602 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/github-graph/queries/queries/github.vql | ||
3 | */ | ||
4 | package queries; | ||
5 | |||
6 | import github.Issue; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Objects; | ||
12 | import java.util.Optional; | ||
13 | import java.util.Set; | ||
14 | import java.util.function.Consumer; | ||
15 | import java.util.stream.Collectors; | ||
16 | import java.util.stream.Stream; | ||
17 | import org.apache.log4j.Logger; | ||
18 | import org.eclipse.emf.ecore.EClass; | ||
19 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
20 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
21 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
27 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
28 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
43 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
44 | import queries.CheckAction; | ||
45 | import queries.IsReopen; | ||
46 | |||
47 | /** | ||
48 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
49 | * | ||
50 | * <p>Original source: | ||
51 | * <code><pre> | ||
52 | * //pattern pullRequestOfIssue(i: Issue, pr: PullRequest) { | ||
53 | * // Issue.pullrequest(i, pr); | ||
54 | * //} | ||
55 | * // | ||
56 | * //{@literal @}Constraint(key={i}, severity="error", message="error") | ||
57 | * //pattern mergedIssueWithoutPr(i: Issue){ | ||
58 | * // find checkAction(i, _, Action::MERGED); | ||
59 | * // neg find pullRequestOfIssue(i, _); | ||
60 | * //} | ||
61 | * | ||
62 | * {@literal @}Constraint(key={i}, severity="error", message="error") | ||
63 | * pattern consecutiveClosesWithoutReopen(i: Issue) { | ||
64 | * find checkAction(i, a1, Action::CLOSED); | ||
65 | * find checkAction(i, a2, Action::CLOSED); | ||
66 | * a1 != a2; | ||
67 | * neg find isReopen(i, _); | ||
68 | * } | ||
69 | * </pre></code> | ||
70 | * | ||
71 | * @see Matcher | ||
72 | * @see Match | ||
73 | * | ||
74 | */ | ||
75 | @SuppressWarnings("all") | ||
76 | public final class ConsecutiveClosesWithoutReopen extends BaseGeneratedEMFQuerySpecification<ConsecutiveClosesWithoutReopen.Matcher> { | ||
77 | /** | ||
78 | * Pattern-specific match representation of the queries.consecutiveClosesWithoutReopen pattern, | ||
79 | * to be used in conjunction with {@link Matcher}. | ||
80 | * | ||
81 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
82 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
83 | * usable to represent a match of the pattern in the result of a query, | ||
84 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
85 | * | ||
86 | * @see Matcher | ||
87 | * | ||
88 | */ | ||
89 | public static abstract class Match extends BasePatternMatch { | ||
90 | private Issue fI; | ||
91 | |||
92 | private static List<String> parameterNames = makeImmutableList("i"); | ||
93 | |||
94 | private Match(final Issue pI) { | ||
95 | this.fI = pI; | ||
96 | } | ||
97 | |||
98 | @Override | ||
99 | public Object get(final String parameterName) { | ||
100 | switch(parameterName) { | ||
101 | case "i": return this.fI; | ||
102 | default: return null; | ||
103 | } | ||
104 | } | ||
105 | |||
106 | @Override | ||
107 | public Object get(final int index) { | ||
108 | switch(index) { | ||
109 | case 0: return this.fI; | ||
110 | default: return null; | ||
111 | } | ||
112 | } | ||
113 | |||
114 | public Issue getI() { | ||
115 | return this.fI; | ||
116 | } | ||
117 | |||
118 | @Override | ||
119 | public boolean set(final String parameterName, final Object newValue) { | ||
120 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
121 | if ("i".equals(parameterName) ) { | ||
122 | this.fI = (Issue) newValue; | ||
123 | return true; | ||
124 | } | ||
125 | return false; | ||
126 | } | ||
127 | |||
128 | public void setI(final Issue pI) { | ||
129 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
130 | this.fI = pI; | ||
131 | } | ||
132 | |||
133 | @Override | ||
134 | public String patternName() { | ||
135 | return "queries.consecutiveClosesWithoutReopen"; | ||
136 | } | ||
137 | |||
138 | @Override | ||
139 | public List<String> parameterNames() { | ||
140 | return ConsecutiveClosesWithoutReopen.Match.parameterNames; | ||
141 | } | ||
142 | |||
143 | @Override | ||
144 | public Object[] toArray() { | ||
145 | return new Object[]{fI}; | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public ConsecutiveClosesWithoutReopen.Match toImmutable() { | ||
150 | return isMutable() ? newMatch(fI) : this; | ||
151 | } | ||
152 | |||
153 | @Override | ||
154 | public String prettyPrint() { | ||
155 | StringBuilder result = new StringBuilder(); | ||
156 | result.append("\"i\"=" + prettyPrintValue(fI)); | ||
157 | return result.toString(); | ||
158 | } | ||
159 | |||
160 | @Override | ||
161 | public int hashCode() { | ||
162 | return Objects.hash(fI); | ||
163 | } | ||
164 | |||
165 | @Override | ||
166 | public boolean equals(final Object obj) { | ||
167 | if (this == obj) | ||
168 | return true; | ||
169 | if (obj == null) { | ||
170 | return false; | ||
171 | } | ||
172 | if ((obj instanceof ConsecutiveClosesWithoutReopen.Match)) { | ||
173 | ConsecutiveClosesWithoutReopen.Match other = (ConsecutiveClosesWithoutReopen.Match) obj; | ||
174 | return Objects.equals(fI, other.fI); | ||
175 | } else { | ||
176 | // this should be infrequent | ||
177 | if (!(obj instanceof IPatternMatch)) { | ||
178 | return false; | ||
179 | } | ||
180 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
181 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
182 | } | ||
183 | } | ||
184 | |||
185 | @Override | ||
186 | public ConsecutiveClosesWithoutReopen specification() { | ||
187 | return ConsecutiveClosesWithoutReopen.instance(); | ||
188 | } | ||
189 | |||
190 | /** | ||
191 | * Returns an empty, mutable match. | ||
192 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
193 | * | ||
194 | * @return the empty match. | ||
195 | * | ||
196 | */ | ||
197 | public static ConsecutiveClosesWithoutReopen.Match newEmptyMatch() { | ||
198 | return new Mutable(null); | ||
199 | } | ||
200 | |||
201 | /** | ||
202 | * Returns a mutable (partial) match. | ||
203 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
204 | * | ||
205 | * @param pI the fixed value of pattern parameter i, or null if not bound. | ||
206 | * @return the new, mutable (partial) match object. | ||
207 | * | ||
208 | */ | ||
209 | public static ConsecutiveClosesWithoutReopen.Match newMutableMatch(final Issue pI) { | ||
210 | return new Mutable(pI); | ||
211 | } | ||
212 | |||
213 | /** | ||
214 | * Returns a new (partial) match. | ||
215 | * This can be used e.g. to call the matcher with a partial match. | ||
216 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
217 | * @param pI the fixed value of pattern parameter i, or null if not bound. | ||
218 | * @return the (partial) match object. | ||
219 | * | ||
220 | */ | ||
221 | public static ConsecutiveClosesWithoutReopen.Match newMatch(final Issue pI) { | ||
222 | return new Immutable(pI); | ||
223 | } | ||
224 | |||
225 | private static final class Mutable extends ConsecutiveClosesWithoutReopen.Match { | ||
226 | Mutable(final Issue pI) { | ||
227 | super(pI); | ||
228 | } | ||
229 | |||
230 | @Override | ||
231 | public boolean isMutable() { | ||
232 | return true; | ||
233 | } | ||
234 | } | ||
235 | |||
236 | private static final class Immutable extends ConsecutiveClosesWithoutReopen.Match { | ||
237 | Immutable(final Issue pI) { | ||
238 | super(pI); | ||
239 | } | ||
240 | |||
241 | @Override | ||
242 | public boolean isMutable() { | ||
243 | return false; | ||
244 | } | ||
245 | } | ||
246 | } | ||
247 | |||
248 | /** | ||
249 | * Generated pattern matcher API of the queries.consecutiveClosesWithoutReopen pattern, | ||
250 | * providing pattern-specific query methods. | ||
251 | * | ||
252 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
253 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
254 | * | ||
255 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
256 | * | ||
257 | * <p>Original source: | ||
258 | * <code><pre> | ||
259 | * //pattern pullRequestOfIssue(i: Issue, pr: PullRequest) { | ||
260 | * // Issue.pullrequest(i, pr); | ||
261 | * //} | ||
262 | * // | ||
263 | * //{@literal @}Constraint(key={i}, severity="error", message="error") | ||
264 | * //pattern mergedIssueWithoutPr(i: Issue){ | ||
265 | * // find checkAction(i, _, Action::MERGED); | ||
266 | * // neg find pullRequestOfIssue(i, _); | ||
267 | * //} | ||
268 | * | ||
269 | * {@literal @}Constraint(key={i}, severity="error", message="error") | ||
270 | * pattern consecutiveClosesWithoutReopen(i: Issue) { | ||
271 | * find checkAction(i, a1, Action::CLOSED); | ||
272 | * find checkAction(i, a2, Action::CLOSED); | ||
273 | * a1 != a2; | ||
274 | * neg find isReopen(i, _); | ||
275 | * } | ||
276 | * </pre></code> | ||
277 | * | ||
278 | * @see Match | ||
279 | * @see ConsecutiveClosesWithoutReopen | ||
280 | * | ||
281 | */ | ||
282 | public static class Matcher extends BaseMatcher<ConsecutiveClosesWithoutReopen.Match> { | ||
283 | /** | ||
284 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
285 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
286 | * | ||
287 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
288 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
289 | * | ||
290 | */ | ||
291 | public static ConsecutiveClosesWithoutReopen.Matcher on(final ViatraQueryEngine engine) { | ||
292 | // check if matcher already exists | ||
293 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
294 | if (matcher == null) { | ||
295 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
296 | } | ||
297 | return matcher; | ||
298 | } | ||
299 | |||
300 | /** | ||
301 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
302 | * @return an initialized matcher | ||
303 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
304 | * | ||
305 | */ | ||
306 | public static ConsecutiveClosesWithoutReopen.Matcher create() { | ||
307 | return new Matcher(); | ||
308 | } | ||
309 | |||
310 | private static final int POSITION_I = 0; | ||
311 | |||
312 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ConsecutiveClosesWithoutReopen.Matcher.class); | ||
313 | |||
314 | /** | ||
315 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
316 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
317 | * | ||
318 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
319 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
320 | * | ||
321 | */ | ||
322 | private Matcher() { | ||
323 | super(querySpecification()); | ||
324 | } | ||
325 | |||
326 | /** | ||
327 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
328 | * @param pI the fixed value of pattern parameter i, or null if not bound. | ||
329 | * @return matches represented as a Match object. | ||
330 | * | ||
331 | */ | ||
332 | public Collection<ConsecutiveClosesWithoutReopen.Match> getAllMatches(final Issue pI) { | ||
333 | return rawStreamAllMatches(new Object[]{pI}).collect(Collectors.toSet()); | ||
334 | } | ||
335 | |||
336 | /** | ||
337 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
338 | * </p> | ||
339 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
340 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
341 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
342 | * @param pI the fixed value of pattern parameter i, or null if not bound. | ||
343 | * @return a stream of matches represented as a Match object. | ||
344 | * | ||
345 | */ | ||
346 | public Stream<ConsecutiveClosesWithoutReopen.Match> streamAllMatches(final Issue pI) { | ||
347 | return rawStreamAllMatches(new Object[]{pI}); | ||
348 | } | ||
349 | |||
350 | /** | ||
351 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
352 | * Neither determinism nor randomness of selection is guaranteed. | ||
353 | * @param pI the fixed value of pattern parameter i, or null if not bound. | ||
354 | * @return a match represented as a Match object, or null if no match is found. | ||
355 | * | ||
356 | */ | ||
357 | public Optional<ConsecutiveClosesWithoutReopen.Match> getOneArbitraryMatch(final Issue pI) { | ||
358 | return rawGetOneArbitraryMatch(new Object[]{pI}); | ||
359 | } | ||
360 | |||
361 | /** | ||
362 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
363 | * under any possible substitution of the unspecified parameters (if any). | ||
364 | * @param pI the fixed value of pattern parameter i, or null if not bound. | ||
365 | * @return true if the input is a valid (partial) match of the pattern. | ||
366 | * | ||
367 | */ | ||
368 | public boolean hasMatch(final Issue pI) { | ||
369 | return rawHasMatch(new Object[]{pI}); | ||
370 | } | ||
371 | |||
372 | /** | ||
373 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
374 | * @param pI the fixed value of pattern parameter i, or null if not bound. | ||
375 | * @return the number of pattern matches found. | ||
376 | * | ||
377 | */ | ||
378 | public int countMatches(final Issue pI) { | ||
379 | return rawCountMatches(new Object[]{pI}); | ||
380 | } | ||
381 | |||
382 | /** | ||
383 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
384 | * Neither determinism nor randomness of selection is guaranteed. | ||
385 | * @param pI the fixed value of pattern parameter i, or null if not bound. | ||
386 | * @param processor the action that will process the selected match. | ||
387 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
388 | * | ||
389 | */ | ||
390 | public boolean forOneArbitraryMatch(final Issue pI, final Consumer<? super ConsecutiveClosesWithoutReopen.Match> processor) { | ||
391 | return rawForOneArbitraryMatch(new Object[]{pI}, processor); | ||
392 | } | ||
393 | |||
394 | /** | ||
395 | * Returns a new (partial) match. | ||
396 | * This can be used e.g. to call the matcher with a partial match. | ||
397 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
398 | * @param pI the fixed value of pattern parameter i, or null if not bound. | ||
399 | * @return the (partial) match object. | ||
400 | * | ||
401 | */ | ||
402 | public ConsecutiveClosesWithoutReopen.Match newMatch(final Issue pI) { | ||
403 | return ConsecutiveClosesWithoutReopen.Match.newMatch(pI); | ||
404 | } | ||
405 | |||
406 | /** | ||
407 | * Retrieve the set of values that occur in matches for i. | ||
408 | * @return the Set of all values or empty set if there are no matches | ||
409 | * | ||
410 | */ | ||
411 | protected Stream<Issue> rawStreamAllValuesOfi(final Object[] parameters) { | ||
412 | return rawStreamAllValues(POSITION_I, parameters).map(Issue.class::cast); | ||
413 | } | ||
414 | |||
415 | /** | ||
416 | * Retrieve the set of values that occur in matches for i. | ||
417 | * @return the Set of all values or empty set if there are no matches | ||
418 | * | ||
419 | */ | ||
420 | public Set<Issue> getAllValuesOfi() { | ||
421 | return rawStreamAllValuesOfi(emptyArray()).collect(Collectors.toSet()); | ||
422 | } | ||
423 | |||
424 | /** | ||
425 | * Retrieve the set of values that occur in matches for i. | ||
426 | * @return the Set of all values or empty set if there are no matches | ||
427 | * | ||
428 | */ | ||
429 | public Stream<Issue> streamAllValuesOfi() { | ||
430 | return rawStreamAllValuesOfi(emptyArray()); | ||
431 | } | ||
432 | |||
433 | @Override | ||
434 | protected ConsecutiveClosesWithoutReopen.Match tupleToMatch(final Tuple t) { | ||
435 | try { | ||
436 | return ConsecutiveClosesWithoutReopen.Match.newMatch((Issue) t.get(POSITION_I)); | ||
437 | } catch(ClassCastException e) { | ||
438 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
439 | return null; | ||
440 | } | ||
441 | } | ||
442 | |||
443 | @Override | ||
444 | protected ConsecutiveClosesWithoutReopen.Match arrayToMatch(final Object[] match) { | ||
445 | try { | ||
446 | return ConsecutiveClosesWithoutReopen.Match.newMatch((Issue) match[POSITION_I]); | ||
447 | } catch(ClassCastException e) { | ||
448 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
449 | return null; | ||
450 | } | ||
451 | } | ||
452 | |||
453 | @Override | ||
454 | protected ConsecutiveClosesWithoutReopen.Match arrayToMatchMutable(final Object[] match) { | ||
455 | try { | ||
456 | return ConsecutiveClosesWithoutReopen.Match.newMutableMatch((Issue) match[POSITION_I]); | ||
457 | } catch(ClassCastException e) { | ||
458 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
459 | return null; | ||
460 | } | ||
461 | } | ||
462 | |||
463 | /** | ||
464 | * @return the singleton instance of the query specification of this pattern | ||
465 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
466 | * | ||
467 | */ | ||
468 | public static IQuerySpecification<ConsecutiveClosesWithoutReopen.Matcher> querySpecification() { | ||
469 | return ConsecutiveClosesWithoutReopen.instance(); | ||
470 | } | ||
471 | } | ||
472 | |||
473 | private ConsecutiveClosesWithoutReopen() { | ||
474 | super(GeneratedPQuery.INSTANCE); | ||
475 | } | ||
476 | |||
477 | /** | ||
478 | * @return the singleton instance of the query specification | ||
479 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
480 | * | ||
481 | */ | ||
482 | public static ConsecutiveClosesWithoutReopen instance() { | ||
483 | try{ | ||
484 | return LazyHolder.INSTANCE; | ||
485 | } catch (ExceptionInInitializerError err) { | ||
486 | throw processInitializerError(err); | ||
487 | } | ||
488 | } | ||
489 | |||
490 | @Override | ||
491 | protected ConsecutiveClosesWithoutReopen.Matcher instantiate(final ViatraQueryEngine engine) { | ||
492 | return ConsecutiveClosesWithoutReopen.Matcher.on(engine); | ||
493 | } | ||
494 | |||
495 | @Override | ||
496 | public ConsecutiveClosesWithoutReopen.Matcher instantiate() { | ||
497 | return ConsecutiveClosesWithoutReopen.Matcher.create(); | ||
498 | } | ||
499 | |||
500 | @Override | ||
501 | public ConsecutiveClosesWithoutReopen.Match newEmptyMatch() { | ||
502 | return ConsecutiveClosesWithoutReopen.Match.newEmptyMatch(); | ||
503 | } | ||
504 | |||
505 | @Override | ||
506 | public ConsecutiveClosesWithoutReopen.Match newMatch(final Object... parameters) { | ||
507 | return ConsecutiveClosesWithoutReopen.Match.newMatch((github.Issue) parameters[0]); | ||
508 | } | ||
509 | |||
510 | /** | ||
511 | * Inner class allowing the singleton instance of {@link ConsecutiveClosesWithoutReopen} to be created | ||
512 | * <b>not</b> at the class load time of the outer class, | ||
513 | * but rather at the first call to {@link ConsecutiveClosesWithoutReopen#instance()}. | ||
514 | * | ||
515 | * <p> This workaround is required e.g. to support recursion. | ||
516 | * | ||
517 | */ | ||
518 | private static class LazyHolder { | ||
519 | private static final ConsecutiveClosesWithoutReopen INSTANCE = new ConsecutiveClosesWithoutReopen(); | ||
520 | |||
521 | /** | ||
522 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
523 | * This initialization order is required to support indirect recursion. | ||
524 | * | ||
525 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
526 | * | ||
527 | */ | ||
528 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
529 | |||
530 | public static Object ensureInitialized() { | ||
531 | INSTANCE.ensureInitializedInternal(); | ||
532 | return null; | ||
533 | } | ||
534 | } | ||
535 | |||
536 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
537 | private static final ConsecutiveClosesWithoutReopen.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
538 | |||
539 | private final PParameter parameter_i = new PParameter("i", "github.Issue", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "Issue")), PParameterDirection.INOUT); | ||
540 | |||
541 | private final List<PParameter> parameters = Arrays.asList(parameter_i); | ||
542 | |||
543 | private GeneratedPQuery() { | ||
544 | super(PVisibility.PUBLIC); | ||
545 | } | ||
546 | |||
547 | @Override | ||
548 | public String getFullyQualifiedName() { | ||
549 | return "queries.consecutiveClosesWithoutReopen"; | ||
550 | } | ||
551 | |||
552 | @Override | ||
553 | public List<String> getParameterNames() { | ||
554 | return Arrays.asList("i"); | ||
555 | } | ||
556 | |||
557 | @Override | ||
558 | public List<PParameter> getParameters() { | ||
559 | return parameters; | ||
560 | } | ||
561 | |||
562 | @Override | ||
563 | public Set<PBody> doGetContainedBodies() { | ||
564 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
565 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
566 | { | ||
567 | PBody body = new PBody(this); | ||
568 | PVariable var_i = body.getOrCreateVariableByName("i"); | ||
569 | PVariable var_a1 = body.getOrCreateVariableByName("a1"); | ||
570 | PVariable var_a2 = body.getOrCreateVariableByName("a2"); | ||
571 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
572 | new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue"))); | ||
573 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
574 | new ExportedParameter(body, var_i, parameter_i) | ||
575 | )); | ||
576 | // find checkAction(i, a1, Action::CLOSED) | ||
577 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
578 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("sure.ghtorrent.github", "Action", "CLOSED").getInstance()); | ||
579 | new PositivePatternCall(body, Tuples.flatTupleOf(var_i, var_a1, var__virtual_0_), CheckAction.instance().getInternalQueryRepresentation()); | ||
580 | // find checkAction(i, a2, Action::CLOSED) | ||
581 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
582 | new ConstantValue(body, var__virtual_1_, getEnumLiteral("sure.ghtorrent.github", "Action", "CLOSED").getInstance()); | ||
583 | new PositivePatternCall(body, Tuples.flatTupleOf(var_i, var_a2, var__virtual_1_), CheckAction.instance().getInternalQueryRepresentation()); | ||
584 | // a1 != a2 | ||
585 | new Inequality(body, var_a1, var_a2); | ||
586 | // neg find isReopen(i, _) | ||
587 | new NegativePatternCall(body, Tuples.flatTupleOf(var_i, var___0_), IsReopen.instance().getInternalQueryRepresentation()); | ||
588 | bodies.add(body); | ||
589 | } | ||
590 | { | ||
591 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
592 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
593 | new ParameterReference("i") | ||
594 | })); | ||
595 | annotation.addAttribute("severity", "error"); | ||
596 | annotation.addAttribute("message", "error"); | ||
597 | addAnnotation(annotation); | ||
598 | } | ||
599 | return bodies; | ||
600 | } | ||
601 | } | ||
602 | } | ||