<commit_before>package chameleon.test.provider;

import java.util.ArrayList;
import java.util.Collection;

import chameleon.core.element.Element;
import chameleon.core.language.Language;

/**
 * A class for searching elements of type E in the elements provided by a provider to the ancestor
 * elements.
 * 
 * @author <NAME>
 *
 * @param <E>
 */
public class BasicDescendantProvider<E extends Element> extends AbstractDescendantProvider<E> {
	
	/**
	 * Create a new basic descendant provider with the given ancestor provider, and the class
	 * object representing the type of the elements that must be provided.
	 */
 /*@
   @ public behavior
   @
   @ pre ancestorProvider != null;
   @ pre cls != null;
   @
   @ post ancestorProvider() == ancestorProvider;
   @ post selectedType() == cls;
   @*/
	public BasicDescendantProvider(ElementProvider<? extends Element> ancestorProvider, Class<E> cls) {
		super(ancestorProvider, cls);
	}

	/**
	 * Return a collection containing all descendants of type E of all elements
	 * provided by the ancestor provider.
	 */
 /*@
   @ public behavior
   @
   @ post (\forall Element ancestor; ancestorProvider().elements().contains(ancestor);
   @         \result.containsAll(ancestor.descendants(selectedType())));
  */
	public Collection<E> elements(Language language) {
		Collection<E> result = new ArrayList();
		Class<E> cls = elementType();
		for(Element<?> element: ancestorProvider().elements(language)) {
			result.addAll(element.descendants(cls));
		}
		return result;
	}
}
<commit_msg>added exceptions test<commit_after>package chameleon.test.provider;

import java.util.ArrayList;
import java.util.Collection;

import chameleon.core.element.Element;
import chameleon.core.language.Language;

/**
 * A class for searching elements of type E in the elements provided by a provider to the ancestor
 * elements.
 * 
 * @author <NAME>
 *
 * @param <E>
 */
public class BasicDescendantProvider<E extends Element> extends AbstractDescendantProvider<E> {
	
	/**
	 * Create a new basic descendant provider with the given ancestor provider, and the class
	 * object representing the type of the elements that must be provided.
	 */
 /*@
   @ public behavior
   @
   @ pre ancestorProvider != null;
   @ pre cls != null;
   @
   @ post ancestorProvider() == ancestorProvider;
   @ post selectedType() == cls;
   @*/
	public BasicDescendantProvider(ElementProvider<? extends Element> ancestorProvider, Class<E> cls) {
		super(ancestorProvider, cls);
	}

	/**
	 * Return a collection containing all descendants of type E of all elements
	 * provided by the ancestor provider.
	 */
 /*@
   @ public behavior
   @
   @ post (\forall Element ancestor; ancestorProvider().elements().contains(ancestor);
   @         \result.containsAll(ancestor.descendants(selectedType())));
  */
	public Collection<E> elements(Language language) {
		Collection<E> result = new ArrayList();
		Class<E> cls = elementType();
		for(Element<?> element: ancestorProvider().elements(language)) {
			if(element == null) {
				System.out.println("debug");
			}
			result.addAll(element.descendants(cls));
		}
		return result;
	}
}

{'fraction_non_alphanumeric': 0.11556829035339064, 'fraction_numerical': 0.0, 'mean_word_length': 3.9952305246422894, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '3831144', 'n_tokens_mistral': 938, 'n_tokens_neox': 880, 'n_words': 265}