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:
parent
e539d8c06d
commit
7c32c381ed
1 changed files with 18 additions and 10 deletions
|
@ -289,13 +289,18 @@ public class Binary extends Openable implements IBinary {
|
|||
// class.
|
||||
// So make sure the path is canonical, otherwise breakpoints
|
||||
// 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);
|
||||
if (file.exists()) {
|
||||
try {
|
||||
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.
|
||||
|
@ -323,6 +328,8 @@ public class Binary extends Openable implements IBinary {
|
|||
String id = CoreModel.getRegistedContentTypeId(sourceFile
|
||||
.getProject(), sourceFile.getName());
|
||||
|
||||
if (id != null)
|
||||
{ // Don't add files we can't get an ID for.
|
||||
TranslationUnit tu;
|
||||
if (wkspFile != null)
|
||||
tu = new TranslationUnit(this, wkspFile, id);
|
||||
|
@ -331,6 +338,7 @@ public class Binary extends Openable implements IBinary {
|
|||
|
||||
info.addChild(tu);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue