Search in sources :

Example 1 with IClassFileEditorInput

use of org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput 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 && document instanceof XtextDocument) {
        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) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) WrappedCoreException(org.eclipse.xtext.ui.generator.trace.WrappedCoreException) IOException(java.io.IOException) IClassFileEditorInput(org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput)

Example 2 with IClassFileEditorInput

use of org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput in project xtext-eclipse by eclipse.

the class XbaseDocumentProvider method createElementInfo.

@Override
protected ElementInfo createElementInfo(Object element) throws CoreException {
    if (element instanceof IClassFileEditorInput) {
        IDocument document = null;
        IStatus status = null;
        try {
            document = createDocument(element);
        } catch (CoreException x) {
            status = x.getStatus();
            document = createEmptyDocument();
        }
        ClassFileInfo info = new ClassFileInfo(document, createAnnotationModel(element));
        info.fStatus = status;
        registerAnnotationInfoProcessor(info);
        return info;
    }
    return super.createElementInfo(element);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) WrappedCoreException(org.eclipse.xtext.ui.generator.trace.WrappedCoreException) IClassFileEditorInput(org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput) IDocument(org.eclipse.jface.text.IDocument)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)2 IStatus (org.eclipse.core.runtime.IStatus)2 IClassFileEditorInput (org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput)2 WrappedCoreException (org.eclipse.xtext.ui.generator.trace.WrappedCoreException)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Status (org.eclipse.core.runtime.Status)1 IClassFile (org.eclipse.jdt.core.IClassFile)1 IDocument (org.eclipse.jface.text.IDocument)1 XtextDocument (org.eclipse.xtext.ui.editor.model.XtextDocument)1 ILocationInEclipseResource (org.eclipse.xtext.ui.generator.trace.ILocationInEclipseResource)1