<commit_before>/**
 * Copyright (c) 2014 committers of YAKINDU and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * Contributors:
 * 	committers of YAKINDU - initial API and implementation
 * 
 */
package org.yakindu.sct.simulation.core.util

import com.google.inject.Inject
import java.util.ArrayList
import java.util.List
import org.yakindu.base.types.Direction
import org.yakindu.base.types.typesystem.ITypeValueProvider
import org.yakindu.sct.model.sgraph.RegularState
import org.yakindu.sct.model.sruntime.ExecutionContext

class ExecutionContextExtensions {
	@Inject protected extension ITypeValueProvider

	def clearOutEvents(ExecutionContext executionContext) {
		executionContext.allEvents.filter[direction == Direction.OUT].forEach[if(raised) raised = false]
	}

	def clearLocalAndInEvents(ExecutionContext executionContext) {
		executionContext.allEvents.filter[direction == Direction.IN || direction == Direction.LOCAL].forEach [
			if (raised) {
				raised = false;
				value = if(type !== null) type.defaultValue else null
			}
		]
	}

	def List<RegularState> getAllActiveStates(ExecutionContext context) {
		context.activeStates.filter(RegularState).map[stateHierachy].flatten.toList
	}
	
	def protected getStateHierachy(RegularState state) {
		var result = new ArrayList<RegularState>()
		result.add(state);
		var container = state.eContainer();
		while (container !== null) {
			if (container instanceof RegularState) {
				result.add(container);<commit_msg>Simplify method to not use type value provider<commit_after>/**
 * Copyright (c) 2014 committers of YAKINDU and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * Contributors:
 * 	committers of YAKINDU - initial API and implementation
 * 
 */
package org.yakindu.sct.simulation.core.util

import java.util.ArrayList
import java.util.List
import org.yakindu.base.types.Direction
import org.yakindu.sct.model.sgraph.RegularState
import org.yakindu.sct.model.sruntime.ExecutionContext

class ExecutionContextExtensions {

	def clearOutEvents(ExecutionContext executionContext) {
		executionContext.allEvents.filter[direction == Direction.OUT].forEach[
			if(raised) raised = false
		]
	}

	def clearLocalAndInEvents(ExecutionContext executionContext) {
		executionContext.allEvents.filter[direction == Direction.IN || direction == Direction.LOCAL].forEach [
			if(raised) raised = false
		]
	}

	def List<RegularState> getAllActiveStates(ExecutionContext context) {
		context.activeStates.filter(RegularState).map[stateHierachy].flatten.toList
	}
	
	def protected getStateHierachy(RegularState state) {
		var result = new ArrayList<RegularState>()
		result.add(state);
		var container = state.eContainer();
		while (container !== null) {
			if (container instanceof RegularState) {
				result.add(container);
{'fraction_non_alphanumeric': 0.09420970266040689, 'fraction_numerical': 0.005007824726134585, 'mean_word_length': 5.018832391713747, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '1572102', 'n_tokens_mistral': 994, 'n_tokens_neox': 911, 'n_words': 228}