Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2009-03-11 09:43:42 +0000
committerMarkus Schorn2009-03-11 09:43:42 +0000
commitd3a3f9413b8c3969c8e225356dbe234a60319b53 (patch)
tree73e7f1ff8199e384c4a50362539bf849b1f04d08
parent8b8f9b767dceda949aea80f721d1c8a41af1d94b (diff)
downloadorg.eclipse.cdt-d3a3f9413b8c3969c8e225356dbe234a60319b53.tar.gz
org.eclipse.cdt-d3a3f9413b8c3969c8e225356dbe234a60319b53.tar.xz
org.eclipse.cdt-d3a3f9413b8c3969c8e225356dbe234a60319b53.zip
Initialization of macro-dictionary for headers with context, bug 267907.
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java25
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java1
2 files changed, 26 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java
index 25a3342b86d..1e8a5478a70 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java
@@ -1413,7 +1413,32 @@ public class IndexBugsTests extends BaseTestCase {
fIndex.releaseReadLock();
}
}
+
+ // #include "h2.h"
+ // int BUG;
+
+ // #define BUG ok
+ // #include "h1.h"
+ public void testIndirectContext_Bug267907() 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 "dir"
// #include "header.h"
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java
index 11245367551..065970596f5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java
@@ -247,6 +247,7 @@ public final class IndexBasedCodeReaderFactory implements IIndexBasedCodeReaderF
return file;
}
file= context;
+ include= context.getParsedInContext();
}
return file;
}

Back to the top