1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52: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.
try {
File file = new File(filename); File file = new File(filename);
if (file.exists()) { if (file.exists()) {
try {
filename = file.getCanonicalPath(); filename = file.getCanonicalPath();
} catch (IOException e) { } else if (filename.startsWith(".")) {
file = new File(obj.getPath().removeLastSegments(1).toOSString(), filename);
filename = file.getCanonicalPath();
} }
} 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,6 +328,8 @@ public class Binary extends Openable implements IBinary {
String id = CoreModel.getRegistedContentTypeId(sourceFile String id = CoreModel.getRegistedContentTypeId(sourceFile
.getProject(), sourceFile.getName()); .getProject(), sourceFile.getName());
if (id != null)
{ // Don't add files we can't get an ID for.
TranslationUnit tu; TranslationUnit tu;
if (wkspFile != null) if (wkspFile != null)
tu = new TranslationUnit(this, wkspFile, id); tu = new TranslationUnit(this, wkspFile, id);
@ -331,6 +338,7 @@ public class Binary extends Openable implements IBinary {
info.addChild(tu); info.addChild(tu);
} }
}
return true; return true;
} }
return false; return false;