diff options
author | Thomas Wolf | 2019-02-09 22:43:36 +0000 |
---|---|---|
committer | Lars Vogel | 2019-02-12 07:17:58 +0000 |
commit | 4ffc136c9a8d8157575a5940a0878030215fa76e (patch) | |
tree | 3c3c7ae6c009f64660d7836467dbe2a6ab9cea76 /org.eclipse.ui.editors | |
parent | 502ba4f4b36e6df1fbceacad1f0c42b4cd32ed76 (diff) | |
download | eclipse.platform.text-4ffc136c9a8d8157575a5940a0878030215fa76e.tar.gz eclipse.platform.text-4ffc136c9a8d8157575a5940a0878030215fa76e.tar.xz eclipse.platform.text-4ffc136c9a8d8157575a5940a0878030215fa76e.zip |
Bug 544315 - DocumentProviderRegistry: also try IPath to get extension
Make getDocumentProvider(IEditorInput) try a little harder by trying
to figure out an IPath from the editor input and use the extension
of that path, if one can be determined.
Change-Id: I6426e0e9fa09b71bd472d5ca545d1333c17323ce
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.ui.editors')
-rw-r--r-- | org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java index d4aa1643725..c08410cc061 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java @@ -25,10 +25,12 @@ import java.util.StringTokenizer; import org.osgi.framework.Bundle; +import org.eclipse.core.runtime.Adapters; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; @@ -36,6 +38,7 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.resources.IFile; import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IPathEditorInput; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.internal.editors.text.NLSUtility; @@ -312,8 +315,17 @@ public class DocumentProviderRegistry { IDocumentProvider provider= null; IFile file= editorInput.getAdapter(IFile.class); - if (file != null) + if (file != null) { provider= getDocumentProvider(file.getFileExtension()); + } else { + IPathEditorInput pathInput= Adapters.adapt(editorInput, IPathEditorInput.class); + if (pathInput != null) { + IPath path= pathInput.getPath(); + if (path != null) { + provider= getDocumentProvider(path.getFileExtension()); + } + } + } if (provider == null) { Set<IConfigurationElement> set= findInputTypeMapping(editorInput.getClass()); |