Search in sources :

Example 1 with WrappedCoreException

use of org.eclipse.xtext.ui.generator.trace.WrappedCoreException in project xtext-eclipse by eclipse.

the class XbaseDocumentProvider method setDocumentContent.

@Override
protected boolean setDocumentContent(IDocument document, IEditorInput input, String encoding) throws CoreException {
    if (input instanceof IClassFileEditorInput) {
        IClassFile classFile = ((IClassFileEditorInput) input).getClassFile();
        ILocationInEclipseResource source = getClassFileSourceStorage(classFile);
        if (source == null) {
            return false;
        }
        InputStream contents = null;
        try {
            contents = source.getContents();
            if (contents != null)
                setDocumentContent(document, contents, encoding);
        } catch (WrappedCoreException e) {
            throw e.getCause();
        } catch (IOException e) {
            throw new CoreException(new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), e.getMessage(), e));
        } finally {
            try {
                if (contents != null)
                    contents.close();
            } catch (IOException e1) {
            }
        }
        setDocumentResource((XtextDocument) document, input, encoding);
        return true;
    }
    return super.setDocumentContent(document, input, encoding);
}
Also used : ILocationInEclipseResource(org.eclipse.xtext.ui.generator.trace.ILocationInEclipseResource) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IClassFile(org.eclipse.jdt.core.IClassFile) CoreException(org.eclipse.core.runtime.CoreException) WrappedCoreException(org.eclipse.xtext.ui.generator.trace.WrappedCoreException) InputStream(java.io.InputStream) WrappedCoreException(org.eclipse.xtext.ui.generator.trace.WrappedCoreException) IOException(java.io.IOException) IClassFileEditorInput(org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 IClassFile (org.eclipse.jdt.core.IClassFile)1 IClassFileEditorInput (org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput)1 ILocationInEclipseResource (org.eclipse.xtext.ui.generator.trace.ILocationInEclipseResource)1 WrappedCoreException (org.eclipse.xtext.ui.generator.trace.WrappedCoreException)1