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

Fix computation of source-context for parsing files in editor.

This commit is contained in:
Markus Schorn 2009-03-04 09:27:57 +00:00
parent 2d44a1f492
commit 8906aaf778
2 changed files with 26 additions and 0 deletions

View file

@ -1488,7 +1488,32 @@ public class IndexBugsTests extends BaseTestCase {
fIndex.releaseReadLock();
}
}
// #include "h2.h"
// int BUG;
// #define BUG ok
// #include "h1.h"
public void testIndirectContext_Bug228012() throws Exception {
String[] contents= getContentsForTest(3);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "h1.h", contents[0]);
IFile hfile= TestSourceReader.createFile(fCProject.getProject(), "h2.h", contents[1]);
TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[2]);
indexManager.reindex(fCProject);
waitForIndexer();
ITranslationUnit tu= (ITranslationUnit) CoreModel.getDefault().create(hfile);
fIndex.acquireReadLock();
try {
IASTTranslationUnit ast= tu.getAST(fIndex, ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT | ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
IASTSimpleDeclaration decl= (IASTSimpleDeclaration) ast.getDeclarations()[0];
assertEquals("ok", decl.getDeclarators()[0].getName().toString());
} finally {
fIndex.releaseReadLock();
}
}
// #include <header.h>
// #define _CONCAT(x,y) x##y

View file

@ -261,6 +261,7 @@ public final class IndexBasedCodeReaderFactory extends AbstractCodeReaderFactory
return file;
}
file= context;
include= context.getParsedInContext();
}
return file;
}