<commit_before>/*
 * generated by Xtext 2.10.0
 */
package com.github.funthomas424242.dsl.validation


/**
 * This class contains custom validation rules. 
 *
 * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation
 */
class AhnenValidator extends AbstractAhnenValidator {
	
//	public static val INVALID_NAME = 'invalidName'
//
//	@Check
//	def checkGreetingStartsWithCapital(Greeting greeting) {
//		if (!Character.isUpperCase(greeting.name.charAt(0))) {
//			warning('Name should start with a capital', 
//					AhnenPackage.Literals.GREETING__NAME,
//					INVALID_NAME)
//		}
//	}
	
}<commit_msg>first validation rule added<commit_after>/*
 * generated by Xtext 2.10.0
 */
package com.github.funthomas424242.dsl.validation

import com.github.funthomas424242.dsl.ahnen.AhnenPackage
import com.github.funthomas424242.dsl.ahnen.Beziehung
import com.github.funthomas424242.dsl.ahnen.Familie
import com.github.funthomas424242.dsl.ahnen.Kinder
import com.github.funthomas424242.dsl.ahnen.Person
import org.eclipse.xtext.validation.Check

/**
 * This class contains custom validation rules. 
 *
 * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation
 */
class AhnenValidator extends AbstractAhnenValidator {
	
	
	@Check
	def void checkFamilyConsistence(Familie familie){
	    var Kinder kinder = familie.kinder;
	    while(kinder.kind != null){
	        checkKindBackRefToFamily(familie,kinder.kind);
	        kinder=kinder.next;
	    }
	}
	
    def void checkKindBackRefToFamily(Familie familie, Person kind){
        info("CHECK für "+familie.name +" "+kind.name,AhnenPackage.Literals.FAMILIE__KINDER);
         var boolean hasBackLink = false;
         for( Beziehung beziehung: kind.beziehungen){
            if( beziehung.beziehung.name ==  familie.name){
                hasBackLink = true;
                info("HAS LINK für "+beziehung.beziehung.name +" "+kind.name,AhnenPackage.Literals.FAMILIE__KINDER);
            } 
         }
         if( hasBackLink ){
           info("Person: "+kind.name+" hat eine Beziehung zur Familie: "+familie.name
               ,AhnenPackage.Literals.FAMILIE__KINDER
           );
         }else{
          info("Person: "+kind.name+" benötigt eine Beziehung zur Familie: "+familie.name
               ,AhnenPackage.Literals.FAMILIE__KINDER
           );
         }
    }
	
	
//	public static val INVALID_NAME = 'invalidName'
//
//	@Check
//	def checkGreetingStartsWithCapital(Greeting greeting) {
//		if (!Character.isUpperCase(greeting.name.charAt(0))) {
//			warning('Name should start with a capital', 
//					AhnenPackage.Literals.GREETING__NAME,
//					INVALID_NAME)
//		}
//	}
	
}
{'fraction_non_alphanumeric': 0.11644345238095238, 'fraction_numerical': 0.021577380952380952, 'mean_word_length': 3.1053435114503816, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '1896702', 'n_tokens_mistral': 960, 'n_tokens_neox': 901, 'n_words': 153}