Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2020-03-03 23:07:26 +0000
committerJeff Johnston2020-03-20 17:59:32 +0000
commit0a271afe3d26b6b75ee332366bbf464dc0c72d4d (patch)
tree4304ff885124c37d65e99a14ac89ec679338d72e
parent2359724b52867d80c43254593c5d86ac96bec249 (diff)
downloadorg.eclipse.cdt-0a271afe3d26b6b75ee332366bbf464dc0c72d4d.tar.gz
org.eclipse.cdt-0a271afe3d26b6b75ee332366bbf464dc0c72d4d.tar.xz
org.eclipse.cdt-0a271afe3d26b6b75ee332366bbf464dc0c72d4d.zip
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
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java
index e6afd167317..e91f87d33c5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java
@@ -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;
}

Back to the top