mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for bug 166026 - getContainingFilename wrong for include directives
This commit is contained in:
parent
6f3df88cd1
commit
c53849b219
2 changed files with 5 additions and 0 deletions
|
@ -226,6 +226,8 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest {
|
|||
assertNotNull(incs);
|
||||
assertEquals(incs.length, 1);
|
||||
assertSoleFileLocation(incs[0], filename, code.indexOf("#inc"), "#include \"foo.h\"".length());
|
||||
// test bug 166026
|
||||
assertEquals(tu.getFilePath(), incs[0].getContainingFilename());
|
||||
|
||||
checkInclude(incs[0], filename, code, "foo.h", false);
|
||||
}
|
||||
|
|
|
@ -2596,6 +2596,9 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
|||
public String getContainingFilename(int offset) {
|
||||
_Context c = findContextForOffset(offset);
|
||||
if( c == null ) return EMPTY_STRING;
|
||||
if (c instanceof _Inclusion && c.containsInDirective(offset, 1)) {
|
||||
c = c.getParent();
|
||||
}
|
||||
_CompositeFileContext file = c.getContainingFileContext();
|
||||
if( file == null ) return EMPTY_STRING;
|
||||
return file.reader.getPath();
|
||||
|
|
Loading…
Add table
Reference in a new issue