|
@@ -1,67 +0,0 @@
|
|
|
-
|
|
|
-/*
|
|
|
- * generated by Xtext
|
|
|
- */
|
|
|
-package org.yakindu.sct.statechart.generator;
|
|
|
-
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import org.eclipse.emf.common.util.URI;
|
|
|
-import org.eclipse.emf.ecore.resource.Resource;
|
|
|
-import org.eclipse.emf.ecore.resource.ResourceSet;
|
|
|
-import org.eclipse.xtext.generator.IGenerator;
|
|
|
-import org.eclipse.xtext.generator.JavaIoFileSystemAccess;
|
|
|
-import org.eclipse.xtext.util.CancelIndicator;
|
|
|
-import org.eclipse.xtext.validation.CheckMode;
|
|
|
-import org.eclipse.xtext.validation.IResourceValidator;
|
|
|
-import org.eclipse.xtext.validation.Issue;
|
|
|
-
|
|
|
-import com.google.inject.Inject;
|
|
|
-import com.google.inject.Injector;
|
|
|
-import com.google.inject.Provider;
|
|
|
-
|
|
|
-public class Main {
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- if (args.length==0) {
|
|
|
- System.err.println("Aborting: no path to EMF resource provided!");
|
|
|
- return;
|
|
|
- }
|
|
|
- Injector injector = new org.yakindu.sct.statechart.ExpressionsStandaloneSetupGenerated().createInjectorAndDoEMFRegistration();
|
|
|
- Main main = injector.getInstance(Main.class);
|
|
|
- main.runGenerator(args[0]);
|
|
|
- }
|
|
|
-
|
|
|
- @Inject
|
|
|
- private Provider<ResourceSet> resourceSetProvider;
|
|
|
-
|
|
|
- @Inject
|
|
|
- private IResourceValidator validator;
|
|
|
-
|
|
|
- @Inject
|
|
|
- private IGenerator generator;
|
|
|
-
|
|
|
- @Inject
|
|
|
- private JavaIoFileSystemAccess fileAccess;
|
|
|
-
|
|
|
- protected void runGenerator(String string) {
|
|
|
- // load the resource
|
|
|
- ResourceSet set = resourceSetProvider.get();
|
|
|
- Resource resource = set.getResource(URI.createURI(string), true);
|
|
|
-
|
|
|
- // validate the resource
|
|
|
- List<Issue> list = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl);
|
|
|
- if (!list.isEmpty()) {
|
|
|
- for (Issue issue : list) {
|
|
|
- System.err.println(issue);
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // configure and start the generator
|
|
|
- fileAccess.setOutputPath("src-gen/");
|
|
|
- generator.doGenerate(resource, fileAccess);
|
|
|
-
|
|
|
- System.out.println("Code generation finished.");
|
|
|
- }
|
|
|
-}
|