<commit_before>/*******************************************************************************
 * Copyright (c) 2012 <NAME>
 * 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
 *******************************************************************************/

package me.gladwell.eclipse.m2e.android.project;

import me.gladwell.eclipse.m2e.android.configuration.DependencyNotFoundInWorkspace;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;

import com.google.inject.Inject;
import com.google.inject.Singleton;

@Singleton
public class AdtEclipseAndroidWorkspace implements AndroidWorkspace {

	private IWorkspace workspace;
	private AndroidProjectFactory<EclipseAndroidProject, IProject> projectFactory;
	private AndroidProjectFactory<MavenAndroidProject, EclipseAndroidProject> projectConverter;

	@Inject
	public AdtEclipseAndroidWorkspace(
			IWorkspace workspace,
			AndroidProjectFactory<EclipseAndroidProject, IProject> projectFactory,
			AndroidProjectFactory<MavenAndroidProject, EclipseAndroidProject> projectConverter) {
		super();
		this.workspace = workspace;
		this.projectFactory = projectFactory;
		this.projectConverter = projectConverter;
	}

	public EclipseAndroidProject findOpenWorkspaceDependency(Dependency dependency) {
		for(IProject project : workspace.getRoot().getProjects()) {
			if (!project.isOpen()) {
				continue;
			}
			EclipseAndroidProject androidProject = projectFactory.createAndroidProject(project);
			if(androidProject.isAndroidProject() && androidProject.isMavenised()) {
				MavenAndroidProject mavenProject = projectConverter.createAndroidProject(androidProject);
				if(mavenProject.matchesDependency(dependency)) {
					return androidProject;
				}
			}
		}

		throw new DependencyNotFoundInWorkspace(dependency);
	}

}
<commit_msg>Added TODO to delegate workspace dependency resolution to m2e API.<commit_after>/*******************************************************************************
 * Copyright (c) 2012 <NAME>
 * 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
 *******************************************************************************/

package me.gladwell.eclipse.m2e.android.project;

import me.gladwell.eclipse.m2e.android.configuration.DependencyNotFoundInWorkspace;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;

import com.google.inject.Inject;
import com.google.inject.Singleton;

@Singleton
public class AdtEclipseAndroidWorkspace implements AndroidWorkspace {

	private IWorkspace workspace;
	private AndroidProjectFactory<EclipseAndroidProject, IProject> projectFactory;
	private AndroidProjectFactory<MavenAndroidProject, EclipseAndroidProject> projectConverter;

	@Inject
	public AdtEclipseAndroidWorkspace(
			IWorkspace workspace,
			AndroidProjectFactory<EclipseAndroidProject, IProject> projectFactory,
			AndroidProjectFactory<MavenAndroidProject, EclipseAndroidProject> projectConverter) {
		super();
		this.workspace = workspace;
		this.projectFactory = projectFactory;
		this.projectConverter = projectConverter;
	}

	// TODO delegate workspace dep resolution to EclipseWorkspaceArtifactRepository
	public EclipseAndroidProject findOpenWorkspaceDependency(Dependency dependency) {
		for(IProject project : workspace.getRoot().getProjects()) {
			if (!project.isOpen()) {
				continue;
			}
			EclipseAndroidProject androidProject = projectFactory.createAndroidProject(project);
			if(androidProject.isAndroidProject() && androidProject.isMavenised()) {
				MavenAndroidProject mavenProject = projectConverter.createAndroidProject(androidProject);
				if(mavenProject.matchesDependency(dependency)) {
					return androidProject;
				}
			}
		}

		throw new DependencyNotFoundInWorkspace(dependency);
	}

}

{'fraction_non_alphanumeric': 0.14892086330935253, 'fraction_numerical': 0.005035971223021582, 'mean_word_length': 6.583636363636364, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '6278508', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1020, 'n_words': 228}