<commit_before>package ccw.util;

import java.util.Collections;
import java.util.Map;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.core.runtime.IExecutableExtensionFactory;

import ccw.util.internal.Activator;
import clojure.lang.Var;
import clojure.osgi.ClojureOSGi;
import clojure.osgi.RunnableWithException;

public class GenericExecutableExtension implements IExecutableExtensionFactory, IExecutableExtension {

	private String bundleName;
	private Var factory;
	private Map<String, String> factoryParams;
	
	public Object create() throws CoreException {
		try {
			return ClojureOSGi.withBundle(BundleUtils.loadAndGetBundle(bundleName), new RunnableWithException() {
				public Object run() throws Exception {
					return factory.invoke(factoryParams);
				}
			});
		} catch (CoreException e) {
			throw e;
		} catch (Exception e) {
			throw new CoreException(Activator.createErrorStatus(
					this.getClass().getName() + " was unable"
						+ " to instanciate Clojure factory "
						+ factory.ns.name.getName() + "/" 
						+ factory.sym.getName() 
						+ " from bundle " + bundleName 
						+ " with following factory params:" + factoryParams, e));
		}
	}

	public void setInitializationData(IConfigurationElement config,
			String propertyName, Object data) throws CoreException {
		assert data instanceof String;
		bundleName = config.getDeclaringExtension().getContributor().getName();
		System.out.println("GenericExecutableExtension instance, bundleName=" + bundleName);
		if (data instanceof String) {
			String name = (String) data;
			initFactory(name);
		} else if (data instanceof Map) {
			@SuppressWarnings("unchecked")
			Map<String, String> factoryParams = (Map<String, String>) data;
			if (factoryParams.containsKey("factory")) {
				String name = factoryParams.get("factory");
				initFactory(name);
				this.factoryParams = Collections.unmodifiableMap(factoryParams);
			} else {
				throw new CoreException(Activator.createErrorStatus(
						  this.getClass().getName() + " was unable to initialize correctly:"<commit_msg>Fix Issue 377: 	wrong assert in GenericExecutableExtension.java<commit_after>package ccw.util;

import java.util.Collections;
import java.util.Map;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.core.runtime.IExecutableExtensionFactory;

import ccw.util.internal.Activator;
import clojure.lang.Var;
import clojure.osgi.ClojureOSGi;
import clojure.osgi.RunnableWithException;

public class GenericExecutableExtension implements IExecutableExtensionFactory, IExecutableExtension {

	private String bundleName;
	private Var factory;
	private Map<String, String> factoryParams;
	
	public Object create() throws CoreException {
		try {
			return ClojureOSGi.withBundle(BundleUtils.loadAndGetBundle(bundleName), new RunnableWithException() {
				public Object run() throws Exception {
					return factory.invoke(factoryParams);
				}
			});
		} catch (CoreException e) {
			throw e;
		} catch (Exception e) {
			throw new CoreException(Activator.createErrorStatus(
					this.getClass().getName() + " was unable"
						+ " to instanciate Clojure factory "
						+ factory.ns.name.getName() + "/" 
						+ factory.sym.getName() 
						+ " from bundle " + bundleName 
						+ " with following factory params:" + factoryParams, e));
		}
	}

	public void setInitializationData(IConfigurationElement config,
			String propertyName, Object data) throws CoreException {
		bundleName = config.getDeclaringExtension().getContributor().getName();
		System.out.println("GenericExecutableExtension instance, bundleName=" + bundleName);
		if (data instanceof String) {
			String name = (String) data;
			initFactory(name);
		} else if (data instanceof Map) {
			@SuppressWarnings("unchecked")
			Map<String, String> factoryParams = (Map<String, String>) data;
			if (factoryParams.containsKey("factory")) {
				String name = factoryParams.get("factory");
				initFactory(name);
				this.factoryParams = Collections.unmodifiableMap(factoryParams);
			} else {
				throw new CoreException(Activator.createErrorStatus(
						  this.getClass().getName() + " was unable to initialize correctly:"
{'fraction_non_alphanumeric': 0.10294453321159552, 'fraction_numerical': 0.0006847751654873316, 'mean_word_length': 4.743119266055046, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1561396', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1215, 'n_words': 287}