Skip to content

Instantly share code, notes, and snippets.

View abelhegedus's full-sized avatar

Ábel Hegedüs abelhegedus

View GitHub Profile
@abelhegedus
abelhegedus / ClassAttributeNames
Created May 24, 2012 15:03
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);
}
@abelhegedus
abelhegedus / IncQueryHeadless.java
Created May 17, 2012 18:48
IncQuery Headless execution
public String execute(String modelPath, String patternFQN) {
ResourceSet resourceSet = new ResourceSetImpl();
URI fileURI = URI.createFileURI(modelPath);
Resource resource = resourceSet.getResource(fileURI, true);
if (resource != null) {
try {
IncQueryMatcher matcher = MatcherFactoryRegistry.getMatcherFactory(patternFQN).getMatcher(resource);
Collection<IPatternMatch> matches = matcher.getAllMatches();
for (IPatternMatch match : matches) {
IncQueryEngine.getDefaultLogger().logError(match.prettyPrint());
@abelhegedus
abelhegedus / SchoolImpl.java
Created May 16, 2012 09:56
Derived feature example
// Query based features
private IncqueryFeatureHandler numberOfSchoolsHandler;
private IncqueryFeatureHandler lastYearHandler;
private IncqueryFeatureHandler teachersWithMostCourses;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*/
protected SchoolImpl() {