Skip to content

Instantly share code, notes, and snippets.

@abelhegedus
Created May 24, 2012 15:03
Show Gist options
  • Save abelhegedus/2782095 to your computer and use it in GitHub Desktop.
Save abelhegedus/2782095 to your computer and use it in GitHub Desktop.
Small examples for EMF-IncQuery part 1
pattern ClassAttributeNames(Cls,Name) = {
EClass(Cls);
EString(Name);
// since eAttributes will refer to EAttribute, we can use its name feature
EClass.eAttributes.name(Cls,Name);
}
pattern ClassAttributeNames(Cls,Name) = {
EClass.eAttributes.name(Cls,Name); // Cls is EClass, Name is EString
}
pattern ClassAttributes(Cls,Attr) = {
EClass(Cls);
EAttribute(Attr);
// path expression for indicating that there is an eAttributes relation between Cls and Attr
EClass.eAttributes(Cls,Attr);
}
pattern ClassAttributes(Cls, Attr : EAttribute) = { // equal to EAttribute(Attr) in the body
EClass.eStructuralFeatures(Cls,Attr);
}
pattern EClassWithGivenName(Cls : EClass) = {
EClass.name(Cls,Name);
check((Name as String).equals("MyClass"));
}
pattern EClassWithGivenName(Cls : EClass) = {
EClass.name(Cls,"MyClass");
}
package pckgname
pattern HelloIncQuery() = {}
pattern HelloIncQuery(Obj) = { // patterns may have an aritrary number of named parameters
EObject(Obj); // type constraint on Obj variable
}
// for registered EPackages, using the nsUri, content assist is available
import "http://www.eclipse.org/emf/2002/Ecore"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment