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

Fix for 142465. Attempt to resolve relative path source file entries. Also check to make sure we can get valid ids for all files before making a TranslationUnit for them.

This commit is contained in:
Ken Ryall 2006-06-15 15:39:04 +00:00
parent e539d8c06d
commit 7c32c381ed

View file

@ -289,13 +289,18 @@ public class Binary extends Openable implements IBinary {
// class. // class.
// So make sure the path is canonical, otherwise breakpoints // So make sure the path is canonical, otherwise breakpoints
// won't be resolved, etc.. // won't be resolved, etc..
// Also check for relative path names and attempt to resolve
// them relative to the executable.
File file = new File(filename); try {
if (file.exists()) { File file = new File(filename);
try { if (file.exists()) {
filename = file.getCanonicalPath();
} else if (filename.startsWith(".")) {
file = new File(obj.getPath().removeLastSegments(1).toOSString(), filename);
filename = file.getCanonicalPath(); filename = file.getCanonicalPath();
} catch (IOException e) {
} }
} catch (IOException e) { // Do nothing.
} }
// See if this source file is already in the project. // See if this source file is already in the project.
@ -323,13 +328,16 @@ public class Binary extends Openable implements IBinary {
String id = CoreModel.getRegistedContentTypeId(sourceFile String id = CoreModel.getRegistedContentTypeId(sourceFile
.getProject(), sourceFile.getName()); .getProject(), sourceFile.getName());
TranslationUnit tu; if (id != null)
if (wkspFile != null) { // Don't add files we can't get an ID for.
tu = new TranslationUnit(this, wkspFile, id); TranslationUnit tu;
else if (wkspFile != null)
tu = new ExternalTranslationUnit(this, path, id); tu = new TranslationUnit(this, wkspFile, id);
else
tu = new ExternalTranslationUnit(this, path, id);
info.addChild(tu); info.addChild(tu);
}
} }
return true; return true;
} }