class UriDocumentContentsFactory implements DocumentContentsFactory {
@Inject private ContentReader contentReader;
@Inject private XtextResourceFactory resourceFactory;
@Override public void createContents(XtextDocument document, Object element) throws CoreException {
UriEditorInput input = supportedEditorInputType().cast(element);
URI uri = input.getFileUri();
try {
String contents = contentsOf(uri);
document.set(contents);
XtextResource resource = resourceFactory.createResource(uri, contents);
document.setInput(resource);