<commit_before>package biz.aQute.resolve;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.felix.resolver.Logger;
import org.osgi.framework.ServiceReference;
import org.osgi.resource.Capability;
import org.osgi.resource.Requirement;
import org.osgi.resource.Resource;
import org.osgi.resource.Wire;
import org.osgi.service.log.LogService;
import org.osgi.service.resolver.ResolutionException;
import org.osgi.service.resolver.Resolver;
import org.slf4j.LoggerFactory;

import aQute.bnd.build.Container;
import aQute.bnd.build.Project;
import aQute.bnd.build.Workspace;
import aQute.bnd.header.Attrs;
import aQute.bnd.header.Parameters;
import aQute.bnd.osgi.Processor;
import aQute.bnd.osgi.resource.CapReqBuilder;
import aQute.bnd.osgi.resource.ResourceUtils;
import aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability;
import aQute.bnd.service.Strategy;

/**
 * This class provides resolving capabilities to a Project (and this a bndrun
 * which is a Run which extends Project). This class is supposed to simplify the
 * sometimes bewildering number of moving cogs in resolving. It is a processor
 * and uses the facilities to provide the different logging schemes used.
 */

public class ProjectResolver extends Processor implements ResolutionCallback {
	private final static org.slf4j.Logger logger = LoggerFactory.getLogger(ProjectResolver.class);

	private final class ReporterLogger extends Logger implements LogService {
		ReporterLogger(int i) {
			super(i);
		}

		@Override
		protected void doLog(int level, String msg, Throwable throwable) {
			switch (level) {
				case Logger.LOG_ERROR : // error
					if (throwable == null) {
						error("%s", msg);
					} else {
						exception(throwable, "%s", msg);
					}
					break;

				case Logger.LOG_WARNING :
					if (throwable == null) {
						warning("%s", msg);
					} else {
						warning("%s: %s", msg, throwable);
					}
					break;

				case Logger.LOG_INFO :
					logger.info("{}", msg, throwable);
					break;

				default :
					logger.debug("{}", msg, throwable);
					break;
			}
		}

		@Override
		public void log(ServiceReference sr, int level, String message) {
			doLog(level, toString(sr) + message, null);

		}

		@Override
		public void log(ServiceReference sr, int level, String message, Throwable exception) {
			doLog(level, toString(sr) + message, exception);
		}

		private String toString(ServiceReference< ? > sr) {
			return "[" + sr.getProperty(org.osgi.framework.Constants.SERVICE_ID) + "] ";
		}
	}

	private Project							project;
	private Map<Resource,List<Wire>>		resolution;
	private ReporterLogger					log			= new ReporterLogger(0);
	private Resolver						resolver	= new BndResolver(new ReporterLogger(0));
	private ResolveProcess					resolve		= new ResolveProcess();
	private Collection<ResolutionCallback>	cbs			= new ArrayList<ResolutionCallback>();

	public ProjectResolver(Project project) throws Exception {
		super(project);
		getSettings(project);
		this.project = project;

		Workspace workspace = project.getWorkspace();
		if (workspace != null)
			addBasicPlugin(new WorkspaceResourcesRepository(workspace));
	}

	public Map<Resource,List<Wire>> resolve() throws ResolutionException {
		resolution = resolve.resolveRequired(project, project, this, resolver, cbs, log);
		return resolution;
	}

	@Override
	public void processCandidates(Requirement requirement, Set<Capability> wired, List<Capability> candidates) {
		// System.out.println("Process candidates " + requirement + " " + wired
		// + " " + candidates);
	}<commit_msg>resolve: WorkspaceResourcesRepo now set in Bndrun constructor<commit_after>package biz.aQute.resolve;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.felix.resolver.Logger;
import org.osgi.framework.ServiceReference;
import org.osgi.resource.Capability;
import org.osgi.resource.Requirement;
import org.osgi.resource.Resource;
import org.osgi.resource.Wire;
import org.osgi.service.log.LogService;
import org.osgi.service.resolver.ResolutionException;
import org.osgi.service.resolver.Resolver;
import org.slf4j.LoggerFactory;

import aQute.bnd.build.Container;
import aQute.bnd.build.Project;
import aQute.bnd.header.Attrs;
import aQute.bnd.header.Parameters;
import aQute.bnd.osgi.Processor;
import aQute.bnd.osgi.resource.CapReqBuilder;
import aQute.bnd.osgi.resource.ResourceUtils;
import aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability;
import aQute.bnd.service.Strategy;

/**
 * This class provides resolving capabilities to a Project (and this a bndrun
 * which is a Run which extends Project). This class is supposed to simplify the
 * sometimes bewildering number of moving cogs in resolving. It is a processor
 * and uses the facilities to provide the different logging schemes used.
 */

public class ProjectResolver extends Processor implements ResolutionCallback {
	private final static org.slf4j.Logger logger = LoggerFactory.getLogger(ProjectResolver.class);

	private final class ReporterLogger extends Logger implements LogService {
		ReporterLogger(int i) {
			super(i);
		}

		@Override
		protected void doLog(int level, String msg, Throwable throwable) {
			switch (level) {
				case Logger.LOG_ERROR : // error
					if (throwable == null) {
						error("%s", msg);
					} else {
						exception(throwable, "%s", msg);
					}
					break;

				case Logger.LOG_WARNING :
					if (throwable == null) {
						warning("%s", msg);
					} else {
						warning("%s: %s", msg, throwable);
					}
					break;

				case Logger.LOG_INFO :
					logger.info("{}", msg, throwable);
					break;

				default :
					logger.debug("{}", msg, throwable);
					break;
			}
		}

		@Override
		public void log(ServiceReference sr, int level, String message) {
			doLog(level, toString(sr) + message, null);

		}

		@Override
		public void log(ServiceReference sr, int level, String message, Throwable exception) {
			doLog(level, toString(sr) + message, exception);
		}

		private String toString(ServiceReference< ? > sr) {
			return "[" + sr.getProperty(org.osgi.framework.Constants.SERVICE_ID) + "] ";
		}
	}

	private Project							project;
	private Map<Resource,List<Wire>>		resolution;
	private ReporterLogger					log			= new ReporterLogger(0);
	private Resolver						resolver	= new BndResolver(new ReporterLogger(0));
	private ResolveProcess					resolve		= new ResolveProcess();
	private Collection<ResolutionCallback>	cbs			= new ArrayList<ResolutionCallback>();

	public ProjectResolver(Project project) {
		super(project);
		getSettings(project);
		this.project = project;
	}

	public Map<Resource,List<Wire>> resolve() throws ResolutionException {
		resolution = resolve.resolveRequired(project, project, this, resolver, cbs, log);
		return resolution;
	}

	@Override
	public void processCandidates(Requirement requirement, Set<Capability> wired, List<Capability> candidates) {
		// System.out.println("Process candidates " + requirement + " " + wired
		// + " " + candidates);
	}
{'fraction_non_alphanumeric': 0.10789953697207802, 'fraction_numerical': 0.001122491932089238, 'mean_word_length': 4.245033112582782, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '4228270', 'n_tokens_mistral': 2457, 'n_tokens_neox': 2138, 'n_words': 552}