<commit_before>package fr.inria.diverse.kcvl.postprocess

import org.eclipse.emf.ecore.EObject

import org.eclipse.xtext.resource.IDerivedStateComputer
import org.eclipse.xtext.resource.DerivedStateAwareResource

import org.omg.CVLMetamodelMaster.cvl.VPackage
import org.omg.CVLMetamodelMaster.cvl.VSpec
import org.omg.CVLMetamodelMaster.cvl.ObjectHandle
import org.omg.CVLMetamodelMaster.cvl.LinkHandle
import org.omg.CVLMetamodelMaster.cvl.ChoiceResolutuion

import static extension fr.inria.diverse.kcvl.KCvlUtils.*

class KCvlPostProcessor implements IDerivedStateComputer
{
	override installDerivedState(DerivedStateAwareResource resource, boolean preLinkingPhase) {
		val root = resource.parseResult?.rootASTElement as VPackage

		if (root !== null)
			root.eAllContents.forEach[completeAST]
	}

	override discardDerivedState(DerivedStateAwareResource resource) {
		// TODO: Do we really need to discard the modification? Seems to work...
	}

	def dispatch void completeAST(ObjectHandle it) {
		try {
			println("CompleteAST(ObjectHandle)")
			MOFRef = MOFRef ?: ""
			reference = reference ?: resolve
		} catch (Exception e) {
			// Don't cry
		}
	}

	def dispatch void completeAST(LinkHandle it) {
		try {
			println("CompleteAST(LinkHandle)")
			MOFRef = MOFRef ?: ""
			reference = reference ?: resolve
		} catch (Exception e) {
			// Don't cry
		}
	}

	def dispatch void completeAST(VSpec it) {
		println("CompleteAST(VSpec)")
		resolutionTime = resolutionTime ?: ""
	}

	def dispatch void completeAST(ChoiceResolutuion it) {
		println("CompleteAST(ChoiceResolutuion)")
		resolvedVSpec = resolvedChoice
	}

	def dispatch void completeAST(EObject o) {
		// ...
	}
}
<commit_msg>... and debug statements are useless now<commit_after>package fr.inria.diverse.kcvl.postprocess

import org.eclipse.emf.ecore.EObject

import org.eclipse.xtext.resource.IDerivedStateComputer
import org.eclipse.xtext.resource.DerivedStateAwareResource

import org.omg.CVLMetamodelMaster.cvl.VPackage
import org.omg.CVLMetamodelMaster.cvl.VSpec
import org.omg.CVLMetamodelMaster.cvl.ObjectHandle
import org.omg.CVLMetamodelMaster.cvl.LinkHandle
import org.omg.CVLMetamodelMaster.cvl.ChoiceResolutuion

import static extension fr.inria.diverse.kcvl.KCvlUtils.*

class KCvlPostProcessor implements IDerivedStateComputer
{
	override installDerivedState(DerivedStateAwareResource resource, boolean preLinkingPhase) {
		val root = resource.parseResult?.rootASTElement as VPackage

		if (root !== null)
			root.eAllContents.forEach[completeAST]
	}

	override discardDerivedState(DerivedStateAwareResource resource) {
		// TODO: Do we really need to discard the modification? Seems to work...
	}

	def dispatch void completeAST(ObjectHandle it) {
		try {
			MOFRef = MOFRef ?: ""
			reference = reference ?: resolve
		} catch (Exception e) {
			// Don't cry
		}
	}

	def dispatch void completeAST(LinkHandle it) {
		try {
			MOFRef = MOFRef ?: ""
			reference = reference ?: resolve
		} catch (Exception e) {
			// Don't cry
		}
	}

	def dispatch void completeAST(VSpec it) {
		resolutionTime = resolutionTime ?: ""
	}

	def dispatch void completeAST(ChoiceResolutuion it) {
		resolvedVSpec = resolvedChoice
	}

	def dispatch void completeAST(EObject o) {
		// ...
	}
}

{'fraction_non_alphanumeric': 0.0951061865189289, 'fraction_numerical': 0.0, 'mean_word_length': 4.546075085324232, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6892986', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1048, 'n_words': 222}