/**
 * Copyright (c) 2011-2012 Eclipse contributors and others.
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v20.html
 */
module org.eclipse.emf.ecore.xcore.Xcore

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

var grammarURI = "classpath:/org/eclipse/emf/ecore/xcore/Xcore.xtext"
var file.extensions = "xcore"
var projectName = "org.eclipse.emf.ecore.xcore"
var testProjectName = "org.eclipse.emf.test.ecore.xcore"
var runtimeProject = "../${projectName}"
var testProject = "../../tests/${testProjectName}"

Workflow {
	bean = StandaloneSetup {
		scanClassPath = true
		platformUri = "${runtimeProject}/.."
		
		registerGeneratedEPackage = "org.eclipse.emf.ecore.xcore.XcorePackage"

		registerGenModelFile = "platform:/resource/org.eclipse.emf.ecore.xcore/model/Xcore.genmodel"
	}

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

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

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

	component = Generator {
		lineDelimiter = '\r\n'
		pathRtProject = runtimeProject
		pathUiProject = "${runtimeProject}.ui"
		pathTestProject = testProject 
		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 {}

			// generates Java API for the generated EPackages
			// fragment = ecore.EcoreGeneratorFragment {}

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

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

			// the Antlr parser
			fragment = parser.antlr.XtextAntlrGeneratorFragment {
				options = {
					classSplitting = true
				}
			}
			
			fragment = junit.Junit4Fragment{}

			// the Ecore2Xtext specific terminal converter
			fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment {}

			// java-based API for validation 
			fragment = validation.JavaValidatorFragment {
			// composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
			// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
			}

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

			// scoping and exporting API 

			fragment = scoping.ImportNamespacesScopingFragment {}
			fragment = exporting.QualifiedNamesFragment {}

			// labeling API 
			fragment = labeling.LabelProviderFragment {
				generateXtendStub = true
			}

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

			// java-based API for content assistance 
			fragment = contentAssist.JavaBasedContentAssistFragment {}

			// antlr parser generator tailored for content assist 
			fragment = parser.antlr.XtextAntlrUiGeneratorFragment {
				options = {
					classSplitting = true
				}
				partialParsing = true
			}

			// provides a compare view
            fragment = compare.CompareFragment {
                fileExtensions = file.extensions
            }

			fragment = builder.BuilderIntegrationFragment {}

			// project wizard (optional) 

			// fragment = projectWizard.SimpleProjectWizardFragment {
			//		generatorProjectName = "${projectName}.generator" 
			//		modelFileExtension = file.extensions
			// }

			// quickfix API 
			fragment = quickfix.QuickfixProviderFragment {}
			
			fragment = generator.GeneratorFragment {
				generateJavaMain = false
				generateMwe = false
			}
			
			// rename refactoring
			fragment = refactoring.RefactorElementNameFragment {
				useJdtRefactoring = true
			}
			
			// Xbase support
			fragment = types.TypesGeneratorFragment {}
			fragment = xbase.XbaseGeneratorFragment {
				generateXtendInferrer = false
				skipExportedPackage = true
			}
		}
	}
}
