diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java index bfedb1f9e71..4f69e4c24b7 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java @@ -776,12 +776,13 @@ public class CProject extends Openable implements ICProject { String tuName = memento.nextToken(); final IPath path= Path.fromPortableString(tuName); CElement tu= null; - try { - tu= (CElement) findElement(path); - } catch (CModelException exc) { - CCorePlugin.log(exc); - } - if (tu == null) { + if (!path.isAbsolute()) { + try { + tu= (CElement) findElement(path); + } catch (CModelException exc) { + CCorePlugin.log(exc); + } + } else { tu= (CElement) CoreModel.getDefault().createTranslationUnitFrom(this, path); } if (tu != null) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java index 6f04ab921ed..b36022e131f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java @@ -1074,7 +1074,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit { if (getResource() == null) { ((CElement)getCProject()).getHandleMemento(buff); buff.append(getHandleMementoDelimiter()); - escapeMementoName(buff, getPath().toPortableString()); + final IPath location= getLocation(); + if (location != null) { + escapeMementoName(buff, location.toPortableString()); + } } else { super.getHandleMemento(buff); } 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 ba7fbd393bb..ece03a2333b 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 @@ -638,7 +638,15 @@ public class EditorUtility { cProject= null; } } else if (input instanceof ITranslationUnitEditorInput) { - cProject= ((ITranslationUnitEditorInput)input).getTranslationUnit().getCProject(); + final ITranslationUnit tu= ((ITranslationUnitEditorInput)input).getTranslationUnit(); + if (tu != null) { + cProject= tu.getCProject(); + } else if (input instanceof ExternalEditorInput) { + IResource resource= ((ExternalEditorInput) input).getMarkerResource(); + if (resource instanceof IProject) { + cProject= CoreModel.getDefault().create((IProject) resource); + } + } } return cProject; }