<commit_before>/*******************************************************************************
 * Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others.
 * 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 org.eclipse.xtext.concurrent;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.resource.XtextResource;

import com.google.inject.ImplementedBy;

/**
 * @author <NAME> - Initial contribution and API
 *
 */
@ImplementedBy(IEObjectHandle.DefaultImpl.class)
public interface IEObjectHandle<T extends EObject> extends IStateAccess<T> {
	
	static class DefaultImpl<P extends EObject> implements IEObjectHandle<P> {
		
		private P internal;
		private IStateAccess<XtextResource> resourceAccess;
		private String fragment;
		
		public DefaultImpl(P internal, IStateAccess<XtextResource> resourceAccess) {
			super();
			this.internal = internal;
			this.resourceAccess = resourceAccess;
			this.fragment = internal.eResource().getURIFragment(internal);
		}

		public <T> T modify(IUnitOfWork<T, P> work) {
			return resourceAccess.modify(new ResourceAccess<T>(work));
		}

		public <T> T readOnly(IUnitOfWork<T, P> work) {
			return resourceAccess.readOnly(new ResourceAccess<T>(work));
		}
		
		class ResourceAccess<T> implements IUnitOfWork<T,XtextResource> {
			
			private IUnitOfWork<T, P> work = null;

			public ResourceAccess(IUnitOfWork<T, P> work) {
				super();
				this.work = work;
			}

			@SuppressWarnings("unchecked")
			public T exec(XtextResource resource) throws Exception {
				P obj = internal;
				if (obj.eResource() != resource) {
					obj = (P) resource.getEObject(fragment);
				}
				return work.exec(obj);
			}
		}

	}

}
<commit_msg>getURI() method added<commit_after>/*******************************************************************************
 * Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others.
 * 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 org.eclipse.xtext.concurrent;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.xtext.resource.XtextResource;

import com.google.inject.ImplementedBy;

/**
 * @author <NAME> - Initial contribution and API
 *
 */
@ImplementedBy(IEObjectHandle.DefaultImpl.class)
public interface IEObjectHandle<T extends EObject> extends IStateAccess<T> {
	
	public URI getURI();
	
	static class DefaultImpl<P extends EObject> implements IEObjectHandle<P> {
		
		private P internal;
		private IStateAccess<XtextResource> resourceAccess;
		private String fragment;
		
		public DefaultImpl(P internal, IStateAccess<XtextResource> resourceAccess) {
			super();
			this.internal = internal;
			this.resourceAccess = resourceAccess;
			this.fragment = internal.eResource().getURIFragment(internal);
		}

		public <T> T modify(IUnitOfWork<T, P> work) {
			return resourceAccess.modify(new ResourceAccess<T>(work));
		}

		public <T> T readOnly(IUnitOfWork<T, P> work) {
			return resourceAccess.readOnly(new ResourceAccess<T>(work));
		}
		
		class ResourceAccess<T> implements IUnitOfWork<T,XtextResource> {
			
			private IUnitOfWork<T, P> work = null;

			public ResourceAccess(IUnitOfWork<T, P> work) {
				super();
				this.work = work;
			}

			@SuppressWarnings("unchecked")
			public T exec(XtextResource resource) throws Exception {
				P obj = internal;
				if (obj.eResource() != resource) {
					obj = (P) resource.getEObject(fragment);
				}
				return work.exec(obj);
			}
		}

		public URI getURI() {
			return EcoreUtil.getURI(internal);
		}

	}

}

{'fraction_non_alphanumeric': 0.17902131782945738, 'fraction_numerical': 0.003875968992248062, 'mean_word_length': 4.602442333785618, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '1697451', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1183, 'n_words': 296}