<commit_before><link rel='stylesheet' href='web/swiss.css'/>

# Example 

Project corresponding to the example of the [15 minutes tutorial (extended)](https://eclipse.org/Xtext/documentation/102_domainmodelwalkthrough.html) using Xtext 2.10. 

Below I report some adaptations to guide my students. In particular, I added a new Gradle task to execute the compiler from command line.

## Modifications to 15 minutes tutorial (parser)

* When creating a new project, select the following configuration: 

<img src="xtext.domainmodel/blob/master/web/configuration.png" width="450" height="500">

* After having run the MWE workflow, add the following code in the project `org.example.domainmodel.web`, folder `src/main/java` in the class `org.example.domainmodel.web.DomainmodelWebModule`:

	def void configureIPreferenceValuesProvider(Binder binder) {
		binder.bind(IPreferenceValuesProvider).annotatedWith(FormatterPreferences).to(FormatterPreferenceValuesProvider)
	}

This code corresponds to a fix to [this bug](https://bugs.eclipse.org/bugs/show_bug.cgi?id=495851) fixed in Xtext 2.11 ([expected release in October 2016](https://projects.eclipse.org/projects/modeling.tmf.xtext/releases/2.11.0)).

## Modifications to 15 minutes tutorial - extended (code generation)

* When [writing a code generator](https://eclipse.org/Xtext/documentation/103_domainmodelnextsteps.html), the class `DomainmodelGenerator` has to implement the interface `IGenerator2`. Find below the resulting code:

	package org.example.domainmodel.generator
	
	import com.google.inject.Inject
	import org.eclipse.emf.ecore.resource.Resource
	import org.eclipse.xtext.generator.IGenerator2
	import org.eclipse.xtext.naming.IQualifiedNameProvider
	import org.example.domainmodel.domainmodel.Entity
	import org.example.domainmodel.domainmodel.Feature
	import org.eclipse.xtext.generator.IFileSystemAccess2
	import org.eclipse.xtext.generator.IGeneratorContext
	
	class DomainmodelGenerator implements IGenerator2 {
	 
	    @Inject extension IQualifiedNameProvider
	 
	    def compile(Entity e) ''' 
	        «IF e.eContainer.fullyQualifiedName != null»
	            package «e.eContainer.fullyQualifiedName»;<commit_msg>fixed link<commit_after><link rel='stylesheet' href='web/swiss.css'/>

# Example 

Project corresponding to the example of the [15 minutes tutorial (extended)](https://eclipse.org/Xtext/documentation/102_domainmodelwalkthrough.html) using Xtext 2.10. 

Below I report some adaptations to guide my students. In particular, I added a new Gradle task to execute the compiler from command line.

## Modifications to 15 minutes tutorial (parser)

* When creating a new project, select the following configuration: 

<img src="./web/configuration.png" width="450" height="500">

* After having run the MWE workflow, add the following code in the project `org.example.domainmodel.web`, folder `src/main/java` in the class `org.example.domainmodel.web.DomainmodelWebModule`:

	def void configureIPreferenceValuesProvider(Binder binder) {
		binder.bind(IPreferenceValuesProvider).annotatedWith(FormatterPreferences).to(FormatterPreferenceValuesProvider)
	}

This code corresponds to a fix to [this bug](https://bugs.eclipse.org/bugs/show_bug.cgi?id=495851) fixed in Xtext 2.11 ([expected release in October 2016](https://projects.eclipse.org/projects/modeling.tmf.xtext/releases/2.11.0)).

## Modifications to 15 minutes tutorial - extended (code generation)

* When [writing a code generator](https://eclipse.org/Xtext/documentation/103_domainmodelnextsteps.html), the class `DomainmodelGenerator` has to implement the interface `IGenerator2`. Find below the resulting code:

	package org.example.domainmodel.generator
	
	import com.google.inject.Inject
	import org.eclipse.emf.ecore.resource.Resource
	import org.eclipse.xtext.generator.IGenerator2
	import org.eclipse.xtext.naming.IQualifiedNameProvider
	import org.example.domainmodel.domainmodel.Entity
	import org.example.domainmodel.domainmodel.Feature
	import org.eclipse.xtext.generator.IFileSystemAccess2
	import org.eclipse.xtext.generator.IGeneratorContext
	
	class DomainmodelGenerator implements IGenerator2 {
	 
	    @Inject extension IQualifiedNameProvider
	 
	    def compile(Entity e) ''' 
	        «IF e.eContainer.fullyQualifiedName != null»
	            package «e.eContainer.fullyQualifiedName»;
{'fraction_non_alphanumeric': 0.09293765815504947, 'fraction_numerical': 0.01932367149758454, 'mean_word_length': 5.247126436781609, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1808445', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1183, 'n_words': 337}