diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableImporter.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableImporter.java index c98e864e3e7..bf6b1ed7f8f 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableImporter.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/executables/StandardExecutableImporter.java @@ -39,6 +39,7 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.content.*; import org.eclipse.debug.core.DebugPlugin; public class StandardExecutableImporter implements IExecutableImporter { @@ -141,8 +142,10 @@ public class StandardExecutableImporter implements IExecutableImporter { String executableName = location.toFile().getName(); try { IContainer fileContainer = createFromRoot(exeProject, location); - IFile exeFile = fileContainer.getFile(new Path(executableName)); + Path exectuableFilePath = new Path(executableName); + IFile exeFile = fileContainer.getFile(exectuableFilePath); if (!exeFile.exists() && validateBinaryParsers(exeProject, new File(path))) { + ensureBinaryType(exectuableFilePath); exeFile.createLink(location, 0, null); } } catch (CoreException e) { @@ -150,6 +153,22 @@ public class StandardExecutableImporter implements IExecutableImporter { } } + private void ensureBinaryType(IPath exectuableFilePath) { + if (Executable.isExecutableFile(exectuableFilePath)) + return; + String ext = exectuableFilePath.getFileExtension(); + if (ext != null) { + // add the extension to the content type manager as a binary + final IContentTypeManager ctm = Platform.getContentTypeManager(); + final IContentType ctbin = ctm.getContentType(CCorePlugin.CONTENT_TYPE_BINARYFILE); + try { + ctbin.addFileSpec(ext, IContentTypeSettings.FILE_EXTENSION_SPEC); + } catch (CoreException e) { + CDebugCorePlugin.log(e); + } + } + } + private boolean isExtensionVisible(IExtension ext) { IConfigurationElement[] elements = ext.getConfigurationElements(); for (int i = 0; i < elements.length; i++) {