diff options
author | bergmann | 2018-06-04 09:36:10 +0000 |
---|---|---|
committer | bergmann | 2018-06-04 09:36:10 +0000 |
commit | 564a920cdb34206ffd1ea282e1098b24fd64690e (patch) | |
tree | e18dc8afa019f0dcf4fdfa0365f50af3b986632f /query/headless | |
parent | cd4f041af61d163832c31e5a660c9b6b039e21f1 (diff) | |
download | org.eclipse.viatra.examples-564a920cdb34206ffd1ea282e1098b24fd64690e.tar.gz org.eclipse.viatra.examples-564a920cdb34206ffd1ea282e1098b24fd64690e.tar.xz org.eclipse.viatra.examples-564a920cdb34206ffd1ea282e1098b24fd64690e.zip |
Bump compatibility to Viatra 2.0
Diffstat (limited to 'query/headless')
40 files changed, 91 insertions, 5311 deletions
diff --git a/query/headless/org.eclipse.viatra.query.application.queries/.classpath b/query/headless/org.eclipse.viatra.query.application.queries/.classpath index 9a39368..f0c5549 100644 --- a/query/headless/org.eclipse.viatra.query.application.queries/.classpath +++ b/query/headless/org.eclipse.viatra.query.application.queries/.classpath @@ -1,8 +1,8 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="src-gen"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="src-gen"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/query/headless/org.eclipse.viatra.query.application.queries/.settings/org.eclipse.jdt.core.prefs b/query/headless/org.eclipse.viatra.query.application.queries/.settings/org.eclipse.jdt.core.prefs index f287d53..0c68a61 100644 --- a/query/headless/org.eclipse.viatra.query.application.queries/.settings/org.eclipse.jdt.core.prefs +++ b/query/headless/org.eclipse.viatra.query.application.queries/.settings/org.eclipse.jdt.core.prefs @@ -1,7 +1,7 @@ -eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
+eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/query/headless/org.eclipse.viatra.query.application.queries/META-INF/MANIFEST.MF b/query/headless/org.eclipse.viatra.query.application.queries/META-INF/MANIFEST.MF index 0a72467..d584a50 100644 --- a/query/headless/org.eclipse.viatra.query.application.queries/META-INF/MANIFEST.MF +++ b/query/headless/org.eclipse.viatra.query.application.queries/META-INF/MANIFEST.MF @@ -3,12 +3,11 @@ Bundle-ManifestVersion: 2 Bundle-Name: VIATRA Headless Example Bundle-SymbolicName: org.eclipse.viatra.query.application.queries;singleton:=true Bundle-Version: 1.2.0.qualifier -Export-Package: org.eclipse.viatra.query.application.queries, - org.eclipse.viatra.query.application.queries.util +Export-Package: org.eclipse.viatra.query.application.queries Require-Bundle: org.eclipse.pde.core, - org.eclipse.emf.ecore, - org.eclipse.emf.transaction, - org.eclipse.xtext.xbase.lib, - org.eclipse.viatra.query.runtime;bundle-version="[1.2.0,2.0.0)" -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 + org.eclipse.emf.ecore, + org.eclipse.emf.transaction, + org.eclipse.xtext.xbase.lib, + org.eclipse.viatra.query.runtime;bundle-version="[2.0.0,3.0.0)" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: org.apache.log4j diff --git a/query/headless/org.eclipse.viatra.query.application.queries/plugin.xml b/query/headless/org.eclipse.viatra.query.application.queries/plugin.xml index 305a031..a446aad 100644 --- a/query/headless/org.eclipse.viatra.query.application.queries/plugin.xml +++ b/query/headless/org.eclipse.viatra.query.application.queries/plugin.xml @@ -1,5 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?><plugin> <extension id="org.eclipse.viatra.query.application.queries.HeadlessQueries" point="org.eclipse.viatra.query.runtime.queryspecification"> - <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:org.eclipse.viatra.query.application.queries.HeadlessQueries" id="org.eclipse.viatra.query.application.queries.HeadlessQueries"/> + <group group="org.eclipse.viatra.query.runtime.extensibility.SingletonExtensionFactory:org.eclipse.viatra.query.application.queries.HeadlessQueries" id="org.eclipse.viatra.query.application.queries.HeadlessQueries"> + <query-specification fqn="org.eclipse.viatra.query.application.queries.eClassNames"/> + <query-specification fqn="org.eclipse.viatra.query.application.queries.eClassNamesKeyword"/> + <query-specification fqn="org.eclipse.viatra.query.application.queries.eObject"/> + <query-specification fqn="org.eclipse.viatra.query.application.queries.classesInPackage"/> + <query-specification fqn="org.eclipse.viatra.query.application.queries.subPackage"/> + <query-specification fqn="org.eclipse.viatra.query.application.queries.classesInPackageHierarchy"/> + <query-specification fqn="org.eclipse.viatra.query.application.queries.ePackage"/> + <query-specification fqn="org.eclipse.viatra.query.application.queries.eClass"/> + </group> </extension> </plugin> diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/.gitignore b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore
\ No newline at end of file diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/.gitignore b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/.gitignore deleted file mode 100644 index 4c9fa50..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -/.ClassesInPackageHierarchyMatch.java._trace -/.ClassesInPackageHierarchyMatcher.java._trace -/.ClassesInPackageMatch.java._trace -/.ClassesInPackageMatcher.java._trace -/.EClassMatch.java._trace -/.EClassMatcher.java._trace -/.EClassNamesKeywordMatch.java._trace -/.EClassNamesKeywordMatcher.java._trace -/.EClassNamesMatch.java._trace -/.EClassNamesMatcher.java._trace -/.EObjectMatch.java._trace -/.EObjectMatcher.java._trace -/.EPackageMatch.java._trace -/.EPackageMatcher.java._trace -/.HeadlessQueries.java._trace -/.SubPackageMatch.java._trace -/.SubPackageMatcher.java._trace diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageHierarchyMatch.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageHierarchyMatch.java deleted file mode 100644 index cf2d46a..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageHierarchyMatch.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Arrays; -import java.util.List; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.viatra.query.application.queries.util.ClassesInPackageHierarchyQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IPatternMatch; -import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; - -/** - * Pattern-specific match representation of the org.eclipse.viatra.query.application.queries.classesInPackageHierarchy pattern, - * to be used in conjunction with {@link ClassesInPackageHierarchyMatcher}. - * - * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. - * Each instance is a (possibly partial) substitution of pattern parameters, - * usable to represent a match of the pattern in the result of a query, - * or to specify the bound (fixed) input parameters when issuing a query. - * - * @see ClassesInPackageHierarchyMatcher - * @see ClassesInPackageHierarchyProcessor - * - */ -@SuppressWarnings("all") -public abstract class ClassesInPackageHierarchyMatch extends BasePatternMatch { - private EPackage fRootP; - - private EClass fContainedClass; - - private static List<String> parameterNames = makeImmutableList("rootP", "containedClass"); - - private ClassesInPackageHierarchyMatch(final EPackage pRootP, final EClass pContainedClass) { - this.fRootP = pRootP; - this.fContainedClass = pContainedClass; - } - - @Override - public Object get(final String parameterName) { - if ("rootP".equals(parameterName)) return this.fRootP; - if ("containedClass".equals(parameterName)) return this.fContainedClass; - return null; - } - - public EPackage getRootP() { - return this.fRootP; - } - - public EClass getContainedClass() { - return this.fContainedClass; - } - - @Override - public boolean set(final String parameterName, final Object newValue) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - if ("rootP".equals(parameterName) ) { - this.fRootP = (EPackage) newValue; - return true; - } - if ("containedClass".equals(parameterName) ) { - this.fContainedClass = (EClass) newValue; - return true; - } - return false; - } - - public void setRootP(final EPackage pRootP) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fRootP = pRootP; - } - - public void setContainedClass(final EClass pContainedClass) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fContainedClass = pContainedClass; - } - - @Override - public String patternName() { - return "org.eclipse.viatra.query.application.queries.classesInPackageHierarchy"; - } - - @Override - public List<String> parameterNames() { - return ClassesInPackageHierarchyMatch.parameterNames; - } - - @Override - public Object[] toArray() { - return new Object[]{fRootP, fContainedClass}; - } - - @Override - public ClassesInPackageHierarchyMatch toImmutable() { - return isMutable() ? newMatch(fRootP, fContainedClass) : this; - } - - @Override - public String prettyPrint() { - StringBuilder result = new StringBuilder(); - result.append("\"rootP\"=" + prettyPrintValue(fRootP) + ", "); - - result.append("\"containedClass\"=" + prettyPrintValue(fContainedClass) - ); - return result.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((fRootP == null) ? 0 : fRootP.hashCode()); - result = prime * result + ((fContainedClass == null) ? 0 : fContainedClass.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (!(obj instanceof ClassesInPackageHierarchyMatch)) { // this should be infrequent - if (obj == null) { - return false; - } - if (!(obj instanceof IPatternMatch)) { - return false; - } - IPatternMatch otherSig = (IPatternMatch) obj; - if (!specification().equals(otherSig.specification())) - return false; - return Arrays.deepEquals(toArray(), otherSig.toArray()); - } - ClassesInPackageHierarchyMatch other = (ClassesInPackageHierarchyMatch) obj; - if (fRootP == null) {if (other.fRootP != null) return false;} - else if (!fRootP.equals(other.fRootP)) return false; - if (fContainedClass == null) {if (other.fContainedClass != null) return false;} - else if (!fContainedClass.equals(other.fContainedClass)) return false; - return true; - } - - @Override - public ClassesInPackageHierarchyQuerySpecification specification() { - try { - return ClassesInPackageHierarchyQuerySpecification.instance(); - } catch (ViatraQueryException ex) { - // This cannot happen, as the match object can only be instantiated if the query specification exists - throw new IllegalStateException (ex); - } - } - - /** - * Returns an empty, mutable match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @return the empty match. - * - */ - public static ClassesInPackageHierarchyMatch newEmptyMatch() { - return new Mutable(null, null); - } - - /** - * Returns a mutable (partial) match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @param pRootP the fixed value of pattern parameter rootP, or null if not bound. - * @param pContainedClass the fixed value of pattern parameter containedClass, or null if not bound. - * @return the new, mutable (partial) match object. - * - */ - public static ClassesInPackageHierarchyMatch newMutableMatch(final EPackage pRootP, final EClass pContainedClass) { - return new Mutable(pRootP, pContainedClass); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pRootP the fixed value of pattern parameter rootP, or null if not bound. - * @param pContainedClass the fixed value of pattern parameter containedClass, or null if not bound. - * @return the (partial) match object. - * - */ - public static ClassesInPackageHierarchyMatch newMatch(final EPackage pRootP, final EClass pContainedClass) { - return new Immutable(pRootP, pContainedClass); - } - - private static final class Mutable extends ClassesInPackageHierarchyMatch { - Mutable(final EPackage pRootP, final EClass pContainedClass) { - super(pRootP, pContainedClass); - } - - @Override - public boolean isMutable() { - return true; - } - } - - private static final class Immutable extends ClassesInPackageHierarchyMatch { - Immutable(final EPackage pRootP, final EClass pContainedClass) { - super(pRootP, pContainedClass); - } - - @Override - public boolean isMutable() { - return false; - } - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageHierarchyMatcher.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageHierarchyMatcher.java deleted file mode 100644 index 8f61ca4..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageHierarchyMatcher.java +++ /dev/null @@ -1,307 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import org.apache.log4j.Logger; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.viatra.query.application.queries.ClassesInPackageHierarchyMatch; -import org.eclipse.viatra.query.application.queries.util.ClassesInPackageHierarchyQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; -import org.eclipse.viatra.query.runtime.api.IQuerySpecification; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; - -/** - * Generated pattern matcher API of the org.eclipse.viatra.query.application.queries.classesInPackageHierarchy pattern, - * providing pattern-specific query methods. - * - * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, - * e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)}. - * - * <p>Matches of the pattern will be represented as {@link ClassesInPackageHierarchyMatch}. - * - * <p>Original source: - * <code><pre> - * {@literal @}Edge(source = rootP, target = containedClass, label = "classIn+") - * {@literal @}Format(color = "#0033ff") - * pattern classesInPackageHierarchy(rootP: EPackage, containedClass: EClass) - * { - * find classesInPackage(rootP,containedClass); - * } or { - * find subPackage+(rootP,somePackage); - * find classesInPackage(somePackage,containedClass); - * } - * </pre></code> - * - * @see ClassesInPackageHierarchyMatch - * @see ClassesInPackageHierarchyProcessor - * @see ClassesInPackageHierarchyQuerySpecification - * - */ -@SuppressWarnings("all") -public class ClassesInPackageHierarchyMatcher extends BaseMatcher<ClassesInPackageHierarchyMatch> { - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * - */ - public static ClassesInPackageHierarchyMatcher on(final ViatraQueryEngine engine) throws ViatraQueryException { - // check if matcher already exists - ClassesInPackageHierarchyMatcher matcher = engine.getExistingMatcher(querySpecification()); - if (matcher == null) { - matcher = new ClassesInPackageHierarchyMatcher(engine); - // do not have to "put" it into engine.matchers, reportMatcherInitialized() will take care of it - } - return matcher; - } - - private final static int POSITION_ROOTP = 0; - - private final static int POSITION_CONTAINEDCLASS = 1; - - private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ClassesInPackageHierarchyMatcher.class); - - /** - * Initializes the pattern matcher over a given EMF model root (recommended: Resource or ResourceSet). - * If a pattern matcher is already constructed with the same root, only a light-weight reference is returned. - * The scope of pattern matching will be the given EMF model root and below (see FAQ for more precise definition). - * The match set will be incrementally refreshed upon updates from this scope. - * <p>The matcher will be created within the managed {@link ViatraQueryEngine} belonging to the EMF model root, so - * multiple matchers will reuse the same engine and benefit from increased performance and reduced memory footprint. - * @param emfRoot the root of the EMF containment hierarchy where the pattern matcher will operate. Recommended: Resource or ResourceSet. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead, e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)} - * - */ - @Deprecated - public ClassesInPackageHierarchyMatcher(final Notifier emfRoot) throws ViatraQueryException { - this(ViatraQueryEngine.on(emfRoot)); - } - - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead - * - */ - @Deprecated - public ClassesInPackageHierarchyMatcher(final ViatraQueryEngine engine) throws ViatraQueryException { - super(engine, querySpecification()); - } - - /** - * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pRootP the fixed value of pattern parameter rootP, or null if not bound. - * @param pContainedClass the fixed value of pattern parameter containedClass, or null if not bound. - * @return matches represented as a ClassesInPackageHierarchyMatch object. - * - */ - public Collection<ClassesInPackageHierarchyMatch> getAllMatches(final EPackage pRootP, final EClass pContainedClass) { - return rawGetAllMatches(new Object[]{pRootP, pContainedClass}); - } - - /** - * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pRootP the fixed value of pattern parameter rootP, or null if not bound. - * @param pContainedClass the fixed value of pattern parameter containedClass, or null if not bound. - * @return a match represented as a ClassesInPackageHierarchyMatch object, or null if no match is found. - * - */ - public ClassesInPackageHierarchyMatch getOneArbitraryMatch(final EPackage pRootP, final EClass pContainedClass) { - return rawGetOneArbitraryMatch(new Object[]{pRootP, pContainedClass}); - } - - /** - * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, - * under any possible substitution of the unspecified parameters (if any). - * @param pRootP the fixed value of pattern parameter rootP, or null if not bound. - * @param pContainedClass the fixed value of pattern parameter containedClass, or null if not bound. - * @return true if the input is a valid (partial) match of the pattern. - * - */ - public boolean hasMatch(final EPackage pRootP, final EClass pContainedClass) { - return rawHasMatch(new Object[]{pRootP, pContainedClass}); - } - - /** - * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pRootP the fixed value of pattern parameter rootP, or null if not bound. - * @param pContainedClass the fixed value of pattern parameter containedClass, or null if not bound. - * @return the number of pattern matches found. - * - */ - public int countMatches(final EPackage pRootP, final EClass pContainedClass) { - return rawCountMatches(new Object[]{pRootP, pContainedClass}); - } - - /** - * Executes the given processor on each match of the pattern that conforms to the given fixed values of some parameters. - * @param pRootP the fixed value of pattern parameter rootP, or null if not bound. - * @param pContainedClass the fixed value of pattern parameter containedClass, or null if not bound. - * @param processor the action that will process each pattern match. - * - */ - public void forEachMatch(final EPackage pRootP, final EClass pContainedClass, final IMatchProcessor<? super ClassesInPackageHierarchyMatch> processor) { - rawForEachMatch(new Object[]{pRootP, pContainedClass}, processor); - } - - /** - * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pRootP the fixed value of pattern parameter rootP, or null if not bound. - * @param pContainedClass the fixed value of pattern parameter containedClass, or null if not bound. - * @param processor the action that will process the selected match. - * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked - * - */ - public boolean forOneArbitraryMatch(final EPackage pRootP, final EClass pContainedClass, final IMatchProcessor<? super ClassesInPackageHierarchyMatch> processor) { - return rawForOneArbitraryMatch(new Object[]{pRootP, pContainedClass}, processor); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pRootP the fixed value of pattern parameter rootP, or null if not bound. - * @param pContainedClass the fixed value of pattern parameter containedClass, or null if not bound. - * @return the (partial) match object. - * - */ - public ClassesInPackageHierarchyMatch newMatch(final EPackage pRootP, final EClass pContainedClass) { - return ClassesInPackageHierarchyMatch.newMatch(pRootP, pContainedClass); - } - - /** - * Retrieve the set of values that occur in matches for rootP. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - protected Set<EPackage> rawAccumulateAllValuesOfrootP(final Object[] parameters) { - Set<EPackage> results = new HashSet<EPackage>(); - rawAccumulateAllValues(POSITION_ROOTP, parameters, results); - return results; - } - - /** - * Retrieve the set of values that occur in matches for rootP. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EPackage> getAllValuesOfrootP() { - return rawAccumulateAllValuesOfrootP(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for rootP. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EPackage> getAllValuesOfrootP(final ClassesInPackageHierarchyMatch partialMatch) { - return rawAccumulateAllValuesOfrootP(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for rootP. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EPackage> getAllValuesOfrootP(final EClass pContainedClass) { - return rawAccumulateAllValuesOfrootP(new Object[]{ - null, - pContainedClass - }); - } - - /** - * Retrieve the set of values that occur in matches for containedClass. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - protected Set<EClass> rawAccumulateAllValuesOfcontainedClass(final Object[] parameters) { - Set<EClass> results = new HashSet<EClass>(); - rawAccumulateAllValues(POSITION_CONTAINEDCLASS, parameters, results); - return results; - } - - /** - * Retrieve the set of values that occur in matches for containedClass. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EClass> getAllValuesOfcontainedClass() { - return rawAccumulateAllValuesOfcontainedClass(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for containedClass. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EClass> getAllValuesOfcontainedClass(final ClassesInPackageHierarchyMatch partialMatch) { - return rawAccumulateAllValuesOfcontainedClass(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for containedClass. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EClass> getAllValuesOfcontainedClass(final EPackage pRootP) { - return rawAccumulateAllValuesOfcontainedClass(new Object[]{ - pRootP, - null - }); - } - - @Override - protected ClassesInPackageHierarchyMatch tupleToMatch(final Tuple t) { - try { - return ClassesInPackageHierarchyMatch.newMatch((EPackage) t.get(POSITION_ROOTP), (EClass) t.get(POSITION_CONTAINEDCLASS)); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in tuple not properly typed!",e); - return null; - } - } - - @Override - protected ClassesInPackageHierarchyMatch arrayToMatch(final Object[] match) { - try { - return ClassesInPackageHierarchyMatch.newMatch((EPackage) match[POSITION_ROOTP], (EClass) match[POSITION_CONTAINEDCLASS]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - @Override - protected ClassesInPackageHierarchyMatch arrayToMatchMutable(final Object[] match) { - try { - return ClassesInPackageHierarchyMatch.newMutableMatch((EPackage) match[POSITION_ROOTP], (EClass) match[POSITION_CONTAINEDCLASS]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - /** - * @return the singleton instance of the query specification of this pattern - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static IQuerySpecification<ClassesInPackageHierarchyMatcher> querySpecification() throws ViatraQueryException { - return ClassesInPackageHierarchyQuerySpecification.instance(); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageMatch.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageMatch.java deleted file mode 100644 index d700694..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageMatch.java +++ /dev/null @@ -1,208 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Arrays; -import java.util.List; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.viatra.query.application.queries.util.ClassesInPackageQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IPatternMatch; -import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; - -/** - * Pattern-specific match representation of the org.eclipse.viatra.query.application.queries.classesInPackage pattern, - * to be used in conjunction with {@link ClassesInPackageMatcher}. - * - * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. - * Each instance is a (possibly partial) substitution of pattern parameters, - * usable to represent a match of the pattern in the result of a query, - * or to specify the bound (fixed) input parameters when issuing a query. - * - * @see ClassesInPackageMatcher - * @see ClassesInPackageProcessor - * - */ -@SuppressWarnings("all") -public abstract class ClassesInPackageMatch extends BasePatternMatch { - private EPackage fP; - - private EClass fEc; - - private static List<String> parameterNames = makeImmutableList("p", "ec"); - - private ClassesInPackageMatch(final EPackage pP, final EClass pEc) { - this.fP = pP; - this.fEc = pEc; - } - - @Override - public Object get(final String parameterName) { - if ("p".equals(parameterName)) return this.fP; - if ("ec".equals(parameterName)) return this.fEc; - return null; - } - - public EPackage getP() { - return this.fP; - } - - public EClass getEc() { - return this.fEc; - } - - @Override - public boolean set(final String parameterName, final Object newValue) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - if ("p".equals(parameterName) ) { - this.fP = (EPackage) newValue; - return true; - } - if ("ec".equals(parameterName) ) { - this.fEc = (EClass) newValue; - return true; - } - return false; - } - - public void setP(final EPackage pP) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fP = pP; - } - - public void setEc(final EClass pEc) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fEc = pEc; - } - - @Override - public String patternName() { - return "org.eclipse.viatra.query.application.queries.classesInPackage"; - } - - @Override - public List<String> parameterNames() { - return ClassesInPackageMatch.parameterNames; - } - - @Override - public Object[] toArray() { - return new Object[]{fP, fEc}; - } - - @Override - public ClassesInPackageMatch toImmutable() { - return isMutable() ? newMatch(fP, fEc) : this; - } - - @Override - public String prettyPrint() { - StringBuilder result = new StringBuilder(); - result.append("\"p\"=" + prettyPrintValue(fP) + ", "); - - result.append("\"ec\"=" + prettyPrintValue(fEc) - ); - return result.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((fP == null) ? 0 : fP.hashCode()); - result = prime * result + ((fEc == null) ? 0 : fEc.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (!(obj instanceof ClassesInPackageMatch)) { // this should be infrequent - if (obj == null) { - return false; - } - if (!(obj instanceof IPatternMatch)) { - return false; - } - IPatternMatch otherSig = (IPatternMatch) obj; - if (!specification().equals(otherSig.specification())) - return false; - return Arrays.deepEquals(toArray(), otherSig.toArray()); - } - ClassesInPackageMatch other = (ClassesInPackageMatch) obj; - if (fP == null) {if (other.fP != null) return false;} - else if (!fP.equals(other.fP)) return false; - if (fEc == null) {if (other.fEc != null) return false;} - else if (!fEc.equals(other.fEc)) return false; - return true; - } - - @Override - public ClassesInPackageQuerySpecification specification() { - try { - return ClassesInPackageQuerySpecification.instance(); - } catch (ViatraQueryException ex) { - // This cannot happen, as the match object can only be instantiated if the query specification exists - throw new IllegalStateException (ex); - } - } - - /** - * Returns an empty, mutable match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @return the empty match. - * - */ - public static ClassesInPackageMatch newEmptyMatch() { - return new Mutable(null, null); - } - - /** - * Returns a mutable (partial) match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @return the new, mutable (partial) match object. - * - */ - public static ClassesInPackageMatch newMutableMatch(final EPackage pP, final EClass pEc) { - return new Mutable(pP, pEc); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @return the (partial) match object. - * - */ - public static ClassesInPackageMatch newMatch(final EPackage pP, final EClass pEc) { - return new Immutable(pP, pEc); - } - - private static final class Mutable extends ClassesInPackageMatch { - Mutable(final EPackage pP, final EClass pEc) { - super(pP, pEc); - } - - @Override - public boolean isMutable() { - return true; - } - } - - private static final class Immutable extends ClassesInPackageMatch { - Immutable(final EPackage pP, final EClass pEc) { - super(pP, pEc); - } - - @Override - public boolean isMutable() { - return false; - } - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageMatcher.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageMatcher.java deleted file mode 100644 index 884bfcf..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageMatcher.java +++ /dev/null @@ -1,300 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import org.apache.log4j.Logger; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.viatra.query.application.queries.ClassesInPackageMatch; -import org.eclipse.viatra.query.application.queries.util.ClassesInPackageQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; -import org.eclipse.viatra.query.runtime.api.IQuerySpecification; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; - -/** - * Generated pattern matcher API of the org.eclipse.viatra.query.application.queries.classesInPackage pattern, - * providing pattern-specific query methods. - * - * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, - * e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)}. - * - * <p>Matches of the pattern will be represented as {@link ClassesInPackageMatch}. - * - * <p>Original source: - * <code><pre> - * {@literal @}Edge(source = p, target = ec, label = "classIn") - * pattern classesInPackage(p : EPackage, ec: EClass) { EPackage.eClassifiers(p,ec); } - * </pre></code> - * - * @see ClassesInPackageMatch - * @see ClassesInPackageProcessor - * @see ClassesInPackageQuerySpecification - * - */ -@SuppressWarnings("all") -public class ClassesInPackageMatcher extends BaseMatcher<ClassesInPackageMatch> { - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * - */ - public static ClassesInPackageMatcher on(final ViatraQueryEngine engine) throws ViatraQueryException { - // check if matcher already exists - ClassesInPackageMatcher matcher = engine.getExistingMatcher(querySpecification()); - if (matcher == null) { - matcher = new ClassesInPackageMatcher(engine); - // do not have to "put" it into engine.matchers, reportMatcherInitialized() will take care of it - } - return matcher; - } - - private final static int POSITION_P = 0; - - private final static int POSITION_EC = 1; - - private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ClassesInPackageMatcher.class); - - /** - * Initializes the pattern matcher over a given EMF model root (recommended: Resource or ResourceSet). - * If a pattern matcher is already constructed with the same root, only a light-weight reference is returned. - * The scope of pattern matching will be the given EMF model root and below (see FAQ for more precise definition). - * The match set will be incrementally refreshed upon updates from this scope. - * <p>The matcher will be created within the managed {@link ViatraQueryEngine} belonging to the EMF model root, so - * multiple matchers will reuse the same engine and benefit from increased performance and reduced memory footprint. - * @param emfRoot the root of the EMF containment hierarchy where the pattern matcher will operate. Recommended: Resource or ResourceSet. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead, e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)} - * - */ - @Deprecated - public ClassesInPackageMatcher(final Notifier emfRoot) throws ViatraQueryException { - this(ViatraQueryEngine.on(emfRoot)); - } - - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead - * - */ - @Deprecated - public ClassesInPackageMatcher(final ViatraQueryEngine engine) throws ViatraQueryException { - super(engine, querySpecification()); - } - - /** - * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @return matches represented as a ClassesInPackageMatch object. - * - */ - public Collection<ClassesInPackageMatch> getAllMatches(final EPackage pP, final EClass pEc) { - return rawGetAllMatches(new Object[]{pP, pEc}); - } - - /** - * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @return a match represented as a ClassesInPackageMatch object, or null if no match is found. - * - */ - public ClassesInPackageMatch getOneArbitraryMatch(final EPackage pP, final EClass pEc) { - return rawGetOneArbitraryMatch(new Object[]{pP, pEc}); - } - - /** - * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, - * under any possible substitution of the unspecified parameters (if any). - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @return true if the input is a valid (partial) match of the pattern. - * - */ - public boolean hasMatch(final EPackage pP, final EClass pEc) { - return rawHasMatch(new Object[]{pP, pEc}); - } - - /** - * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @return the number of pattern matches found. - * - */ - public int countMatches(final EPackage pP, final EClass pEc) { - return rawCountMatches(new Object[]{pP, pEc}); - } - - /** - * Executes the given processor on each match of the pattern that conforms to the given fixed values of some parameters. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @param processor the action that will process each pattern match. - * - */ - public void forEachMatch(final EPackage pP, final EClass pEc, final IMatchProcessor<? super ClassesInPackageMatch> processor) { - rawForEachMatch(new Object[]{pP, pEc}, processor); - } - - /** - * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @param processor the action that will process the selected match. - * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked - * - */ - public boolean forOneArbitraryMatch(final EPackage pP, final EClass pEc, final IMatchProcessor<? super ClassesInPackageMatch> processor) { - return rawForOneArbitraryMatch(new Object[]{pP, pEc}, processor); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @return the (partial) match object. - * - */ - public ClassesInPackageMatch newMatch(final EPackage pP, final EClass pEc) { - return ClassesInPackageMatch.newMatch(pP, pEc); - } - - /** - * Retrieve the set of values that occur in matches for p. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - protected Set<EPackage> rawAccumulateAllValuesOfp(final Object[] parameters) { - Set<EPackage> results = new HashSet<EPackage>(); - rawAccumulateAllValues(POSITION_P, parameters, results); - return results; - } - - /** - * Retrieve the set of values that occur in matches for p. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EPackage> getAllValuesOfp() { - return rawAccumulateAllValuesOfp(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for p. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EPackage> getAllValuesOfp(final ClassesInPackageMatch partialMatch) { - return rawAccumulateAllValuesOfp(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for p. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EPackage> getAllValuesOfp(final EClass pEc) { - return rawAccumulateAllValuesOfp(new Object[]{ - null, - pEc - }); - } - - /** - * Retrieve the set of values that occur in matches for ec. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - protected Set<EClass> rawAccumulateAllValuesOfec(final Object[] parameters) { - Set<EClass> results = new HashSet<EClass>(); - rawAccumulateAllValues(POSITION_EC, parameters, results); - return results; - } - - /** - * Retrieve the set of values that occur in matches for ec. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EClass> getAllValuesOfec() { - return rawAccumulateAllValuesOfec(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for ec. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EClass> getAllValuesOfec(final ClassesInPackageMatch partialMatch) { - return rawAccumulateAllValuesOfec(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for ec. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EClass> getAllValuesOfec(final EPackage pP) { - return rawAccumulateAllValuesOfec(new Object[]{ - pP, - null - }); - } - - @Override - protected ClassesInPackageMatch tupleToMatch(final Tuple t) { - try { - return ClassesInPackageMatch.newMatch((EPackage) t.get(POSITION_P), (EClass) t.get(POSITION_EC)); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in tuple not properly typed!",e); - return null; - } - } - - @Override - protected ClassesInPackageMatch arrayToMatch(final Object[] match) { - try { - return ClassesInPackageMatch.newMatch((EPackage) match[POSITION_P], (EClass) match[POSITION_EC]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - @Override - protected ClassesInPackageMatch arrayToMatchMutable(final Object[] match) { - try { - return ClassesInPackageMatch.newMutableMatch((EPackage) match[POSITION_P], (EClass) match[POSITION_EC]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - /** - * @return the singleton instance of the query specification of this pattern - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static IQuerySpecification<ClassesInPackageMatcher> querySpecification() throws ViatraQueryException { - return ClassesInPackageQuerySpecification.instance(); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassMatch.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassMatch.java deleted file mode 100644 index e92d3d6..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassMatch.java +++ /dev/null @@ -1,183 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Arrays; -import java.util.List; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.viatra.query.application.queries.util.EClassQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IPatternMatch; -import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; - -/** - * Pattern-specific match representation of the org.eclipse.viatra.query.application.queries.eClass pattern, - * to be used in conjunction with {@link EClassMatcher}. - * - * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. - * Each instance is a (possibly partial) substitution of pattern parameters, - * usable to represent a match of the pattern in the result of a query, - * or to specify the bound (fixed) input parameters when issuing a query. - * - * @see EClassMatcher - * @see EClassProcessor - * - */ -@SuppressWarnings("all") -public abstract class EClassMatch extends BasePatternMatch { - private EClass fEc; - - private static List<String> parameterNames = makeImmutableList("ec"); - - private EClassMatch(final EClass pEc) { - this.fEc = pEc; - } - - @Override - public Object get(final String parameterName) { - if ("ec".equals(parameterName)) return this.fEc; - return null; - } - - public EClass getEc() { - return this.fEc; - } - - @Override - public boolean set(final String parameterName, final Object newValue) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - if ("ec".equals(parameterName) ) { - this.fEc = (EClass) newValue; - return true; - } - return false; - } - - public void setEc(final EClass pEc) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fEc = pEc; - } - - @Override - public String patternName() { - return "org.eclipse.viatra.query.application.queries.eClass"; - } - - @Override - public List<String> parameterNames() { - return EClassMatch.parameterNames; - } - - @Override - public Object[] toArray() { - return new Object[]{fEc}; - } - - @Override - public EClassMatch toImmutable() { - return isMutable() ? newMatch(fEc) : this; - } - - @Override - public String prettyPrint() { - StringBuilder result = new StringBuilder(); - result.append("\"ec\"=" + prettyPrintValue(fEc) - ); - return result.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((fEc == null) ? 0 : fEc.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (!(obj instanceof EClassMatch)) { // this should be infrequent - if (obj == null) { - return false; - } - if (!(obj instanceof IPatternMatch)) { - return false; - } - IPatternMatch otherSig = (IPatternMatch) obj; - if (!specification().equals(otherSig.specification())) - return false; - return Arrays.deepEquals(toArray(), otherSig.toArray()); - } - EClassMatch other = (EClassMatch) obj; - if (fEc == null) {if (other.fEc != null) return false;} - else if (!fEc.equals(other.fEc)) return false; - return true; - } - - @Override - public EClassQuerySpecification specification() { - try { - return EClassQuerySpecification.instance(); - } catch (ViatraQueryException ex) { - // This cannot happen, as the match object can only be instantiated if the query specification exists - throw new IllegalStateException (ex); - } - } - - /** - * Returns an empty, mutable match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @return the empty match. - * - */ - public static EClassMatch newEmptyMatch() { - return new Mutable(null); - } - - /** - * Returns a mutable (partial) match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @return the new, mutable (partial) match object. - * - */ - public static EClassMatch newMutableMatch(final EClass pEc) { - return new Mutable(pEc); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @return the (partial) match object. - * - */ - public static EClassMatch newMatch(final EClass pEc) { - return new Immutable(pEc); - } - - private static final class Mutable extends EClassMatch { - Mutable(final EClass pEc) { - super(pEc); - } - - @Override - public boolean isMutable() { - return true; - } - } - - private static final class Immutable extends EClassMatch { - Immutable(final EClass pEc) { - super(pEc); - } - - @Override - public boolean isMutable() { - return false; - } - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassMatcher.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassMatcher.java deleted file mode 100644 index 7085c0a..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassMatcher.java +++ /dev/null @@ -1,229 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import org.apache.log4j.Logger; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.viatra.query.application.queries.EClassMatch; -import org.eclipse.viatra.query.application.queries.util.EClassQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; -import org.eclipse.viatra.query.runtime.api.IQuerySpecification; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; - -/** - * Generated pattern matcher API of the org.eclipse.viatra.query.application.queries.eClass pattern, - * providing pattern-specific query methods. - * - * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, - * e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)}. - * - * <p>Matches of the pattern will be represented as {@link EClassMatch}. - * - * <p>Original source: - * <code><pre> - * {@literal @}Item(item = ec, label = "EC: $ec.name$") - * {@literal @}Format(color = "#e8da2c") - * pattern eClass(ec : EClass) { EClass(ec); } - * </pre></code> - * - * @see EClassMatch - * @see EClassProcessor - * @see EClassQuerySpecification - * - */ -@SuppressWarnings("all") -public class EClassMatcher extends BaseMatcher<EClassMatch> { - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * - */ - public static EClassMatcher on(final ViatraQueryEngine engine) throws ViatraQueryException { - // check if matcher already exists - EClassMatcher matcher = engine.getExistingMatcher(querySpecification()); - if (matcher == null) { - matcher = new EClassMatcher(engine); - // do not have to "put" it into engine.matchers, reportMatcherInitialized() will take care of it - } - return matcher; - } - - private final static int POSITION_EC = 0; - - private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(EClassMatcher.class); - - /** - * Initializes the pattern matcher over a given EMF model root (recommended: Resource or ResourceSet). - * If a pattern matcher is already constructed with the same root, only a light-weight reference is returned. - * The scope of pattern matching will be the given EMF model root and below (see FAQ for more precise definition). - * The match set will be incrementally refreshed upon updates from this scope. - * <p>The matcher will be created within the managed {@link ViatraQueryEngine} belonging to the EMF model root, so - * multiple matchers will reuse the same engine and benefit from increased performance and reduced memory footprint. - * @param emfRoot the root of the EMF containment hierarchy where the pattern matcher will operate. Recommended: Resource or ResourceSet. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead, e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)} - * - */ - @Deprecated - public EClassMatcher(final Notifier emfRoot) throws ViatraQueryException { - this(ViatraQueryEngine.on(emfRoot)); - } - - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead - * - */ - @Deprecated - public EClassMatcher(final ViatraQueryEngine engine) throws ViatraQueryException { - super(engine, querySpecification()); - } - - /** - * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @return matches represented as a EClassMatch object. - * - */ - public Collection<EClassMatch> getAllMatches(final EClass pEc) { - return rawGetAllMatches(new Object[]{pEc}); - } - - /** - * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @return a match represented as a EClassMatch object, or null if no match is found. - * - */ - public EClassMatch getOneArbitraryMatch(final EClass pEc) { - return rawGetOneArbitraryMatch(new Object[]{pEc}); - } - - /** - * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, - * under any possible substitution of the unspecified parameters (if any). - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @return true if the input is a valid (partial) match of the pattern. - * - */ - public boolean hasMatch(final EClass pEc) { - return rawHasMatch(new Object[]{pEc}); - } - - /** - * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @return the number of pattern matches found. - * - */ - public int countMatches(final EClass pEc) { - return rawCountMatches(new Object[]{pEc}); - } - - /** - * Executes the given processor on each match of the pattern that conforms to the given fixed values of some parameters. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @param processor the action that will process each pattern match. - * - */ - public void forEachMatch(final EClass pEc, final IMatchProcessor<? super EClassMatch> processor) { - rawForEachMatch(new Object[]{pEc}, processor); - } - - /** - * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @param processor the action that will process the selected match. - * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked - * - */ - public boolean forOneArbitraryMatch(final EClass pEc, final IMatchProcessor<? super EClassMatch> processor) { - return rawForOneArbitraryMatch(new Object[]{pEc}, processor); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pEc the fixed value of pattern parameter ec, or null if not bound. - * @return the (partial) match object. - * - */ - public EClassMatch newMatch(final EClass pEc) { - return EClassMatch.newMatch(pEc); - } - - /** - * Retrieve the set of values that occur in matches for ec. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - protected Set<EClass> rawAccumulateAllValuesOfec(final Object[] parameters) { - Set<EClass> results = new HashSet<EClass>(); - rawAccumulateAllValues(POSITION_EC, parameters, results); - return results; - } - - /** - * Retrieve the set of values that occur in matches for ec. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EClass> getAllValuesOfec() { - return rawAccumulateAllValuesOfec(emptyArray()); - } - - @Override - protected EClassMatch tupleToMatch(final Tuple t) { - try { - return EClassMatch.newMatch((EClass) t.get(POSITION_EC)); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in tuple not properly typed!",e); - return null; - } - } - - @Override - protected EClassMatch arrayToMatch(final Object[] match) { - try { - return EClassMatch.newMatch((EClass) match[POSITION_EC]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - @Override - protected EClassMatch arrayToMatchMutable(final Object[] match) { - try { - return EClassMatch.newMutableMatch((EClass) match[POSITION_EC]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - /** - * @return the singleton instance of the query specification of this pattern - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static IQuerySpecification<EClassMatcher> querySpecification() throws ViatraQueryException { - return EClassQuerySpecification.instance(); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesKeywordMatch.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesKeywordMatch.java deleted file mode 100644 index 46c7eca..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesKeywordMatch.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Arrays; -import java.util.List; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.viatra.query.application.queries.util.EClassNamesKeywordQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IPatternMatch; -import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; - -/** - * Pattern-specific match representation of the org.eclipse.viatra.query.application.queries.eClassNamesKeyword pattern, - * to be used in conjunction with {@link EClassNamesKeywordMatcher}. - * - * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. - * Each instance is a (possibly partial) substitution of pattern parameters, - * usable to represent a match of the pattern in the result of a query, - * or to specify the bound (fixed) input parameters when issuing a query. - * - * @see EClassNamesKeywordMatcher - * @see EClassNamesKeywordProcessor - * - */ -@SuppressWarnings("all") -public abstract class EClassNamesKeywordMatch extends BasePatternMatch { - private EClass fC; - - private String fN; - - private static List<String> parameterNames = makeImmutableList("c", "n"); - - private EClassNamesKeywordMatch(final EClass pC, final String pN) { - this.fC = pC; - this.fN = pN; - } - - @Override - public Object get(final String parameterName) { - if ("c".equals(parameterName)) return this.fC; - if ("n".equals(parameterName)) return this.fN; - return null; - } - - public EClass getC() { - return this.fC; - } - - public String getN() { - return this.fN; - } - - @Override - public boolean set(final String parameterName, final Object newValue) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - if ("c".equals(parameterName) ) { - this.fC = (EClass) newValue; - return true; - } - if ("n".equals(parameterName) ) { - this.fN = (String) newValue; - return true; - } - return false; - } - - public void setC(final EClass pC) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fC = pC; - } - - public void setN(final String pN) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fN = pN; - } - - @Override - public String patternName() { - return "org.eclipse.viatra.query.application.queries.eClassNamesKeyword"; - } - - @Override - public List<String> parameterNames() { - return EClassNamesKeywordMatch.parameterNames; - } - - @Override - public Object[] toArray() { - return new Object[]{fC, fN}; - } - - @Override - public EClassNamesKeywordMatch toImmutable() { - return isMutable() ? newMatch(fC, fN) : this; - } - - @Override - public String prettyPrint() { - StringBuilder result = new StringBuilder(); - result.append("\"c\"=" + prettyPrintValue(fC) + ", "); - - result.append("\"n\"=" + prettyPrintValue(fN) - ); - return result.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((fC == null) ? 0 : fC.hashCode()); - result = prime * result + ((fN == null) ? 0 : fN.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (!(obj instanceof EClassNamesKeywordMatch)) { // this should be infrequent - if (obj == null) { - return false; - } - if (!(obj instanceof IPatternMatch)) { - return false; - } - IPatternMatch otherSig = (IPatternMatch) obj; - if (!specification().equals(otherSig.specification())) - return false; - return Arrays.deepEquals(toArray(), otherSig.toArray()); - } - EClassNamesKeywordMatch other = (EClassNamesKeywordMatch) obj; - if (fC == null) {if (other.fC != null) return false;} - else if (!fC.equals(other.fC)) return false; - if (fN == null) {if (other.fN != null) return false;} - else if (!fN.equals(other.fN)) return false; - return true; - } - - @Override - public EClassNamesKeywordQuerySpecification specification() { - try { - return EClassNamesKeywordQuerySpecification.instance(); - } catch (ViatraQueryException ex) { - // This cannot happen, as the match object can only be instantiated if the query specification exists - throw new IllegalStateException (ex); - } - } - - /** - * Returns an empty, mutable match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @return the empty match. - * - */ - public static EClassNamesKeywordMatch newEmptyMatch() { - return new Mutable(null, null); - } - - /** - * Returns a mutable (partial) match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @return the new, mutable (partial) match object. - * - */ - public static EClassNamesKeywordMatch newMutableMatch(final EClass pC, final String pN) { - return new Mutable(pC, pN); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @return the (partial) match object. - * - */ - public static EClassNamesKeywordMatch newMatch(final EClass pC, final String pN) { - return new Immutable(pC, pN); - } - - private static final class Mutable extends EClassNamesKeywordMatch { - Mutable(final EClass pC, final String pN) { - super(pC, pN); - } - - @Override - public boolean isMutable() { - return true; - } - } - - private static final class Immutable extends EClassNamesKeywordMatch { - Immutable(final EClass pC, final String pN) { - super(pC, pN); - } - - @Override - public boolean isMutable() { - return false; - } - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesKeywordMatcher.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesKeywordMatcher.java deleted file mode 100644 index 35b9134..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesKeywordMatcher.java +++ /dev/null @@ -1,302 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import org.apache.log4j.Logger; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.viatra.query.application.queries.EClassNamesKeywordMatch; -import org.eclipse.viatra.query.application.queries.util.EClassNamesKeywordQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; -import org.eclipse.viatra.query.runtime.api.IQuerySpecification; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; - -/** - * Generated pattern matcher API of the org.eclipse.viatra.query.application.queries.eClassNamesKeyword pattern, - * providing pattern-specific query methods. - * - * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, - * e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)}. - * - * <p>Matches of the pattern will be represented as {@link EClassNamesKeywordMatch}. - * - * <p>Original source: - * <code><pre> - * pattern eClassNamesKeyword(c: EClass, n: EString) - * { - * EClass.name(c,n); - * check("A" == n); - * } - * </pre></code> - * - * @see EClassNamesKeywordMatch - * @see EClassNamesKeywordProcessor - * @see EClassNamesKeywordQuerySpecification - * - */ -@SuppressWarnings("all") -public class EClassNamesKeywordMatcher extends BaseMatcher<EClassNamesKeywordMatch> { - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * - */ - public static EClassNamesKeywordMatcher on(final ViatraQueryEngine engine) throws ViatraQueryException { - // check if matcher already exists - EClassNamesKeywordMatcher matcher = engine.getExistingMatcher(querySpecification()); - if (matcher == null) { - matcher = new EClassNamesKeywordMatcher(engine); - // do not have to "put" it into engine.matchers, reportMatcherInitialized() will take care of it - } - return matcher; - } - - private final static int POSITION_C = 0; - - private final static int POSITION_N = 1; - - private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(EClassNamesKeywordMatcher.class); - - /** - * Initializes the pattern matcher over a given EMF model root (recommended: Resource or ResourceSet). - * If a pattern matcher is already constructed with the same root, only a light-weight reference is returned. - * The scope of pattern matching will be the given EMF model root and below (see FAQ for more precise definition). - * The match set will be incrementally refreshed upon updates from this scope. - * <p>The matcher will be created within the managed {@link ViatraQueryEngine} belonging to the EMF model root, so - * multiple matchers will reuse the same engine and benefit from increased performance and reduced memory footprint. - * @param emfRoot the root of the EMF containment hierarchy where the pattern matcher will operate. Recommended: Resource or ResourceSet. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead, e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)} - * - */ - @Deprecated - public EClassNamesKeywordMatcher(final Notifier emfRoot) throws ViatraQueryException { - this(ViatraQueryEngine.on(emfRoot)); - } - - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead - * - */ - @Deprecated - public EClassNamesKeywordMatcher(final ViatraQueryEngine engine) throws ViatraQueryException { - super(engine, querySpecification()); - } - - /** - * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @return matches represented as a EClassNamesKeywordMatch object. - * - */ - public Collection<EClassNamesKeywordMatch> getAllMatches(final EClass pC, final String pN) { - return rawGetAllMatches(new Object[]{pC, pN}); - } - - /** - * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @return a match represented as a EClassNamesKeywordMatch object, or null if no match is found. - * - */ - public EClassNamesKeywordMatch getOneArbitraryMatch(final EClass pC, final String pN) { - return rawGetOneArbitraryMatch(new Object[]{pC, pN}); - } - - /** - * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, - * under any possible substitution of the unspecified parameters (if any). - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @return true if the input is a valid (partial) match of the pattern. - * - */ - public boolean hasMatch(final EClass pC, final String pN) { - return rawHasMatch(new Object[]{pC, pN}); - } - - /** - * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @return the number of pattern matches found. - * - */ - public int countMatches(final EClass pC, final String pN) { - return rawCountMatches(new Object[]{pC, pN}); - } - - /** - * Executes the given processor on each match of the pattern that conforms to the given fixed values of some parameters. - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @param processor the action that will process each pattern match. - * - */ - public void forEachMatch(final EClass pC, final String pN, final IMatchProcessor<? super EClassNamesKeywordMatch> processor) { - rawForEachMatch(new Object[]{pC, pN}, processor); - } - - /** - * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @param processor the action that will process the selected match. - * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked - * - */ - public boolean forOneArbitraryMatch(final EClass pC, final String pN, final IMatchProcessor<? super EClassNamesKeywordMatch> processor) { - return rawForOneArbitraryMatch(new Object[]{pC, pN}, processor); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @return the (partial) match object. - * - */ - public EClassNamesKeywordMatch newMatch(final EClass pC, final String pN) { - return EClassNamesKeywordMatch.newMatch(pC, pN); - } - - /** - * Retrieve the set of values that occur in matches for c. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - protected Set<EClass> rawAccumulateAllValuesOfc(final Object[] parameters) { - Set<EClass> results = new HashSet<EClass>(); - rawAccumulateAllValues(POSITION_C, parameters, results); - return results; - } - - /** - * Retrieve the set of values that occur in matches for c. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EClass> getAllValuesOfc() { - return rawAccumulateAllValuesOfc(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for c. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EClass> getAllValuesOfc(final EClassNamesKeywordMatch partialMatch) { - return rawAccumulateAllValuesOfc(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for c. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EClass> getAllValuesOfc(final String pN) { - return rawAccumulateAllValuesOfc(new Object[]{ - null, - pN - }); - } - - /** - * Retrieve the set of values that occur in matches for n. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - protected Set<String> rawAccumulateAllValuesOfn(final Object[] parameters) { - Set<String> results = new HashSet<String>(); - rawAccumulateAllValues(POSITION_N, parameters, results); - return results; - } - - /** - * Retrieve the set of values that occur in matches for n. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<String> getAllValuesOfn() { - return rawAccumulateAllValuesOfn(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for n. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<String> getAllValuesOfn(final EClassNamesKeywordMatch partialMatch) { - return rawAccumulateAllValuesOfn(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for n. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<String> getAllValuesOfn(final EClass pC) { - return rawAccumulateAllValuesOfn(new Object[]{ - pC, - null - }); - } - - @Override - protected EClassNamesKeywordMatch tupleToMatch(final Tuple t) { - try { - return EClassNamesKeywordMatch.newMatch((EClass) t.get(POSITION_C), (String) t.get(POSITION_N)); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in tuple not properly typed!",e); - return null; - } - } - - @Override - protected EClassNamesKeywordMatch arrayToMatch(final Object[] match) { - try { - return EClassNamesKeywordMatch.newMatch((EClass) match[POSITION_C], (String) match[POSITION_N]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - @Override - protected EClassNamesKeywordMatch arrayToMatchMutable(final Object[] match) { - try { - return EClassNamesKeywordMatch.newMutableMatch((EClass) match[POSITION_C], (String) match[POSITION_N]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - /** - * @return the singleton instance of the query specification of this pattern - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static IQuerySpecification<EClassNamesKeywordMatcher> querySpecification() throws ViatraQueryException { - return EClassNamesKeywordQuerySpecification.instance(); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesMatch.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesMatch.java deleted file mode 100644 index bf7d57e..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesMatch.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Arrays; -import java.util.List; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.viatra.query.application.queries.util.EClassNamesQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IPatternMatch; -import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; - -/** - * Pattern-specific match representation of the org.eclipse.viatra.query.application.queries.eClassNames pattern, - * to be used in conjunction with {@link EClassNamesMatcher}. - * - * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. - * Each instance is a (possibly partial) substitution of pattern parameters, - * usable to represent a match of the pattern in the result of a query, - * or to specify the bound (fixed) input parameters when issuing a query. - * - * @see EClassNamesMatcher - * @see EClassNamesProcessor - * - */ -@SuppressWarnings("all") -public abstract class EClassNamesMatch extends BasePatternMatch { - private EClass fC; - - private String fN; - - private static List<String> parameterNames = makeImmutableList("c", "n"); - - private EClassNamesMatch(final EClass pC, final String pN) { - this.fC = pC; - this.fN = pN; - } - - @Override - public Object get(final String parameterName) { - if ("c".equals(parameterName)) return this.fC; - if ("n".equals(parameterName)) return this.fN; - return null; - } - - public EClass getC() { - return this.fC; - } - - public String getN() { - return this.fN; - } - - @Override - public boolean set(final String parameterName, final Object newValue) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - if ("c".equals(parameterName) ) { - this.fC = (EClass) newValue; - return true; - } - if ("n".equals(parameterName) ) { - this.fN = (String) newValue; - return true; - } - return false; - } - - public void setC(final EClass pC) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fC = pC; - } - - public void setN(final String pN) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fN = pN; - } - - @Override - public String patternName() { - return "org.eclipse.viatra.query.application.queries.eClassNames"; - } - - @Override - public List<String> parameterNames() { - return EClassNamesMatch.parameterNames; - } - - @Override - public Object[] toArray() { - return new Object[]{fC, fN}; - } - - @Override - public EClassNamesMatch toImmutable() { - return isMutable() ? newMatch(fC, fN) : this; - } - - @Override - public String prettyPrint() { - StringBuilder result = new StringBuilder(); - result.append("\"c\"=" + prettyPrintValue(fC) + ", "); - - result.append("\"n\"=" + prettyPrintValue(fN) - ); - return result.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((fC == null) ? 0 : fC.hashCode()); - result = prime * result + ((fN == null) ? 0 : fN.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (!(obj instanceof EClassNamesMatch)) { // this should be infrequent - if (obj == null) { - return false; - } - if (!(obj instanceof IPatternMatch)) { - return false; - } - IPatternMatch otherSig = (IPatternMatch) obj; - if (!specification().equals(otherSig.specification())) - return false; - return Arrays.deepEquals(toArray(), otherSig.toArray()); - } - EClassNamesMatch other = (EClassNamesMatch) obj; - if (fC == null) {if (other.fC != null) return false;} - else if (!fC.equals(other.fC)) return false; - if (fN == null) {if (other.fN != null) return false;} - else if (!fN.equals(other.fN)) return false; - return true; - } - - @Override - public EClassNamesQuerySpecification specification() { - try { - return EClassNamesQuerySpecification.instance(); - } catch (ViatraQueryException ex) { - // This cannot happen, as the match object can only be instantiated if the query specification exists - throw new IllegalStateException (ex); - } - } - - /** - * Returns an empty, mutable match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @return the empty match. - * - */ - public static EClassNamesMatch newEmptyMatch() { - return new Mutable(null, null); - } - - /** - * Returns a mutable (partial) match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @return the new, mutable (partial) match object. - * - */ - public static EClassNamesMatch newMutableMatch(final EClass pC, final String pN) { - return new Mutable(pC, pN); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @return the (partial) match object. - * - */ - public static EClassNamesMatch newMatch(final EClass pC, final String pN) { - return new Immutable(pC, pN); - } - - private static final class Mutable extends EClassNamesMatch { - Mutable(final EClass pC, final String pN) { - super(pC, pN); - } - - @Override - public boolean isMutable() { - return true; - } - } - - private static final class Immutable extends EClassNamesMatch { - Immutable(final EClass pC, final String pN) { - super(pC, pN); - } - - @Override - public boolean isMutable() { - return false; - } - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesMatcher.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesMatcher.java deleted file mode 100644 index 017f46d..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesMatcher.java +++ /dev/null @@ -1,300 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import org.apache.log4j.Logger; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.viatra.query.application.queries.EClassNamesMatch; -import org.eclipse.viatra.query.application.queries.util.EClassNamesQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; -import org.eclipse.viatra.query.runtime.api.IQuerySpecification; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; - -/** - * Generated pattern matcher API of the org.eclipse.viatra.query.application.queries.eClassNames pattern, - * providing pattern-specific query methods. - * - * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, - * e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)}. - * - * <p>Matches of the pattern will be represented as {@link EClassNamesMatch}. - * - * <p>Original source: - * <code><pre> - * pattern eClassNames(c: EClass, n : EString)= { - * EClass.name(c,n); - * } - * </pre></code> - * - * @see EClassNamesMatch - * @see EClassNamesProcessor - * @see EClassNamesQuerySpecification - * - */ -@SuppressWarnings("all") -public class EClassNamesMatcher extends BaseMatcher<EClassNamesMatch> { - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * - */ - public static EClassNamesMatcher on(final ViatraQueryEngine engine) throws ViatraQueryException { - // check if matcher already exists - EClassNamesMatcher matcher = engine.getExistingMatcher(querySpecification()); - if (matcher == null) { - matcher = new EClassNamesMatcher(engine); - // do not have to "put" it into engine.matchers, reportMatcherInitialized() will take care of it - } - return matcher; - } - - private final static int POSITION_C = 0; - - private final static int POSITION_N = 1; - - private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(EClassNamesMatcher.class); - - /** - * Initializes the pattern matcher over a given EMF model root (recommended: Resource or ResourceSet). - * If a pattern matcher is already constructed with the same root, only a light-weight reference is returned. - * The scope of pattern matching will be the given EMF model root and below (see FAQ for more precise definition). - * The match set will be incrementally refreshed upon updates from this scope. - * <p>The matcher will be created within the managed {@link ViatraQueryEngine} belonging to the EMF model root, so - * multiple matchers will reuse the same engine and benefit from increased performance and reduced memory footprint. - * @param emfRoot the root of the EMF containment hierarchy where the pattern matcher will operate. Recommended: Resource or ResourceSet. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead, e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)} - * - */ - @Deprecated - public EClassNamesMatcher(final Notifier emfRoot) throws ViatraQueryException { - this(ViatraQueryEngine.on(emfRoot)); - } - - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead - * - */ - @Deprecated - public EClassNamesMatcher(final ViatraQueryEngine engine) throws ViatraQueryException { - super(engine, querySpecification()); - } - - /** - * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @return matches represented as a EClassNamesMatch object. - * - */ - public Collection<EClassNamesMatch> getAllMatches(final EClass pC, final String pN) { - return rawGetAllMatches(new Object[]{pC, pN}); - } - - /** - * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @return a match represented as a EClassNamesMatch object, or null if no match is found. - * - */ - public EClassNamesMatch getOneArbitraryMatch(final EClass pC, final String pN) { - return rawGetOneArbitraryMatch(new Object[]{pC, pN}); - } - - /** - * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, - * under any possible substitution of the unspecified parameters (if any). - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @return true if the input is a valid (partial) match of the pattern. - * - */ - public boolean hasMatch(final EClass pC, final String pN) { - return rawHasMatch(new Object[]{pC, pN}); - } - - /** - * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @return the number of pattern matches found. - * - */ - public int countMatches(final EClass pC, final String pN) { - return rawCountMatches(new Object[]{pC, pN}); - } - - /** - * Executes the given processor on each match of the pattern that conforms to the given fixed values of some parameters. - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @param processor the action that will process each pattern match. - * - */ - public void forEachMatch(final EClass pC, final String pN, final IMatchProcessor<? super EClassNamesMatch> processor) { - rawForEachMatch(new Object[]{pC, pN}, processor); - } - - /** - * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @param processor the action that will process the selected match. - * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked - * - */ - public boolean forOneArbitraryMatch(final EClass pC, final String pN, final IMatchProcessor<? super EClassNamesMatch> processor) { - return rawForOneArbitraryMatch(new Object[]{pC, pN}, processor); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pC the fixed value of pattern parameter c, or null if not bound. - * @param pN the fixed value of pattern parameter n, or null if not bound. - * @return the (partial) match object. - * - */ - public EClassNamesMatch newMatch(final EClass pC, final String pN) { - return EClassNamesMatch.newMatch(pC, pN); - } - - /** - * Retrieve the set of values that occur in matches for c. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - protected Set<EClass> rawAccumulateAllValuesOfc(final Object[] parameters) { - Set<EClass> results = new HashSet<EClass>(); - rawAccumulateAllValues(POSITION_C, parameters, results); - return results; - } - - /** - * Retrieve the set of values that occur in matches for c. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EClass> getAllValuesOfc() { - return rawAccumulateAllValuesOfc(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for c. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EClass> getAllValuesOfc(final EClassNamesMatch partialMatch) { - return rawAccumulateAllValuesOfc(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for c. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EClass> getAllValuesOfc(final String pN) { - return rawAccumulateAllValuesOfc(new Object[]{ - null, - pN - }); - } - - /** - * Retrieve the set of values that occur in matches for n. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - protected Set<String> rawAccumulateAllValuesOfn(final Object[] parameters) { - Set<String> results = new HashSet<String>(); - rawAccumulateAllValues(POSITION_N, parameters, results); - return results; - } - - /** - * Retrieve the set of values that occur in matches for n. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<String> getAllValuesOfn() { - return rawAccumulateAllValuesOfn(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for n. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<String> getAllValuesOfn(final EClassNamesMatch partialMatch) { - return rawAccumulateAllValuesOfn(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for n. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<String> getAllValuesOfn(final EClass pC) { - return rawAccumulateAllValuesOfn(new Object[]{ - pC, - null - }); - } - - @Override - protected EClassNamesMatch tupleToMatch(final Tuple t) { - try { - return EClassNamesMatch.newMatch((EClass) t.get(POSITION_C), (String) t.get(POSITION_N)); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in tuple not properly typed!",e); - return null; - } - } - - @Override - protected EClassNamesMatch arrayToMatch(final Object[] match) { - try { - return EClassNamesMatch.newMatch((EClass) match[POSITION_C], (String) match[POSITION_N]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - @Override - protected EClassNamesMatch arrayToMatchMutable(final Object[] match) { - try { - return EClassNamesMatch.newMutableMatch((EClass) match[POSITION_C], (String) match[POSITION_N]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - /** - * @return the singleton instance of the query specification of this pattern - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static IQuerySpecification<EClassNamesMatcher> querySpecification() throws ViatraQueryException { - return EClassNamesQuerySpecification.instance(); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EObjectMatch.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EObjectMatch.java deleted file mode 100644 index 15cea1c..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EObjectMatch.java +++ /dev/null @@ -1,183 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Arrays; -import java.util.List; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.viatra.query.application.queries.util.EObjectQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IPatternMatch; -import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; - -/** - * Pattern-specific match representation of the org.eclipse.viatra.query.application.queries.eObject pattern, - * to be used in conjunction with {@link EObjectMatcher}. - * - * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. - * Each instance is a (possibly partial) substitution of pattern parameters, - * usable to represent a match of the pattern in the result of a query, - * or to specify the bound (fixed) input parameters when issuing a query. - * - * @see EObjectMatcher - * @see EObjectProcessor - * - */ -@SuppressWarnings("all") -public abstract class EObjectMatch extends BasePatternMatch { - private EObject fO; - - private static List<String> parameterNames = makeImmutableList("o"); - - private EObjectMatch(final EObject pO) { - this.fO = pO; - } - - @Override - public Object get(final String parameterName) { - if ("o".equals(parameterName)) return this.fO; - return null; - } - - public EObject getO() { - return this.fO; - } - - @Override - public boolean set(final String parameterName, final Object newValue) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - if ("o".equals(parameterName) ) { - this.fO = (EObject) newValue; - return true; - } - return false; - } - - public void setO(final EObject pO) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fO = pO; - } - - @Override - public String patternName() { - return "org.eclipse.viatra.query.application.queries.eObject"; - } - - @Override - public List<String> parameterNames() { - return EObjectMatch.parameterNames; - } - - @Override - public Object[] toArray() { - return new Object[]{fO}; - } - - @Override - public EObjectMatch toImmutable() { - return isMutable() ? newMatch(fO) : this; - } - - @Override - public String prettyPrint() { - StringBuilder result = new StringBuilder(); - result.append("\"o\"=" + prettyPrintValue(fO) - ); - return result.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((fO == null) ? 0 : fO.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (!(obj instanceof EObjectMatch)) { // this should be infrequent - if (obj == null) { - return false; - } - if (!(obj instanceof IPatternMatch)) { - return false; - } - IPatternMatch otherSig = (IPatternMatch) obj; - if (!specification().equals(otherSig.specification())) - return false; - return Arrays.deepEquals(toArray(), otherSig.toArray()); - } - EObjectMatch other = (EObjectMatch) obj; - if (fO == null) {if (other.fO != null) return false;} - else if (!fO.equals(other.fO)) return false; - return true; - } - - @Override - public EObjectQuerySpecification specification() { - try { - return EObjectQuerySpecification.instance(); - } catch (ViatraQueryException ex) { - // This cannot happen, as the match object can only be instantiated if the query specification exists - throw new IllegalStateException (ex); - } - } - - /** - * Returns an empty, mutable match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @return the empty match. - * - */ - public static EObjectMatch newEmptyMatch() { - return new Mutable(null); - } - - /** - * Returns a mutable (partial) match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @param pO the fixed value of pattern parameter o, or null if not bound. - * @return the new, mutable (partial) match object. - * - */ - public static EObjectMatch newMutableMatch(final EObject pO) { - return new Mutable(pO); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pO the fixed value of pattern parameter o, or null if not bound. - * @return the (partial) match object. - * - */ - public static EObjectMatch newMatch(final EObject pO) { - return new Immutable(pO); - } - - private static final class Mutable extends EObjectMatch { - Mutable(final EObject pO) { - super(pO); - } - - @Override - public boolean isMutable() { - return true; - } - } - - private static final class Immutable extends EObjectMatch { - Immutable(final EObject pO) { - super(pO); - } - - @Override - public boolean isMutable() { - return false; - } - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EObjectMatcher.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EObjectMatcher.java deleted file mode 100644 index c751405..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EObjectMatcher.java +++ /dev/null @@ -1,229 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import org.apache.log4j.Logger; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.viatra.query.application.queries.EObjectMatch; -import org.eclipse.viatra.query.application.queries.util.EObjectQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; -import org.eclipse.viatra.query.runtime.api.IQuerySpecification; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; - -/** - * Generated pattern matcher API of the org.eclipse.viatra.query.application.queries.eObject pattern, - * providing pattern-specific query methods. - * - * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, - * e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)}. - * - * <p>Matches of the pattern will be represented as {@link EObjectMatch}. - * - * <p>Original source: - * <code><pre> - * pattern eObject(o) { - * EObject(o); - * } - * </pre></code> - * - * @see EObjectMatch - * @see EObjectProcessor - * @see EObjectQuerySpecification - * - */ -@SuppressWarnings("all") -public class EObjectMatcher extends BaseMatcher<EObjectMatch> { - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * - */ - public static EObjectMatcher on(final ViatraQueryEngine engine) throws ViatraQueryException { - // check if matcher already exists - EObjectMatcher matcher = engine.getExistingMatcher(querySpecification()); - if (matcher == null) { - matcher = new EObjectMatcher(engine); - // do not have to "put" it into engine.matchers, reportMatcherInitialized() will take care of it - } - return matcher; - } - - private final static int POSITION_O = 0; - - private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(EObjectMatcher.class); - - /** - * Initializes the pattern matcher over a given EMF model root (recommended: Resource or ResourceSet). - * If a pattern matcher is already constructed with the same root, only a light-weight reference is returned. - * The scope of pattern matching will be the given EMF model root and below (see FAQ for more precise definition). - * The match set will be incrementally refreshed upon updates from this scope. - * <p>The matcher will be created within the managed {@link ViatraQueryEngine} belonging to the EMF model root, so - * multiple matchers will reuse the same engine and benefit from increased performance and reduced memory footprint. - * @param emfRoot the root of the EMF containment hierarchy where the pattern matcher will operate. Recommended: Resource or ResourceSet. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead, e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)} - * - */ - @Deprecated - public EObjectMatcher(final Notifier emfRoot) throws ViatraQueryException { - this(ViatraQueryEngine.on(emfRoot)); - } - - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead - * - */ - @Deprecated - public EObjectMatcher(final ViatraQueryEngine engine) throws ViatraQueryException { - super(engine, querySpecification()); - } - - /** - * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pO the fixed value of pattern parameter o, or null if not bound. - * @return matches represented as a EObjectMatch object. - * - */ - public Collection<EObjectMatch> getAllMatches(final EObject pO) { - return rawGetAllMatches(new Object[]{pO}); - } - - /** - * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pO the fixed value of pattern parameter o, or null if not bound. - * @return a match represented as a EObjectMatch object, or null if no match is found. - * - */ - public EObjectMatch getOneArbitraryMatch(final EObject pO) { - return rawGetOneArbitraryMatch(new Object[]{pO}); - } - - /** - * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, - * under any possible substitution of the unspecified parameters (if any). - * @param pO the fixed value of pattern parameter o, or null if not bound. - * @return true if the input is a valid (partial) match of the pattern. - * - */ - public boolean hasMatch(final EObject pO) { - return rawHasMatch(new Object[]{pO}); - } - - /** - * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pO the fixed value of pattern parameter o, or null if not bound. - * @return the number of pattern matches found. - * - */ - public int countMatches(final EObject pO) { - return rawCountMatches(new Object[]{pO}); - } - - /** - * Executes the given processor on each match of the pattern that conforms to the given fixed values of some parameters. - * @param pO the fixed value of pattern parameter o, or null if not bound. - * @param processor the action that will process each pattern match. - * - */ - public void forEachMatch(final EObject pO, final IMatchProcessor<? super EObjectMatch> processor) { - rawForEachMatch(new Object[]{pO}, processor); - } - - /** - * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pO the fixed value of pattern parameter o, or null if not bound. - * @param processor the action that will process the selected match. - * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked - * - */ - public boolean forOneArbitraryMatch(final EObject pO, final IMatchProcessor<? super EObjectMatch> processor) { - return rawForOneArbitraryMatch(new Object[]{pO}, processor); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pO the fixed value of pattern parameter o, or null if not bound. - * @return the (partial) match object. - * - */ - public EObjectMatch newMatch(final EObject pO) { - return EObjectMatch.newMatch(pO); - } - - /** - * Retrieve the set of values that occur in matches for o. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - protected Set<EObject> rawAccumulateAllValuesOfo(final Object[] parameters) { - Set<EObject> results = new HashSet<EObject>(); - rawAccumulateAllValues(POSITION_O, parameters, results); - return results; - } - - /** - * Retrieve the set of values that occur in matches for o. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EObject> getAllValuesOfo() { - return rawAccumulateAllValuesOfo(emptyArray()); - } - - @Override - protected EObjectMatch tupleToMatch(final Tuple t) { - try { - return EObjectMatch.newMatch((EObject) t.get(POSITION_O)); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in tuple not properly typed!",e); - return null; - } - } - - @Override - protected EObjectMatch arrayToMatch(final Object[] match) { - try { - return EObjectMatch.newMatch((EObject) match[POSITION_O]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - @Override - protected EObjectMatch arrayToMatchMutable(final Object[] match) { - try { - return EObjectMatch.newMutableMatch((EObject) match[POSITION_O]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - /** - * @return the singleton instance of the query specification of this pattern - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static IQuerySpecification<EObjectMatcher> querySpecification() throws ViatraQueryException { - return EObjectQuerySpecification.instance(); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EPackageMatch.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EPackageMatch.java deleted file mode 100644 index 385e1cd..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EPackageMatch.java +++ /dev/null @@ -1,183 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Arrays; -import java.util.List; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.viatra.query.application.queries.util.EPackageQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IPatternMatch; -import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; - -/** - * Pattern-specific match representation of the org.eclipse.viatra.query.application.queries.ePackage pattern, - * to be used in conjunction with {@link EPackageMatcher}. - * - * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. - * Each instance is a (possibly partial) substitution of pattern parameters, - * usable to represent a match of the pattern in the result of a query, - * or to specify the bound (fixed) input parameters when issuing a query. - * - * @see EPackageMatcher - * @see EPackageProcessor - * - */ -@SuppressWarnings("all") -public abstract class EPackageMatch extends BasePatternMatch { - private EPackage fP; - - private static List<String> parameterNames = makeImmutableList("p"); - - private EPackageMatch(final EPackage pP) { - this.fP = pP; - } - - @Override - public Object get(final String parameterName) { - if ("p".equals(parameterName)) return this.fP; - return null; - } - - public EPackage getP() { - return this.fP; - } - - @Override - public boolean set(final String parameterName, final Object newValue) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - if ("p".equals(parameterName) ) { - this.fP = (EPackage) newValue; - return true; - } - return false; - } - - public void setP(final EPackage pP) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fP = pP; - } - - @Override - public String patternName() { - return "org.eclipse.viatra.query.application.queries.ePackage"; - } - - @Override - public List<String> parameterNames() { - return EPackageMatch.parameterNames; - } - - @Override - public Object[] toArray() { - return new Object[]{fP}; - } - - @Override - public EPackageMatch toImmutable() { - return isMutable() ? newMatch(fP) : this; - } - - @Override - public String prettyPrint() { - StringBuilder result = new StringBuilder(); - result.append("\"p\"=" + prettyPrintValue(fP) - ); - return result.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((fP == null) ? 0 : fP.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (!(obj instanceof EPackageMatch)) { // this should be infrequent - if (obj == null) { - return false; - } - if (!(obj instanceof IPatternMatch)) { - return false; - } - IPatternMatch otherSig = (IPatternMatch) obj; - if (!specification().equals(otherSig.specification())) - return false; - return Arrays.deepEquals(toArray(), otherSig.toArray()); - } - EPackageMatch other = (EPackageMatch) obj; - if (fP == null) {if (other.fP != null) return false;} - else if (!fP.equals(other.fP)) return false; - return true; - } - - @Override - public EPackageQuerySpecification specification() { - try { - return EPackageQuerySpecification.instance(); - } catch (ViatraQueryException ex) { - // This cannot happen, as the match object can only be instantiated if the query specification exists - throw new IllegalStateException (ex); - } - } - - /** - * Returns an empty, mutable match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @return the empty match. - * - */ - public static EPackageMatch newEmptyMatch() { - return new Mutable(null); - } - - /** - * Returns a mutable (partial) match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @return the new, mutable (partial) match object. - * - */ - public static EPackageMatch newMutableMatch(final EPackage pP) { - return new Mutable(pP); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @return the (partial) match object. - * - */ - public static EPackageMatch newMatch(final EPackage pP) { - return new Immutable(pP); - } - - private static final class Mutable extends EPackageMatch { - Mutable(final EPackage pP) { - super(pP); - } - - @Override - public boolean isMutable() { - return true; - } - } - - private static final class Immutable extends EPackageMatch { - Immutable(final EPackage pP) { - super(pP); - } - - @Override - public boolean isMutable() { - return false; - } - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EPackageMatcher.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EPackageMatcher.java deleted file mode 100644 index 0eb10b4..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EPackageMatcher.java +++ /dev/null @@ -1,229 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import org.apache.log4j.Logger; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.viatra.query.application.queries.EPackageMatch; -import org.eclipse.viatra.query.application.queries.util.EPackageQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; -import org.eclipse.viatra.query.runtime.api.IQuerySpecification; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; - -/** - * Generated pattern matcher API of the org.eclipse.viatra.query.application.queries.ePackage pattern, - * providing pattern-specific query methods. - * - * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, - * e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)}. - * - * <p>Matches of the pattern will be represented as {@link EPackageMatch}. - * - * <p>Original source: - * <code><pre> - * {@literal @}Item(item = p, label = "P: $p.name$") - * {@literal @}Format(color = "#791662", textColor = "#ffffff") - * pattern ePackage(p : EPackage) { EPackage(p); } - * </pre></code> - * - * @see EPackageMatch - * @see EPackageProcessor - * @see EPackageQuerySpecification - * - */ -@SuppressWarnings("all") -public class EPackageMatcher extends BaseMatcher<EPackageMatch> { - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * - */ - public static EPackageMatcher on(final ViatraQueryEngine engine) throws ViatraQueryException { - // check if matcher already exists - EPackageMatcher matcher = engine.getExistingMatcher(querySpecification()); - if (matcher == null) { - matcher = new EPackageMatcher(engine); - // do not have to "put" it into engine.matchers, reportMatcherInitialized() will take care of it - } - return matcher; - } - - private final static int POSITION_P = 0; - - private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(EPackageMatcher.class); - - /** - * Initializes the pattern matcher over a given EMF model root (recommended: Resource or ResourceSet). - * If a pattern matcher is already constructed with the same root, only a light-weight reference is returned. - * The scope of pattern matching will be the given EMF model root and below (see FAQ for more precise definition). - * The match set will be incrementally refreshed upon updates from this scope. - * <p>The matcher will be created within the managed {@link ViatraQueryEngine} belonging to the EMF model root, so - * multiple matchers will reuse the same engine and benefit from increased performance and reduced memory footprint. - * @param emfRoot the root of the EMF containment hierarchy where the pattern matcher will operate. Recommended: Resource or ResourceSet. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead, e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)} - * - */ - @Deprecated - public EPackageMatcher(final Notifier emfRoot) throws ViatraQueryException { - this(ViatraQueryEngine.on(emfRoot)); - } - - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead - * - */ - @Deprecated - public EPackageMatcher(final ViatraQueryEngine engine) throws ViatraQueryException { - super(engine, querySpecification()); - } - - /** - * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @return matches represented as a EPackageMatch object. - * - */ - public Collection<EPackageMatch> getAllMatches(final EPackage pP) { - return rawGetAllMatches(new Object[]{pP}); - } - - /** - * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @return a match represented as a EPackageMatch object, or null if no match is found. - * - */ - public EPackageMatch getOneArbitraryMatch(final EPackage pP) { - return rawGetOneArbitraryMatch(new Object[]{pP}); - } - - /** - * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, - * under any possible substitution of the unspecified parameters (if any). - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @return true if the input is a valid (partial) match of the pattern. - * - */ - public boolean hasMatch(final EPackage pP) { - return rawHasMatch(new Object[]{pP}); - } - - /** - * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @return the number of pattern matches found. - * - */ - public int countMatches(final EPackage pP) { - return rawCountMatches(new Object[]{pP}); - } - - /** - * Executes the given processor on each match of the pattern that conforms to the given fixed values of some parameters. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param processor the action that will process each pattern match. - * - */ - public void forEachMatch(final EPackage pP, final IMatchProcessor<? super EPackageMatch> processor) { - rawForEachMatch(new Object[]{pP}, processor); - } - - /** - * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param processor the action that will process the selected match. - * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked - * - */ - public boolean forOneArbitraryMatch(final EPackage pP, final IMatchProcessor<? super EPackageMatch> processor) { - return rawForOneArbitraryMatch(new Object[]{pP}, processor); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @return the (partial) match object. - * - */ - public EPackageMatch newMatch(final EPackage pP) { - return EPackageMatch.newMatch(pP); - } - - /** - * Retrieve the set of values that occur in matches for p. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - protected Set<EPackage> rawAccumulateAllValuesOfp(final Object[] parameters) { - Set<EPackage> results = new HashSet<EPackage>(); - rawAccumulateAllValues(POSITION_P, parameters, results); - return results; - } - - /** - * Retrieve the set of values that occur in matches for p. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EPackage> getAllValuesOfp() { - return rawAccumulateAllValuesOfp(emptyArray()); - } - - @Override - protected EPackageMatch tupleToMatch(final Tuple t) { - try { - return EPackageMatch.newMatch((EPackage) t.get(POSITION_P)); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in tuple not properly typed!",e); - return null; - } - } - - @Override - protected EPackageMatch arrayToMatch(final Object[] match) { - try { - return EPackageMatch.newMatch((EPackage) match[POSITION_P]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - @Override - protected EPackageMatch arrayToMatchMutable(final Object[] match) { - try { - return EPackageMatch.newMutableMatch((EPackage) match[POSITION_P]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - /** - * @return the singleton instance of the query specification of this pattern - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static IQuerySpecification<EPackageMatcher> querySpecification() throws ViatraQueryException { - return EPackageQuerySpecification.instance(); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/HeadlessQueries.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/HeadlessQueries.java index 7646931..f958315 100644 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/HeadlessQueries.java +++ b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/HeadlessQueries.java @@ -1,29 +1,23 @@ +/** + * Generated from platform:/resource/org.eclipse.viatra.query.application.queries/src/org/eclipse/viatra/query/application/queries/headlessQueries.vql + */ package org.eclipse.viatra.query.application.queries; -import org.eclipse.viatra.query.application.queries.ClassesInPackageHierarchyMatcher; -import org.eclipse.viatra.query.application.queries.ClassesInPackageMatcher; -import org.eclipse.viatra.query.application.queries.EClassMatcher; -import org.eclipse.viatra.query.application.queries.EClassNamesKeywordMatcher; -import org.eclipse.viatra.query.application.queries.EClassNamesMatcher; -import org.eclipse.viatra.query.application.queries.EObjectMatcher; -import org.eclipse.viatra.query.application.queries.EPackageMatcher; -import org.eclipse.viatra.query.application.queries.SubPackageMatcher; -import org.eclipse.viatra.query.application.queries.util.ClassesInPackageHierarchyQuerySpecification; -import org.eclipse.viatra.query.application.queries.util.ClassesInPackageQuerySpecification; -import org.eclipse.viatra.query.application.queries.util.EClassNamesKeywordQuerySpecification; -import org.eclipse.viatra.query.application.queries.util.EClassNamesQuerySpecification; -import org.eclipse.viatra.query.application.queries.util.EClassQuerySpecification; -import org.eclipse.viatra.query.application.queries.util.EObjectQuerySpecification; -import org.eclipse.viatra.query.application.queries.util.EPackageQuerySpecification; -import org.eclipse.viatra.query.application.queries.util.SubPackageQuerySpecification; +import org.eclipse.viatra.query.application.queries.ClassesInPackage; +import org.eclipse.viatra.query.application.queries.ClassesInPackageHierarchy; +import org.eclipse.viatra.query.application.queries.EClass; +import org.eclipse.viatra.query.application.queries.EClassNames; +import org.eclipse.viatra.query.application.queries.EClassNamesKeyword; +import org.eclipse.viatra.query.application.queries.EObject; +import org.eclipse.viatra.query.application.queries.EPackage; +import org.eclipse.viatra.query.application.queries.SubPackage; import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; /** - * A pattern group formed of all patterns defined in headlessQueries.vql. + * A pattern group formed of all public patterns defined in headlessQueries.vql. * - * <p>Use the static instance as any {@link org.eclipse.viatra.query.runtime.api.IPatternGroup}, to conveniently prepare + * <p>Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare * a VIATRA Query engine for matching all patterns originally defined in file headlessQueries.vql, * in order to achieve better performance than one-by-one on-demand matcher initialization. * @@ -38,7 +32,7 @@ import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; * <li>eClass</li> * </ul> * - * @see IPatternGroup + * @see IQueryGroup * */ @SuppressWarnings("all") @@ -47,90 +41,90 @@ public final class HeadlessQueries extends BaseGeneratedPatternGroup { * Access the pattern group. * * @return the singleton instance of the group - * @throws ViatraQueryException if there was an error loading the generated code of pattern specifications + * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications * */ - public static HeadlessQueries instance() throws ViatraQueryException { + public static HeadlessQueries instance() { if (INSTANCE == null) { - INSTANCE = new HeadlessQueries(); + INSTANCE = new HeadlessQueries(); } return INSTANCE; } private static HeadlessQueries INSTANCE; - private HeadlessQueries() throws ViatraQueryException { - querySpecifications.add(EClassNamesQuerySpecification.instance()); - querySpecifications.add(EClassNamesKeywordQuerySpecification.instance()); - querySpecifications.add(EObjectQuerySpecification.instance()); - querySpecifications.add(ClassesInPackageQuerySpecification.instance()); - querySpecifications.add(SubPackageQuerySpecification.instance()); - querySpecifications.add(ClassesInPackageHierarchyQuerySpecification.instance()); - querySpecifications.add(EPackageQuerySpecification.instance()); - querySpecifications.add(EClassQuerySpecification.instance()); + private HeadlessQueries() { + querySpecifications.add(EClassNames.instance()); + querySpecifications.add(EClassNamesKeyword.instance()); + querySpecifications.add(EObject.instance()); + querySpecifications.add(ClassesInPackage.instance()); + querySpecifications.add(SubPackage.instance()); + querySpecifications.add(ClassesInPackageHierarchy.instance()); + querySpecifications.add(EPackage.instance()); + querySpecifications.add(EClass.instance()); } - public EClassNamesQuerySpecification getEClassNames() throws ViatraQueryException { - return EClassNamesQuerySpecification.instance(); + public EClassNames getEClassNames() { + return EClassNames.instance(); } - public EClassNamesMatcher getEClassNames(final ViatraQueryEngine engine) throws ViatraQueryException { - return EClassNamesMatcher.on(engine); + public EClassNames.Matcher getEClassNames(final ViatraQueryEngine engine) { + return EClassNames.Matcher.on(engine); } - public EClassNamesKeywordQuerySpecification getEClassNamesKeyword() throws ViatraQueryException { - return EClassNamesKeywordQuerySpecification.instance(); + public EClassNamesKeyword getEClassNamesKeyword() { + return EClassNamesKeyword.instance(); } - public EClassNamesKeywordMatcher getEClassNamesKeyword(final ViatraQueryEngine engine) throws ViatraQueryException { - return EClassNamesKeywordMatcher.on(engine); + public EClassNamesKeyword.Matcher getEClassNamesKeyword(final ViatraQueryEngine engine) { + return EClassNamesKeyword.Matcher.on(engine); } - public EObjectQuerySpecification getEObject() throws ViatraQueryException { - return EObjectQuerySpecification.instance(); + public EObject getEObject() { + return EObject.instance(); } - public EObjectMatcher getEObject(final ViatraQueryEngine engine) throws ViatraQueryException { - return EObjectMatcher.on(engine); + public EObject.Matcher getEObject(final ViatraQueryEngine engine) { + return EObject.Matcher.on(engine); } - public ClassesInPackageQuerySpecification getClassesInPackage() throws ViatraQueryException { - return ClassesInPackageQuerySpecification.instance(); + public ClassesInPackage getClassesInPackage() { + return ClassesInPackage.instance(); } - public ClassesInPackageMatcher getClassesInPackage(final ViatraQueryEngine engine) throws ViatraQueryException { - return ClassesInPackageMatcher.on(engine); + public ClassesInPackage.Matcher getClassesInPackage(final ViatraQueryEngine engine) { + return ClassesInPackage.Matcher.on(engine); } - public SubPackageQuerySpecification getSubPackage() throws ViatraQueryException { - return SubPackageQuerySpecification.instance(); + public SubPackage getSubPackage() { + return SubPackage.instance(); } - public SubPackageMatcher getSubPackage(final ViatraQueryEngine engine) throws ViatraQueryException { - return SubPackageMatcher.on(engine); + public SubPackage.Matcher getSubPackage(final ViatraQueryEngine engine) { + return SubPackage.Matcher.on(engine); } - public ClassesInPackageHierarchyQuerySpecification getClassesInPackageHierarchy() throws ViatraQueryException { - return ClassesInPackageHierarchyQuerySpecification.instance(); + public ClassesInPackageHierarchy getClassesInPackageHierarchy() { + return ClassesInPackageHierarchy.instance(); } - public ClassesInPackageHierarchyMatcher getClassesInPackageHierarchy(final ViatraQueryEngine engine) throws ViatraQueryException { - return ClassesInPackageHierarchyMatcher.on(engine); + public ClassesInPackageHierarchy.Matcher getClassesInPackageHierarchy(final ViatraQueryEngine engine) { + return ClassesInPackageHierarchy.Matcher.on(engine); } - public EPackageQuerySpecification getEPackage() throws ViatraQueryException { - return EPackageQuerySpecification.instance(); + public EPackage getEPackage() { + return EPackage.instance(); } - public EPackageMatcher getEPackage(final ViatraQueryEngine engine) throws ViatraQueryException { - return EPackageMatcher.on(engine); + public EPackage.Matcher getEPackage(final ViatraQueryEngine engine) { + return EPackage.Matcher.on(engine); } - public EClassQuerySpecification getEClass() throws ViatraQueryException { - return EClassQuerySpecification.instance(); + public EClass getEClass() { + return EClass.instance(); } - public EClassMatcher getEClass(final ViatraQueryEngine engine) throws ViatraQueryException { - return EClassMatcher.on(engine); + public EClass.Matcher getEClass(final ViatraQueryEngine engine) { + return EClass.Matcher.on(engine); } } diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/SubPackageMatch.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/SubPackageMatch.java deleted file mode 100644 index 3539481..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/SubPackageMatch.java +++ /dev/null @@ -1,207 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Arrays; -import java.util.List; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.viatra.query.application.queries.util.SubPackageQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IPatternMatch; -import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; - -/** - * Pattern-specific match representation of the org.eclipse.viatra.query.application.queries.subPackage pattern, - * to be used in conjunction with {@link SubPackageMatcher}. - * - * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. - * Each instance is a (possibly partial) substitution of pattern parameters, - * usable to represent a match of the pattern in the result of a query, - * or to specify the bound (fixed) input parameters when issuing a query. - * - * @see SubPackageMatcher - * @see SubPackageProcessor - * - */ -@SuppressWarnings("all") -public abstract class SubPackageMatch extends BasePatternMatch { - private EPackage fP; - - private EPackage fSp; - - private static List<String> parameterNames = makeImmutableList("p", "sp"); - - private SubPackageMatch(final EPackage pP, final EPackage pSp) { - this.fP = pP; - this.fSp = pSp; - } - - @Override - public Object get(final String parameterName) { - if ("p".equals(parameterName)) return this.fP; - if ("sp".equals(parameterName)) return this.fSp; - return null; - } - - public EPackage getP() { - return this.fP; - } - - public EPackage getSp() { - return this.fSp; - } - - @Override - public boolean set(final String parameterName, final Object newValue) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - if ("p".equals(parameterName) ) { - this.fP = (EPackage) newValue; - return true; - } - if ("sp".equals(parameterName) ) { - this.fSp = (EPackage) newValue; - return true; - } - return false; - } - - public void setP(final EPackage pP) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fP = pP; - } - - public void setSp(final EPackage pSp) { - if (!isMutable()) throw new java.lang.UnsupportedOperationException(); - this.fSp = pSp; - } - - @Override - public String patternName() { - return "org.eclipse.viatra.query.application.queries.subPackage"; - } - - @Override - public List<String> parameterNames() { - return SubPackageMatch.parameterNames; - } - - @Override - public Object[] toArray() { - return new Object[]{fP, fSp}; - } - - @Override - public SubPackageMatch toImmutable() { - return isMutable() ? newMatch(fP, fSp) : this; - } - - @Override - public String prettyPrint() { - StringBuilder result = new StringBuilder(); - result.append("\"p\"=" + prettyPrintValue(fP) + ", "); - - result.append("\"sp\"=" + prettyPrintValue(fSp) - ); - return result.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((fP == null) ? 0 : fP.hashCode()); - result = prime * result + ((fSp == null) ? 0 : fSp.hashCode()); - return result; - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if (!(obj instanceof SubPackageMatch)) { // this should be infrequent - if (obj == null) { - return false; - } - if (!(obj instanceof IPatternMatch)) { - return false; - } - IPatternMatch otherSig = (IPatternMatch) obj; - if (!specification().equals(otherSig.specification())) - return false; - return Arrays.deepEquals(toArray(), otherSig.toArray()); - } - SubPackageMatch other = (SubPackageMatch) obj; - if (fP == null) {if (other.fP != null) return false;} - else if (!fP.equals(other.fP)) return false; - if (fSp == null) {if (other.fSp != null) return false;} - else if (!fSp.equals(other.fSp)) return false; - return true; - } - - @Override - public SubPackageQuerySpecification specification() { - try { - return SubPackageQuerySpecification.instance(); - } catch (ViatraQueryException ex) { - // This cannot happen, as the match object can only be instantiated if the query specification exists - throw new IllegalStateException (ex); - } - } - - /** - * Returns an empty, mutable match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @return the empty match. - * - */ - public static SubPackageMatch newEmptyMatch() { - return new Mutable(null, null); - } - - /** - * Returns a mutable (partial) match. - * Fields of the mutable match can be filled to create a partial match, usable as matcher input. - * - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pSp the fixed value of pattern parameter sp, or null if not bound. - * @return the new, mutable (partial) match object. - * - */ - public static SubPackageMatch newMutableMatch(final EPackage pP, final EPackage pSp) { - return new Mutable(pP, pSp); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pSp the fixed value of pattern parameter sp, or null if not bound. - * @return the (partial) match object. - * - */ - public static SubPackageMatch newMatch(final EPackage pP, final EPackage pSp) { - return new Immutable(pP, pSp); - } - - private static final class Mutable extends SubPackageMatch { - Mutable(final EPackage pP, final EPackage pSp) { - super(pP, pSp); - } - - @Override - public boolean isMutable() { - return true; - } - } - - private static final class Immutable extends SubPackageMatch { - Immutable(final EPackage pP, final EPackage pSp) { - super(pP, pSp); - } - - @Override - public boolean isMutable() { - return false; - } - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/SubPackageMatcher.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/SubPackageMatcher.java deleted file mode 100644 index 92aa03b..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/SubPackageMatcher.java +++ /dev/null @@ -1,299 +0,0 @@ -package org.eclipse.viatra.query.application.queries; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; -import org.apache.log4j.Logger; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.viatra.query.application.queries.SubPackageMatch; -import org.eclipse.viatra.query.application.queries.util.SubPackageQuerySpecification; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; -import org.eclipse.viatra.query.runtime.api.IQuerySpecification; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; -import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; - -/** - * Generated pattern matcher API of the org.eclipse.viatra.query.application.queries.subPackage pattern, - * providing pattern-specific query methods. - * - * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, - * e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)}. - * - * <p>Matches of the pattern will be represented as {@link SubPackageMatch}. - * - * <p>Original source: - * <code><pre> - * {@literal @}Edge(source = p, target = sp, label = "sub") - * pattern subPackage(p: EPackage, sp: EPackage){ EPackage.eSubpackages(p,sp); } - * </pre></code> - * - * @see SubPackageMatch - * @see SubPackageProcessor - * @see SubPackageQuerySpecification - * - */ -@SuppressWarnings("all") -public class SubPackageMatcher extends BaseMatcher<SubPackageMatch> { - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * - */ - public static SubPackageMatcher on(final ViatraQueryEngine engine) throws ViatraQueryException { - // check if matcher already exists - SubPackageMatcher matcher = engine.getExistingMatcher(querySpecification()); - if (matcher == null) { - matcher = new SubPackageMatcher(engine); - // do not have to "put" it into engine.matchers, reportMatcherInitialized() will take care of it - } - return matcher; - } - - private final static int POSITION_P = 0; - - private final static int POSITION_SP = 1; - - private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(SubPackageMatcher.class); - - /** - * Initializes the pattern matcher over a given EMF model root (recommended: Resource or ResourceSet). - * If a pattern matcher is already constructed with the same root, only a light-weight reference is returned. - * The scope of pattern matching will be the given EMF model root and below (see FAQ for more precise definition). - * The match set will be incrementally refreshed upon updates from this scope. - * <p>The matcher will be created within the managed {@link ViatraQueryEngine} belonging to the EMF model root, so - * multiple matchers will reuse the same engine and benefit from increased performance and reduced memory footprint. - * @param emfRoot the root of the EMF containment hierarchy where the pattern matcher will operate. Recommended: Resource or ResourceSet. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead, e.g. in conjunction with {@link ViatraQueryEngine#on(Notifier)} - * - */ - @Deprecated - public SubPackageMatcher(final Notifier emfRoot) throws ViatraQueryException { - this(ViatraQueryEngine.on(emfRoot)); - } - - /** - * Initializes the pattern matcher within an existing VIATRA Query engine. - * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. - * The match set will be incrementally refreshed upon updates. - * @param engine the existing VIATRA Query engine in which this matcher will be created. - * @throws ViatraQueryException if an error occurs during pattern matcher creation - * @deprecated use {@link #on(ViatraQueryEngine)} instead - * - */ - @Deprecated - public SubPackageMatcher(final ViatraQueryEngine engine) throws ViatraQueryException { - super(engine, querySpecification()); - } - - /** - * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pSp the fixed value of pattern parameter sp, or null if not bound. - * @return matches represented as a SubPackageMatch object. - * - */ - public Collection<SubPackageMatch> getAllMatches(final EPackage pP, final EPackage pSp) { - return rawGetAllMatches(new Object[]{pP, pSp}); - } - - /** - * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pSp the fixed value of pattern parameter sp, or null if not bound. - * @return a match represented as a SubPackageMatch object, or null if no match is found. - * - */ - public SubPackageMatch getOneArbitraryMatch(final EPackage pP, final EPackage pSp) { - return rawGetOneArbitraryMatch(new Object[]{pP, pSp}); - } - - /** - * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, - * under any possible substitution of the unspecified parameters (if any). - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pSp the fixed value of pattern parameter sp, or null if not bound. - * @return true if the input is a valid (partial) match of the pattern. - * - */ - public boolean hasMatch(final EPackage pP, final EPackage pSp) { - return rawHasMatch(new Object[]{pP, pSp}); - } - - /** - * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pSp the fixed value of pattern parameter sp, or null if not bound. - * @return the number of pattern matches found. - * - */ - public int countMatches(final EPackage pP, final EPackage pSp) { - return rawCountMatches(new Object[]{pP, pSp}); - } - - /** - * Executes the given processor on each match of the pattern that conforms to the given fixed values of some parameters. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pSp the fixed value of pattern parameter sp, or null if not bound. - * @param processor the action that will process each pattern match. - * - */ - public void forEachMatch(final EPackage pP, final EPackage pSp, final IMatchProcessor<? super SubPackageMatch> processor) { - rawForEachMatch(new Object[]{pP, pSp}, processor); - } - - /** - * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. - * Neither determinism nor randomness of selection is guaranteed. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pSp the fixed value of pattern parameter sp, or null if not bound. - * @param processor the action that will process the selected match. - * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked - * - */ - public boolean forOneArbitraryMatch(final EPackage pP, final EPackage pSp, final IMatchProcessor<? super SubPackageMatch> processor) { - return rawForOneArbitraryMatch(new Object[]{pP, pSp}, processor); - } - - /** - * Returns a new (partial) match. - * This can be used e.g. to call the matcher with a partial match. - * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. - * @param pP the fixed value of pattern parameter p, or null if not bound. - * @param pSp the fixed value of pattern parameter sp, or null if not bound. - * @return the (partial) match object. - * - */ - public SubPackageMatch newMatch(final EPackage pP, final EPackage pSp) { - return SubPackageMatch.newMatch(pP, pSp); - } - - /** - * Retrieve the set of values that occur in matches for p. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - protected Set<EPackage> rawAccumulateAllValuesOfp(final Object[] parameters) { - Set<EPackage> results = new HashSet<EPackage>(); - rawAccumulateAllValues(POSITION_P, parameters, results); - return results; - } - - /** - * Retrieve the set of values that occur in matches for p. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EPackage> getAllValuesOfp() { - return rawAccumulateAllValuesOfp(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for p. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EPackage> getAllValuesOfp(final SubPackageMatch partialMatch) { - return rawAccumulateAllValuesOfp(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for p. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EPackage> getAllValuesOfp(final EPackage pSp) { - return rawAccumulateAllValuesOfp(new Object[]{ - null, - pSp - }); - } - - /** - * Retrieve the set of values that occur in matches for sp. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - protected Set<EPackage> rawAccumulateAllValuesOfsp(final Object[] parameters) { - Set<EPackage> results = new HashSet<EPackage>(); - rawAccumulateAllValues(POSITION_SP, parameters, results); - return results; - } - - /** - * Retrieve the set of values that occur in matches for sp. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EPackage> getAllValuesOfsp() { - return rawAccumulateAllValuesOfsp(emptyArray()); - } - - /** - * Retrieve the set of values that occur in matches for sp. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EPackage> getAllValuesOfsp(final SubPackageMatch partialMatch) { - return rawAccumulateAllValuesOfsp(partialMatch.toArray()); - } - - /** - * Retrieve the set of values that occur in matches for sp. - * @return the Set of all values, null if no parameter with the given name exists, empty set if there are no matches - * - */ - public Set<EPackage> getAllValuesOfsp(final EPackage pP) { - return rawAccumulateAllValuesOfsp(new Object[]{ - pP, - null - }); - } - - @Override - protected SubPackageMatch tupleToMatch(final Tuple t) { - try { - return SubPackageMatch.newMatch((EPackage) t.get(POSITION_P), (EPackage) t.get(POSITION_SP)); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in tuple not properly typed!",e); - return null; - } - } - - @Override - protected SubPackageMatch arrayToMatch(final Object[] match) { - try { - return SubPackageMatch.newMatch((EPackage) match[POSITION_P], (EPackage) match[POSITION_SP]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - @Override - protected SubPackageMatch arrayToMatchMutable(final Object[] match) { - try { - return SubPackageMatch.newMutableMatch((EPackage) match[POSITION_P], (EPackage) match[POSITION_SP]); - } catch(ClassCastException e) { - LOGGER.error("Element(s) in array not properly typed!",e); - return null; - } - } - - /** - * @return the singleton instance of the query specification of this pattern - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static IQuerySpecification<SubPackageMatcher> querySpecification() throws ViatraQueryException { - return SubPackageQuerySpecification.instance(); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/.gitignore b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/.gitignore deleted file mode 100644 index b21d549..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -/.ClassesInPackageHierarchyProcessor.java._trace -/.ClassesInPackageHierarchyQuerySpecification.java._trace -/.ClassesInPackageProcessor.java._trace -/.ClassesInPackageQuerySpecification.java._trace -/.EClassNamesKeywordProcessor.java._trace -/.EClassNamesKeywordQuerySpecification.java._trace -/.EClassNamesProcessor.java._trace -/.EClassNamesQuerySpecification.java._trace -/.EClassProcessor.java._trace -/.EClassQuerySpecification.java._trace -/.EObjectProcessor.java._trace -/.EObjectQuerySpecification.java._trace -/.EPackageProcessor.java._trace -/.EPackageQuerySpecification.java._trace -/.SubPackageProcessor.java._trace -/.SubPackageQuerySpecification.java._trace diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageHierarchyProcessor.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageHierarchyProcessor.java deleted file mode 100644 index 851e211..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageHierarchyProcessor.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.viatra.query.application.queries.ClassesInPackageHierarchyMatch; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; - -/** - * A match processor tailored for the org.eclipse.viatra.query.application.queries.classesInPackageHierarchy pattern. - * - * Clients should derive an (anonymous) class that implements the abstract process(). - * - */ -@SuppressWarnings("all") -public abstract class ClassesInPackageHierarchyProcessor implements IMatchProcessor<ClassesInPackageHierarchyMatch> { - /** - * Defines the action that is to be executed on each match. - * @param pRootP the value of pattern parameter rootP in the currently processed match - * @param pContainedClass the value of pattern parameter containedClass in the currently processed match - * - */ - public abstract void process(final EPackage pRootP, final EClass pContainedClass); - - @Override - public void process(final ClassesInPackageHierarchyMatch match) { - process(match.getRootP(), match.getContainedClass()); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageHierarchyQuerySpecification.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageHierarchyQuerySpecification.java deleted file mode 100644 index f4e3ee8..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageHierarchyQuerySpecification.java +++ /dev/null @@ -1,169 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import com.google.common.collect.Sets; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.viatra.query.application.queries.ClassesInPackageHierarchyMatch; -import org.eclipse.viatra.query.application.queries.ClassesInPackageHierarchyMatcher; -import org.eclipse.viatra.query.application.queries.util.ClassesInPackageQuerySpecification; -import org.eclipse.viatra.query.application.queries.util.SubPackageQuerySpecification; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; -import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; -import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; -import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; -import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.BinaryTransitiveClosure; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.QueryInitializationException; -import org.eclipse.viatra.query.runtime.matchers.tuple.FlatTuple; - -/** - * A pattern-specific query specification that can instantiate ClassesInPackageHierarchyMatcher in a type-safe way. - * - * @see ClassesInPackageHierarchyMatcher - * @see ClassesInPackageHierarchyMatch - * - */ -@SuppressWarnings("all") -public final class ClassesInPackageHierarchyQuerySpecification extends BaseGeneratedEMFQuerySpecification<ClassesInPackageHierarchyMatcher> { - private ClassesInPackageHierarchyQuerySpecification() { - super(GeneratedPQuery.INSTANCE); - } - - /** - * @return the singleton instance of the query specification - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static ClassesInPackageHierarchyQuerySpecification instance() throws ViatraQueryException { - try{ - return LazyHolder.INSTANCE; - } catch (ExceptionInInitializerError err) { - throw processInitializerError(err); - } - } - - @Override - protected ClassesInPackageHierarchyMatcher instantiate(final ViatraQueryEngine engine) throws ViatraQueryException { - return ClassesInPackageHierarchyMatcher.on(engine); - } - - @Override - public ClassesInPackageHierarchyMatch newEmptyMatch() { - return ClassesInPackageHierarchyMatch.newEmptyMatch(); - } - - @Override - public ClassesInPackageHierarchyMatch newMatch(final Object... parameters) { - return ClassesInPackageHierarchyMatch.newMatch((org.eclipse.emf.ecore.EPackage) parameters[0], (org.eclipse.emf.ecore.EClass) parameters[1]); - } - - /** - * Inner class allowing the singleton instance of {@link ClassesInPackageHierarchyQuerySpecification} to be created - * <b>not</b> at the class load time of the outer class, - * but rather at the first call to {@link ClassesInPackageHierarchyQuerySpecification#instance()}. - * - * <p> This workaround is required e.g. to support recursion. - * - */ - private static class LazyHolder { - private final static ClassesInPackageHierarchyQuerySpecification INSTANCE = new ClassesInPackageHierarchyQuerySpecification(); - - /** - * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. - * This initialization order is required to support indirect recursion. - * - * <p> The static initializer is defined using a helper field to work around limitations of the code generator. - * - */ - private final static Object STATIC_INITIALIZER = ensureInitialized(); - - public static Object ensureInitialized() { - INSTANCE.ensureInitializedInternalSneaky(); - return null; - } - } - - private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { - private final static ClassesInPackageHierarchyQuerySpecification.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - - @Override - public String getFullyQualifiedName() { - return "org.eclipse.viatra.query.application.queries.classesInPackageHierarchy"; - } - - @Override - public List<String> getParameterNames() { - return Arrays.asList("rootP","containedClass"); - } - - @Override - public List<PParameter> getParameters() { - return Arrays.asList(new PParameter("rootP", "org.eclipse.emf.ecore.EPackage"),new PParameter("containedClass", "org.eclipse.emf.ecore.EClass")); - } - - @Override - public Set<PBody> doGetContainedBodies() throws QueryInitializationException { - Set<PBody> bodies = Sets.newLinkedHashSet(); - try { - { - PBody body = new PBody(this); - PVariable var_rootP = body.getOrCreateVariableByName("rootP"); - PVariable var_containedClass = body.getOrCreateVariableByName("containedClass"); - new TypeConstraint(body, new FlatTuple(var_rootP), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); - new TypeConstraint(body, new FlatTuple(var_containedClass), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass"))); - body.setSymbolicParameters(Arrays.<ExportedParameter>asList( - new ExportedParameter(body, var_rootP, "rootP"), - new ExportedParameter(body, var_containedClass, "containedClass") - )); - // find classesInPackage(rootP,containedClass) - new PositivePatternCall(body, new FlatTuple(var_rootP, var_containedClass), ClassesInPackageQuerySpecification.instance().getInternalQueryRepresentation()); - bodies.add(body); - } - { - PBody body = new PBody(this); - PVariable var_rootP = body.getOrCreateVariableByName("rootP"); - PVariable var_containedClass = body.getOrCreateVariableByName("containedClass"); - PVariable var_somePackage = body.getOrCreateVariableByName("somePackage"); - new TypeConstraint(body, new FlatTuple(var_rootP), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); - new TypeConstraint(body, new FlatTuple(var_containedClass), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass"))); - body.setSymbolicParameters(Arrays.<ExportedParameter>asList( - new ExportedParameter(body, var_rootP, "rootP"), - new ExportedParameter(body, var_containedClass, "containedClass") - )); - // find subPackage+(rootP,somePackage) - new BinaryTransitiveClosure(body, new FlatTuple(var_rootP, var_somePackage), SubPackageQuerySpecification.instance().getInternalQueryRepresentation()); - // find classesInPackage(somePackage,containedClass) - new PositivePatternCall(body, new FlatTuple(var_somePackage, var_containedClass), ClassesInPackageQuerySpecification.instance().getInternalQueryRepresentation()); - bodies.add(body); - } - { - PAnnotation annotation = new PAnnotation("Edge"); - annotation.addAttribute("source", new ParameterReference("rootP")); - annotation.addAttribute("label", "classIn+"); - annotation.addAttribute("target", new ParameterReference("containedClass")); - addAnnotation(annotation); - } - { - PAnnotation annotation = new PAnnotation("Format"); - annotation.addAttribute("color", "#0033ff"); - addAnnotation(annotation); - } - // to silence compiler error - if (false) throw new ViatraQueryException("Never", "happens"); - } catch (ViatraQueryException ex) { - throw processDependencyException(ex); - } - return bodies; - } - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageProcessor.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageProcessor.java deleted file mode 100644 index b91cb6d..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageProcessor.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.viatra.query.application.queries.ClassesInPackageMatch; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; - -/** - * A match processor tailored for the org.eclipse.viatra.query.application.queries.classesInPackage pattern. - * - * Clients should derive an (anonymous) class that implements the abstract process(). - * - */ -@SuppressWarnings("all") -public abstract class ClassesInPackageProcessor implements IMatchProcessor<ClassesInPackageMatch> { - /** - * Defines the action that is to be executed on each match. - * @param pP the value of pattern parameter p in the currently processed match - * @param pEc the value of pattern parameter ec in the currently processed match - * - */ - public abstract void process(final EPackage pP, final EClass pEc); - - @Override - public void process(final ClassesInPackageMatch match) { - process(match.getP(), match.getEc()); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageQuerySpecification.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageQuerySpecification.java deleted file mode 100644 index 86fa4cb..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageQuerySpecification.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import com.google.common.collect.Sets; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.viatra.query.application.queries.ClassesInPackageMatch; -import org.eclipse.viatra.query.application.queries.ClassesInPackageMatcher; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; -import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; -import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; -import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; -import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; -import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.QueryInitializationException; -import org.eclipse.viatra.query.runtime.matchers.tuple.FlatTuple; - -/** - * A pattern-specific query specification that can instantiate ClassesInPackageMatcher in a type-safe way. - * - * @see ClassesInPackageMatcher - * @see ClassesInPackageMatch - * - */ -@SuppressWarnings("all") -public final class ClassesInPackageQuerySpecification extends BaseGeneratedEMFQuerySpecification<ClassesInPackageMatcher> { - private ClassesInPackageQuerySpecification() { - super(GeneratedPQuery.INSTANCE); - } - - /** - * @return the singleton instance of the query specification - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static ClassesInPackageQuerySpecification instance() throws ViatraQueryException { - try{ - return LazyHolder.INSTANCE; - } catch (ExceptionInInitializerError err) { - throw processInitializerError(err); - } - } - - @Override - protected ClassesInPackageMatcher instantiate(final ViatraQueryEngine engine) throws ViatraQueryException { - return ClassesInPackageMatcher.on(engine); - } - - @Override - public ClassesInPackageMatch newEmptyMatch() { - return ClassesInPackageMatch.newEmptyMatch(); - } - - @Override - public ClassesInPackageMatch newMatch(final Object... parameters) { - return ClassesInPackageMatch.newMatch((org.eclipse.emf.ecore.EPackage) parameters[0], (org.eclipse.emf.ecore.EClass) parameters[1]); - } - - /** - * Inner class allowing the singleton instance of {@link ClassesInPackageQuerySpecification} to be created - * <b>not</b> at the class load time of the outer class, - * but rather at the first call to {@link ClassesInPackageQuerySpecification#instance()}. - * - * <p> This workaround is required e.g. to support recursion. - * - */ - private static class LazyHolder { - private final static ClassesInPackageQuerySpecification INSTANCE = new ClassesInPackageQuerySpecification(); - - /** - * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. - * This initialization order is required to support indirect recursion. - * - * <p> The static initializer is defined using a helper field to work around limitations of the code generator. - * - */ - private final static Object STATIC_INITIALIZER = ensureInitialized(); - - public static Object ensureInitialized() { - INSTANCE.ensureInitializedInternalSneaky(); - return null; - } - } - - private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { - private final static ClassesInPackageQuerySpecification.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - - @Override - public String getFullyQualifiedName() { - return "org.eclipse.viatra.query.application.queries.classesInPackage"; - } - - @Override - public List<String> getParameterNames() { - return Arrays.asList("p","ec"); - } - - @Override - public List<PParameter> getParameters() { - return Arrays.asList(new PParameter("p", "org.eclipse.emf.ecore.EPackage"),new PParameter("ec", "org.eclipse.emf.ecore.EClass")); - } - - @Override - public Set<PBody> doGetContainedBodies() throws QueryInitializationException { - Set<PBody> bodies = Sets.newLinkedHashSet(); - try { - { - PBody body = new PBody(this); - PVariable var_p = body.getOrCreateVariableByName("p"); - PVariable var_ec = body.getOrCreateVariableByName("ec"); - new TypeConstraint(body, new FlatTuple(var_p), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); - new TypeConstraint(body, new FlatTuple(var_ec), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass"))); - body.setSymbolicParameters(Arrays.<ExportedParameter>asList( - new ExportedParameter(body, var_p, "p"), - new ExportedParameter(body, var_ec, "ec") - )); - // EPackage.eClassifiers(p,ec) - new TypeConstraint(body, new FlatTuple(var_p), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); - PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); - new TypeConstraint(body, new FlatTuple(var_p, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage", "eClassifiers"))); - new Equality(body, var__virtual_0_, var_ec); - bodies.add(body); - } - { - PAnnotation annotation = new PAnnotation("Edge"); - annotation.addAttribute("source", new ParameterReference("p")); - annotation.addAttribute("label", "classIn"); - annotation.addAttribute("target", new ParameterReference("ec")); - addAnnotation(annotation); - } - // to silence compiler error - if (false) throw new ViatraQueryException("Never", "happens"); - } catch (ViatraQueryException ex) { - throw processDependencyException(ex); - } - return bodies; - } - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesKeywordProcessor.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesKeywordProcessor.java deleted file mode 100644 index 37be5d2..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesKeywordProcessor.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.viatra.query.application.queries.EClassNamesKeywordMatch; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; - -/** - * A match processor tailored for the org.eclipse.viatra.query.application.queries.eClassNamesKeyword pattern. - * - * Clients should derive an (anonymous) class that implements the abstract process(). - * - */ -@SuppressWarnings("all") -public abstract class EClassNamesKeywordProcessor implements IMatchProcessor<EClassNamesKeywordMatch> { - /** - * Defines the action that is to be executed on each match. - * @param pC the value of pattern parameter c in the currently processed match - * @param pN the value of pattern parameter n in the currently processed match - * - */ - public abstract void process(final EClass pC, final String pN); - - @Override - public void process(final EClassNamesKeywordMatch match) { - process(match.getC(), match.getN()); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesKeywordQuerySpecification.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesKeywordQuerySpecification.java deleted file mode 100644 index 2f771e1..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesKeywordQuerySpecification.java +++ /dev/null @@ -1,170 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import com.google.common.base.Objects; -import com.google.common.collect.Sets; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.viatra.query.application.queries.EClassNamesKeywordMatch; -import org.eclipse.viatra.query.application.queries.EClassNamesKeywordMatcher; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; -import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; -import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; -import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; -import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; -import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; -import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.QueryInitializationException; -import org.eclipse.viatra.query.runtime.matchers.tuple.FlatTuple; - -/** - * A pattern-specific query specification that can instantiate EClassNamesKeywordMatcher in a type-safe way. - * - * @see EClassNamesKeywordMatcher - * @see EClassNamesKeywordMatch - * - */ -@SuppressWarnings("all") -public final class EClassNamesKeywordQuerySpecification extends BaseGeneratedEMFQuerySpecification<EClassNamesKeywordMatcher> { - private EClassNamesKeywordQuerySpecification() { - super(GeneratedPQuery.INSTANCE); - } - - /** - * @return the singleton instance of the query specification - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static EClassNamesKeywordQuerySpecification instance() throws ViatraQueryException { - try{ - return LazyHolder.INSTANCE; - } catch (ExceptionInInitializerError err) { - throw processInitializerError(err); - } - } - - @Override - protected EClassNamesKeywordMatcher instantiate(final ViatraQueryEngine engine) throws ViatraQueryException { - return EClassNamesKeywordMatcher.on(engine); - } - - @Override - public EClassNamesKeywordMatch newEmptyMatch() { - return EClassNamesKeywordMatch.newEmptyMatch(); - } - - @Override - public EClassNamesKeywordMatch newMatch(final Object... parameters) { - return EClassNamesKeywordMatch.newMatch((org.eclipse.emf.ecore.EClass) parameters[0], (java.lang.String) parameters[1]); - } - - /** - * Inner class allowing the singleton instance of {@link EClassNamesKeywordQuerySpecification} to be created - * <b>not</b> at the class load time of the outer class, - * but rather at the first call to {@link EClassNamesKeywordQuerySpecification#instance()}. - * - * <p> This workaround is required e.g. to support recursion. - * - */ - private static class LazyHolder { - private final static EClassNamesKeywordQuerySpecification INSTANCE = new EClassNamesKeywordQuerySpecification(); - - /** - * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. - * This initialization order is required to support indirect recursion. - * - * <p> The static initializer is defined using a helper field to work around limitations of the code generator. - * - */ - private final static Object STATIC_INITIALIZER = ensureInitialized(); - - public static Object ensureInitialized() { - INSTANCE.ensureInitializedInternalSneaky(); - return null; - } - } - - private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { - private final static EClassNamesKeywordQuerySpecification.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - - @Override - public String getFullyQualifiedName() { - return "org.eclipse.viatra.query.application.queries.eClassNamesKeyword"; - } - - @Override - public List<String> getParameterNames() { - return Arrays.asList("c","n"); - } - - @Override - public List<PParameter> getParameters() { - return Arrays.asList(new PParameter("c", "org.eclipse.emf.ecore.EClass"),new PParameter("n", "java.lang.String")); - } - - @Override - public Set<PBody> doGetContainedBodies() throws QueryInitializationException { - Set<PBody> bodies = Sets.newLinkedHashSet(); - try { - { - PBody body = new PBody(this); - PVariable var_c = body.getOrCreateVariableByName("c"); - PVariable var_n = body.getOrCreateVariableByName("n"); - new TypeConstraint(body, new FlatTuple(var_c), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass"))); - new TypeConstraint(body, new FlatTuple(var_n), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EString"))); - body.setSymbolicParameters(Arrays.<ExportedParameter>asList( - new ExportedParameter(body, var_c, "c"), - new ExportedParameter(body, var_n, "n") - )); - // EClass.name(c,n) - new TypeConstraint(body, new FlatTuple(var_c), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass"))); - PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); - new TypeConstraint(body, new FlatTuple(var_c, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "ENamedElement", "name"))); - new Equality(body, var__virtual_0_, var_n); - // check("A" == n) - new ExpressionEvaluation(body, new IExpressionEvaluator() { - - @Override - public String getShortDescription() { - return "Expression evaluation from pattern eClassNamesKeyword"; - } - - @Override - public Iterable<String> getInputParameterNames() { - return Arrays.asList("n"); - } - - @Override - public Object evaluateExpression(IValueProvider provider) throws Exception { - java.lang.String n = (java.lang.String) provider.getValue("n"); - return evaluateExpression_1_1(n); - } - - }, null); - bodies.add(body); - } - // to silence compiler error - if (false) throw new ViatraQueryException("Never", "happens"); - } catch (ViatraQueryException ex) { - throw processDependencyException(ex); - } - return bodies; - } - } - - private static boolean evaluateExpression_1_1(final String n) { - boolean _equals = Objects.equal("A", n); - return _equals; - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesProcessor.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesProcessor.java deleted file mode 100644 index 9077c03..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesProcessor.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.viatra.query.application.queries.EClassNamesMatch; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; - -/** - * A match processor tailored for the org.eclipse.viatra.query.application.queries.eClassNames pattern. - * - * Clients should derive an (anonymous) class that implements the abstract process(). - * - */ -@SuppressWarnings("all") -public abstract class EClassNamesProcessor implements IMatchProcessor<EClassNamesMatch> { - /** - * Defines the action that is to be executed on each match. - * @param pC the value of pattern parameter c in the currently processed match - * @param pN the value of pattern parameter n in the currently processed match - * - */ - public abstract void process(final EClass pC, final String pN); - - @Override - public void process(final EClassNamesMatch match) { - process(match.getC(), match.getN()); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesQuerySpecification.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesQuerySpecification.java deleted file mode 100644 index 8bf21bf..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesQuerySpecification.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import com.google.common.collect.Sets; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.viatra.query.application.queries.EClassNamesMatch; -import org.eclipse.viatra.query.application.queries.EClassNamesMatcher; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; -import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; -import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; -import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; -import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.QueryInitializationException; -import org.eclipse.viatra.query.runtime.matchers.tuple.FlatTuple; - -/** - * A pattern-specific query specification that can instantiate EClassNamesMatcher in a type-safe way. - * - * @see EClassNamesMatcher - * @see EClassNamesMatch - * - */ -@SuppressWarnings("all") -public final class EClassNamesQuerySpecification extends BaseGeneratedEMFQuerySpecification<EClassNamesMatcher> { - private EClassNamesQuerySpecification() { - super(GeneratedPQuery.INSTANCE); - } - - /** - * @return the singleton instance of the query specification - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static EClassNamesQuerySpecification instance() throws ViatraQueryException { - try{ - return LazyHolder.INSTANCE; - } catch (ExceptionInInitializerError err) { - throw processInitializerError(err); - } - } - - @Override - protected EClassNamesMatcher instantiate(final ViatraQueryEngine engine) throws ViatraQueryException { - return EClassNamesMatcher.on(engine); - } - - @Override - public EClassNamesMatch newEmptyMatch() { - return EClassNamesMatch.newEmptyMatch(); - } - - @Override - public EClassNamesMatch newMatch(final Object... parameters) { - return EClassNamesMatch.newMatch((org.eclipse.emf.ecore.EClass) parameters[0], (java.lang.String) parameters[1]); - } - - /** - * Inner class allowing the singleton instance of {@link EClassNamesQuerySpecification} to be created - * <b>not</b> at the class load time of the outer class, - * but rather at the first call to {@link EClassNamesQuerySpecification#instance()}. - * - * <p> This workaround is required e.g. to support recursion. - * - */ - private static class LazyHolder { - private final static EClassNamesQuerySpecification INSTANCE = new EClassNamesQuerySpecification(); - - /** - * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. - * This initialization order is required to support indirect recursion. - * - * <p> The static initializer is defined using a helper field to work around limitations of the code generator. - * - */ - private final static Object STATIC_INITIALIZER = ensureInitialized(); - - public static Object ensureInitialized() { - INSTANCE.ensureInitializedInternalSneaky(); - return null; - } - } - - private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { - private final static EClassNamesQuerySpecification.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - - @Override - public String getFullyQualifiedName() { - return "org.eclipse.viatra.query.application.queries.eClassNames"; - } - - @Override - public List<String> getParameterNames() { - return Arrays.asList("c","n"); - } - - @Override - public List<PParameter> getParameters() { - return Arrays.asList(new PParameter("c", "org.eclipse.emf.ecore.EClass"),new PParameter("n", "java.lang.String")); - } - - @Override - public Set<PBody> doGetContainedBodies() throws QueryInitializationException { - Set<PBody> bodies = Sets.newLinkedHashSet(); - try { - { - PBody body = new PBody(this); - PVariable var_c = body.getOrCreateVariableByName("c"); - PVariable var_n = body.getOrCreateVariableByName("n"); - new TypeConstraint(body, new FlatTuple(var_c), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass"))); - new TypeConstraint(body, new FlatTuple(var_n), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EString"))); - body.setSymbolicParameters(Arrays.<ExportedParameter>asList( - new ExportedParameter(body, var_c, "c"), - new ExportedParameter(body, var_n, "n") - )); - // EClass.name(c,n) - new TypeConstraint(body, new FlatTuple(var_c), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass"))); - PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); - new TypeConstraint(body, new FlatTuple(var_c, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "ENamedElement", "name"))); - new Equality(body, var__virtual_0_, var_n); - bodies.add(body); - } - // to silence compiler error - if (false) throw new ViatraQueryException("Never", "happens"); - } catch (ViatraQueryException ex) { - throw processDependencyException(ex); - } - return bodies; - } - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassProcessor.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassProcessor.java deleted file mode 100644 index 99b2ba2..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassProcessor.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.viatra.query.application.queries.EClassMatch; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; - -/** - * A match processor tailored for the org.eclipse.viatra.query.application.queries.eClass pattern. - * - * Clients should derive an (anonymous) class that implements the abstract process(). - * - */ -@SuppressWarnings("all") -public abstract class EClassProcessor implements IMatchProcessor<EClassMatch> { - /** - * Defines the action that is to be executed on each match. - * @param pEc the value of pattern parameter ec in the currently processed match - * - */ - public abstract void process(final EClass pEc); - - @Override - public void process(final EClassMatch match) { - process(match.getEc()); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassQuerySpecification.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassQuerySpecification.java deleted file mode 100644 index 4525689..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassQuerySpecification.java +++ /dev/null @@ -1,144 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import com.google.common.collect.Sets; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.viatra.query.application.queries.EClassMatch; -import org.eclipse.viatra.query.application.queries.EClassMatcher; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; -import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; -import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; -import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; -import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.QueryInitializationException; -import org.eclipse.viatra.query.runtime.matchers.tuple.FlatTuple; - -/** - * A pattern-specific query specification that can instantiate EClassMatcher in a type-safe way. - * - * @see EClassMatcher - * @see EClassMatch - * - */ -@SuppressWarnings("all") -public final class EClassQuerySpecification extends BaseGeneratedEMFQuerySpecification<EClassMatcher> { - private EClassQuerySpecification() { - super(GeneratedPQuery.INSTANCE); - } - - /** - * @return the singleton instance of the query specification - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static EClassQuerySpecification instance() throws ViatraQueryException { - try{ - return LazyHolder.INSTANCE; - } catch (ExceptionInInitializerError err) { - throw processInitializerError(err); - } - } - - @Override - protected EClassMatcher instantiate(final ViatraQueryEngine engine) throws ViatraQueryException { - return EClassMatcher.on(engine); - } - - @Override - public EClassMatch newEmptyMatch() { - return EClassMatch.newEmptyMatch(); - } - - @Override - public EClassMatch newMatch(final Object... parameters) { - return EClassMatch.newMatch((org.eclipse.emf.ecore.EClass) parameters[0]); - } - - /** - * Inner class allowing the singleton instance of {@link EClassQuerySpecification} to be created - * <b>not</b> at the class load time of the outer class, - * but rather at the first call to {@link EClassQuerySpecification#instance()}. - * - * <p> This workaround is required e.g. to support recursion. - * - */ - private static class LazyHolder { - private final static EClassQuerySpecification INSTANCE = new EClassQuerySpecification(); - - /** - * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. - * This initialization order is required to support indirect recursion. - * - * <p> The static initializer is defined using a helper field to work around limitations of the code generator. - * - */ - private final static Object STATIC_INITIALIZER = ensureInitialized(); - - public static Object ensureInitialized() { - INSTANCE.ensureInitializedInternalSneaky(); - return null; - } - } - - private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { - private final static EClassQuerySpecification.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - - @Override - public String getFullyQualifiedName() { - return "org.eclipse.viatra.query.application.queries.eClass"; - } - - @Override - public List<String> getParameterNames() { - return Arrays.asList("ec"); - } - - @Override - public List<PParameter> getParameters() { - return Arrays.asList(new PParameter("ec", "org.eclipse.emf.ecore.EClass")); - } - - @Override - public Set<PBody> doGetContainedBodies() throws QueryInitializationException { - Set<PBody> bodies = Sets.newLinkedHashSet(); - try { - { - PBody body = new PBody(this); - PVariable var_ec = body.getOrCreateVariableByName("ec"); - new TypeConstraint(body, new FlatTuple(var_ec), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass"))); - body.setSymbolicParameters(Arrays.<ExportedParameter>asList( - new ExportedParameter(body, var_ec, "ec") - )); - // EClass(ec) - new TypeConstraint(body, new FlatTuple(var_ec), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EClass"))); - bodies.add(body); - } - { - PAnnotation annotation = new PAnnotation("Item"); - annotation.addAttribute("item", new ParameterReference("ec")); - annotation.addAttribute("label", "EC: $ec.name$"); - addAnnotation(annotation); - } - { - PAnnotation annotation = new PAnnotation("Format"); - annotation.addAttribute("color", "#e8da2c"); - addAnnotation(annotation); - } - // to silence compiler error - if (false) throw new ViatraQueryException("Never", "happens"); - } catch (ViatraQueryException ex) { - throw processDependencyException(ex); - } - return bodies; - } - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EObjectProcessor.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EObjectProcessor.java deleted file mode 100644 index 37bbebe..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EObjectProcessor.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.viatra.query.application.queries.EObjectMatch; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; - -/** - * A match processor tailored for the org.eclipse.viatra.query.application.queries.eObject pattern. - * - * Clients should derive an (anonymous) class that implements the abstract process(). - * - */ -@SuppressWarnings("all") -public abstract class EObjectProcessor implements IMatchProcessor<EObjectMatch> { - /** - * Defines the action that is to be executed on each match. - * @param pO the value of pattern parameter o in the currently processed match - * - */ - public abstract void process(final EObject pO); - - @Override - public void process(final EObjectMatch match) { - process(match.getO()); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EObjectQuerySpecification.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EObjectQuerySpecification.java deleted file mode 100644 index a648eb2..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EObjectQuerySpecification.java +++ /dev/null @@ -1,130 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import com.google.common.collect.Sets; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.viatra.query.application.queries.EObjectMatch; -import org.eclipse.viatra.query.application.queries.EObjectMatcher; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; -import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; -import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.QueryInitializationException; -import org.eclipse.viatra.query.runtime.matchers.tuple.FlatTuple; - -/** - * A pattern-specific query specification that can instantiate EObjectMatcher in a type-safe way. - * - * @see EObjectMatcher - * @see EObjectMatch - * - */ -@SuppressWarnings("all") -public final class EObjectQuerySpecification extends BaseGeneratedEMFQuerySpecification<EObjectMatcher> { - private EObjectQuerySpecification() { - super(GeneratedPQuery.INSTANCE); - } - - /** - * @return the singleton instance of the query specification - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static EObjectQuerySpecification instance() throws ViatraQueryException { - try{ - return LazyHolder.INSTANCE; - } catch (ExceptionInInitializerError err) { - throw processInitializerError(err); - } - } - - @Override - protected EObjectMatcher instantiate(final ViatraQueryEngine engine) throws ViatraQueryException { - return EObjectMatcher.on(engine); - } - - @Override - public EObjectMatch newEmptyMatch() { - return EObjectMatch.newEmptyMatch(); - } - - @Override - public EObjectMatch newMatch(final Object... parameters) { - return EObjectMatch.newMatch((org.eclipse.emf.ecore.EObject) parameters[0]); - } - - /** - * Inner class allowing the singleton instance of {@link EObjectQuerySpecification} to be created - * <b>not</b> at the class load time of the outer class, - * but rather at the first call to {@link EObjectQuerySpecification#instance()}. - * - * <p> This workaround is required e.g. to support recursion. - * - */ - private static class LazyHolder { - private final static EObjectQuerySpecification INSTANCE = new EObjectQuerySpecification(); - - /** - * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. - * This initialization order is required to support indirect recursion. - * - * <p> The static initializer is defined using a helper field to work around limitations of the code generator. - * - */ - private final static Object STATIC_INITIALIZER = ensureInitialized(); - - public static Object ensureInitialized() { - INSTANCE.ensureInitializedInternalSneaky(); - return null; - } - } - - private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { - private final static EObjectQuerySpecification.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - - @Override - public String getFullyQualifiedName() { - return "org.eclipse.viatra.query.application.queries.eObject"; - } - - @Override - public List<String> getParameterNames() { - return Arrays.asList("o"); - } - - @Override - public List<PParameter> getParameters() { - return Arrays.asList(new PParameter("o", "org.eclipse.emf.ecore.EObject")); - } - - @Override - public Set<PBody> doGetContainedBodies() throws QueryInitializationException { - Set<PBody> bodies = Sets.newLinkedHashSet(); - try { - { - PBody body = new PBody(this); - PVariable var_o = body.getOrCreateVariableByName("o"); - body.setSymbolicParameters(Arrays.<ExportedParameter>asList( - new ExportedParameter(body, var_o, "o") - )); - // EObject(o) - new TypeConstraint(body, new FlatTuple(var_o), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EObject"))); - bodies.add(body); - } - // to silence compiler error - if (false) throw new ViatraQueryException("Never", "happens"); - } catch (ViatraQueryException ex) { - throw processDependencyException(ex); - } - return bodies; - } - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EPackageProcessor.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EPackageProcessor.java deleted file mode 100644 index 835e4f5..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EPackageProcessor.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.viatra.query.application.queries.EPackageMatch; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; - -/** - * A match processor tailored for the org.eclipse.viatra.query.application.queries.ePackage pattern. - * - * Clients should derive an (anonymous) class that implements the abstract process(). - * - */ -@SuppressWarnings("all") -public abstract class EPackageProcessor implements IMatchProcessor<EPackageMatch> { - /** - * Defines the action that is to be executed on each match. - * @param pP the value of pattern parameter p in the currently processed match - * - */ - public abstract void process(final EPackage pP); - - @Override - public void process(final EPackageMatch match) { - process(match.getP()); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EPackageQuerySpecification.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EPackageQuerySpecification.java deleted file mode 100644 index 81d29e7..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EPackageQuerySpecification.java +++ /dev/null @@ -1,145 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import com.google.common.collect.Sets; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.viatra.query.application.queries.EPackageMatch; -import org.eclipse.viatra.query.application.queries.EPackageMatcher; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; -import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; -import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; -import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; -import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.QueryInitializationException; -import org.eclipse.viatra.query.runtime.matchers.tuple.FlatTuple; - -/** - * A pattern-specific query specification that can instantiate EPackageMatcher in a type-safe way. - * - * @see EPackageMatcher - * @see EPackageMatch - * - */ -@SuppressWarnings("all") -public final class EPackageQuerySpecification extends BaseGeneratedEMFQuerySpecification<EPackageMatcher> { - private EPackageQuerySpecification() { - super(GeneratedPQuery.INSTANCE); - } - - /** - * @return the singleton instance of the query specification - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static EPackageQuerySpecification instance() throws ViatraQueryException { - try{ - return LazyHolder.INSTANCE; - } catch (ExceptionInInitializerError err) { - throw processInitializerError(err); - } - } - - @Override - protected EPackageMatcher instantiate(final ViatraQueryEngine engine) throws ViatraQueryException { - return EPackageMatcher.on(engine); - } - - @Override - public EPackageMatch newEmptyMatch() { - return EPackageMatch.newEmptyMatch(); - } - - @Override - public EPackageMatch newMatch(final Object... parameters) { - return EPackageMatch.newMatch((org.eclipse.emf.ecore.EPackage) parameters[0]); - } - - /** - * Inner class allowing the singleton instance of {@link EPackageQuerySpecification} to be created - * <b>not</b> at the class load time of the outer class, - * but rather at the first call to {@link EPackageQuerySpecification#instance()}. - * - * <p> This workaround is required e.g. to support recursion. - * - */ - private static class LazyHolder { - private final static EPackageQuerySpecification INSTANCE = new EPackageQuerySpecification(); - - /** - * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. - * This initialization order is required to support indirect recursion. - * - * <p> The static initializer is defined using a helper field to work around limitations of the code generator. - * - */ - private final static Object STATIC_INITIALIZER = ensureInitialized(); - - public static Object ensureInitialized() { - INSTANCE.ensureInitializedInternalSneaky(); - return null; - } - } - - private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { - private final static EPackageQuerySpecification.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - - @Override - public String getFullyQualifiedName() { - return "org.eclipse.viatra.query.application.queries.ePackage"; - } - - @Override - public List<String> getParameterNames() { - return Arrays.asList("p"); - } - - @Override - public List<PParameter> getParameters() { - return Arrays.asList(new PParameter("p", "org.eclipse.emf.ecore.EPackage")); - } - - @Override - public Set<PBody> doGetContainedBodies() throws QueryInitializationException { - Set<PBody> bodies = Sets.newLinkedHashSet(); - try { - { - PBody body = new PBody(this); - PVariable var_p = body.getOrCreateVariableByName("p"); - new TypeConstraint(body, new FlatTuple(var_p), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); - body.setSymbolicParameters(Arrays.<ExportedParameter>asList( - new ExportedParameter(body, var_p, "p") - )); - // EPackage(p) - new TypeConstraint(body, new FlatTuple(var_p), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); - bodies.add(body); - } - { - PAnnotation annotation = new PAnnotation("Item"); - annotation.addAttribute("item", new ParameterReference("p")); - annotation.addAttribute("label", "P: $p.name$"); - addAnnotation(annotation); - } - { - PAnnotation annotation = new PAnnotation("Format"); - annotation.addAttribute("color", "#791662"); - annotation.addAttribute("textColor", "#ffffff"); - addAnnotation(annotation); - } - // to silence compiler error - if (false) throw new ViatraQueryException("Never", "happens"); - } catch (ViatraQueryException ex) { - throw processDependencyException(ex); - } - return bodies; - } - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/SubPackageProcessor.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/SubPackageProcessor.java deleted file mode 100644 index 8460e27..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/SubPackageProcessor.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.viatra.query.application.queries.SubPackageMatch; -import org.eclipse.viatra.query.runtime.api.IMatchProcessor; - -/** - * A match processor tailored for the org.eclipse.viatra.query.application.queries.subPackage pattern. - * - * Clients should derive an (anonymous) class that implements the abstract process(). - * - */ -@SuppressWarnings("all") -public abstract class SubPackageProcessor implements IMatchProcessor<SubPackageMatch> { - /** - * Defines the action that is to be executed on each match. - * @param pP the value of pattern parameter p in the currently processed match - * @param pSp the value of pattern parameter sp in the currently processed match - * - */ - public abstract void process(final EPackage pP, final EPackage pSp); - - @Override - public void process(final SubPackageMatch match) { - process(match.getP(), match.getSp()); - } -} diff --git a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/SubPackageQuerySpecification.java b/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/SubPackageQuerySpecification.java deleted file mode 100644 index 00592a4..0000000 --- a/query/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/SubPackageQuerySpecification.java +++ /dev/null @@ -1,148 +0,0 @@ -package org.eclipse.viatra.query.application.queries.util; - -import com.google.common.collect.Sets; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.viatra.query.application.queries.SubPackageMatch; -import org.eclipse.viatra.query.application.queries.SubPackageMatcher; -import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; -import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; -import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; -import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; -import org.eclipse.viatra.query.runtime.exception.ViatraQueryException; -import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; -import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; -import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; -import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; -import org.eclipse.viatra.query.runtime.matchers.psystem.queries.QueryInitializationException; -import org.eclipse.viatra.query.runtime.matchers.tuple.FlatTuple; - -/** - * A pattern-specific query specification that can instantiate SubPackageMatcher in a type-safe way. - * - * @see SubPackageMatcher - * @see SubPackageMatch - * - */ -@SuppressWarnings("all") -public final class SubPackageQuerySpecification extends BaseGeneratedEMFQuerySpecification<SubPackageMatcher> { - private SubPackageQuerySpecification() { - super(GeneratedPQuery.INSTANCE); - } - - /** - * @return the singleton instance of the query specification - * @throws ViatraQueryException if the pattern definition could not be loaded - * - */ - public static SubPackageQuerySpecification instance() throws ViatraQueryException { - try{ - return LazyHolder.INSTANCE; - } catch (ExceptionInInitializerError err) { - throw processInitializerError(err); - } - } - - @Override - protected SubPackageMatcher instantiate(final ViatraQueryEngine engine) throws ViatraQueryException { - return SubPackageMatcher.on(engine); - } - - @Override - public SubPackageMatch newEmptyMatch() { - return SubPackageMatch.newEmptyMatch(); - } - - @Override - public SubPackageMatch newMatch(final Object... parameters) { - return SubPackageMatch.newMatch((org.eclipse.emf.ecore.EPackage) parameters[0], (org.eclipse.emf.ecore.EPackage) parameters[1]); - } - - /** - * Inner class allowing the singleton instance of {@link SubPackageQuerySpecification} to be created - * <b>not</b> at the class load time of the outer class, - * but rather at the first call to {@link SubPackageQuerySpecification#instance()}. - * - * <p> This workaround is required e.g. to support recursion. - * - */ - private static class LazyHolder { - private final static SubPackageQuerySpecification INSTANCE = new SubPackageQuerySpecification(); - - /** - * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. - * This initialization order is required to support indirect recursion. - * - * <p> The static initializer is defined using a helper field to work around limitations of the code generator. - * - */ - private final static Object STATIC_INITIALIZER = ensureInitialized(); - - public static Object ensureInitialized() { - INSTANCE.ensureInitializedInternalSneaky(); - return null; - } - } - - private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { - private final static SubPackageQuerySpecification.GeneratedPQuery INSTANCE = new GeneratedPQuery(); - - @Override - public String getFullyQualifiedName() { - return "org.eclipse.viatra.query.application.queries.subPackage"; - } - - @Override - public List<String> getParameterNames() { - return Arrays.asList("p","sp"); - } - - @Override - public List<PParameter> getParameters() { - return Arrays.asList(new PParameter("p", "org.eclipse.emf.ecore.EPackage"),new PParameter("sp", "org.eclipse.emf.ecore.EPackage")); - } - - @Override - public Set<PBody> doGetContainedBodies() throws QueryInitializationException { - Set<PBody> bodies = Sets.newLinkedHashSet(); - try { - { - PBody body = new PBody(this); - PVariable var_p = body.getOrCreateVariableByName("p"); - PVariable var_sp = body.getOrCreateVariableByName("sp"); - new TypeConstraint(body, new FlatTuple(var_p), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); - new TypeConstraint(body, new FlatTuple(var_sp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); - body.setSymbolicParameters(Arrays.<ExportedParameter>asList( - new ExportedParameter(body, var_p, "p"), - new ExportedParameter(body, var_sp, "sp") - )); - // EPackage.eSubpackages(p,sp) - new TypeConstraint(body, new FlatTuple(var_p), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage"))); - PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); - new TypeConstraint(body, new FlatTuple(var_p, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.eclipse.org/emf/2002/Ecore", "EPackage", "eSubpackages"))); - new Equality(body, var__virtual_0_, var_sp); - bodies.add(body); - } - { - PAnnotation annotation = new PAnnotation("Edge"); - annotation.addAttribute("source", new ParameterReference("p")); - annotation.addAttribute("label", "sub"); - annotation.addAttribute("target", new ParameterReference("sp")); - addAnnotation(annotation); - } - // to silence compiler error - if (false) throw new ViatraQueryException("Never", "happens"); - } catch (ViatraQueryException ex) { - throw processDependencyException(ex); - } - return bodies; - } - } -} |