Created
May 24, 2012 15:03
-
-
Save abelhegedus/2782095 to your computer and use it in GitHub Desktop.
Small examples for EMF-IncQuery part 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pattern ClassAttributeNames(Cls,Name) = { | |
EClass.eAttributes.name(Cls,Name); // Cls is EClass, Name is EString | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pattern ClassAttributes(Cls, Attr : EAttribute) = { // equal to EAttribute(Attr) in the body | |
EClass.eStructuralFeatures(Cls,Attr); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pattern EClassWithGivenName(Cls : EClass) = { | |
EClass.name(Cls,Name); | |
check((Name as String).equals("MyClass")); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pattern EClassWithGivenName(Cls : EClass) = { | |
EClass.name(Cls,"MyClass"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pckgname | |
pattern HelloIncQuery() = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pattern HelloIncQuery(Obj) = { // patterns may have an aritrary number of named parameters | |
EObject(Obj); // type constraint on Obj variable | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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