<commit_before>package fr.inria.diverse.k3.sle.validation

import fr.inria.diverse.k3.sle.metamodel.k3sle.Metamodel
import fr.inria.diverse.k3.sle.metamodel.k3sle.K3slePackage

import fr.inria.diverse.k3.sle.lib.ModelUtils

import org.eclipse.xtext.validation.Check

class K3SLEValidator extends AbstractK3SLEValidator
{
	@Check
	def checkEcoreIsSet(Metamodel mm) {
		if (mm.ecore?.uri === null && mm.inheritanceRelation?.superMetamodel?.ecore?.uri === null) {
			error("A valid Ecore file must be imported", K3slePackage.Literals.METAMODEL__ECORE)
		} else if (mm.ecore?.uri !== null && mm.inheritanceRelation?.superMetamodel?.ecore?.uri !== null) {
			error("An Ecore file has already been imported in the super metamodel", K3slePackage.Literals.METAMODEL__ECORE)
		}
	}

	@Check
	def checkGenModelIsSet(Metamodel mm) {
		if (mm.ecore?.uri !== null && mm.ecore?.uri.endsWith(".ecore") && mm.ecore?.genmodelUri === null) {
			// !!!<commit_msg>k3sle: Enforce unique names within a megamodel<commit_after>package fr.inria.diverse.k3.sle.validation

import fr.inria.diverse.k3.sle.metamodel.k3sle.MegamodelRoot
import fr.inria.diverse.k3.sle.metamodel.k3sle.Element
import fr.inria.diverse.k3.sle.metamodel.k3sle.Metamodel
import fr.inria.diverse.k3.sle.metamodel.k3sle.K3slePackage

import fr.inria.diverse.k3.sle.lib.ModelUtils

import org.eclipse.xtext.validation.Check

class K3SLEValidator extends AbstractK3SLEValidator
{
	@Check
	def checkNamesAreUnique(Element e) {
		if ((e.eContainer as MegamodelRoot).elements.exists[e_ |
			   e_ != e
			&& e_.eClass == e.eClass
			&& e_.name == e.name
		])
			error("Names must be unique", K3slePackage.Literals.ELEMENT__NAME)
	}

	@Check
	def checkEcoreIsSet(Metamodel mm) {
		if (mm.ecore?.uri === null && mm.inheritanceRelation?.superMetamodel?.ecore?.uri === null) {
			error("A valid Ecore file must be imported", K3slePackage.Literals.METAMODEL__ECORE)
		} else if (mm.ecore?.uri !== null && mm.inheritanceRelation?.superMetamodel?.ecore?.uri !== null) {
			error("An Ecore file has already been imported in the super metamodel", K3slePackage.Literals.METAMODEL__ECORE)
		}
	}

	@Check
	def checkGenModelIsSet(Metamodel mm) {
		if (mm.ecore?.uri !== null && mm.ecore?.uri.endsWith(".ecore") && mm.ecore?.genmodelUri === null) {
			// !!!
{'fraction_non_alphanumeric': 0.13848842289209262, 'fraction_numerical': 0.012232415902140673, 'mean_word_length': 4.6265356265356266, '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': '684722', 'n_tokens_mistral': 944, 'n_tokens_neox': 873, 'n_words': 147}