1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Fix translation unit restore for external includes

This commit is contained in:
Anton Leherbauer 2008-03-13 13:14:39 +00:00
parent f0495f62d0
commit 8cfa0b6b69
3 changed files with 20 additions and 8 deletions

View file

@ -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) {

View file

@ -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);
}

View file

@ -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;
}