Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2011 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.ui.refactoring.impl;
 
import  org.eclipse.text.edits.ReplaceEdit;
import  org.eclipse.text.edits.TextEdit;
Serialize an EMF resource and delivers the resulting text as an TextEdit that replaces the old content.

Author(s):
Jan Koehnlein - Initial contribution and API
public class EmfResourceChangeUtil {
	public void addSaveAsUpdate(Resource resourceIRefactoringUpdateAcceptor updateAcceptorthrows IOException {
		IRefactoringDocument document = updateAcceptor.getDocument(resource.getURI());
		resource.save(outputStreamnull);
		String newContent = new String(outputStream.toByteArray(), .getEncoding(resource.getURI()));
		updateAcceptor.accept(resource.getURI(),
				new ReplaceEdit(0, document.getOriginalContents().length(), newContent));
	}
New to GrepCode? Check out our FAQ X