mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
Bug 560754 - Clicking on header with no extension brings up text editor
- modify EditorUtility.getEditorInputForLocation() so that if we are dealing with an external Include element and we can't get a TranslationUnit then check the parent to find a contentTypeId and create an appropriate ExternalTranslationUnit to use in creating the ExternalEditorInput Change-Id: Id99305606d058b8c105fe9b4099f5561620b07fd
This commit is contained in:
parent
2359724b52
commit
0a271afe3d
1 changed files with 19 additions and 0 deletions
|
@ -39,6 +39,9 @@ import org.eclipse.cdt.core.model.ISourceReference;
|
|||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.core.resources.FileStorage;
|
||||
import org.eclipse.cdt.internal.core.model.ExternalTranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.model.Include;
|
||||
import org.eclipse.cdt.internal.core.model.WorkingCopy;
|
||||
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
||||
import org.eclipse.cdt.internal.ui.ICStatusConstants;
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
|
@ -454,6 +457,19 @@ public class EditorUtility {
|
|||
ICProject cproject = context.getCProject();
|
||||
if (cproject != null) {
|
||||
ITranslationUnit unit = CoreModel.getDefault().createTranslationUnitFrom(cproject, location);
|
||||
if (unit == null && (context instanceof Include) && location.toFile().exists()) {
|
||||
ICElement parent = context.getParent();
|
||||
if (parent instanceof WorkingCopy) {
|
||||
WorkingCopy copy = (WorkingCopy) parent;
|
||||
if (copy.isCLanguage()) {
|
||||
unit = new ExternalTranslationUnit(cproject, URIUtil.toURI(location),
|
||||
CCorePlugin.CONTENT_TYPE_CHEADER);
|
||||
} else if (copy.isCXXLanguage()) {
|
||||
unit = new ExternalTranslationUnit(cproject, URIUtil.toURI(location),
|
||||
CCorePlugin.CONTENT_TYPE_CXXHEADER);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (unit != null) {
|
||||
return new ExternalEditorInput(unit);
|
||||
}
|
||||
|
@ -618,6 +634,9 @@ public class EditorUtility {
|
|||
} else if (input instanceof ITranslationUnitEditorInput) {
|
||||
ITranslationUnitEditorInput editorInput = (ITranslationUnitEditorInput) input;
|
||||
cElement = editorInput.getTranslationUnit();
|
||||
if (cElement == null && input instanceof ExternalEditorInput && inputObject instanceof ICElement) {
|
||||
cElement = ((ICElement) inputObject).getAncestor(ICElement.C_UNIT);
|
||||
}
|
||||
} else if (inputObject instanceof ICElement) {
|
||||
cElement = (ICElement) inputObject;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue