Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2010 itemis AG ( 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 /
 package org.eclipse.xtext.ui.refactoring.impl;
import  org.eclipse.core.runtime.IProgressMonitor;
import  org.eclipse.core.runtime.OperationCanceledException;
A generic reference updater for EMF resources referring to Xtext elements. Uses the resources default serialization mechanism to update resources. This only works if the resource does not have errors. For Xtext-based languages it is far more fault tolerant to use a DefaultReferenceUpdater that only serializes the sections of the document that actually represent cross-references.

Jan Koehnlein - Initial contribution and API
Holger Schill
	protected void createReferenceUpdates(ElementRenameArguments elementRenameArguments,
			Multimap<URIIReferenceDescriptionresource2referencesResourceSet resourceSet,
			IRefactoringUpdateAcceptor updateAcceptor, IProgressMonitor monitor) {
		for (URI referringResourceURI : resource2references.keySet()) {
			try {
				if (monitor.isCanceled())
					throw new OperationCanceledException();
				Resource referringResource = resourceSet.getResource(referringResourceURIfalse);
				EObject refactoredElement = resourceSet.getEObject(elementRenameArguments.getNewElementURI(elementRenameArguments.getTargetElementURI()), true);
				if (referringResource != refactoredElement.eResource()) {
					if (refactoredElement instanceof EClassifier) { 
						for (IReferenceDescription reference : resource2references.get(referringResourceURI)) {
							EObject referringEReference = referringResource.getEObject(
							if (referringEReference != null && referringEReference instanceof EReference)
catch (OperationCanceledException e) {
				throw e;
catch (Exception exc) {
				throw new WrappedException(exc);
New to GrepCode? Check out our FAQ X