diff options
Diffstat (limited to 'examples/headless')
61 files changed, 0 insertions, 6986 deletions
diff --git a/examples/headless/org.eclipse.viatra.query.application.queries/.classpath b/examples/headless/org.eclipse.viatra.query.application.queries/.classpath deleted file mode 100644 index 9a39368d9..000000000 --- a/examples/headless/org.eclipse.viatra.query.application.queries/.classpath +++ /dev/null @@ -1,8 +0,0 @@ -<?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>
diff --git a/examples/headless/org.eclipse.viatra.query.application.queries/.project b/examples/headless/org.eclipse.viatra.query.application.queries/.project deleted file mode 100644 index a0d7537c8..000000000 --- a/examples/headless/org.eclipse.viatra.query.application.queries/.project +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.viatra.query.application.queries</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.viatra.query.tooling.core.projectbuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
- <nature>org.eclipse.viatra.query.projectnature</nature>
- </natures>
-</projectDescription>
diff --git a/examples/headless/org.eclipse.viatra.query.application.queries/.settings/org.eclipse.jdt.core.prefs b/examples/headless/org.eclipse.viatra.query.application.queries/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index f287d53cf..000000000 --- a/examples/headless/org.eclipse.viatra.query.application.queries/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -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
diff --git a/examples/headless/org.eclipse.viatra.query.application.queries/.settings/org.eclipse.pde.core.prefs b/examples/headless/org.eclipse.viatra.query.application.queries/.settings/org.eclipse.pde.core.prefs deleted file mode 100644 index 13325c951..000000000 --- a/examples/headless/org.eclipse.viatra.query.application.queries/.settings/org.eclipse.pde.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1
-pluginProject.equinox=false
-resolve.requirebundle=false
diff --git a/examples/headless/org.eclipse.viatra.query.application.queries/META-INF/MANIFEST.MF b/examples/headless/org.eclipse.viatra.query.application.queries/META-INF/MANIFEST.MF deleted file mode 100644 index 0a72467eb..000000000 --- a/examples/headless/org.eclipse.viatra.query.application.queries/META-INF/MANIFEST.MF +++ /dev/null @@ -1,14 +0,0 @@ -Manifest-Version: 1.0 -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 -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 -Import-Package: org.apache.log4j diff --git a/examples/headless/org.eclipse.viatra.query.application.queries/build.properties b/examples/headless/org.eclipse.viatra.query.application.queries/build.properties deleted file mode 100644 index 74c4830d6..000000000 --- a/examples/headless/org.eclipse.viatra.query.application.queries/build.properties +++ /dev/null @@ -1,7 +0,0 @@ -bin.includes = META-INF/,\
- .,\
- plugin.xml,\
- src/
-source.. = src/,\
- src-gen/
-output.. = bin/
diff --git a/examples/headless/org.eclipse.viatra.query.application.queries/plugin.xml b/examples/headless/org.eclipse.viatra.query.application.queries/plugin.xml deleted file mode 100644 index 305a03158..000000000 --- a/examples/headless/org.eclipse.viatra.query.application.queries/plugin.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?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"/> - </extension> -</plugin> diff --git a/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/.gitignore b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/.gitignore deleted file mode 100644 index 4c9fa5042..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageHierarchyMatch.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageHierarchyMatch.java deleted file mode 100644 index cf2d46a6b..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageHierarchyMatcher.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageHierarchyMatcher.java deleted file mode 100644 index 8f61ca42b..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageMatch.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageMatch.java deleted file mode 100644 index d700694a1..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageMatcher.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/ClassesInPackageMatcher.java deleted file mode 100644 index 884bfcfce..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassMatch.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassMatch.java deleted file mode 100644 index e92d3d69e..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassMatcher.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassMatcher.java deleted file mode 100644 index 7085c0ac9..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesKeywordMatch.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesKeywordMatch.java deleted file mode 100644 index 46c7eca08..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesKeywordMatcher.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesKeywordMatcher.java deleted file mode 100644 index 35b9134dc..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesMatch.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesMatch.java deleted file mode 100644 index bf7d57e6d..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesMatcher.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EClassNamesMatcher.java deleted file mode 100644 index 017f46da5..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EObjectMatch.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EObjectMatch.java deleted file mode 100644 index 15cea1cef..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EObjectMatcher.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EObjectMatcher.java deleted file mode 100644 index c7514050c..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EPackageMatch.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EPackageMatch.java deleted file mode 100644 index 385e1cdf8..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EPackageMatcher.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/EPackageMatcher.java deleted file mode 100644 index 0eb10b4d4..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/HeadlessQueries.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/HeadlessQueries.java deleted file mode 100644 index 764693146..000000000 --- a/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/HeadlessQueries.java +++ /dev/null @@ -1,136 +0,0 @@ -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.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. - * - * <p>Use the static instance as any {@link org.eclipse.viatra.query.runtime.api.IPatternGroup}, 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. - * - * <p> From package org.eclipse.viatra.query.application.queries, the group contains the definition of the following patterns: <ul> - * <li>eClassNames</li> - * <li>eClassNamesKeyword</li> - * <li>eObject</li> - * <li>classesInPackage</li> - * <li>subPackage</li> - * <li>classesInPackageHierarchy</li> - * <li>ePackage</li> - * <li>eClass</li> - * </ul> - * - * @see IPatternGroup - * - */ -@SuppressWarnings("all") -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 - * - */ - public static HeadlessQueries instance() throws ViatraQueryException { - if (INSTANCE == null) { - 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()); - } - - public EClassNamesQuerySpecification getEClassNames() throws ViatraQueryException { - return EClassNamesQuerySpecification.instance(); - } - - public EClassNamesMatcher getEClassNames(final ViatraQueryEngine engine) throws ViatraQueryException { - return EClassNamesMatcher.on(engine); - } - - public EClassNamesKeywordQuerySpecification getEClassNamesKeyword() throws ViatraQueryException { - return EClassNamesKeywordQuerySpecification.instance(); - } - - public EClassNamesKeywordMatcher getEClassNamesKeyword(final ViatraQueryEngine engine) throws ViatraQueryException { - return EClassNamesKeywordMatcher.on(engine); - } - - public EObjectQuerySpecification getEObject() throws ViatraQueryException { - return EObjectQuerySpecification.instance(); - } - - public EObjectMatcher getEObject(final ViatraQueryEngine engine) throws ViatraQueryException { - return EObjectMatcher.on(engine); - } - - public ClassesInPackageQuerySpecification getClassesInPackage() throws ViatraQueryException { - return ClassesInPackageQuerySpecification.instance(); - } - - public ClassesInPackageMatcher getClassesInPackage(final ViatraQueryEngine engine) throws ViatraQueryException { - return ClassesInPackageMatcher.on(engine); - } - - public SubPackageQuerySpecification getSubPackage() throws ViatraQueryException { - return SubPackageQuerySpecification.instance(); - } - - public SubPackageMatcher getSubPackage(final ViatraQueryEngine engine) throws ViatraQueryException { - return SubPackageMatcher.on(engine); - } - - public ClassesInPackageHierarchyQuerySpecification getClassesInPackageHierarchy() throws ViatraQueryException { - return ClassesInPackageHierarchyQuerySpecification.instance(); - } - - public ClassesInPackageHierarchyMatcher getClassesInPackageHierarchy(final ViatraQueryEngine engine) throws ViatraQueryException { - return ClassesInPackageHierarchyMatcher.on(engine); - } - - public EPackageQuerySpecification getEPackage() throws ViatraQueryException { - return EPackageQuerySpecification.instance(); - } - - public EPackageMatcher getEPackage(final ViatraQueryEngine engine) throws ViatraQueryException { - return EPackageMatcher.on(engine); - } - - public EClassQuerySpecification getEClass() throws ViatraQueryException { - return EClassQuerySpecification.instance(); - } - - public EClassMatcher getEClass(final ViatraQueryEngine engine) throws ViatraQueryException { - return EClassMatcher.on(engine); - } -} diff --git a/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/SubPackageMatch.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/SubPackageMatch.java deleted file mode 100644 index 353948182..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/SubPackageMatcher.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/SubPackageMatcher.java deleted file mode 100644 index 92aa03baf..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/.gitignore b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/.gitignore deleted file mode 100644 index b21d549bb..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageHierarchyProcessor.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageHierarchyProcessor.java deleted file mode 100644 index 851e211ea..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageHierarchyQuerySpecification.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageHierarchyQuerySpecification.java deleted file mode 100644 index f4e3ee864..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageProcessor.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageProcessor.java deleted file mode 100644 index b91cb6db3..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageQuerySpecification.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/ClassesInPackageQuerySpecification.java deleted file mode 100644 index 86fa4cbb2..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesKeywordProcessor.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesKeywordProcessor.java deleted file mode 100644 index 37be5d209..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesKeywordQuerySpecification.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesKeywordQuerySpecification.java deleted file mode 100644 index 2f771e1bd..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesProcessor.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesProcessor.java deleted file mode 100644 index 9077c036d..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesQuerySpecification.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassNamesQuerySpecification.java deleted file mode 100644 index 8bf21bfb0..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassProcessor.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassProcessor.java deleted file mode 100644 index 99b2ba2af..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassQuerySpecification.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EClassQuerySpecification.java deleted file mode 100644 index 45256890a..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EObjectProcessor.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EObjectProcessor.java deleted file mode 100644 index 37bbebe9d..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EObjectQuerySpecification.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EObjectQuerySpecification.java deleted file mode 100644 index a648eb2de..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EPackageProcessor.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EPackageProcessor.java deleted file mode 100644 index 835e4f5ed..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EPackageQuerySpecification.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/EPackageQuerySpecification.java deleted file mode 100644 index 81d29e7be..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/SubPackageProcessor.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/SubPackageProcessor.java deleted file mode 100644 index 8460e272f..000000000 --- a/examples/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/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/SubPackageQuerySpecification.java b/examples/headless/org.eclipse.viatra.query.application.queries/src-gen/org/eclipse/viatra/query/application/queries/util/SubPackageQuerySpecification.java deleted file mode 100644 index 00592a434..000000000 --- a/examples/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; - } - } -} diff --git a/examples/headless/org.eclipse.viatra.query.application.queries/src/org/eclipse/viatra/query/application/queries/headlessQueries.vql b/examples/headless/org.eclipse.viatra.query.application.queries/src/org/eclipse/viatra/query/application/queries/headlessQueries.vql deleted file mode 100644 index 0c98e24a1..000000000 --- a/examples/headless/org.eclipse.viatra.query.application.queries/src/org/eclipse/viatra/query/application/queries/headlessQueries.vql +++ /dev/null @@ -1,41 +0,0 @@ -package org.eclipse.viatra.query.application.queries;
-
-import "http://www.eclipse.org/emf/2002/Ecore"
-
-pattern eClassNames(c: EClass, n : EString)= {
- EClass.name(c,n);
-}
-
-pattern eClassNamesKeyword(c: EClass, n: EString)
-{
- EClass.name(c,n);
- check("A" == n);
-}
-
-pattern eObject(o) {
- EObject(o);
-}
-
-@Edge(source = p, target = ec, label = "classIn")
-pattern classesInPackage(p : EPackage, ec: EClass) { EPackage.eClassifiers(p,ec); }
-
-@Edge(source = p, target = sp, label = "sub")
-pattern subPackage(p: EPackage, sp: EPackage){ EPackage.eSubpackages(p,sp); }
-
-@Edge(source = rootP, target = containedClass, label = "classIn+")
-@Format(color = "#0033ff")
-pattern classesInPackageHierarchy(rootP: EPackage, containedClass: EClass)
-{
- find classesInPackage(rootP,containedClass);
-} or {
- find subPackage+(rootP,somePackage);
- find classesInPackage(somePackage,containedClass);
-}
-
-@Item(item = p, label = "P: $p.name$")
-@Format(color = "#791662", textColor = "#ffffff")
-pattern ePackage(p : EPackage) { EPackage(p); }
-
-@Item(item = ec, label = "EC: $ec.name$")
-@Format(color = "#e8da2c")
-pattern eClass(ec : EClass) { EClass(ec); }
diff --git a/examples/headless/org.eclipse.viatra.query.application.queries/src/org/eclipse/viatra/query/application/queries/test.vql b/examples/headless/org.eclipse.viatra.query.application.queries/src/org/eclipse/viatra/query/application/queries/test.vql deleted file mode 100644 index 2f0830d4c..000000000 --- a/examples/headless/org.eclipse.viatra.query.application.queries/src/org/eclipse/viatra/query/application/queries/test.vql +++ /dev/null @@ -1 +0,0 @@ -package org.eclipse.viatra.query.application.queries
\ No newline at end of file diff --git a/examples/headless/org.eclipse.viatra.query.application.queries/testmodels/Test.ecore b/examples/headless/org.eclipse.viatra.query.application.queries/testmodels/Test.ecore deleted file mode 100644 index 78799ba3f..000000000 --- a/examples/headless/org.eclipse.viatra.query.application.queries/testmodels/Test.ecore +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="root" nsURI="http://test.info" nsPrefix="test"> - <eClassifiers xsi:type="ecore:EClass" name="A"/> - <eSubpackages name="subpackage1" nsURI="http://test.info/sp1" nsPrefix="sp1"> - <eClassifiers xsi:type="ecore:EClass" name="B"/> - <eSubpackages name="subsubpackage1" nsURI="http://test.info/sp1/ssp1" nsPrefix="ssp1"> - <eClassifiers xsi:type="ecore:EClass" name="D"/> - </eSubpackages> - </eSubpackages> - <eSubpackages name="subpackage2" nsURI="http://test.info/sp2" nsPrefix="sp2"> - <eClassifiers xsi:type="ecore:EClass" name="C"/> - </eSubpackages> -</ecore:EPackage> diff --git a/examples/headless/org.eclipse.viatra.query.application/.classpath b/examples/headless/org.eclipse.viatra.query.application/.classpath deleted file mode 100644 index ad32c83a7..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/.classpath +++ /dev/null @@ -1,7 +0,0 @@ -<?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="output" path="bin"/> -</classpath> diff --git a/examples/headless/org.eclipse.viatra.query.application/.project b/examples/headless/org.eclipse.viatra.query.application/.project deleted file mode 100644 index 97ccc2209..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/.project +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>org.eclipse.viatra.query.application</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.pde.PluginNature</nature> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> diff --git a/examples/headless/org.eclipse.viatra.query.application/.settings/org.eclipse.jdt.core.prefs b/examples/headless/org.eclipse.viatra.query.application/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index c537b6306..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -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 diff --git a/examples/headless/org.eclipse.viatra.query.application/META-INF/MANIFEST.MF b/examples/headless/org.eclipse.viatra.query.application/META-INF/MANIFEST.MF deleted file mode 100644 index 2c1df8291..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/META-INF/MANIFEST.MF +++ /dev/null @@ -1,16 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: VIATRA Headless Application -Bundle-SymbolicName: org.eclipse.viatra.query.application;singleton:=true -Bundle-Version: 1.2.0.qualifier -Bundle-ClassPath: . -Require-Bundle: org.eclipse.core.runtime;bundle-version="3.7.0", - org.eclipse.viatra.query.application.queries;bundle-version="0.0.2", - org.eclipse.viatra.addon.databinding.runtime;bundle-version="[1.2.0,1.3.0)", - org.eclipse.core.databinding;bundle-version="1.4.0", - org.eclipse.viatra.query.tooling.core;bundle-version="[1.2.0,1.3.0)", - org.eclipse.viatra.query.patternlanguage.emf;bundle-version="[1.2.0,1.3.0)", - org.eclipse.viatra.query.runtime;bundle-version="[1.2.0,1.3.0)", - com.google.inject, - org.eclipse.emf.ecore.xmi;bundle-version="2.11.1" -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/examples/headless/org.eclipse.viatra.query.application/build.properties b/examples/headless/org.eclipse.viatra.query.application/build.properties deleted file mode 100644 index ce082b113..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -1source.. = src/
-bin.includes = META-INF/,\
- .,\
- plugin.xml
-source.. = src/
diff --git a/examples/headless/org.eclipse.viatra.query.application/incquery-generic.product b/examples/headless/org.eclipse.viatra.query.application/incquery-generic.product deleted file mode 100644 index 2eabd86e4..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/incquery-generic.product +++ /dev/null @@ -1,204 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?pde version="3.5"?> - -<product name="Example Headless VIATRA Query Application (Using Generic API)" uid="org.eclipse.viatra.query.application.generic" id="viatra.query.generic" application="org.eclipse.viatra.query.application.app.generic" version="1.2.0.qualifier" useFeatures="false" includeLaunchers="true"> - - <configIni use="default"> - </configIni> - - <launcherArgs> - <programArgs>--launcher.XX:MaxPermSize=768m ---launcher.XX:+UseParallelGC ---launcher.XX:PermSize=256m --consolelog - </programArgs> - <vmArgs>-Xms200m --Xmx1584m --Declipse.log.backup.max=100 --Declipse.log.size.max=0 - </vmArgs> - <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts - </vmArgsMac> - </launcherArgs> - - <launcher> - <solaris/> - <win useIco="false"> - <bmp/> - </win> - </launcher> - - <vm> - </vm> - - <plugins> - <plugin id="com.google.guava"/> - <plugin id="com.google.inject"/> - <plugin id="com.google.inject.multibindings" fragment="true"/> - <plugin id="com.ibm.icu"/> - <plugin id="javax.annotation"/> - <plugin id="javax.inject"/> - <plugin id="javax.xml"/> - <plugin id="org.antlr.runtime"/> - <plugin id="org.apache.batik.css"/> - <plugin id="org.apache.batik.util"/> - <plugin id="org.apache.batik.util.gui"/> - <plugin id="org.apache.commons.jxpath"/> - <plugin id="org.apache.commons.lang"/> - <plugin id="org.apache.log4j"/> - <plugin id="org.eclipse.ant.core"/> - <plugin id="org.eclipse.compare"/> - <plugin id="org.eclipse.compare.core"/> - <plugin id="org.eclipse.core.commands"/> - <plugin id="org.eclipse.core.contenttype"/> - <plugin id="org.eclipse.core.databinding"/> - <plugin id="org.eclipse.core.databinding.observable"/> - <plugin id="org.eclipse.core.databinding.property"/> - <plugin id="org.eclipse.core.expressions"/> - <plugin id="org.eclipse.core.filebuffers"/> - <plugin id="org.eclipse.core.filesystem"/> - <plugin id="org.eclipse.core.filesystem.java7" fragment="true"/> - <plugin id="org.eclipse.core.filesystem.macosx" fragment="true"/> - <plugin id="org.eclipse.core.jobs"/> - <plugin id="org.eclipse.core.resources"/> - <plugin id="org.eclipse.core.runtime"/> - <plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/> - <plugin id="org.eclipse.core.variables"/> - <plugin id="org.eclipse.debug.core"/> - <plugin id="org.eclipse.debug.ui"/> - <plugin id="org.eclipse.e4.core.commands"/> - <plugin id="org.eclipse.e4.core.contexts"/> - <plugin id="org.eclipse.e4.core.di"/> - <plugin id="org.eclipse.e4.core.di.annotations"/> - <plugin id="org.eclipse.e4.core.di.extensions"/> - <plugin id="org.eclipse.e4.core.services"/> - <plugin id="org.eclipse.e4.emf.xpath"/> - <plugin id="org.eclipse.e4.ui.bindings"/> - <plugin id="org.eclipse.e4.ui.css.core"/> - <plugin id="org.eclipse.e4.ui.css.swt"/> - <plugin id="org.eclipse.e4.ui.css.swt.theme"/> - <plugin id="org.eclipse.e4.ui.di"/> - <plugin id="org.eclipse.e4.ui.model.workbench"/> - <plugin id="org.eclipse.e4.ui.services"/> - <plugin id="org.eclipse.e4.ui.widgets"/> - <plugin id="org.eclipse.e4.ui.workbench"/> - <plugin id="org.eclipse.e4.ui.workbench.addons.swt"/> - <plugin id="org.eclipse.e4.ui.workbench.renderers.swt"/> - <plugin id="org.eclipse.e4.ui.workbench.renderers.swt.cocoa" fragment="true"/> - <plugin id="org.eclipse.e4.ui.workbench.swt"/> - <plugin id="org.eclipse.e4.ui.workbench3"/> - <plugin id="org.eclipse.emf.codegen"/> - <plugin id="org.eclipse.emf.codegen.ecore"/> - <plugin id="org.eclipse.emf.common"/> - <plugin id="org.eclipse.emf.common.ui"/> - <plugin id="org.eclipse.emf.databinding"/> - <plugin id="org.eclipse.emf.ecore"/> - <plugin id="org.eclipse.emf.ecore.change"/> - <plugin id="org.eclipse.emf.ecore.xmi"/> - <plugin id="org.eclipse.emf.edit"/> - <plugin id="org.eclipse.emf.edit.ui"/> - <plugin id="org.eclipse.emf.transaction"/> - <plugin id="org.eclipse.emf.validation"/> - <plugin id="org.eclipse.equinox.app"/> - <plugin id="org.eclipse.equinox.bidi"/> - <plugin id="org.eclipse.equinox.common"/> - <plugin id="org.eclipse.equinox.ds"/> - <plugin id="org.eclipse.equinox.frameworkadmin"/> - <plugin id="org.eclipse.equinox.frameworkadmin.equinox"/> - <plugin id="org.eclipse.equinox.p2.artifact.repository"/> - <plugin id="org.eclipse.equinox.p2.core"/> - <plugin id="org.eclipse.equinox.p2.director"/> - <plugin id="org.eclipse.equinox.p2.director.app"/> - <plugin id="org.eclipse.equinox.p2.engine"/> - <plugin id="org.eclipse.equinox.p2.garbagecollector"/> - <plugin id="org.eclipse.equinox.p2.jarprocessor"/> - <plugin id="org.eclipse.equinox.p2.metadata"/> - <plugin id="org.eclipse.equinox.p2.metadata.repository"/> - <plugin id="org.eclipse.equinox.p2.publisher"/> - <plugin id="org.eclipse.equinox.p2.publisher.eclipse"/> - <plugin id="org.eclipse.equinox.p2.repository"/> - <plugin id="org.eclipse.equinox.p2.repository.tools"/> - <plugin id="org.eclipse.equinox.p2.touchpoint.eclipse"/> - <plugin id="org.eclipse.equinox.preferences"/> - <plugin id="org.eclipse.equinox.registry"/> - <plugin id="org.eclipse.equinox.security"/> - <plugin id="org.eclipse.equinox.security.macosx" fragment="true"/> - <plugin id="org.eclipse.equinox.simpleconfigurator"/> - <plugin id="org.eclipse.equinox.simpleconfigurator.manipulator"/> - <plugin id="org.eclipse.equinox.util"/> - <plugin id="org.eclipse.help"/> - <plugin id="org.eclipse.jdt.compiler.apt" fragment="true"/> - <plugin id="org.eclipse.jdt.compiler.tool" fragment="true"/> - <plugin id="org.eclipse.jdt.core"/> - <plugin id="org.eclipse.jdt.core.manipulation"/> - <plugin id="org.eclipse.jdt.debug"/> - <plugin id="org.eclipse.jdt.launching"/> - <plugin id="org.eclipse.jdt.ui"/> - <plugin id="org.eclipse.jface"/> - <plugin id="org.eclipse.jface.databinding"/> - <plugin id="org.eclipse.jface.text"/> - <plugin id="org.eclipse.ltk.core.refactoring"/> - <plugin id="org.eclipse.ltk.ui.refactoring"/> - <plugin id="org.eclipse.osgi"/> - <plugin id="org.eclipse.osgi.compatibility.state" fragment="true"/> - <plugin id="org.eclipse.osgi.services"/> - <plugin id="org.eclipse.pde.build"/> - <plugin id="org.eclipse.pde.core"/> - <plugin id="org.eclipse.search"/> - <plugin id="org.eclipse.swt"/> - <plugin id="org.eclipse.swt.cocoa.macosx.x86_64" fragment="true"/> - <plugin id="org.eclipse.team.core"/> - <plugin id="org.eclipse.team.ui"/> - <plugin id="org.eclipse.text"/> - <plugin id="org.eclipse.ui"/> - <plugin id="org.eclipse.ui.cocoa" fragment="true"/> - <plugin id="org.eclipse.ui.console"/> - <plugin id="org.eclipse.ui.editors"/> - <plugin id="org.eclipse.ui.forms"/> - <plugin id="org.eclipse.ui.ide"/> - <plugin id="org.eclipse.ui.navigator"/> - <plugin id="org.eclipse.ui.navigator.resources"/> - <plugin id="org.eclipse.ui.views"/> - <plugin id="org.eclipse.ui.views.properties.tabbed"/> - <plugin id="org.eclipse.ui.workbench"/> - <plugin id="org.eclipse.ui.workbench.texteditor"/> - <plugin id="org.eclipse.update.configurator"/> - <plugin id="org.eclipse.viatra.addon.databinding.runtime"/> - <plugin id="org.eclipse.viatra.query.application"/> - <plugin id="org.eclipse.viatra.query.application.queries"/> - <plugin id="org.eclipse.viatra.query.patternlanguage"/> - <plugin id="org.eclipse.viatra.query.patternlanguage.emf"/> - <plugin id="org.eclipse.viatra.query.runtime"/> - <plugin id="org.eclipse.viatra.query.runtime.base"/> - <plugin id="org.eclipse.viatra.query.runtime.base.itc"/> - <plugin id="org.eclipse.viatra.query.runtime.matchers"/> - <plugin id="org.eclipse.viatra.query.runtime.rete"/> - <plugin id="org.eclipse.viatra.query.runtime.rete.recipes"/> - <plugin id="org.eclipse.viatra.query.tooling.core"/> - <plugin id="org.eclipse.viatra.query.tooling.generator.model"/> - <plugin id="org.eclipse.viatra.transformation.evm"/> - <plugin id="org.eclipse.xtend.lib"/> - <plugin id="org.eclipse.xtend.lib.macro"/> - <plugin id="org.eclipse.xtext"/> - <plugin id="org.eclipse.xtext.builder"/> - <plugin id="org.eclipse.xtext.common.types"/> - <plugin id="org.eclipse.xtext.common.types.ui"/> - <plugin id="org.eclipse.xtext.ide"/> - <plugin id="org.eclipse.xtext.logging" fragment="true"/> - <plugin id="org.eclipse.xtext.smap"/> - <plugin id="org.eclipse.xtext.ui"/> - <plugin id="org.eclipse.xtext.util"/> - <plugin id="org.eclipse.xtext.xbase"/> - <plugin id="org.eclipse.xtext.xbase.lib"/> - <plugin id="org.objectweb.asm"/> - <plugin id="org.sat4j.core"/> - <plugin id="org.sat4j.pb"/> - <plugin id="org.tukaani.xz"/> - <plugin id="org.w3c.css.sac"/> - <plugin id="org.w3c.dom.events"/> - <plugin id="org.w3c.dom.smil"/> - <plugin id="org.w3c.dom.svg"/> - </plugins> - - -</product> diff --git a/examples/headless/org.eclipse.viatra.query.application/incquery-specific.product b/examples/headless/org.eclipse.viatra.query.application/incquery-specific.product deleted file mode 100644 index 6bd024932..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/incquery-specific.product +++ /dev/null @@ -1,206 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<?pde version="3.5"?> - -<product name="Example Headless VIATRA Query Application (Using Specific Generated API)" uid="org.eclipse.viatra.query.application.specific" id="viatra.query.specific" application="org.eclipse.viatra.query.application.app.patternspecific" version="1.2.0.qualifier" useFeatures="false" includeLaunchers="true"> - - <configIni use="default"> - </configIni> - - <launcherArgs> - <programArgs>--launcher.XX:MaxPermSize=768m ---launcher.XX:+UseParallelGC ---launcher.XX:PermSize=256m --consolelog - </programArgs> - <vmArgs>-Xms200m --Xmx1584m --Declipse.log.backup.max=100 --Declipse.log.size.max=0 - </vmArgs> - <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts - </vmArgsMac> - </launcherArgs> - - <windowImages/> - - <launcher> - <solaris/> - <win useIco="false"> - <bmp/> - </win> - </launcher> - - <vm> - </vm> - - <plugins> - <plugin id="com.google.guava"/> - <plugin id="com.google.inject"/> - <plugin id="com.google.inject.multibindings" fragment="true"/> - <plugin id="com.ibm.icu"/> - <plugin id="javax.annotation"/> - <plugin id="javax.inject"/> - <plugin id="javax.xml"/> - <plugin id="org.antlr.runtime"/> - <plugin id="org.apache.batik.css"/> - <plugin id="org.apache.batik.util"/> - <plugin id="org.apache.batik.util.gui"/> - <plugin id="org.apache.commons.jxpath"/> - <plugin id="org.apache.commons.lang"/> - <plugin id="org.apache.log4j"/> - <plugin id="org.eclipse.ant.core"/> - <plugin id="org.eclipse.compare"/> - <plugin id="org.eclipse.compare.core"/> - <plugin id="org.eclipse.core.commands"/> - <plugin id="org.eclipse.core.contenttype"/> - <plugin id="org.eclipse.core.databinding"/> - <plugin id="org.eclipse.core.databinding.observable"/> - <plugin id="org.eclipse.core.databinding.property"/> - <plugin id="org.eclipse.core.expressions"/> - <plugin id="org.eclipse.core.filebuffers"/> - <plugin id="org.eclipse.core.filesystem"/> - <plugin id="org.eclipse.core.filesystem.java7" fragment="true"/> - <plugin id="org.eclipse.core.filesystem.macosx" fragment="true"/> - <plugin id="org.eclipse.core.jobs"/> - <plugin id="org.eclipse.core.resources"/> - <plugin id="org.eclipse.core.runtime"/> - <plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/> - <plugin id="org.eclipse.core.variables"/> - <plugin id="org.eclipse.debug.core"/> - <plugin id="org.eclipse.debug.ui"/> - <plugin id="org.eclipse.e4.core.commands"/> - <plugin id="org.eclipse.e4.core.contexts"/> - <plugin id="org.eclipse.e4.core.di"/> - <plugin id="org.eclipse.e4.core.di.annotations"/> - <plugin id="org.eclipse.e4.core.di.extensions"/> - <plugin id="org.eclipse.e4.core.services"/> - <plugin id="org.eclipse.e4.emf.xpath"/> - <plugin id="org.eclipse.e4.ui.bindings"/> - <plugin id="org.eclipse.e4.ui.css.core"/> - <plugin id="org.eclipse.e4.ui.css.swt"/> - <plugin id="org.eclipse.e4.ui.css.swt.theme"/> - <plugin id="org.eclipse.e4.ui.di"/> - <plugin id="org.eclipse.e4.ui.model.workbench"/> - <plugin id="org.eclipse.e4.ui.services"/> - <plugin id="org.eclipse.e4.ui.widgets"/> - <plugin id="org.eclipse.e4.ui.workbench"/> - <plugin id="org.eclipse.e4.ui.workbench.addons.swt"/> - <plugin id="org.eclipse.e4.ui.workbench.renderers.swt"/> - <plugin id="org.eclipse.e4.ui.workbench.renderers.swt.cocoa" fragment="true"/> - <plugin id="org.eclipse.e4.ui.workbench.swt"/> - <plugin id="org.eclipse.e4.ui.workbench3"/> - <plugin id="org.eclipse.emf.codegen"/> - <plugin id="org.eclipse.emf.codegen.ecore"/> - <plugin id="org.eclipse.emf.common"/> - <plugin id="org.eclipse.emf.common.ui"/> - <plugin id="org.eclipse.emf.databinding"/> - <plugin id="org.eclipse.emf.ecore"/> - <plugin id="org.eclipse.emf.ecore.change"/> - <plugin id="org.eclipse.emf.ecore.xmi"/> - <plugin id="org.eclipse.emf.edit"/> - <plugin id="org.eclipse.emf.edit.ui"/> - <plugin id="org.eclipse.emf.transaction"/> - <plugin id="org.eclipse.emf.validation"/> - <plugin id="org.eclipse.equinox.app"/> - <plugin id="org.eclipse.equinox.bidi"/> - <plugin id="org.eclipse.equinox.common"/> - <plugin id="org.eclipse.equinox.ds"/> - <plugin id="org.eclipse.equinox.frameworkadmin"/> - <plugin id="org.eclipse.equinox.frameworkadmin.equinox"/> - <plugin id="org.eclipse.equinox.p2.artifact.repository"/> - <plugin id="org.eclipse.equinox.p2.core"/> - <plugin id="org.eclipse.equinox.p2.director"/> - <plugin id="org.eclipse.equinox.p2.director.app"/> - <plugin id="org.eclipse.equinox.p2.engine"/> - <plugin id="org.eclipse.equinox.p2.garbagecollector"/> - <plugin id="org.eclipse.equinox.p2.jarprocessor"/> - <plugin id="org.eclipse.equinox.p2.metadata"/> - <plugin id="org.eclipse.equinox.p2.metadata.repository"/> - <plugin id="org.eclipse.equinox.p2.publisher"/> - <plugin id="org.eclipse.equinox.p2.publisher.eclipse"/> - <plugin id="org.eclipse.equinox.p2.repository"/> - <plugin id="org.eclipse.equinox.p2.repository.tools"/> - <plugin id="org.eclipse.equinox.p2.touchpoint.eclipse"/> - <plugin id="org.eclipse.equinox.preferences"/> - <plugin id="org.eclipse.equinox.registry"/> - <plugin id="org.eclipse.equinox.security"/> - <plugin id="org.eclipse.equinox.security.macosx" fragment="true"/> - <plugin id="org.eclipse.equinox.simpleconfigurator"/> - <plugin id="org.eclipse.equinox.simpleconfigurator.manipulator"/> - <plugin id="org.eclipse.equinox.util"/> - <plugin id="org.eclipse.help"/> - <plugin id="org.eclipse.jdt.compiler.apt" fragment="true"/> - <plugin id="org.eclipse.jdt.compiler.tool" fragment="true"/> - <plugin id="org.eclipse.jdt.core"/> - <plugin id="org.eclipse.jdt.core.manipulation"/> - <plugin id="org.eclipse.jdt.debug"/> - <plugin id="org.eclipse.jdt.launching"/> - <plugin id="org.eclipse.jdt.ui"/> - <plugin id="org.eclipse.jface"/> - <plugin id="org.eclipse.jface.databinding"/> - <plugin id="org.eclipse.jface.text"/> - <plugin id="org.eclipse.ltk.core.refactoring"/> - <plugin id="org.eclipse.ltk.ui.refactoring"/> - <plugin id="org.eclipse.osgi"/> - <plugin id="org.eclipse.osgi.compatibility.state" fragment="true"/> - <plugin id="org.eclipse.osgi.services"/> - <plugin id="org.eclipse.pde.build"/> - <plugin id="org.eclipse.pde.core"/> - <plugin id="org.eclipse.search"/> - <plugin id="org.eclipse.swt"/> - <plugin id="org.eclipse.swt.cocoa.macosx.x86_64" fragment="true"/> - <plugin id="org.eclipse.team.core"/> - <plugin id="org.eclipse.team.ui"/> - <plugin id="org.eclipse.text"/> - <plugin id="org.eclipse.ui"/> - <plugin id="org.eclipse.ui.cocoa" fragment="true"/> - <plugin id="org.eclipse.ui.console"/> - <plugin id="org.eclipse.ui.editors"/> - <plugin id="org.eclipse.ui.forms"/> - <plugin id="org.eclipse.ui.ide"/> - <plugin id="org.eclipse.ui.navigator"/> - <plugin id="org.eclipse.ui.navigator.resources"/> - <plugin id="org.eclipse.ui.views"/> - <plugin id="org.eclipse.ui.views.properties.tabbed"/> - <plugin id="org.eclipse.ui.workbench"/> - <plugin id="org.eclipse.ui.workbench.texteditor"/> - <plugin id="org.eclipse.update.configurator"/> - <plugin id="org.eclipse.viatra.addon.databinding.runtime"/> - <plugin id="org.eclipse.viatra.query.application"/> - <plugin id="org.eclipse.viatra.query.application.queries"/> - <plugin id="org.eclipse.viatra.query.patternlanguage"/> - <plugin id="org.eclipse.viatra.query.patternlanguage.emf"/> - <plugin id="org.eclipse.viatra.query.runtime"/> - <plugin id="org.eclipse.viatra.query.runtime.base"/> - <plugin id="org.eclipse.viatra.query.runtime.base.itc"/> - <plugin id="org.eclipse.viatra.query.runtime.matchers"/> - <plugin id="org.eclipse.viatra.query.runtime.rete"/> - <plugin id="org.eclipse.viatra.query.runtime.rete.recipes"/> - <plugin id="org.eclipse.viatra.query.tooling.core"/> - <plugin id="org.eclipse.viatra.query.tooling.generator.model"/> - <plugin id="org.eclipse.viatra.transformation.evm"/> - <plugin id="org.eclipse.xtend.lib"/> - <plugin id="org.eclipse.xtend.lib.macro"/> - <plugin id="org.eclipse.xtext"/> - <plugin id="org.eclipse.xtext.builder"/> - <plugin id="org.eclipse.xtext.common.types"/> - <plugin id="org.eclipse.xtext.common.types.ui"/> - <plugin id="org.eclipse.xtext.ide"/> - <plugin id="org.eclipse.xtext.logging" fragment="true"/> - <plugin id="org.eclipse.xtext.smap"/> - <plugin id="org.eclipse.xtext.ui"/> - <plugin id="org.eclipse.xtext.util"/> - <plugin id="org.eclipse.xtext.xbase"/> - <plugin id="org.eclipse.xtext.xbase.lib"/> - <plugin id="org.objectweb.asm"/> - <plugin id="org.sat4j.core"/> - <plugin id="org.sat4j.pb"/> - <plugin id="org.tukaani.xz"/> - <plugin id="org.w3c.css.sac"/> - <plugin id="org.w3c.dom.events"/> - <plugin id="org.w3c.dom.smil"/> - <plugin id="org.w3c.dom.svg"/> - </plugins> - - -</product> diff --git a/examples/headless/org.eclipse.viatra.query.application/plugin.xml b/examples/headless/org.eclipse.viatra.query.application/plugin.xml deleted file mode 100644 index 43f5c6948..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/plugin.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
- <extension
- id="org.eclipse.viatra.query.application.app.generic"
- point="org.eclipse.core.runtime.applications">
- <application
- cardinality="singleton-global"
- thread="main"
- visible="true">
- <run
- class="org.eclipse.viatra.query.application.generic.GenericEclipseViatraQueryApplication">
- </run>
- </application>
- </extension>
- <extension
- id="org.eclipse.viatra.query.application.app.patternspecific"
- point="org.eclipse.core.runtime.applications">
- <application
- cardinality="singleton-global"
- thread="main"
- visible="true">
- <run
- class="org.eclipse.viatra.query.application.patternspecific.PatternSpecificEclipseViatraQueryApplication">
- </run>
- </application>
- </extension>
- <extension
- id="viatra.query.generic"
- point="org.eclipse.core.runtime.products">
- <product
- application="org.eclipse.viatra.query.application.app.generic"
- name="Generic VIATRA Query Application">
- <property
- name="appName"
- value="Generic VIATRA Query Application">
- </property>
- </product>
- </extension>
- <extension
- id="viatra.query.specific"
- point="org.eclipse.core.runtime.products">
- <product
- application="org.eclipse.viatra.query.application.app.patternspecific"
- name="PatternSpecific VIATRA Query Application">
- <property
- name="appName"
- value="PatternSpecific VIATRA Query Application">
- </property>
- </product>
- </extension>
-
-</plugin>
diff --git a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/common/DefaultRealm.java b/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/common/DefaultRealm.java deleted file mode 100644 index 900eace7c..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/common/DefaultRealm.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.eclipse.viatra.query.application.common; - -import org.eclipse.core.databinding.observable.Realm; - -/** - * Simple realm implementation that will set itself as default when constructed. Invoke - * {@link #dispose()} to remove the realm from being the default. Does not support asyncExec(...). - * - * Original source: http://wiki.eclipse.org/JFace_Data_Binding/Realm - */ -public class DefaultRealm extends Realm { - private Realm previousRealm; - - public DefaultRealm() { - previousRealm = super.setDefault(this); - } - - /** - * @return always returns true - */ - public boolean isCurrent() { - return true; - } - - protected void syncExec(Runnable runnable) { - runnable.run(); - } - - /** - * @throws UnsupportedOperationException - */ - public void asyncExec(Runnable runnable) { - throw new UnsupportedOperationException("asyncExec is unsupported"); - } - - /** - * Removes the realm from being the current and sets the previous realm to the default. - */ - public void dispose() { - if (getDefault() == this) { - setDefault(previousRealm); - } - } -} - diff --git a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/common/ViatraQueryHeadless.java b/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/common/ViatraQueryHeadless.java deleted file mode 100644 index a01b0fe02..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/common/ViatraQueryHeadless.java +++ /dev/null @@ -1,259 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2004-2011 Abel Hegedus, Istvan Rath and Daniel Varro
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Abel Hegedus - initial API and implementation
- * Istvan Rath - refactorings to accommodate to generic/patternspecific API differences
- *******************************************************************************/
-package org.eclipse.viatra.query.application.common;
-
-
-import java.util.Collection;
-
-import org.eclipse.core.databinding.observable.set.IObservableSet;
-import org.eclipse.core.databinding.observable.set.ISetChangeListener;
-import org.eclipse.core.databinding.observable.set.SetChangeEvent;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.viatra.addon.databinding.runtime.api.ViatraObservables;
-import org.eclipse.viatra.query.application.queries.EClassNamesMatcher;
-import org.eclipse.viatra.query.application.queries.EObjectMatch;
-import org.eclipse.viatra.query.application.queries.EObjectMatcher;
-import org.eclipse.viatra.query.application.queries.EPackageMatch;
-import org.eclipse.viatra.query.application.queries.EPackageMatcher;
-import org.eclipse.viatra.query.application.queries.HeadlessQueries;
-import org.eclipse.viatra.query.application.queries.util.EClassNamesProcessor;
-import org.eclipse.viatra.query.application.queries.util.EObjectProcessor;
-import org.eclipse.viatra.query.application.queries.util.EPackageProcessor;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
-import org.eclipse.viatra.query.runtime.emf.EMFScope;
-import org.eclipse.viatra.query.runtime.exception.ViatraQueryException;
-
-/**
- * @author Abel Hegedus
- * @author Istvan Rath
- *
- */
-public class ViatraQueryHeadless {
-
- protected Resource loadModel(String modelPath) {
- URI fileURI = URI.createFileURI(modelPath);
- return loadModel(fileURI);
- }
-
- protected Resource loadModel(URI fileURI) {
- // Loads the resource
- ResourceSet resourceSet = new ResourceSetImpl();
- Resource resource = resourceSet.getResource(fileURI, true);
- return resource;
- }
-
- protected void prettyPrintMatches(StringBuilder results, Collection<? extends IPatternMatch> matches) {
- for (IPatternMatch match : matches) {
- results.append(match.prettyPrint()+"; ");
- }
- if(matches.size() == 0) {
- results.append("Empty match set");
- }
- results.append("\n");
- }
-
-
- public String executeDemo(String modelPath) {
- final StringBuilder results = new StringBuilder();
- Resource resource = loadModel(modelPath);
- if (resource != null) {
- try {
- // get all matches of the pattern
- // initialization
- // phase 1: (managed) ViatraQueryEngine
- ViatraQueryEngine engine = ViatraQueryEngine.on(new EMFScope(resource));
- // phase 2: the matcher itself
- EObjectMatcher matcher = EObjectMatcher.on(engine);
- // get all matches of the pattern
- Collection<EObjectMatch> matches = matcher.getAllMatches();
- prettyPrintMatches(results, matches);
- // using a match processor
- matcher.forEachMatch(new EObjectProcessor() {
- @Override
- public void process(EObject o) {
- results.append("\tEObject: " + o.toString() + "\n");
- }
- });
- // matching with partially bound input parameters
- // a new matcher initialization will trigger a new traversal of the model
- // unless you use pattern groups, see executePatternSpecific_PatternGroups below
- EClassNamesMatcher matcher2 = EClassNamesMatcher.on(engine);
- // defining an input mask by binding "name" to "A" ->
- matcher2.forEachMatch( matcher2.newMatch(null, "A") , new EClassNamesProcessor() {
- @Override
- public void process(EClass c, String n) {
- results.append("\tEClass with name A: " + c.toString() + "\n");
- }
- });
- } catch (ViatraQueryException e) {
- e.printStackTrace();
- results.append(e.getMessage());
- }
- } else {
- results.append("Resource not found");
- }
- return results.toString();
- }
-
- public String executeDemo_PatternGroups(String modelPath) {
- final StringBuilder results = new StringBuilder();
- Resource resource = loadModel(modelPath);
- if (resource != null) {
- try {
- // initialization
- // phase 1: (managed) ViatraQueryEngine
- ViatraQueryEngine engine = ViatraQueryEngine.on(new EMFScope(resource));
- // phase 2: the group of pattern matchers
- HeadlessQueries patternGroup = HeadlessQueries.instance();
- patternGroup.prepare(engine);
- // from here on everything is the same
- EObjectMatcher matcher = EObjectMatcher.on(engine);
- // get all matches of the pattern
- Collection<EObjectMatch> matches = matcher.getAllMatches();
- prettyPrintMatches(results, matches);
- // using a match processor
- matcher.forEachMatch(new EObjectProcessor() {
- @Override
- public void process(EObject o) {
- results.append("\tEObject: " + o.toString() + "\n");
- }
- });
- // matching with partially bound input parameters
- // because EClassNamesMatcher is included in the patterngroup, *no new traversal* will be done here
- EClassNamesMatcher matcher2 = EClassNamesMatcher.on(engine);
- // defining an input mask by binding "name" to "A" ->
- matcher2.forEachMatch(null, "A" , new EClassNamesProcessor() {
- @Override
- public void process(EClass c, String n) {
- results.append("\tEClass with name A: " + c.toString() + "\n");
- }
- });
- // projections
- for (EClass ec: matcher2.getAllValuesOfc(matcher2.newMatch(null,"A")))
- {
- results.append("\tEClass with name A: " + ec.toString() + "\n");
- }
- } catch (ViatraQueryException e) {
- e.printStackTrace();
- results.append(e.getMessage());
- }
- } else {
- results.append("Resource not found");
- }
- return results.toString();
- }
-
- // incrementally track changes
-
- protected void performModelModification(Resource res) {
- // somewhat brittle code, assumes there is a root EPackage in the Resource
- EPackage rootPackage = (EPackage)res.getContents().get(0);
- // add a new EPackage
- EPackage newPackage = EcoreFactory.eINSTANCE.createEPackage();
- newPackage.setName("NewPackage");
- rootPackage.getESubpackages().add(newPackage);
- }
-
- public String executeTrackChangesDemo(String modelPath)
- {
- final StringBuilder results = new StringBuilder();
- Resource resource = loadModel(modelPath);
- if (resource != null) {
- try {
- // initialization
- // phase 1: (managed) ViatraQueryEngine
- ViatraQueryEngine engine = ViatraQueryEngine.on(new EMFScope(resource));
- // phase 2: pattern matcher for packages
- EPackageMatcher matcher = EPackageMatcher.on(engine);
- matcher.forEachMatch(new EPackageProcessor() {
- @Override
- public void process(EPackage p) {
- results.append("\tEPackage before modification: " + p.getName()+"\n");
- }
- });
- // phase 3: prepare for change processing
- changeProcessing_databinding(results, matcher);
- // phase 4: modify model, change processor will update results accordingly
- performModelModification(resource);
- }
- catch (ViatraQueryException e) {
- e.printStackTrace();
- results.append(e.getMessage());
- }
- } else {
- results.append("Resource not found");
- }
- return results.toString();
- }
-
-
-
- private void changeProcessing_databinding(final StringBuilder results, ViatraQueryMatcher<?> matcher) {
- // (+) changes can also be tracked using JFace Databinding
- // this approach provides good performance, as the observable callbacks are guaranteed to be called
- // in a consistent state, and only when there is a relevant change; anything
- // can be written into the callback method
- // (-) * the databinding API introduces additional dependencies
- // * is does not support generics, hence typesafe programming is not possible
- // * a "Realm" needs to be set up for headless execution
- DefaultRealm realm = new DefaultRealm();
- IObservableSet set = ViatraObservables.observeMatchesAsSet(matcher);
-
- set.addSetChangeListener(new ISetChangeListener() {
- @Override
- public void handleSetChange(SetChangeEvent event) {
- for (Object _o : event.diff.getAdditions()) {
- if (_o instanceof EPackageMatch) {
- results.append("\tNew EPackage found by changeset databinding: " + ((EPackageMatch)_o).getP().getName()+"\n");
- }
- }
- for (Object _o : event.diff.getRemovals()) {
- // left empty
- }
- }
- });
-
- /* the same could also be done with a list:
- IObservableList list = ViatraObservables.observeMatchesAsList(factory, engine);
- list.addListChangeListener(new IListChangeListener() {
-
- @Override
- public void handleListChange(ListChangeEvent event) {
- for (ListDiffEntry lde : event.diff.getDifferences())
- {
- if (lde.isAddition()) {
- Object _o = lde.getElement();
- if (_o instanceof EPackageMatch) {
- results.append("\tNew EPackage found by changeset databinding: " + ((EPackageMatch)_o).getP().getName()+"\n");
- }
- }
- else {
- // left emptry
- }
- }
- }
- });
- */
- }
-
-
-
-}
diff --git a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/common/ViatraQueryHeadlessAdvanced.java b/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/common/ViatraQueryHeadlessAdvanced.java deleted file mode 100644 index ab7113996..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/common/ViatraQueryHeadlessAdvanced.java +++ /dev/null @@ -1,179 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2004-2011 Abel Hegedus, Istvan Rath and Daniel Varro
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Abel Hegedus - initial API and implementation
- * Istvan Rath - refactorings to accommodate to generic/patternspecific API differences
- *******************************************************************************/
-package org.eclipse.viatra.query.application.common;
-
-
-
-import java.util.Collection;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.viatra.query.patternlanguage.emf.EMFPatternLanguageStandaloneSetup;
-import org.eclipse.viatra.query.patternlanguage.emf.eMFPatternLanguage.PatternModel;
-import org.eclipse.viatra.query.patternlanguage.emf.specification.SpecificationBuilder;
-import org.eclipse.viatra.query.patternlanguage.helper.CorePatternLanguageHelper;
-import org.eclipse.viatra.query.patternlanguage.patternLanguage.Pattern;
-import org.eclipse.viatra.query.runtime.api.AdvancedViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.IMatchProcessor;
-import org.eclipse.viatra.query.runtime.api.IMatchUpdateListener;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
-import org.eclipse.viatra.query.runtime.emf.EMFScope;
-import org.eclipse.viatra.query.runtime.exception.ViatraQueryException;
-import org.eclipse.viatra.query.runtime.extensibility.QuerySpecificationRegistry;
-
-/**
- * @author Abel Hegedus
- * @author Istvan Rath
- *
- */
-public class ViatraQueryHeadlessAdvanced extends ViatraQueryHeadless {
-
- /**
- * Returns the match set for patternFQN over the model in modelPath in pretty printed form
- *
- * @param modelPath
- * @param patternFQN
- * @return
- */
- public String executeDemo_GenericAPI_LoadFromVQL(URI modelURI, URI fileURI, String patternFQN) {
- final StringBuilder results = new StringBuilder();
- Resource resource = loadModel(modelURI);
- if (resource != null) {
- try {
- // get all matches of the pattern
- // create an *unmanaged* engine to ensure that noone else is going
- // to use our engine
- AdvancedViatraQueryEngine engine = AdvancedViatraQueryEngine.createUnmanagedEngine(new EMFScope(resource));
- // instantiate a pattern matcher through the registry, by only knowing its FQN
- // assuming that there is a pattern definition registered matching 'patternFQN'
-
- Pattern p = null;
-
- // Initializing Xtext-based resource parser
- new EMFPatternLanguageStandaloneSetup().createInjectorAndDoEMFRegistration();
-
- //Loading pattern resource from file
- ResourceSet resourceSet = new ResourceSetImpl();
-
- Resource patternResource = resourceSet.getResource(fileURI, true);
-
- // navigate to the pattern definition that we want
- if (patternResource != null) {
- if (patternResource.getErrors().size() == 0 && patternResource.getContents().size() >= 1) {
- EObject topElement = patternResource.getContents().get(0);
- if (topElement instanceof PatternModel) {
- for (Pattern _p : ((PatternModel) topElement).getPatterns()) {
- if (patternFQN.equals(CorePatternLanguageHelper.getFullyQualifiedName(_p))) {
- p = _p; break;
- }
- }
- }
- }
- }
- if (p == null) {
- throw new RuntimeException(String.format("Pattern %s not found", patternFQN));
- }
- SpecificationBuilder builder = new SpecificationBuilder();
- final IQuerySpecification<? extends ViatraQueryMatcher<? extends IPatternMatch>> specification = builder.getOrCreateSpecification(p);
- QuerySpecificationRegistry.registerQuerySpecification(specification);
-
- // Initialize matcher from specification
- ViatraQueryMatcher<? extends IPatternMatch> matcher = engine.getMatcher(specification);
-
- if (matcher!=null) {
- Collection<? extends IPatternMatch> matches = matcher.getAllMatches();
- prettyPrintMatches(results, matches);
- }
-
- // wipe the engine
- engine.wipe();
- // after a wipe, new patterns can be rebuilt with much less overhead than
- // complete traversal (as the base indexes will be kept)
-
- // completely dispose of the engine once's it is not needed
- engine.dispose();
- resource.unload();
- } catch (ViatraQueryException e) {
- e.printStackTrace();
- results.append(e.getMessage());
- }
- } else {
- results.append("Resource not found");
- }
- return results.toString();
- }
-
-
- // incrementally track changes
-
-
- public String executeTrackChangesDemo_Advanced(URI modelURI, String patternFQN)
- {
- final StringBuilder results = new StringBuilder();
- Resource resource = loadModel(modelURI);
- if (resource != null) {
- try {
- // initialization
- // phase 1: (managed) ViatraQueryEngine
- AdvancedViatraQueryEngine engine = AdvancedViatraQueryEngine.createUnmanagedEngine(new EMFScope(resource));
- // phase 2: pattern matcher for packages
- ViatraQueryMatcher<? extends IPatternMatch> matcher = QuerySpecificationRegistry.getQuerySpecification(patternFQN).getMatcher(engine);
- matcher.forEachMatch(new IMatchProcessor<IPatternMatch>() {
- @Override
- public void process(IPatternMatch match) {
- results.append("\tMatch before modification: " + match.prettyPrint()+"\n");
- }
- });
- // phase 3: prepare for advanced change processing
- changeProcessing_lowlevel(results, matcher, engine);
- // phase 4: modify model, change processor will update results accordingly
- performModelModification(resource);
- }
- catch (ViatraQueryException e) {
- e.printStackTrace();
- results.append(e.getMessage());
- }
- } else {
- results.append("Resource not found");
- }
- return results.toString();
- }
-
- private void changeProcessing_lowlevel(final StringBuilder results,
- ViatraQueryMatcher<? extends IPatternMatch> matcher,
- AdvancedViatraQueryEngine engine) {
- // (+) these update callbacks are called whenever there is an actual change in the
- // result set of the pattern you are interested in. Hence, they are called fewer times
- // than the "afterUpdates" option, giving better performance.
- // (-) the downside is that the callbacks are *not* guaranteed to be called in a consistent
- // state (i.e. when the update propagation is settled), hence
- // * you must not invoke pattern matching and model manipulation _inside_ the callback method
- // * the callbacks might encounter "hazards", i.e. when an appearance is followed immediately by a disappearance.
- engine.addMatchUpdateListener(matcher, new IMatchUpdateListener<IPatternMatch>() {
- @Override
- public void notifyDisappearance(IPatternMatch match) {
- // left empty
- }
- @Override
- public void notifyAppearance(IPatternMatch match) {
- results.append("\tNew match found by changeset low level callback: " + match.prettyPrint()+"\n");
- }
- }, false);
- }
-
-
-}
diff --git a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/common/ViatraQueryHeadlessBenchmark.java b/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/common/ViatraQueryHeadlessBenchmark.java deleted file mode 100644 index f88dd1ca7..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/common/ViatraQueryHeadlessBenchmark.java +++ /dev/null @@ -1,158 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2004-2011 Abel Hegedus, Istvan Rath and Daniel Varro
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Abel Hegedus - initial API and implementation
- * Istvan Rath - refactorings to accommodate to generic/patternspecific API differences
- *******************************************************************************/
-package org.eclipse.viatra.query.application.common;
-
-
-import java.util.Collection;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.viatra.query.application.queries.EObjectMatch;
-import org.eclipse.viatra.query.application.queries.EObjectMatcher;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngineManager;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryMatcher;
-import org.eclipse.viatra.query.runtime.emf.EMFScope;
-import org.eclipse.viatra.query.runtime.exception.ViatraQueryException;
-import org.eclipse.viatra.query.runtime.extensibility.QuerySpecificationRegistry;
-
-/**
- * @author Abel Hegedus
- * @author Istvan Rath
- *
- */
-public class ViatraQueryHeadlessBenchmark {
-
- private Resource loadModel(String modelPath) {
- // Loads the resource
- long start = System.nanoTime();
- ResourceSet resourceSet = new ResourceSetImpl();
- URI fileURI = URI.createFileURI(modelPath);
- Resource resource = resourceSet.getResource(fileURI, true);
-
- long resourceInit = System.nanoTime();
- System.out.println("EMF load took: " + (resourceInit - start) / 1000000 + " ms");
-
- return resource;
- }
-
-
- private void prettyPrintMatches(StringBuilder results, Collection<? extends IPatternMatch> matches) {
- System.out.println("Found matches:");
- for (IPatternMatch match : matches) {
- System.out.println(match.prettyPrint());
- results.append(match.prettyPrint());
- }
-
- if(matches.size() == 0) {
- results.append("Empty match set");
- }
- }
-
- private void measureMemory(StringBuilder results) {
- System.gc();
- System.gc();
- System.gc();
- System.gc();
- System.gc();
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- long usedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
- System.out.println("Used memory: " + usedMemory + " bytes");
- System.out.println("Used memory: " + (usedMemory / 1024) / 1024 + " megabytes");
-
-
- }
-
- public String executePatternSpecificBenchmark(String modelPath) {
- StringBuilder results = new StringBuilder();
-
- Resource resource = loadModel(modelPath);
-
- if (resource != null) {
- try {
- // get all matches of the pattern
- long startMatching = System.nanoTime();
- ViatraQueryEngine engine = ViatraQueryEngineManager.getInstance().getQueryEngine(new EMFScope(resource));
- EObjectMatcher matcher = EObjectMatcher.on(engine);
- long matcherInit = System.nanoTime();
- Collection<EObjectMatch> matches = matcher.getAllMatches();
- long collectedMatches = System.nanoTime();
- System.out.println(
- "Init took: " + (matcherInit - startMatching) / 1000000 + " Collecting took: "
- + (collectedMatches - matcherInit) / 1000000 + " ms");
- measureMemory(results);
- prettyPrintMatches(results, matches);
-
- } catch (ViatraQueryException e) {
- e.printStackTrace();
- results.append(e.getMessage());
- }
- } else {
- results.append("Resource not found");
- }
- return results.toString();
- }
-
- /**
- * Returns the match set for patternFQN over the model in modelPath in pretty printed form
- *
- * @param modelPath
- * @param patternFQN
- * @return
- */
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public String executeGenericBenchmark(String modelPath, String patternFQN) {
- StringBuilder results = new StringBuilder();
-
- Resource resource = loadModel(modelPath);
-
- if (resource != null) {
- try {
- long startMatching = System.nanoTime();
- ViatraQueryEngine engine = ViatraQueryEngineManager.getInstance().getQueryEngine(new EMFScope(resource));
- ViatraQueryMatcher matcher = QuerySpecificationRegistry.getQuerySpecification(patternFQN).getMatcher(engine);
- long matcherInit = System.nanoTime();
- // assuming that there is a pattern definition registered matching 'patternFQN'
- if (matcher!=null) {
- Collection<IPatternMatch> matches = matcher.getAllMatches();
- prettyPrintMatches(results, matches);
- // get all matches of the pattern
- long collectedMatches = System.nanoTime();
- System.out.println(
- "Init took: " + (matcherInit - startMatching) / 1000000 + " Collecting took: "
- + (collectedMatches - matcherInit) / 1000000 + " ms");
- measureMemory(results);
- prettyPrintMatches(results, matches);
- }
- } catch (ViatraQueryException e) {
- e.printStackTrace();
- results.append(e.getMessage());
- }
- } else {
- results.append("Resource not found");
- }
- return results.toString();
- }
-
-
-
-
-}
diff --git a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/generic/GenericEclipseViatraQueryApplication.java b/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/generic/GenericEclipseViatraQueryApplication.java deleted file mode 100644 index a7d5ffe65..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/generic/GenericEclipseViatraQueryApplication.java +++ /dev/null @@ -1,86 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2004-2011 Abel Hegedus and Daniel Varro
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Abel Hegedus - initial API and implementation
- *******************************************************************************/
-package org.eclipse.viatra.query.application.generic;
-
-import java.util.Map;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.equinox.app.IApplication;
-import org.eclipse.equinox.app.IApplicationContext;
-import org.eclipse.viatra.query.application.common.ViatraQueryHeadlessAdvanced;
-
-/**
- * @author Abel Hegedus
- *
- */
-public class GenericEclipseViatraQueryApplication implements IApplication {
-
- private static String modelParam = "-m";
- private static String patternParam = "-p";
-
-
-
- @Override
- public Object start(IApplicationContext context) throws Exception {
-
- Map<String, Object> arguments = context.getArguments();
- String[] args = (String[]) arguments.get("application.args");
- String model = null;
- String patternFQN = null;
- if (args == null || args.length == 0) {
- displayHelp();
- return IApplication.EXIT_OK;
- }
- int i = 0;
- while (i < args.length) {
- if (args[i].equals(modelParam)) {
- model = args[i + 1];
- i += 2;
- continue;
- }
- if (args[i].equals(patternParam)) {
- patternFQN = args[i + 1];
- i += 2;
- continue;
- } else {
- i++;
- continue;
- }
- }
-
- if (model == null) {
- System.out.println("Model parameter not set");
- displayHelp();
- return IApplication.EXIT_OK;
- }
- if (patternFQN == null) {
- System.out.println("PatternFQN parameter not set");
- displayHelp();
- return IApplication.EXIT_OK;
- }
-
- ViatraQueryHeadlessAdvanced hla = new ViatraQueryHeadlessAdvanced();
-// System.out.println(hla.executeDemo_GenericAPI(model, patternFQN));
- URI fileURI = URI.createPlatformPluginURI("org.eclipse.viatra.query.application.queries/src/org/eclipse/viatra/query/application/queries/headlessQueries.vql", false);
- URI modelURI = URI.createFileURI(model);
- System.out.println(hla.executeDemo_GenericAPI_LoadFromVQL(modelURI, fileURI, patternFQN));
- System.out.println(hla.executeTrackChangesDemo_Advanced(modelURI, patternFQN));
-
- return IApplication.EXIT_OK;
- }
-
- @Override
- public void stop() {}
-
- private void displayHelp() {
- System.out.println("Usage:\n<call> -m <modelFilePAth> -p <patternFQN>\n -m : Required, the model to match on.\n -p : Required, the pattern fqn to match");
- }
-}
diff --git a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/generic/GenericViatraQueryApplication.java b/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/generic/GenericViatraQueryApplication.java deleted file mode 100644 index f93336460..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/generic/GenericViatraQueryApplication.java +++ /dev/null @@ -1,89 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2004-2011 Abel Hegedus and Daniel Varro
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Abel Hegedus - initial API and implementation
- *******************************************************************************/
-package org.eclipse.viatra.query.application.generic;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
-import org.eclipse.viatra.query.application.common.ViatraQueryHeadlessAdvanced;
-
-/**
- * @author Abel Hegedus
- *
- */
-public class GenericViatraQueryApplication {
-
- private static String modelParam = "-m";
- private static String patternParam = "-p";
- private static String eiqFileParam = "-e";
-
-
- public static void main(String[] args) {
- String model = null;
- String eiqFile = null;
- String patternFQN = null;
- if (args == null || args.length == 0) {
- displayHelp();
- return;
- }
- int i = 0;
- while (i < args.length) {
- if (args[i].equals(modelParam)) {
- model = args[i + 1];
- i += 2;
- continue;
- } else if (args[i].equals(patternParam)) {
- patternFQN = args[i + 1];
- i += 2;
- continue;
- } else if (args[i].equals(eiqFileParam)) {
- eiqFile = args[i + 1];
- i += 2;
- continue;
- } else {
- i++;
- continue;
- }
- }
-
- if (model == null) {
- System.out.println("Model parameter not set");
- displayHelp();
- return;
- }
- if (patternFQN == null) {
- System.out.println("PatternFQN parameter not set");
- displayHelp();
- return;
- }
- if (eiqFile == null) {
- System.out.println("EIQ file parameter not set");
- displayHelp();
- return;
- }
-
- ViatraQueryHeadlessAdvanced hla = new ViatraQueryHeadlessAdvanced();
- // Initializing metamodel
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
- URI fileURI = URI.createFileURI(eiqFile);
- URI modelURI = URI.createFileURI(model);
- System.out.println(hla.executeDemo_GenericAPI_LoadFromVQL(modelURI, fileURI, patternFQN));
- System.out.println(hla.executeTrackChangesDemo_Advanced(modelURI, patternFQN));
-
- }
-
- private static void displayHelp() {
- System.out.println("Usage:\n<call> -m <modelFilePath> -e <eiqFilePath> -p <patternFQN>");
- System.out.println(" -m : Required, the model to match on.");
- System.out.println(" -e : Required, the pattern definition file (.eiq) to match on.");
- System.out.println(" -p : Required, the pattern fqn to match");
- }
-}
diff --git a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/patternspecific/PatternSpecificEclipseViatraQueryApplication.java b/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/patternspecific/PatternSpecificEclipseViatraQueryApplication.java deleted file mode 100644 index 09e5dc139..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/patternspecific/PatternSpecificEclipseViatraQueryApplication.java +++ /dev/null @@ -1,76 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2004-2011 Abel Hegedus, Istvan Rath and Daniel Varro
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Abel Hegedus - initial API and implementation
- * Istvan Rath - modifications for pattern-specific API demonstration
- *******************************************************************************/
-package org.eclipse.viatra.query.application.patternspecific;
-
-import java.util.Map;
-
-import org.eclipse.equinox.app.IApplication;
-import org.eclipse.equinox.app.IApplicationContext;
-import org.eclipse.viatra.query.application.common.ViatraQueryHeadless;
-
-/**
- * @author Abel Hegedus
- * @author Istvan Rath
- *
- */
-public class PatternSpecificEclipseViatraQueryApplication implements IApplication {
-
- private static String modelParam = "-m";
-
- @Override
- public Object start(IApplicationContext context) throws Exception {
-
- Map<String, Object> arguments = context.getArguments();
- String[] args = (String[]) arguments.get("application.args");
- String model = null;
- if (args == null || args.length == 0) {
- displayHelp();
- return IApplication.EXIT_OK;
- }
- int i = 0;
- while (i < args.length) {
- if (args[i].equals(modelParam)) {
- model = args[i + 1];
- i += 2;
- continue;
- }
- else {
- i++;
- continue;
- }
- }
-
- if (model == null) {
- System.out.println("Model parameter not set");
- displayHelp();
- return IApplication.EXIT_OK;
- }
-
- ViatraQueryHeadless hl = new ViatraQueryHeadless();
- System.out.println(hl.executeDemo(model));
- System.out.println(hl.executeDemo_PatternGroups(model));
- System.out.println(hl.executeTrackChangesDemo(model));
-
-
-
- return IApplication.EXIT_OK;
- }
-
- @Override
- public void stop() {
-
- }
-
- private void displayHelp() {
- System.out.println("Usage:\n<call> -m <modelFilePAth> \n -m : Required, the model to match on.");
- }
-}
diff --git a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/patternspecific/PatternSpecificViatraQueryApplication.java b/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/patternspecific/PatternSpecificViatraQueryApplication.java deleted file mode 100644 index b64a51299..000000000 --- a/examples/headless/org.eclipse.viatra.query.application/src/org/eclipse/viatra/query/application/patternspecific/PatternSpecificViatraQueryApplication.java +++ /dev/null @@ -1,68 +0,0 @@ -/*******************************************************************************
- * Copyright (c) 2004-2011 Abel Hegedus, Istvan Rath and Daniel Varro
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Abel Hegedus - initial API and implementation
- * Istvan Rath - modifications for pattern-specific API demonstration
- *******************************************************************************/
-package org.eclipse.viatra.query.application.patternspecific;
-
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
-import org.eclipse.viatra.query.application.common.ViatraQueryHeadless;
-
-/**
- * @author Abel Hegedus
- * @author Istvan Rath
- *
- */
-public class PatternSpecificViatraQueryApplication {
-
- private static String modelParam = "-m";
-
- public static void main(String[] args) {
-
- String model = null;
- if (args == null || args.length == 0) {
- displayHelp();
- return;
- }
- int i = 0;
- while (i < args.length) {
- if (args[i].equals(modelParam)) {
- model = args[i + 1];
- i += 2;
- continue;
- }
- else {
- i++;
- continue;
- }
- }
-
- if (model == null) {
- System.out.println("Model parameter not set");
- displayHelp();
- return;
- }
-
- // Initializing metamodel
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
-
- ViatraQueryHeadless hl = new ViatraQueryHeadless();
- System.out.println(hl.executeDemo(model));
- System.out.println(hl.executeDemo_PatternGroups(model));
- System.out.println(hl.executeTrackChangesDemo(model));
-
-
-
- }
-
- private static void displayHelp() {
- System.out.println("Usage:\n<call> -m <modelFilePAth> \n -m : Required, the model to match on.");
- }
-}
|