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
| // Query based features | |
| private IncqueryFeatureHandler numberOfSchoolsHandler; | |
| private IncqueryFeatureHandler lastYearHandler; | |
| private IncqueryFeatureHandler teachersWithMostCourses; | |
| /** | |
| * <!-- begin-user-doc --> | |
| * <!-- end-user-doc --> | |
| */ | |
| protected SchoolImpl() { |
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
| 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()); |
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 ClassWithGivenNameAndHasAttribute(Cls : EClass) = { | |
| find EClassWithGivenName(Cls); | |
| find ClassAttributes(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 AtLeastThreeAttributes(Cls : EClass) = { | |
| M == count find ClassAttributes(Cls,Attr); | |
| check((M as Integer) > 2); | |
| } |
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
| IEditorPart editorPart = pm.getParent().getParent().getEditorPart(); | |
| if(editorPart.getSite().getPage().getActiveEditor() != editorPart) { | |
| //bring editor part to top | |
| editorPart.getSite().getPage().bringToTop(editorPart); // this should make it active as well, otherwise infinite execption | |
| IHandlerService handlerService = (IHandlerService) editorPart.getSite().getService(IHandlerService.class); | |
| try { | |
| handlerService.executeCommand(CommandConstants.SHOW_LOCATION_COMMAND_ID, null); | |
| return; | |
| } catch (Exception e) { | |
| IncQueryEngine.getDefaultLogger().logError("Exception when activating show location!", e); |
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
| @QueryBasedFeature(feature = "jobs") | |
| pattern ChecklistEntryJobCorrespondence(CLE : ChecklistEntry, Job : Job) = { | |
| Job.name(Job,JobName); | |
| System.name(System,SysName); | |
| Job.runsOn(Job,System); | |
| ChecklistEntry.jobPaths(CLE,JobPath); | |
| check((JobPath as String).equals((SysName as String).concat('/').concat(JobName as String))); | |
| } | |
| @QueryBasedFeature(feature = "task") |
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
| @Test | |
| def shortTest(){ | |
| val patternModel = parseHelper.parse(' | |
| import "http://www.eclipse.org/viatra2/patternlanguage/core/PatternLanguage" | |
| pattern resolutionTest(Name) = { | |
| Pattern(Name); | |
| } ') as PatternModel | |
| patternModel.assertMatchResults("uri/to/test/expected") | |
| } |
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
| import org.eclipse.viatra2.patternlanguage.eMFPatternLanguage.PatternModel | |
| import org.eclipse.viatra2.patternlanguage.core.patternLanguage.PatternLanguageFactory | |
| import org.eclipse.viatra2.patternlanguage.eMFPatternLanguage.EMFPatternLanguageFactory | |
| import org.eclipse.emf.ecore.EcorePackage | |
| import org.junit.Test | |
| import org.junit.runner.RunWith | |
| import org.eclipse.xtext.junit4.XtextRunner | |
| import org.eclipse.xtext.junit4.InjectWith | |
| import org.eclipse.viatra2.emf.incquery.testing.core.injector.EMFPatternLanguageInjectorProvider | |
| import org.eclipse.emf.common.util.URI |
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 school.tests | |
| import org.eclipse.core.resources.IFile | |
| import org.eclipse.emf.ecore.EStructuralFeature | |
| import org.eclipse.incquery.querybasedfeatures.runtime.QueryBasedFeatureSettingDelegateFactory | |
| import org.eclipse.incquery.runtime.patternregistry.PatternRegistry | |
| import org.eclipse.incquery.patternlanguage.patternLanguage.Pattern | |
| import org.eclipse.emf.ecore.EPackage | |
| import org.eclipse.emf.ecore.EcoreFactory | |
| import org.eclipse.incquery.runtime.extensibility.QuerySpecificationRegistry |
OlderNewer