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:
parent
2d44a1f492
commit
8906aaf778
2 changed files with 26 additions and 0 deletions
|
@ -1489,6 +1489,31 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
// #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
|
||||
|
|
|
@ -261,6 +261,7 @@ public final class IndexBasedCodeReaderFactory extends AbstractCodeReaderFactory
|
|||
return file;
|
||||
}
|
||||
file= context;
|
||||
include= context.getParsedInContext();
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue