<commit_before>package eventBRefinementSlicer.internal.datastructures;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.eclipse.core.runtime.CoreException;
import org.eventb.core.ast.FormulaFactory;
import org.eventb.core.ast.ITypeEnvironmentBuilder;
import org.eventb.core.IContextRoot;
import org.eventb.core.IEvent;
import org.eventb.core.IInvariant;
import org.eventb.core.IMachineRoot;
import org.eventb.core.ISCEvent;
import org.eventb.core.ISCInvariant;
import org.eventb.core.ISCMachineRoot;
import org.eventb.core.ISCVariable;
import org.eventb.core.ISeesContext;
import org.eventb.core.ITraceableElement;
import org.eventb.core.IVariable;

import eventBRefinementSlicer.internal.util.SCUtil;

public class EventBMachine extends EventBUnit {

	private List<EventBInvariant> invariants = new ArrayList<>();
	private List<EventBVariable> variables = new ArrayList<>();
	private List<EventBVariable> abstractVariables = new ArrayList<>();
	private Set<EventBContext> seenContexts = new HashSet<>();
	private List<EventBEvent> events = new ArrayList<>();
	private ISCMachineRoot scMachineRoot = null;

	public EventBMachine(IMachineRoot machineRoot) throws CoreException {
		this.scMachineRoot = SCUtil.makeStaticCheckedMachine(machineRoot);
		for (IInvariant originalInvariant : machineRoot.getInvariants()) {
			ITraceableElement originalSCElement = SCUtil.findSCElement(originalInvariant, scMachineRoot.getSCInvariants());
			assert (originalSCElement instanceof ISCInvariant);
			EventBInvariant invariant = new EventBInvariant(originalInvariant, (ISCInvariant) originalSCElement, this);
			invariants.add(invariant);
		}
		for (IVariable originalVariable : machineRoot.getVariables()) {
			ITraceableElement originalSCElement = SCUtil.findSCElement(originalVariable, scMachineRoot.getSCVariables());
			assert (originalSCElement instanceof ISCVariable);
			EventBVariable variable = new EventBVariable(originalVariable, (ISCVariable) originalSCElement, this);
			variables.add(variable);
		}
		for (ISCVariable scVariable : scMachineRoot.getSCVariables()) {
			if (scVariable.isAbstract()) {
				EventBVariable abstractVariable = new EventBVariable(scVariable, this);
				abstractVariables.add(abstractVariable);
			}
		}
		for (ISeesContext seenContext : machineRoot.getSeesClauses()) {
			IContextRoot contextRoot = seenContext.getSeenContextRoot();
			EventBContext context = new EventBContext(contextRoot);
			seenContexts.add(context);
		}
		for (IEvent originalEvent : machineRoot.getEvents()) {
			ITraceableElement originalSCElement = SCUtil.findSCElement(originalEvent, scMachineRoot.getSCEvents());
			assert (originalSCElement instanceof ISCEvent);
			EventBEvent event = new EventBEvent(originalEvent, (ISCEvent) originalSCElement, this);
			events.add(event);
		}
		for (EventBInvariant invariant : invariants) {
			invariant.setDependees(invariant.calculateDependees());
		}
		for (EventBVariable variable : variables) {
			variable.setDependees(variable.calculateDependees());
		}
	}

	public List<EventBInvariant> getInvariants() {
		return invariants;
	}

	public List<EventBVariable> getVariables() {
		return variables;
	}

	public Set<EventBContext> getSeenContexts() {
		return seenContexts;
	}

	public List<EventBEvent> getEvents() {
		return events;
	}

	public ISCMachineRoot getScMachineRoot() {
		return scMachineRoot;
	}

	public void addSeenContext(EventBContext context) {
		seenContexts.add(context);
	}

	public void removeSeenContext(EventBContext context) {
		seenContexts.remove(context);
	}
	
	public EventBAttribute findAttributeByLabel(String identifierName) {
		for (EventBVariable variable : variables) {
			if (variable.getLabel().equals(identifierName)) {
				return variable;
			}
		}
		for (EventBVariable abstractVariable : abstractVariables) {
			if (abstractVariable.getLabel().equals(identifierName)) {
				return abstractVariable;
			}
		}
		for (EventBContext context : seenContexts) {
			EventBAttribute attribute = context.findAttributeByLabel(identifierName);
			if (attribute != null) {
				return attribute;
			}
		}
		return null;
	}

	public ITypeEnvironmentBuilder getTypeEnvironment() throws CoreException {
		return scMachineRoot.getTypeEnvironment();
	}
	
	public FormulaFactory getFormulaFactory() {
		return scMachineRoot.getFormulaFactory();
	}
}<commit_msg>Changes seenContexts in EventBMachine from Set to List<commit_after>package eventBRefinementSlicer.internal.datastructures;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.runtime.CoreException;
import org.eventb.core.IContextRoot;
import org.eventb.core.IEvent;
import org.eventb.core.IInvariant;
import org.eventb.core.IMachineRoot;
import org.eventb.core.ISCEvent;
import org.eventb.core.ISCInvariant;
import org.eventb.core.ISCMachineRoot;
import org.eventb.core.ISCVariable;
import org.eventb.core.ISeesContext;
import org.eventb.core.ITraceableElement;
import org.eventb.core.IVariable;
import org.eventb.core.ast.FormulaFactory;
import org.eventb.core.ast.ITypeEnvironmentBuilder;

import eventBRefinementSlicer.internal.util.SCUtil;

public class EventBMachine extends EventBUnit {

	private List<EventBInvariant> invariants = new ArrayList<>();
	private List<EventBVariable> variables = new ArrayList<>();
	private List<EventBVariable> abstractVariables = new ArrayList<>();
	private List<EventBContext> seenContexts = new ArrayList<>();
	private List<EventBEvent> events = new ArrayList<>();
	private ISCMachineRoot scMachineRoot = null;

	public EventBMachine(IMachineRoot machineRoot) throws CoreException {
		this.scMachineRoot = SCUtil.makeStaticCheckedMachine(machineRoot);
		for (IInvariant originalInvariant : machineRoot.getInvariants()) {
			ITraceableElement originalSCElement = SCUtil.findSCElement(originalInvariant, scMachineRoot.getSCInvariants());
			assert (originalSCElement instanceof ISCInvariant);
			EventBInvariant invariant = new EventBInvariant(originalInvariant, (ISCInvariant) originalSCElement, this);
			invariants.add(invariant);
		}
		for (IVariable originalVariable : machineRoot.getVariables()) {
			ITraceableElement originalSCElement = SCUtil.findSCElement(originalVariable, scMachineRoot.getSCVariables());
			assert (originalSCElement instanceof ISCVariable);
			EventBVariable variable = new EventBVariable(originalVariable, (ISCVariable) originalSCElement, this);
			variables.add(variable);
		}
		for (ISCVariable scVariable : scMachineRoot.getSCVariables()) {
			if (scVariable.isAbstract()) {
				EventBVariable abstractVariable = new EventBVariable(scVariable, this);
				abstractVariables.add(abstractVariable);
			}
		}
		for (ISeesContext seenContext : machineRoot.getSeesClauses()) {
			IContextRoot contextRoot = seenContext.getSeenContextRoot();
			EventBContext context = new EventBContext(contextRoot);
			seenContexts.add(context);
		}
		for (IEvent originalEvent : machineRoot.getEvents()) {
			ITraceableElement originalSCElement = SCUtil.findSCElement(originalEvent, scMachineRoot.getSCEvents());
			assert (originalSCElement instanceof ISCEvent);
			EventBEvent event = new EventBEvent(originalEvent, (ISCEvent) originalSCElement, this);
			events.add(event);
		}
		for (EventBInvariant invariant : invariants) {
			invariant.setDependees(invariant.calculateDependees());
		}
		for (EventBVariable variable : variables) {
			variable.setDependees(variable.calculateDependees());
		}
	}

	public List<EventBInvariant> getInvariants() {
		return invariants;
	}

	public List<EventBVariable> getVariables() {
		return variables;
	}

	public List<EventBContext> getSeenContexts() {
		return seenContexts;
	}

	public List<EventBEvent> getEvents() {
		return events;
	}

	public ISCMachineRoot getScMachineRoot() {
		return scMachineRoot;
	}

	public void addSeenContext(EventBContext context) {
		seenContexts.add(context);
	}

	public void removeSeenContext(EventBContext context) {
		seenContexts.remove(context);
	}

	@Override
	public EventBAttribute findAttributeByLabel(String identifierName) {
		for (EventBVariable variable : variables) {
			if (variable.getLabel().equals(identifierName)) {
				return variable;
			}
		}
		for (EventBVariable abstractVariable : abstractVariables) {
			if (abstractVariable.getLabel().equals(identifierName)) {
				return abstractVariable;
			}
		}
		for (EventBContext context : seenContexts) {
			EventBAttribute attribute = context.findAttributeByLabel(identifierName);
			if (attribute != null) {
				return attribute;
			}
		}
		return null;
	}

	@Override
	public ITypeEnvironmentBuilder getTypeEnvironment() throws CoreException {
		return scMachineRoot.getTypeEnvironment();
	}

	@Override
	public FormulaFactory getFormulaFactory() {
		return scMachineRoot.getFormulaFactory();
	}
}
{'fraction_non_alphanumeric': 0.09469267407575414, 'fraction_numerical': 0.0, 'mean_word_length': 5.955047318611987, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '3321925', 'n_tokens_mistral': 2808, 'n_tokens_neox': 2542, 'n_words': 518}