Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2008-03-13 13:14:39 +0000
committerAnton Leherbauer2008-03-13 13:14:39 +0000
commit8cfa0b6b690295abaae98099a19ce7a5a4bcc57e (patch)
treec597ba42901e66b5b7e3885a5d28bcc2e70b36de
parentf0495f62d0995a89ef62d3388342dacddc99dbb6 (diff)
downloadorg.eclipse.cdt-8cfa0b6b690295abaae98099a19ce7a5a4bcc57e.tar.gz
org.eclipse.cdt-8cfa0b6b690295abaae98099a19ce7a5a4bcc57e.tar.xz
org.eclipse.cdt-8cfa0b6b690295abaae98099a19ce7a5a4bcc57e.zip
Fix translation unit restore for external includes
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java13
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java10
3 files changed, 20 insertions, 8 deletions
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;
}

Back to the top