All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.xtext.xbase.testing.SynchronizedXtextResourceSetProvider Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (c) 2013, 2017 itemis AG (http://www.itemis.eu) and others.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0
 *******************************************************************************/
package org.eclipse.xtext.xbase.testing;

import org.eclipse.xtext.common.types.access.IJvmTypeProvider;
import org.eclipse.xtext.resource.SynchronizedXtextResourceSet;

import com.google.inject.Inject;
import com.google.inject.Provider;

/**
 * Yields an empty resource set that is configured with an injected class loader
 * and a classpath based {@link IJvmTypeProvider}. 
 * 
 * @author Sebastian Zarnekow
 * @since 2.4
 */
public class SynchronizedXtextResourceSetProvider implements Provider {

	@Inject
	private ClassLoader classLoader;

	@Inject
	private IJvmTypeProvider.Factory typeProviderFactory;

	@Override
	public SynchronizedXtextResourceSet get() {
		SynchronizedXtextResourceSet result = new SynchronizedXtextResourceSet();
		result.setClasspathURIContext(classLoader);
		typeProviderFactory.findOrCreateTypeProvider(result);
		return result;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy