Closed abelhegedus closed 11 years ago
Although we don't consider it as a public API at the moment, it would be nice to have a concise way of creating patterns from code. I think this could work similarly to the ExtensionGenerator used by the generator fragments.
Syntax ideas:
val pattern = patternBuilder.pattern("myRuntimePackage.myRuntimePattern")[ patternBuilder.parameter("MyParam", EcorePackage::eInstance.EClass) patternBuilder.eClassifierConstraint("MyVar", EcorePackage::eInstance.EReference) patternBuilder.pathExpression("MyParam", "MyVar", EcorePackage::eInstance.EClass_EAttributes) patternBuilder.patternCall("someOtherPackage.otherPattern", "MyVar") ] if(patternBuilder.validate(pattern)){ val fact = MatcherFactoryRegistry::getOrCreateMatcherFactory(pattern) fact.getMatcher(resourceSet).forEachMatch[ println(prettyPrintMatch()) ] }
Of course, it allows for nice tricks like:
patternBuilder.negPatternCall([...])[ patternBuilder.pathExpression()...]
While it also brings up questions like:
The above examples didn't cover equality checks, count find, and annotations (although the later is probably not needed).
Moved to Eclipse.org BugZilla https://bugs.eclipse.org/bugs/show_bug.cgi?id=398810
Although we don't consider it as a public API at the moment, it would be nice to have a concise way of creating patterns from code. I think this could work similarly to the ExtensionGenerator used by the generator fragments.
Syntax ideas:
Of course, it allows for nice tricks like:
patternBuilder.negPatternCall([...])[ patternBuilder.pathExpression()...]
While it also brings up questions like:
The above examples didn't cover equality checks, count find, and annotations (although the later is probably not needed).