module org.yakindu.sct.model.stext.Stext

import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*

var grammarURI = "classpath:/org/yakindu/sct/model/stext/SText.xtext"
var file.extensions = "stext"
var projectName = "org.yakindu.sct.model.stext"
var runtimeProject = "../${projectName}"

Workflow {
    bean = StandaloneSetup {
	    scanClassPath = true
		platformUri = "${runtimeProject}/.."
		registerGenModelFile = "platform:/resource/org.yakindu.sct.model.sgraph/model/emf/sgraph.genmodel"
		registerGenModelFile = "platform:/resource/org.yakindu.base.types/model/types.genmodel"
		registerGenModelFile = "platform:/resource/org.yakindu.base.expressions/model/generated/Expressions.genmodel"
		registerGeneratedEPackage = "org.yakindu.sct.model.sgraph.SGraphPackage"
		registerGeneratedEPackage = "org.yakindu.base.types.TypesPackage"
		registerGeneratedEPackage = "org.yakindu.base.expressions.expressions.ExpressionsPackage"
	}

	component = DirectoryCleaner {
		directory = "${runtimeProject}/src-gen"
	}

	component = DirectoryCleaner {
		directory = "${runtimeProject}/model"
	}

	component = DirectoryCleaner {
		directory = "${runtimeProject}.ui/src-gen"
	}

	component = Generator {
		pathRtProject = runtimeProject
		pathUiProject = "${runtimeProject}.ui"
		pathTestProject = "${runtimeProject}.test"
		projectNameRt = projectName
		projectNameUi = "${projectName}.ui"
		language = {
			uri = grammarURI
			fileExtensions = file.extensions

			// Java API to access grammar elements (required by several other fragments)
			fragment = grammarAccess.GrammarAccessFragment {
				xmlVersion = "1.0"
			}

			// generates Java API for the generated EPackages 
			fragment = ecore.EcoreGeneratorFragment {
				generateEdit = true
				genModel = "model/SText.genmodel"
				emfRuntimeVersion = "2.8"
				xmiModelDirectory = "${runtimeProject}/model"
			}

			// the serialization component
			fragment = parseTreeConstructor.ParseTreeConstructorFragment {}

			// a custom ResourceFactory for use with EMF 
			fragment = resourceFactory.ResourceFactoryFragment {
				fileExtensions = file.extensions
			}

			// The antlr parser generator fragment.
			fragment = parser.antlr.XtextAntlrGeneratorFragment {
			//  options = {
			//		backtrack = true
			//	}
			}
			
			// java-based API for validation 
			fragment = validation.JavaValidatorFragment {
				composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
				composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
				// registerForImportedPackages = true
			}

			// scoping and exporting API
			// fragment = scoping.ImportURIScopingFragment {}
			// fragment = exporting.SimpleNamesFragment {}

			// scoping and exporting API 
			fragment = scoping.ImportNamespacesScopingFragment {}
			fragment = exporting.QualifiedNamesFragment {}
			fragment = builder.BuilderIntegrationFragment {}

			// generator API
			//fragment = generator.GeneratorFragment {
			//	generateMwe = true
			//	generateJavaMain = true
			//}
			
			// formatter API 
			fragment = formatting.FormatterFragment {}

			// labeling API 
			fragment = labeling.LabelProviderFragment {}

			// outline API 
			fragment = outline.OutlineTreeProviderFragment {}
			fragment = outline.QuickOutlineFragment {}

			// quickfix API 
			fragment = quickfix.QuickfixProviderFragment {}

			// content assist API  
			fragment = contentAssist.JavaBasedContentAssistFragment {}
			
			// rename refactoring  
			fragment = refactoring.RefactorElementNameFragment {}

			// generates a more lightweight Antlr parser and lexer tailored for content assist  
			fragment = parser.antlr.XtextAntlrUiGeneratorFragment {}

			// generates junit test support classes into Generator#pathTestProject
			fragment = junit.Junit4Fragment {}

			// project wizard (optional) 
			// fragment = projectWizard.SimpleProjectWizardFragment {
			// 		generatorProjectName = "${projectName}.generator" 
			//		modelFileExtension = file.extensions
			// }
			
//			fragment = types.TypesGeneratorFragment {}
			// generates the required bindings only if the grammar inherits from Xbase
//			fragment = xbase.XbaseGeneratorFragment {}
		}
	}
}
