mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Store #undef in index, bug 227088.
This commit is contained in:
parent
9aed58bb4e
commit
70db16224a
12 changed files with 303 additions and 241 deletions
|
@ -99,9 +99,15 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
return fCProject.getProject();
|
return fCProject.getProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StringBuffer[] getContentsForTest(int blocks) throws IOException {
|
protected String[] getContentsForTest(int blocks) throws IOException {
|
||||||
return TestSourceReader.getContentsForTest(
|
StringBuffer[] help= TestSourceReader.getContentsForTest(
|
||||||
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
|
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
|
||||||
|
String[] result= new String[help.length];
|
||||||
|
int i=0;
|
||||||
|
for (StringBuffer buf : help) {
|
||||||
|
result[i++]= buf.toString();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IFile createFile(IContainer container, String fileName, String contents) throws Exception {
|
protected IFile createFile(IContainer container, String fileName, String contents) throws Exception {
|
||||||
|
@ -141,9 +147,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// because of fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=193779
|
// because of fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=193779
|
||||||
// this test case passes. However https://bugs.eclipse.org/bugs/show_bug.cgi?id=154563
|
// this test case passes. However https://bugs.eclipse.org/bugs/show_bug.cgi?id=154563
|
||||||
// remains to be fixed.
|
// remains to be fixed.
|
||||||
StringBuffer[] content= getContentsForTest(3);
|
String[] content= getContentsForTest(3);
|
||||||
|
|
||||||
IFile file= createFile(getProject(), "header.h", content[0].toString());
|
IFile file= createFile(getProject(), "header.h", content[0]);
|
||||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
|
@ -157,7 +163,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
file.setContents(new ByteArrayInputStream(content[1].toString().getBytes()), true, false, NPM);
|
file.setContents(new ByteArrayInputStream(content[1].getBytes()), true, false, NPM);
|
||||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
|
@ -180,9 +186,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// class B {};
|
// class B {};
|
||||||
// B var;
|
// B var;
|
||||||
public void test173997_2() throws Exception {
|
public void test173997_2() throws Exception {
|
||||||
StringBuffer[] content= getContentsForTest(2);
|
String[] content= getContentsForTest(2);
|
||||||
|
|
||||||
IFile file= createFile(getProject(), "header.h", content[0].toString());
|
IFile file= createFile(getProject(), "header.h", content[0]);
|
||||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
IIndex index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
|
@ -197,7 +203,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
file.setContents(new ByteArrayInputStream(content[1].toString().getBytes()), true, false, NPM);
|
file.setContents(new ByteArrayInputStream(content[1].getBytes()), true, false, NPM);
|
||||||
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(file, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
index= CCorePlugin.getIndexManager().getIndex(fCProject);
|
||||||
|
@ -220,7 +226,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// void function162011(Class162011 x){};
|
// void function162011(Class162011 x){};
|
||||||
// }
|
// }
|
||||||
public void testBug162011() throws Exception {
|
public void testBug162011() throws Exception {
|
||||||
String content = getContentsForTest(1)[0].toString();
|
String content = getContentsForTest(1)[0];
|
||||||
String fileName = "bug162011.cpp";
|
String fileName = "bug162011.cpp";
|
||||||
String funcName = "function162011";
|
String funcName = "function162011";
|
||||||
|
|
||||||
|
@ -407,7 +413,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// #define macro164500 2
|
// #define macro164500 2
|
||||||
public void test164500() throws Exception {
|
public void test164500() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0];
|
||||||
|
|
||||||
IFile file= TestSourceReader.createFile(fCProject.getProject(), "test164500.cpp", content);
|
IFile file= TestSourceReader.createFile(fCProject.getProject(), "test164500.cpp", content);
|
||||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
||||||
|
@ -417,12 +423,12 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
IIndexFile ifile= fIndex.getFile(ILinkage.CPP_LINKAGE_ID, IndexLocationFactory.getWorkspaceIFL(file));
|
||||||
assertNotNull(ifile);
|
assertNotNull(ifile);
|
||||||
IIndexMacro[] macros= ifile.getMacros();
|
IIndexMacro[] macros= ifile.getMacros();
|
||||||
assertEquals(2, macros.length);
|
assertEquals(3, macros.length);
|
||||||
IIndexMacro m= macros[0];
|
IIndexMacro m= macros[0];
|
||||||
assertEquals("1", new String(m.getExpansionImage()));
|
assertEquals("1", new String(m.getExpansionImage()));
|
||||||
assertEquals("macro164500", new String(m.getName()));
|
assertEquals("macro164500", new String(m.getName()));
|
||||||
|
|
||||||
m= macros[1];
|
m= macros[2];
|
||||||
assertEquals("2", new String(m.getExpansionImage()));
|
assertEquals("2", new String(m.getExpansionImage()));
|
||||||
assertEquals("macro164500", new String(m.getName()));
|
assertEquals("macro164500", new String(m.getName()));
|
||||||
}
|
}
|
||||||
|
@ -441,7 +447,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
String pname = "deleteTest"+System.currentTimeMillis();
|
String pname = "deleteTest"+System.currentTimeMillis();
|
||||||
ICProject cproject = CProjectHelper.createCCProject(pname, "bin", IPDOMManager.ID_FAST_INDEXER);
|
ICProject cproject = CProjectHelper.createCCProject(pname, "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0];
|
||||||
IFile file= TestSourceReader.createFile(cproject.getProject(), "content.cpp", content);
|
IFile file= TestSourceReader.createFile(cproject.getProject(), "content.cpp", content);
|
||||||
TestSourceReader.waitUntilFileIsIndexed(index, file, INDEX_WAIT_TIME);
|
TestSourceReader.waitUntilFileIsIndexed(index, file, INDEX_WAIT_TIME);
|
||||||
CProjectHelper.delete(cproject);
|
CProjectHelper.delete(cproject);
|
||||||
|
@ -468,7 +474,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
ICProject cproject = CProjectHelper.createCCProject("moveTest", "bin", IPDOMManager.ID_FAST_INDEXER);
|
ICProject cproject = CProjectHelper.createCCProject("moveTest", "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0];
|
||||||
IFile file= TestSourceReader.createFile(cproject.getProject(), "content.cpp", content);
|
IFile file= TestSourceReader.createFile(cproject.getProject(), "content.cpp", content);
|
||||||
TestSourceReader.waitUntilFileIsIndexed(index, file, INDEX_WAIT_TIME);
|
TestSourceReader.waitUntilFileIsIndexed(index, file, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
|
@ -504,9 +510,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
ICProject cproject = CProjectHelper.createCCProject("seq1", "bin", IPDOMManager.ID_FAST_INDEXER);
|
ICProject cproject = CProjectHelper.createCCProject("seq1", "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||||
try {
|
try {
|
||||||
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
IIndex index = CCorePlugin.getIndexManager().getIndex(cproject);
|
||||||
StringBuffer[] testData = getContentsForTest(3);
|
String[] testData = getContentsForTest(3);
|
||||||
IFile header= TestSourceReader.createFile(cproject.getProject(), "header.h", testData[0].toString());
|
IFile header= TestSourceReader.createFile(cproject.getProject(), "header.h", testData[0]);
|
||||||
IFile referer= TestSourceReader.createFile(cproject.getProject(), "content.cpp", testData[1].toString());
|
IFile referer= TestSourceReader.createFile(cproject.getProject(), "content.cpp", testData[1]);
|
||||||
TestSourceReader.waitUntilFileIsIndexed(index, referer, INDEX_WAIT_TIME);
|
TestSourceReader.waitUntilFileIsIndexed(index, referer, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
index.acquireReadLock();
|
index.acquireReadLock();
|
||||||
|
@ -520,7 +526,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
InputStream in = new ByteArrayInputStream(testData[2].toString().getBytes());
|
InputStream in = new ByteArrayInputStream(testData[2].getBytes());
|
||||||
header.setContents(in, IResource.FORCE, null);
|
header.setContents(in, IResource.FORCE, null);
|
||||||
TestSourceReader.waitUntilFileIsIndexed(index, header, INDEX_WAIT_TIME);
|
TestSourceReader.waitUntilFileIsIndexed(index, header, INDEX_WAIT_TIME);
|
||||||
|
|
||||||
|
@ -544,7 +550,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// } S20070201;
|
// } S20070201;
|
||||||
public void test172454_1() throws Exception {
|
public void test172454_1() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0];
|
||||||
|
|
||||||
IFile file= TestSourceReader.createFile(fCProject.getProject(), "test172454.c", content);
|
IFile file= TestSourceReader.createFile(fCProject.getProject(), "test172454.c", content);
|
||||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
||||||
|
@ -579,7 +585,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// } S20070201;
|
// } S20070201;
|
||||||
public void test172454_2() throws Exception {
|
public void test172454_2() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0];
|
||||||
|
|
||||||
IFile file= TestSourceReader.createFile(fCProject.getProject(), "test172454.cpp", content);
|
IFile file= TestSourceReader.createFile(fCProject.getProject(), "test172454.cpp", content);
|
||||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
||||||
|
@ -615,7 +621,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// enum {e20070206};
|
// enum {e20070206};
|
||||||
public void test156671() throws Exception {
|
public void test156671() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0];
|
||||||
|
|
||||||
IFile file= TestSourceReader.createFile(fCProject.getProject(), "test156671.cpp", content);
|
IFile file= TestSourceReader.createFile(fCProject.getProject(), "test156671.cpp", content);
|
||||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
||||||
|
@ -634,7 +640,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// typedef int T20070213;
|
// typedef int T20070213;
|
||||||
public void test173997() throws Exception {
|
public void test173997() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0];
|
||||||
|
|
||||||
IFile file= TestSourceReader.createFile(fCProject.getProject(), "test173997.cpp", content);
|
IFile file= TestSourceReader.createFile(fCProject.getProject(), "test173997.cpp", content);
|
||||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
||||||
|
@ -691,7 +697,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// };
|
// };
|
||||||
public void testFindBindingsWithPrefix() throws Exception {
|
public void testFindBindingsWithPrefix() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0];
|
||||||
|
|
||||||
IFile file= TestSourceReader.createFile(fCProject.getProject(), "testFBWP.cpp", content);
|
IFile file= TestSourceReader.createFile(fCProject.getProject(), "testFBWP.cpp", content);
|
||||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
||||||
|
@ -725,7 +731,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// class a { class b { class c { void f(); }; }; };
|
// class a { class b { class c { void f(); }; }; };
|
||||||
public void testFilterFindBindingsFQCharArray() throws Exception {
|
public void testFilterFindBindingsFQCharArray() throws Exception {
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
String content= getContentsForTest(1)[0].toString();
|
String content= getContentsForTest(1)[0];
|
||||||
|
|
||||||
IFile file= TestSourceReader.createFile(fCProject.getProject(), "testFilterFindBindingsFQCharArray.cpp", content);
|
IFile file= TestSourceReader.createFile(fCProject.getProject(), "testFilterFindBindingsFQCharArray.cpp", content);
|
||||||
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
TestSourceReader.waitUntilFileIsIndexed(fIndex, file, INDEX_WAIT_TIME);
|
||||||
|
@ -758,13 +764,13 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// #include "../__bugsTest__/common.h"
|
// #include "../__bugsTest__/common.h"
|
||||||
// StructA_T gvar2;
|
// StructA_T gvar2;
|
||||||
public void testFileInMultipleFragments_bug192352() throws Exception {
|
public void testFileInMultipleFragments_bug192352() throws Exception {
|
||||||
StringBuffer[] contents= getContentsForTest(3);
|
String[] contents= getContentsForTest(3);
|
||||||
|
|
||||||
ICProject p2 = CProjectHelper.createCCProject("__bugsTest_2_", "bin", IPDOMManager.ID_FAST_INDEXER);
|
ICProject p2 = CProjectHelper.createCCProject("__bugsTest_2_", "bin", IPDOMManager.ID_FAST_INDEXER);
|
||||||
try {
|
try {
|
||||||
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "common.h", contents[0].toString());
|
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "common.h", contents[0]);
|
||||||
IFile f2= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[1].toString());
|
IFile f2= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[1]);
|
||||||
IFile f3= TestSourceReader.createFile(p2.getProject(), "src.cpp", contents[2].toString());
|
IFile f3= TestSourceReader.createFile(p2.getProject(), "src.cpp", contents[2]);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
|
||||||
IIndex index= CCorePlugin.getIndexManager().getIndex(new ICProject[]{fCProject, p2});
|
IIndex index= CCorePlugin.getIndexManager().getIndex(new ICProject[]{fCProject, p2});
|
||||||
|
@ -808,14 +814,14 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// #endif
|
// #endif
|
||||||
public void testIncludeGuardsOutsideOfHeader_Bug167100() throws Exception {
|
public void testIncludeGuardsOutsideOfHeader_Bug167100() throws Exception {
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
StringBuffer[] contents= getContentsForTest(5);
|
String[] contents= getContentsForTest(5);
|
||||||
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "header1.h", contents[0].toString());
|
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "header1.h", contents[0]);
|
||||||
IFile f2= TestSourceReader.createFile(fCProject.getProject(), "header2.h", contents[1].toString());
|
IFile f2= TestSourceReader.createFile(fCProject.getProject(), "header2.h", contents[1]);
|
||||||
IFile f3= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[2].toString());
|
IFile f3= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[2]);
|
||||||
indexManager.reindex(fCProject);
|
indexManager.reindex(fCProject);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
IFile f4= TestSourceReader.createFile(fCProject.getProject(), "src2.cpp", contents[3].toString());
|
IFile f4= TestSourceReader.createFile(fCProject.getProject(), "src2.cpp", contents[3]);
|
||||||
IFile f5= TestSourceReader.createFile(fCProject.getProject(), "src3.cpp", contents[4].toString());
|
IFile f5= TestSourceReader.createFile(fCProject.getProject(), "src3.cpp", contents[4]);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
|
||||||
IIndex index= indexManager.getIndex(fCProject);
|
IIndex index= indexManager.getIndex(fCProject);
|
||||||
|
@ -849,7 +855,7 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// globalVar++;
|
// globalVar++;
|
||||||
// }
|
// }
|
||||||
public void testDependentProjectsWithFullIndexer_Bug197311() throws Exception {
|
public void testDependentProjectsWithFullIndexer_Bug197311() throws Exception {
|
||||||
StringBuffer[] contents= getContentsForTest(2);
|
String[] contents= getContentsForTest(2);
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
indexManager.setIndexerId(fCProject, IPDOMManager.ID_FULL_INDEXER);
|
indexManager.setIndexerId(fCProject, IPDOMManager.ID_FULL_INDEXER);
|
||||||
ICProject p2 = CProjectHelper.createCCProject("bug197311", "bin", IPDOMManager.ID_FULL_INDEXER);
|
ICProject p2 = CProjectHelper.createCCProject("bug197311", "bin", IPDOMManager.ID_FULL_INDEXER);
|
||||||
|
@ -858,9 +864,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
pd.setReferencedProjects(refs);
|
pd.setReferencedProjects(refs);
|
||||||
p2.getProject().setDescription(pd, new NullProgressMonitor());
|
p2.getProject().setDescription(pd, new NullProgressMonitor());
|
||||||
try {
|
try {
|
||||||
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "common.h", contents[0].toString());
|
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "common.h", contents[0]);
|
||||||
IFile f2= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[1].toString());
|
IFile f2= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[1]);
|
||||||
IFile f3= TestSourceReader.createFile(p2.getProject(), "src.cpp", contents[1].toString());
|
IFile f3= TestSourceReader.createFile(p2.getProject(), "src.cpp", contents[1]);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
|
||||||
IIndex index= indexManager.getIndex(p2, IIndexManager.ADD_DEPENDENCIES);
|
IIndex index= indexManager.getIndex(p2, IIndexManager.ADD_DEPENDENCIES);
|
||||||
|
@ -909,11 +915,11 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// MAC()= MAC(1) + MAC(1,2);
|
// MAC()= MAC(1) + MAC(1,2);
|
||||||
// }
|
// }
|
||||||
public void testVariadicMacros_Bug200239_1() throws Exception {
|
public void testVariadicMacros_Bug200239_1() throws Exception {
|
||||||
StringBuffer[] contents= getContentsForTest(2);
|
String[] contents= getContentsForTest(2);
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0].toString());
|
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
|
||||||
waitUntilFileIsIndexed(f1, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(f1, INDEX_WAIT_TIME);
|
||||||
IFile f2= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[1].toString());
|
IFile f2= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[1]);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
|
@ -936,11 +942,11 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// GMAC()= GMAC(1) + GMAC(1,2);
|
// GMAC()= GMAC(1) + GMAC(1,2);
|
||||||
// }
|
// }
|
||||||
public void testVariadicMacros_Bug200239_2() throws Exception {
|
public void testVariadicMacros_Bug200239_2() throws Exception {
|
||||||
StringBuffer[] contents= getContentsForTest(2);
|
String[] contents= getContentsForTest(2);
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0].toString());
|
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
|
||||||
waitUntilFileIsIndexed(f1, INDEX_WAIT_TIME);
|
waitUntilFileIsIndexed(f1, INDEX_WAIT_TIME);
|
||||||
IFile f2= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[1].toString());
|
IFile f2= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[1]);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
|
@ -959,9 +965,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// typedef bug200553_A bug200553_B;
|
// typedef bug200553_A bug200553_B;
|
||||||
// typedef bug200553_B bug200553_A;
|
// typedef bug200553_B bug200553_A;
|
||||||
public void testTypedefRecursionCpp_Bug200553() throws Exception {
|
public void testTypedefRecursionCpp_Bug200553() throws Exception {
|
||||||
StringBuffer[] contents= getContentsForTest(1);
|
String[] contents= getContentsForTest(1);
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[0].toString());
|
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "src.cpp", contents[0]);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -1010,9 +1016,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// typedef bug200553_A bug200553_B;
|
// typedef bug200553_A bug200553_B;
|
||||||
// typedef bug200553_B bug200553_A;
|
// typedef bug200553_B bug200553_A;
|
||||||
public void testTypedefRecursionC_Bug200553() throws Exception {
|
public void testTypedefRecursionC_Bug200553() throws Exception {
|
||||||
StringBuffer[] contents= getContentsForTest(1);
|
String[] contents= getContentsForTest(1);
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "src.c", contents[0].toString());
|
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "src.c", contents[0]);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -1053,9 +1059,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// #include "source.cpp"
|
// #include "source.cpp"
|
||||||
// #endif
|
// #endif
|
||||||
public void testIncludeSource_Bug199412() throws Exception {
|
public void testIncludeSource_Bug199412() throws Exception {
|
||||||
StringBuffer[] contents= getContentsForTest(1);
|
String[] contents= getContentsForTest(1);
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[0].toString());
|
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[0]);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
|
|
||||||
final ITranslationUnit tu= (ITranslationUnit) fCProject.findElement(new Path("source.cpp"));
|
final ITranslationUnit tu= (ITranslationUnit) fCProject.findElement(new Path("source.cpp"));
|
||||||
|
@ -1087,9 +1093,9 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
// void func_209049(long long x);
|
// void func_209049(long long x);
|
||||||
public void testGPPTypes_Bug209049() throws Exception {
|
public void testGPPTypes_Bug209049() throws Exception {
|
||||||
StringBuffer[] contents= getContentsForTest(1);
|
String[] contents= getContentsForTest(1);
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[0].toString());
|
IFile f1= TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[0]);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
try {
|
try {
|
||||||
|
@ -1109,11 +1115,11 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// staticInHeader();
|
// staticInHeader();
|
||||||
// }
|
// }
|
||||||
public void testStaticFunctionsInHeader_Bug180305() throws Exception {
|
public void testStaticFunctionsInHeader_Bug180305() throws Exception {
|
||||||
StringBuffer[] contents= getContentsForTest(2);
|
String[] contents= getContentsForTest(2);
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "source1.cpp", contents[1].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "source1.cpp", contents[1]);
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "source2.cpp", contents[1].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "source2.cpp", contents[1]);
|
||||||
indexManager.reindex(fCProject);
|
indexManager.reindex(fCProject);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
|
@ -1136,11 +1142,11 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// int a= staticConstInHeader;
|
// int a= staticConstInHeader;
|
||||||
// }
|
// }
|
||||||
public void testStaticVariableInHeader_Bug180305() throws Exception {
|
public void testStaticVariableInHeader_Bug180305() throws Exception {
|
||||||
StringBuffer[] contents= getContentsForTest(2);
|
String[] contents= getContentsForTest(2);
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "source1.cpp", contents[1].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "source1.cpp", contents[1]);
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "source2.cpp", contents[1].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "source2.cpp", contents[1]);
|
||||||
indexManager.reindex(fCProject);
|
indexManager.reindex(fCProject);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
|
@ -1163,11 +1169,11 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// staticInHeader();
|
// staticInHeader();
|
||||||
// }
|
// }
|
||||||
public void testStaticFunctionsInHeaderC_Bug180305() throws Exception {
|
public void testStaticFunctionsInHeaderC_Bug180305() throws Exception {
|
||||||
StringBuffer[] contents= getContentsForTest(2);
|
String[] contents= getContentsForTest(2);
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "source1.c", contents[1].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "source1.c", contents[1]);
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "source2.c", contents[1].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "source2.c", contents[1]);
|
||||||
indexManager.reindex(fCProject);
|
indexManager.reindex(fCProject);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
|
@ -1190,11 +1196,11 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// int a= staticConstInHeader;
|
// int a= staticConstInHeader;
|
||||||
// }
|
// }
|
||||||
public void testStaticVariableInHeaderC_Bug180305() throws Exception {
|
public void testStaticVariableInHeaderC_Bug180305() throws Exception {
|
||||||
StringBuffer[] contents= getContentsForTest(2);
|
String[] contents= getContentsForTest(2);
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "source1.c", contents[1].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "source1.c", contents[1]);
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "source2.c", contents[1].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "source2.c", contents[1]);
|
||||||
indexManager.reindex(fCProject);
|
indexManager.reindex(fCProject);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
|
@ -1214,10 +1220,10 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
|
|
||||||
// #include "header.x"
|
// #include "header.x"
|
||||||
public void testNonStandardSuffix_Bug205778() throws Exception {
|
public void testNonStandardSuffix_Bug205778() throws Exception {
|
||||||
StringBuffer[] contents= getContentsForTest(2);
|
String[] contents= getContentsForTest(2);
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "header.x", contents[0].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "header.x", contents[0]);
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[1].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[1]);
|
||||||
indexManager.reindex(fCProject);
|
indexManager.reindex(fCProject);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
|
@ -1237,10 +1243,10 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// };
|
// };
|
||||||
// #include "MyClass_inline.h"
|
// #include "MyClass_inline.h"
|
||||||
public void testAddingMemberBeforeContainer_Bug203170() throws Exception {
|
public void testAddingMemberBeforeContainer_Bug203170() throws Exception {
|
||||||
StringBuffer[] contents= getContentsForTest(2);
|
String[] contents= getContentsForTest(2);
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "MyClass_inline.h", contents[0].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "MyClass_inline.h", contents[0]);
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[1].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "source.cpp", contents[1]);
|
||||||
indexManager.reindex(fCProject);
|
indexManager.reindex(fCProject);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
|
@ -1268,11 +1274,11 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
// a.b;
|
// a.b;
|
||||||
// }
|
// }
|
||||||
public void testUnrelatedTypedef_Bug214146() throws Exception {
|
public void testUnrelatedTypedef_Bug214146() throws Exception {
|
||||||
StringBuffer[] contents= getContentsForTest(3);
|
String[] contents= getContentsForTest(3);
|
||||||
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "s1.cpp", contents[0].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "s1.cpp", contents[0]);
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "h1.h", contents[1].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "h1.h", contents[1]);
|
||||||
TestSourceReader.createFile(fCProject.getProject(), "s2.h", contents[2].toString());
|
TestSourceReader.createFile(fCProject.getProject(), "s2.h", contents[2]);
|
||||||
indexManager.reindex(fCProject);
|
indexManager.reindex(fCProject);
|
||||||
waitForIndexer();
|
waitForIndexer();
|
||||||
fIndex.acquireReadLock();
|
fIndex.acquireReadLock();
|
||||||
|
@ -1286,4 +1292,35 @@ public class IndexBugsTests extends BaseTestCase {
|
||||||
fIndex.releaseReadLock();
|
fIndex.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #undef XXX
|
||||||
|
|
||||||
|
// #define XXX
|
||||||
|
// #include "header.h"
|
||||||
|
// #ifdef XXX
|
||||||
|
// int bug227088;
|
||||||
|
// #else
|
||||||
|
// int ok;
|
||||||
|
// #endif
|
||||||
|
public void testUndefInHeader_Bug227088() throws Exception {
|
||||||
|
String[] contents= getContentsForTest(2);
|
||||||
|
final IIndexManager indexManager = CCorePlugin.getIndexManager();
|
||||||
|
TestSourceReader.createFile(fCProject.getProject(), "header.h", contents[0]);
|
||||||
|
TestSourceReader.createFile(fCProject.getProject(), "s1.cpp", contents[1]);
|
||||||
|
TestSourceReader.createFile(fCProject.getProject(), "s2.cpp", contents[1]);
|
||||||
|
indexManager.reindex(fCProject);
|
||||||
|
waitForIndexer();
|
||||||
|
fIndex.acquireReadLock();
|
||||||
|
try {
|
||||||
|
IIndexBinding[] bindings = fIndex.findBindings("bug227088".toCharArray(), IndexFilter.ALL, NPM);
|
||||||
|
assertEquals(0, bindings.length);
|
||||||
|
bindings = fIndex.findBindings("ok".toCharArray(), IndexFilter.ALL, NPM);
|
||||||
|
assertEquals(1, bindings.length);
|
||||||
|
IIndexName[] decls = fIndex.findNames(bindings[0], IIndex.FIND_ALL_OCCURENCES);
|
||||||
|
assertEquals(2, decls.length);
|
||||||
|
} finally {
|
||||||
|
fIndex.releaseReadLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -36,7 +36,8 @@ public interface IMacroBinding extends IBinding {
|
||||||
char[][] getParameterList();
|
char[][] getParameterList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the expansion of this macro definition. For dynamic macros an exemplary image is returned.
|
* Returns the expansion of this macro definition, or <code>null</code> if the definition is not
|
||||||
|
* available. For dynamic macros an exemplary image is returned.
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
char[] getExpansion();
|
char[] getExpansion();
|
||||||
|
@ -51,7 +52,8 @@ public interface IMacroBinding extends IBinding {
|
||||||
char[][] getParameterPlaceholderList();
|
char[][] getParameterPlaceholderList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the image of the expansion (also containing comments). For dynamic macros an exemplary image is returned.
|
* Returns the image of the expansion (also containing comments), or <code>null</code> if the definition
|
||||||
|
* is not available. For dynamic macros an exemplary image is returned.
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
char[] getExpansionImage();
|
char[] getExpansionImage();
|
||||||
|
|
|
@ -37,7 +37,7 @@ public interface IIndexMacro extends IMacroBinding, IIndexBinding {
|
||||||
* If available, return the file location for the macro definition of this macro,
|
* If available, return the file location for the macro definition of this macro,
|
||||||
* otherwise return <code>null</code>.
|
* otherwise return <code>null</code>.
|
||||||
*/
|
*/
|
||||||
IASTFileLocation getFileLocation();
|
IASTFileLocation getFileLocation() throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the file in which this macro is defined and belongs to.
|
* Returns the file in which this macro is defined and belongs to.
|
||||||
|
@ -47,7 +47,8 @@ public interface IIndexMacro extends IMacroBinding, IIndexBinding {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the definition of this macro, or <code>null</code> if not available.
|
* Returns the name of the definition of this macro, or <code>null</code> if not available.
|
||||||
|
* @throws CoreException
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
IIndexName getDefinition();
|
IIndexName getDefinition() throws CoreException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import java.util.Collection;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||||
import org.eclipse.cdt.core.index.IIndex;
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
|
@ -72,7 +72,7 @@ public interface IWritableIndex extends IIndex {
|
||||||
*/
|
*/
|
||||||
void setFileContent(IIndexFragmentFile sourceFile,
|
void setFileContent(IIndexFragmentFile sourceFile,
|
||||||
int linkageID, IncludeInformation[] includes,
|
int linkageID, IncludeInformation[] includes,
|
||||||
IASTPreprocessorMacroDefinition[] macros, IASTName[][] names,
|
IASTPreprocessorStatement[] macros, IASTName[][] names,
|
||||||
ASTFilePathResolver resolver) throws CoreException;
|
ASTFilePathResolver resolver) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,7 +15,7 @@ package org.eclipse.cdt.internal.core.index;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndex.IncludeInformation;
|
import org.eclipse.cdt.internal.core.index.IWritableIndex.IncludeInformation;
|
||||||
import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver;
|
import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver;
|
||||||
|
@ -52,7 +52,7 @@ public interface IWritableIndexFragment extends IIndexFragment {
|
||||||
*/
|
*/
|
||||||
void addFileContent(IIndexFragmentFile sourceFile,
|
void addFileContent(IIndexFragmentFile sourceFile,
|
||||||
IncludeInformation[] includes,
|
IncludeInformation[] includes,
|
||||||
IASTPreprocessorMacroDefinition[] macros, IASTName[][] names, ASTFilePathResolver resolver) throws CoreException;
|
IASTPreprocessorStatement[] macros, IASTName[][] names, ASTFilePathResolver resolver) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Acquires a write lock, while giving up a certain amount of read locks.
|
* Acquires a write lock, while giving up a certain amount of read locks.
|
||||||
|
@ -69,7 +69,7 @@ public interface IWritableIndexFragment extends IIndexFragment {
|
||||||
/**
|
/**
|
||||||
* Write the key, value mapping to the fragment properties. If a mapping for the
|
* Write the key, value mapping to the fragment properties. If a mapping for the
|
||||||
* same key already exists, it is overwritten.
|
* same key already exists, it is overwritten.
|
||||||
* @param key a non-null property name
|
* @param propertyName a non-null property name
|
||||||
* @param value a value to associate with the key. may not be null.
|
* @param value a value to associate with the key. may not be null.
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
* @throws NullPointerException if key is null
|
* @throws NullPointerException if key is null
|
||||||
|
|
|
@ -15,7 +15,7 @@ package org.eclipse.cdt.internal.core.index;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver;
|
import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver;
|
||||||
|
@ -60,15 +60,14 @@ public class WritableCIndex extends CIndex implements IWritableIndex {
|
||||||
|
|
||||||
public void setFileContent(IIndexFragmentFile file, int linkageID,
|
public void setFileContent(IIndexFragmentFile file, int linkageID,
|
||||||
IncludeInformation[] includes,
|
IncludeInformation[] includes,
|
||||||
IASTPreprocessorMacroDefinition[] macros, IASTName[][] names, ASTFilePathResolver resolver) throws CoreException {
|
IASTPreprocessorStatement[] macros, IASTName[][] names, ASTFilePathResolver resolver) throws CoreException {
|
||||||
|
|
||||||
IIndexFragment indexFragment = file.getIndexFragment();
|
IIndexFragment indexFragment = file.getIndexFragment();
|
||||||
if (!isWritableFragment(indexFragment)) {
|
if (!isWritableFragment(indexFragment)) {
|
||||||
assert false : "Attempt to update file of read-only fragment"; //$NON-NLS-1$
|
assert false : "Attempt to update file of read-only fragment"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int i = 0; i < includes.length; i++) {
|
for (IncludeInformation ii : includes) {
|
||||||
IncludeInformation ii= includes[i];
|
|
||||||
if (ii.fLocation != null) {
|
if (ii.fLocation != null) {
|
||||||
ii.fTargetFile= addFile(linkageID, ii.fLocation);
|
ii.fTargetFile= addFile(linkageID, ii.fLocation);
|
||||||
}
|
}
|
||||||
|
|
|
@ -782,10 +782,17 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
||||||
|
|
||||||
private void addMacroDefinition(IIndexMacro macro) {
|
private void addMacroDefinition(IIndexMacro macro) {
|
||||||
try {
|
try {
|
||||||
PreprocessorMacro result= MacroDefinitionParser.parseMacroDefinition(macro.getNameCharArray(), macro.getParameterList(), macro.getExpansionImage());
|
final char[] expansionImage = macro.getExpansionImage();
|
||||||
final IASTFileLocation loc= macro.getFileLocation();
|
if (expansionImage == null) {
|
||||||
fLocationMap.registerMacroFromIndex(result, loc, -1);
|
// this is an undef
|
||||||
fMacroDictionary.put(result.getNameCharArray(), result);
|
fMacroDictionary.remove(macro.getNameCharArray());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PreprocessorMacro result= MacroDefinitionParser.parseMacroDefinition(macro.getNameCharArray(), macro.getParameterList(), expansionImage);
|
||||||
|
final IASTFileLocation loc= macro.getFileLocation();
|
||||||
|
fLocationMap.registerMacroFromIndex(result, loc, -1);
|
||||||
|
fMacroDictionary.put(result.getNameCharArray(), result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
fLog.traceLog("Invalid macro definition: '" + macro.getName() + "'"); //$NON-NLS-1$//$NON-NLS-2$
|
fLog.traceLog("Invalid macro definition: '" + macro.getName() + "'"); //$NON-NLS-1$//$NON-NLS-2$
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
|
@ -46,6 +47,7 @@ import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
|
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||||
|
import org.eclipse.core.runtime.Assert;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -244,11 +246,10 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
final boolean checkConfig= (fUpdateFlags & IIndexManager.UPDATE_CHECK_CONFIGURATION) != 0;
|
final boolean checkConfig= (fUpdateFlags & IIndexManager.UPDATE_CHECK_CONFIGURATION) != 0;
|
||||||
|
|
||||||
int count= 0;
|
int count= 0;
|
||||||
for (int i = 0; i < fFilesToUpdate.length; i++) {
|
for (final Object tu : fFilesToUpdate) {
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final Object tu= fFilesToUpdate[i];
|
|
||||||
final IIndexFileLocation ifl= fResolver.resolveFile(tu);
|
final IIndexFileLocation ifl= fResolver.resolveFile(tu);
|
||||||
if (ifl == null)
|
if (ifl == null)
|
||||||
continue;
|
continue;
|
||||||
|
@ -260,8 +261,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
if ((isSourceUnit && !isExcludedSource) || fIndexHeadersWithoutContext) {
|
if ((isSourceUnit && !isExcludedSource) || fIndexHeadersWithoutContext) {
|
||||||
// headers or sources required with a specific linkage
|
// headers or sources required with a specific linkage
|
||||||
AbstractLanguage[] langs= fResolver.getLanguages(tu);
|
AbstractLanguage[] langs= fResolver.getLanguages(tu);
|
||||||
for (int j = 0; j < langs.length; j++) {
|
for (AbstractLanguage lang : langs) {
|
||||||
int linkageID = langs[j].getLinkageID();
|
int linkageID = lang.getLinkageID();
|
||||||
IIndexFragmentFile ifile= getFile(linkageID, indexFiles);
|
IIndexFragmentFile ifile= getFile(linkageID, indexFiles);
|
||||||
if (ifile == null || !ifile.hasContent()) {
|
if (ifile == null || !ifile.hasContent()) {
|
||||||
store(tu, linkageID, isSourceUnit, files);
|
store(tu, linkageID, isSourceUnit, files);
|
||||||
|
@ -285,8 +286,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle other files present in index
|
// handle other files present in index
|
||||||
for (int j = 0; j < indexFiles.length; j++) {
|
for (IIndexFragmentFile ifile : indexFiles) {
|
||||||
IIndexFragmentFile ifile = indexFiles[j];
|
|
||||||
if (ifile != null && ifile.hasContent()) {
|
if (ifile != null && ifile.hasContent()) {
|
||||||
IIndexInclude ctx= ifile.getParsedInContext();
|
IIndexInclude ctx= ifile.getParsedInContext();
|
||||||
if (ctx == null) {
|
if (ctx == null) {
|
||||||
|
@ -354,8 +354,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private IIndexFragmentFile getFile(int linkageID, IIndexFragmentFile[] indexFiles) throws CoreException {
|
private IIndexFragmentFile getFile(int linkageID, IIndexFragmentFile[] indexFiles) throws CoreException {
|
||||||
for (int i = 0; i < indexFiles.length; i++) {
|
for (IIndexFragmentFile ifile : indexFiles) {
|
||||||
IIndexFragmentFile ifile = indexFiles[i];
|
|
||||||
if (ifile != null && ifile.getLinkageID() == linkageID) {
|
if (ifile != null && ifile.getLinkageID() == linkageID) {
|
||||||
return ifile;
|
return ifile;
|
||||||
}
|
}
|
||||||
|
@ -391,26 +390,23 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
if (!filesToRemove.isEmpty() || !ifilesToRemove.isEmpty()) {
|
if (!filesToRemove.isEmpty() || !ifilesToRemove.isEmpty()) {
|
||||||
fIndex.acquireWriteLock(1);
|
fIndex.acquireWriteLock(1);
|
||||||
try {
|
try {
|
||||||
for (Iterator<Object> iterator = fFilesToRemove.iterator(); iterator.hasNext();) {
|
for (Object tu : fFilesToRemove) {
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Object tu = iterator.next();
|
|
||||||
IIndexFileLocation ifl= fResolver.resolveFile(tu);
|
IIndexFileLocation ifl= fResolver.resolveFile(tu);
|
||||||
if (ifl == null)
|
if (ifl == null)
|
||||||
continue;
|
continue;
|
||||||
IIndexFragmentFile[] ifiles= fIndex.getWritableFiles(ifl);
|
IIndexFragmentFile[] ifiles= fIndex.getWritableFiles(ifl);
|
||||||
for (int i = 0; i < ifiles.length; i++) {
|
for (IIndexFragmentFile ifile : ifiles) {
|
||||||
IIndexFragmentFile ifile = ifiles[i];
|
|
||||||
fIndex.clearFile(ifile, null);
|
fIndex.clearFile(ifile, null);
|
||||||
}
|
}
|
||||||
updateRequestedFiles(-1);
|
updateRequestedFiles(-1);
|
||||||
}
|
}
|
||||||
for (Iterator<IIndexFragmentFile> iterator = ifilesToRemove.iterator(); iterator.hasNext();) {
|
for (IIndexFragmentFile ifile : ifilesToRemove) {
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IIndexFragmentFile ifile= iterator.next();
|
|
||||||
fIndex.clearFile(ifile, null);
|
fIndex.clearFile(ifile, null);
|
||||||
updateRequestedFiles(-1);
|
updateRequestedFiles(-1);
|
||||||
}
|
}
|
||||||
|
@ -422,11 +418,10 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseFilesUpFront(IProgressMonitor monitor) throws CoreException {
|
private void parseFilesUpFront(IProgressMonitor monitor) throws CoreException {
|
||||||
for (Iterator<String> iter = fFilesUpFront.iterator(); iter.hasNext();) {
|
for (String upfront : fFilesUpFront) {
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String upfront= iter.next();
|
|
||||||
String filePath = upfront;
|
String filePath = upfront;
|
||||||
filePath= filePath.trim();
|
filePath= filePath.trim();
|
||||||
if (filePath.length() == 0) {
|
if (filePath.length() == 0) {
|
||||||
|
@ -442,8 +437,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
new Object[]{fileName, path.removeLastSegments(1).toString()}));
|
new Object[]{fileName, path.removeLastSegments(1).toString()}));
|
||||||
|
|
||||||
AbstractLanguage[] langs= getLanguages(fileName);
|
AbstractLanguage[] langs= getLanguages(fileName);
|
||||||
for (int i = 0; i < langs.length; i++) {
|
for (AbstractLanguage lang : langs) {
|
||||||
AbstractLanguage lang= langs[i];
|
|
||||||
int linkageID= lang.getLinkageID();
|
int linkageID= lang.getLinkageID();
|
||||||
String code= "#include \"" + filePath + "\"\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
String code= "#include \"" + filePath + "\"\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
|
@ -471,10 +465,9 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
// sources
|
// sources
|
||||||
List<Object> files= fileListMap.get(getFileListKey(linkageID, true));
|
List<Object> files= fileListMap.get(getFileListKey(linkageID, true));
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (Iterator<Object> iter = files.iterator(); iter.hasNext();) {
|
for (Object tu : files) {
|
||||||
if (monitor.isCanceled())
|
if (monitor.isCanceled())
|
||||||
return;
|
return;
|
||||||
final Object tu= iter.next();
|
|
||||||
final IIndexFileLocation ifl = fResolver.resolveFile(tu);
|
final IIndexFileLocation ifl = fResolver.resolveFile(tu);
|
||||||
if (ifl == null)
|
if (ifl == null)
|
||||||
continue;
|
continue;
|
||||||
|
@ -575,9 +568,9 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
IPath path= getPathForLabel(ifl);
|
IPath path= getPathForLabel(ifl);
|
||||||
AbstractLanguage[] langs= fResolver.getLanguages(tu);
|
AbstractLanguage[] langs= fResolver.getLanguages(tu);
|
||||||
AbstractLanguage lang= null;
|
AbstractLanguage lang= null;
|
||||||
for (int i = 0; i < langs.length; i++) {
|
for (AbstractLanguage lang2 : langs) {
|
||||||
if (langs[i].getLinkageID() == linkageID) {
|
if (lang2.getLinkageID() == linkageID) {
|
||||||
lang= langs[i];
|
lang= lang2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -617,8 +610,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
enteredFiles.add(topIfl);
|
enteredFiles.add(topIfl);
|
||||||
IDependencyTree tree= ast.getDependencyTree();
|
IDependencyTree tree= ast.getDependencyTree();
|
||||||
IASTInclusionNode[] inclusions= tree.getInclusions();
|
IASTInclusionNode[] inclusions= tree.getInclusions();
|
||||||
for (int i=0; i < inclusions.length; i++) {
|
for (IASTInclusionNode inclusion : inclusions) {
|
||||||
collectOrderedIFLs(linkageID, inclusions[i], enteredFiles, orderedIFLs);
|
collectOrderedIFLs(linkageID, inclusion, enteredFiles, orderedIFLs);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileContent info= getFileInfo(linkageID, topIfl);
|
FileContent info= getFileInfo(linkageID, topIfl);
|
||||||
|
@ -634,10 +627,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
// mark as updated in any case, to avoid parsing files that caused an exception to be thrown.
|
// mark as updated in any case, to avoid parsing files that caused an exception to be thrown.
|
||||||
for (IIndexFileLocation ifl : ifls) {
|
for (IIndexFileLocation ifl : ifls) {
|
||||||
info= getFileInfo(linkageID, ifl);
|
info= getFileInfo(linkageID, ifl);
|
||||||
assert info != null;
|
Assert.isNotNull(info);
|
||||||
if (info != null) {
|
info.fIsUpdated= true;
|
||||||
info.fIsUpdated= true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -648,8 +639,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
final IIndexFileLocation ifl= fResolver.resolveASTPath(id.getPath());
|
final IIndexFileLocation ifl= fResolver.resolveASTPath(id.getPath());
|
||||||
final boolean isFirstEntry= enteredFiles.add(ifl);
|
final boolean isFirstEntry= enteredFiles.add(ifl);
|
||||||
IASTInclusionNode[] nested= inclusion.getNestedInclusions();
|
IASTInclusionNode[] nested= inclusion.getNestedInclusions();
|
||||||
for (int i = 0; i < nested.length; i++) {
|
for (IASTInclusionNode element : nested) {
|
||||||
collectOrderedIFLs(linkageID, nested[i], enteredFiles, orderedIFLs);
|
collectOrderedIFLs(linkageID, element, enteredFiles, orderedIFLs);
|
||||||
}
|
}
|
||||||
if (isFirstEntry && needToUpdateHeader(linkageID, ifl)) {
|
if (isFirstEntry && needToUpdateHeader(linkageID, ifl)) {
|
||||||
orderedIFLs.add(ifl);
|
orderedIFLs.add(ifl);
|
||||||
|
@ -719,8 +710,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
int result= 0;
|
int result= 0;
|
||||||
Map<String, String> macros= scannerInfo.getDefinedSymbols();
|
Map<String, String> macros= scannerInfo.getDefinedSymbols();
|
||||||
if (macros != null) {
|
if (macros != null) {
|
||||||
for (Iterator<Map.Entry<String,String>> i = macros.entrySet().iterator(); i.hasNext();) {
|
for (Entry<String, String> entry : macros.entrySet()) {
|
||||||
Map.Entry<String,String> entry = i.next();
|
|
||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
String value = entry.getValue();
|
String value = entry.getValue();
|
||||||
result= addToHashcode(result, key);
|
result= addToHashcode(result, key);
|
||||||
|
@ -731,8 +721,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
}
|
}
|
||||||
String[] a= scannerInfo.getIncludePaths();
|
String[] a= scannerInfo.getIncludePaths();
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
for (int i = 0; i < a.length; i++) {
|
for (String element : a) {
|
||||||
result= addToHashcode(result, a[i]);
|
result= addToHashcode(result, element);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -740,22 +730,22 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
IExtendedScannerInfo esi= (IExtendedScannerInfo) scannerInfo;
|
IExtendedScannerInfo esi= (IExtendedScannerInfo) scannerInfo;
|
||||||
a= esi.getIncludeFiles();
|
a= esi.getIncludeFiles();
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
for (int i = 0; i < a.length; i++) {
|
for (String element : a) {
|
||||||
result= addToHashcode(result, a[i]);
|
result= addToHashcode(result, element);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a= esi.getLocalIncludePath();
|
a= esi.getLocalIncludePath();
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
for (int i = 0; i < a.length; i++) {
|
for (String element : a) {
|
||||||
result= addToHashcode(result, a[i]);
|
result= addToHashcode(result, element);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a= esi.getMacroFiles();
|
a= esi.getMacroFiles();
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
for (int i = 0; i < a.length; i++) {
|
for (String element : a) {
|
||||||
result= addToHashcode(result, a[i]);
|
result= addToHashcode(result, element);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -770,22 +760,20 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
|
||||||
public final FileContent getFileContent(int linkageID, IIndexFileLocation ifl) throws CoreException {
|
public final FileContent getFileContent(int linkageID, IIndexFileLocation ifl) throws CoreException {
|
||||||
if (!needToUpdateHeader(linkageID, ifl)) {
|
if (!needToUpdateHeader(linkageID, ifl)) {
|
||||||
FileContent info= getFileInfo(linkageID, ifl);
|
FileContent info= getFileInfo(linkageID, ifl);
|
||||||
assert info != null;
|
Assert.isNotNull(info);
|
||||||
if (info != null) {
|
if (info.fIndexFile == null) {
|
||||||
|
info.fIndexFile= fIndex.getFile(linkageID, ifl);
|
||||||
if (info.fIndexFile == null) {
|
if (info.fIndexFile == null) {
|
||||||
info.fIndexFile= fIndex.getFile(linkageID, ifl);
|
return null;
|
||||||
if (info.fIndexFile == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (info.fMacros == null) {
|
|
||||||
info.fMacros= info.fIndexFile.getMacros();
|
|
||||||
}
|
|
||||||
if (info.fDirectives == null) {
|
|
||||||
info.fDirectives= info.fIndexFile.getUsingDirectives();
|
|
||||||
}
|
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
|
if (info.fMacros == null) {
|
||||||
|
info.fMacros= info.fIndexFile.getMacros();
|
||||||
|
}
|
||||||
|
if (info.fDirectives == null) {
|
||||||
|
info.fDirectives= info.fIndexFile.getUsingDirectives();
|
||||||
|
}
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorUndefStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
@ -39,7 +41,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.parser.IProblem;
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||||
|
@ -69,7 +70,7 @@ abstract public class PDOMWriter {
|
||||||
|
|
||||||
private static class Symbols {
|
private static class Symbols {
|
||||||
ArrayList<IASTName[]> fNames= new ArrayList<IASTName[]>();
|
ArrayList<IASTName[]> fNames= new ArrayList<IASTName[]>();
|
||||||
ArrayList<IASTPreprocessorMacroDefinition> fMacros= new ArrayList<IASTPreprocessorMacroDefinition>();
|
ArrayList<IASTPreprocessorStatement> fMacros= new ArrayList<IASTPreprocessorStatement>();
|
||||||
ArrayList<IASTPreprocessorIncludeStatement> fIncludes= new ArrayList<IASTPreprocessorIncludeStatement>();
|
ArrayList<IASTPreprocessorIncludeStatement> fIncludes= new ArrayList<IASTPreprocessorIncludeStatement>();
|
||||||
}
|
}
|
||||||
private boolean fShowProblems;
|
private boolean fShowProblems;
|
||||||
|
@ -122,12 +123,7 @@ abstract public class PDOMWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts symbols from the given ast and adds them to the index. It will
|
* Extracts symbols from the given ast and adds them to the index.
|
||||||
* make calls to
|
|
||||||
* {@link #needToUpdate(IIndexFileLocation)},
|
|
||||||
* {@link #postAddToIndex(IIndexFileLocation, IIndexFile)},
|
|
||||||
* {@link #getLastModified(IIndexFileLocation)} and
|
|
||||||
* {@link #findLocation(String)} to obtain further information.
|
|
||||||
*
|
*
|
||||||
* When flushIndex is set to <code>false</code>, you must make sure to flush the
|
* When flushIndex is set to <code>false</code>, you must make sure to flush the
|
||||||
* index after your last write operation.
|
* index after your last write operation.
|
||||||
|
@ -142,8 +138,8 @@ abstract public class PDOMWriter {
|
||||||
fShowSyntaxProblems= true;
|
fShowSyntaxProblems= true;
|
||||||
}
|
}
|
||||||
final Map<IIndexFileLocation, Symbols> symbolMap= new HashMap<IIndexFileLocation, Symbols>();
|
final Map<IIndexFileLocation, Symbols> symbolMap= new HashMap<IIndexFileLocation, Symbols>();
|
||||||
for (int i = 0; i < ifls.length; i++) {
|
for (IIndexFileLocation ifl : ifls) {
|
||||||
prepareInMap(symbolMap, ifls[i]);
|
prepareInMap(symbolMap, ifl);
|
||||||
}
|
}
|
||||||
ArrayList<IStatus> stati= new ArrayList<IStatus>();
|
ArrayList<IStatus> stati= new ArrayList<IStatus>();
|
||||||
|
|
||||||
|
@ -161,7 +157,7 @@ abstract public class PDOMWriter {
|
||||||
}
|
}
|
||||||
if (!stati.isEmpty()) {
|
if (!stati.isEmpty()) {
|
||||||
String path= null;
|
String path= null;
|
||||||
if (ifls != null && ifls.length > 0) {
|
if (ifls.length > 0) {
|
||||||
path= ifls[ifls.length-1].getURI().getPath();
|
path= ifls[ifls.length-1].getURI().getPath();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -218,11 +214,10 @@ abstract public class PDOMWriter {
|
||||||
|
|
||||||
private void resolveNames(final Map<IIndexFileLocation, Symbols> symbolMap, IIndexFileLocation[] ifls, ArrayList<IStatus> stati, IProgressMonitor pm) {
|
private void resolveNames(final Map<IIndexFileLocation, Symbols> symbolMap, IIndexFileLocation[] ifls, ArrayList<IStatus> stati, IProgressMonitor pm) {
|
||||||
long start= System.currentTimeMillis();
|
long start= System.currentTimeMillis();
|
||||||
for (int i=0; i<ifls.length; i++) {
|
for (IIndexFileLocation path : ifls) {
|
||||||
if (pm.isCanceled()) {
|
if (pm.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IIndexFileLocation path= ifls[i];
|
|
||||||
Symbols symbols= symbolMap.get(path);
|
Symbols symbols= symbolMap.get(path);
|
||||||
|
|
||||||
final ArrayList<IASTName[]> names= symbols.fNames;
|
final ArrayList<IASTName[]> names= symbols.fNames;
|
||||||
|
@ -277,39 +272,39 @@ abstract public class PDOMWriter {
|
||||||
final HashSet<IIndexFileLocation> contextIFLs= new HashSet<IIndexFileLocation>();
|
final HashSet<IIndexFileLocation> contextIFLs= new HashSet<IIndexFileLocation>();
|
||||||
final IIndexFileLocation astIFL = fResolver.resolveASTPath(ast.getFilePath());
|
final IIndexFileLocation astIFL = fResolver.resolveASTPath(ast.getFilePath());
|
||||||
|
|
||||||
// includes
|
|
||||||
int unresolvedIncludes= 0;
|
int unresolvedIncludes= 0;
|
||||||
IASTPreprocessorIncludeStatement[] includes = ast.getIncludeDirectives();
|
IASTPreprocessorStatement[] stmts = ast.getAllPreprocessorStatements();
|
||||||
for (int i= 0; i < includes.length; i++) {
|
for (final IASTPreprocessorStatement stmt : stmts) {
|
||||||
final IASTPreprocessorIncludeStatement include = includes[i];
|
// includes
|
||||||
final IASTFileLocation astLoc= include.getFileLocation();
|
if (stmt instanceof IASTPreprocessorIncludeStatement) {
|
||||||
final IIndexFileLocation sourceIFL= astLoc != null ? fResolver.resolveASTPath(astLoc.getFileName()) : astIFL; // command-line includes
|
IASTPreprocessorIncludeStatement include= (IASTPreprocessorIncludeStatement) stmt;
|
||||||
final boolean updateSource= symbolMap.containsKey(sourceIFL);
|
|
||||||
if (updateSource) {
|
final IASTFileLocation astLoc= include.getFileLocation();
|
||||||
addToMap(symbolMap, sourceIFL, include);
|
final IIndexFileLocation sourceIFL= astLoc != null ? fResolver.resolveASTPath(astLoc.getFileName()) : astIFL; // command-line includes
|
||||||
}
|
final boolean updateSource= symbolMap.containsKey(sourceIFL);
|
||||||
if (include.isActive()) {
|
if (updateSource) {
|
||||||
if (!include.isResolved()) {
|
addToMap(symbolMap, sourceIFL, include);
|
||||||
unresolvedIncludes++;
|
|
||||||
}
|
}
|
||||||
else if (updateSource) {
|
if (include.isActive()) {
|
||||||
// the include was parsed, check if we want to update the included file in the index
|
if (!include.isResolved()) {
|
||||||
final IIndexFileLocation targetIFL= fResolver.resolveASTPath(include.getPath());
|
unresolvedIncludes++;
|
||||||
if (symbolMap.containsKey(targetIFL) && contextIFLs.add(targetIFL)) {
|
}
|
||||||
contextIncludes.add(include);
|
else if (updateSource) {
|
||||||
|
// the include was parsed, check if we want to update the included file in the index
|
||||||
|
final IIndexFileLocation targetIFL= fResolver.resolveASTPath(include.getPath());
|
||||||
|
if (symbolMap.containsKey(targetIFL) && contextIFLs.add(targetIFL)) {
|
||||||
|
contextIncludes.add(include);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// macros
|
||||||
|
else if (stmt instanceof IASTPreprocessorMacroDefinition || stmt instanceof IASTPreprocessorUndefStatement) {
|
||||||
// macros
|
IASTFileLocation sourceLoc = stmt.getFileLocation();
|
||||||
IASTPreprocessorMacroDefinition[] macros = ast.getMacroDefinitions();
|
if (sourceLoc != null) { // skip built-ins and command line macros
|
||||||
for (int i2 = 0; i2 < macros.length; ++i2) {
|
IIndexFileLocation path2 = fResolver.resolveASTPath(sourceLoc.getFileName());
|
||||||
IASTPreprocessorMacroDefinition macro = macros[i2];
|
addToMap(symbolMap, path2, stmt);
|
||||||
IASTFileLocation sourceLoc = macro.getFileLocation();
|
}
|
||||||
if (sourceLoc != null) { // skip built-ins and command line macros
|
|
||||||
IIndexFileLocation path2 = fResolver.resolveASTPath(sourceLoc.getFileName());
|
|
||||||
addToMap(symbolMap, path2, macro);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,7 +407,7 @@ abstract public class PDOMWriter {
|
||||||
lists.fIncludes.add(thing);
|
lists.fIncludes.add(thing);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToMap(Map<IIndexFileLocation, Symbols> map, IIndexFileLocation location, IASTPreprocessorMacroDefinition thing) {
|
private void addToMap(Map<IIndexFileLocation, Symbols> map, IIndexFileLocation location, IASTPreprocessorStatement thing) {
|
||||||
Symbols lists= map.get(location);
|
Symbols lists= map.get(location);
|
||||||
if (lists != null)
|
if (lists != null)
|
||||||
lists.fMacros.add(thing);
|
lists.fMacros.add(thing);
|
||||||
|
@ -439,10 +434,10 @@ abstract public class PDOMWriter {
|
||||||
file.setScannerConfigurationHashcode(configHash);
|
file.setScannerConfigurationHashcode(configHash);
|
||||||
Symbols lists= symbolMap.get(location);
|
Symbols lists= symbolMap.get(location);
|
||||||
if (lists != null) {
|
if (lists != null) {
|
||||||
IASTPreprocessorMacroDefinition[] macros= lists.fMacros.toArray(new IASTPreprocessorMacroDefinition[lists.fMacros.size()]);
|
IASTPreprocessorStatement[] macros= lists.fMacros.toArray(new IASTPreprocessorStatement[lists.fMacros.size()]);
|
||||||
IASTName[][] names= lists.fNames.toArray(new IASTName[lists.fNames.size()][]);
|
IASTName[][] names= lists.fNames.toArray(new IASTName[lists.fNames.size()][]);
|
||||||
for (int j= 0; j<names.length; j++) {
|
for (IASTName[] name2 : names) {
|
||||||
final IASTName name= names[j][0];
|
final IASTName name= name2[0];
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
ASTInternal.setFullyResolved(name.getBinding(), true);
|
ASTInternal.setFullyResolved(name.getBinding(), true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,11 @@ package org.eclipse.cdt.internal.core.pdom;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexLocationConverter;
|
import org.eclipse.cdt.core.index.IIndexLocationConverter;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||||
|
@ -56,7 +55,7 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFileContent(IIndexFragmentFile sourceFile, IncludeInformation[] includes,
|
public void addFileContent(IIndexFragmentFile sourceFile, IncludeInformation[] includes,
|
||||||
IASTPreprocessorMacroDefinition[] macros, IASTName[][] names, ASTFilePathResolver pathResolver) throws CoreException {
|
IASTPreprocessorStatement[] macros, IASTName[][] names, ASTFilePathResolver pathResolver) throws CoreException {
|
||||||
assert sourceFile.getIndexFragment() == this;
|
assert sourceFile.getIndexFragment() == this;
|
||||||
|
|
||||||
PDOMFile pdomFile = (PDOMFile) sourceFile;
|
PDOMFile pdomFile = (PDOMFile) sourceFile;
|
||||||
|
@ -113,7 +112,6 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment {
|
||||||
* <b>A write-lock must be obtained before calling this method</b>
|
* <b>A write-lock must be obtained before calling this method</b>
|
||||||
*
|
*
|
||||||
* @param newConverter the converter to use to update internal file representations
|
* @param newConverter the converter to use to update internal file representations
|
||||||
* @return a list of PDOMFiles for which the location converter returned null when queried for the new internal representation
|
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public void rewriteLocations(final IIndexLocationConverter newConverter) throws CoreException {
|
public void rewriteLocations(final IIndexLocationConverter newConverter) throws CoreException {
|
||||||
|
@ -131,8 +129,7 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment {
|
||||||
|
|
||||||
clearFileIndex();
|
clearFileIndex();
|
||||||
final List<PDOMFile> notConverted = new ArrayList<PDOMFile>();
|
final List<PDOMFile> notConverted = new ArrayList<PDOMFile>();
|
||||||
for(Iterator<PDOMFile> i= pdomfiles.iterator(); i.hasNext(); ) {
|
for (PDOMFile file : pdomfiles) {
|
||||||
PDOMFile file= i.next();
|
|
||||||
String internalFormat = newConverter.toInternalFormat(file.getLocation());
|
String internalFormat = newConverter.toInternalFormat(file.getLocation());
|
||||||
if(internalFormat!=null) {
|
if(internalFormat!=null) {
|
||||||
file.setInternalLocation(internalFormat);
|
file.setInternalLocation(internalFormat);
|
||||||
|
@ -144,8 +141,7 @@ public class WritablePDOM extends PDOM implements IWritableIndexFragment {
|
||||||
|
|
||||||
|
|
||||||
// remove content where converter returns null
|
// remove content where converter returns null
|
||||||
for(Iterator<PDOMFile> i = notConverted.iterator(); i.hasNext(); ) {
|
for (PDOMFile file : notConverted) {
|
||||||
PDOMFile file = i.next();
|
|
||||||
file.convertIncludersToUnresolved();
|
file.convertIncludersToUnresolved();
|
||||||
file.clear(null);
|
file.clear(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorUndefStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
|
@ -225,21 +227,31 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
pdom.getDB().putInt(record + FIRST_MACRO, rec);
|
pdom.getDB().putInt(record + FIRST_MACRO, rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMacros(IASTPreprocessorMacroDefinition[] macros) throws CoreException {
|
public void addMacros(IASTPreprocessorStatement[] macros) throws CoreException {
|
||||||
assert getFirstMacro() == null;
|
assert getFirstMacro() == null;
|
||||||
|
|
||||||
PDOMMacro lastMacro= null;
|
PDOMMacro lastMacro= null;
|
||||||
final PDOMLinkage linkage = getLinkage();
|
final PDOMLinkage linkage = getLinkage();
|
||||||
for (int i = 0; i < macros.length; i++) {
|
for (IASTPreprocessorStatement stmt : macros) {
|
||||||
IASTPreprocessorMacroDefinition macro = macros[i];
|
PDOMMacro pdomMacro= null;
|
||||||
PDOMMacroContainer container= linkage.getMacroContainer(macro.getName().toCharArray());
|
if (stmt instanceof IASTPreprocessorMacroDefinition) {
|
||||||
PDOMMacro pdomMacro = new PDOMMacro(pdom, container, macro, this);
|
IASTPreprocessorMacroDefinition macro= (IASTPreprocessorMacroDefinition) stmt;
|
||||||
if (lastMacro == null) {
|
PDOMMacroContainer container= linkage.getMacroContainer(macro.getName().toCharArray());
|
||||||
setFirstMacro(pdomMacro);
|
pdomMacro = new PDOMMacro(pdom, container, macro, this);
|
||||||
} else {
|
}
|
||||||
lastMacro.setNextMacro(pdomMacro);
|
else if (stmt instanceof IASTPreprocessorUndefStatement) {
|
||||||
|
IASTPreprocessorUndefStatement undef= (IASTPreprocessorUndefStatement) stmt;
|
||||||
|
PDOMMacroContainer container= linkage.getMacroContainer(undef.getMacroName().toCharArray());
|
||||||
|
pdomMacro = new PDOMMacro(pdom, container, undef, this);
|
||||||
|
}
|
||||||
|
if (pdomMacro != null) {
|
||||||
|
if (lastMacro == null) {
|
||||||
|
setFirstMacro(pdomMacro);
|
||||||
|
} else {
|
||||||
|
lastMacro.setNextMacro(pdomMacro);
|
||||||
|
}
|
||||||
|
lastMacro= pdomMacro;
|
||||||
}
|
}
|
||||||
lastMacro= pdomMacro;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,8 +273,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
HashMap<IASTName, PDOMName> nameCache= new HashMap<IASTName, PDOMName>();
|
HashMap<IASTName, PDOMName> nameCache= new HashMap<IASTName, PDOMName>();
|
||||||
PDOMName lastName= null;
|
PDOMName lastName= null;
|
||||||
PDOMMacroReferenceName lastMacroName= null;
|
PDOMMacroReferenceName lastMacroName= null;
|
||||||
for (int i = 0; i < names.length; i++) {
|
for (IASTName[] name : names) {
|
||||||
IASTName[] name = names[i];
|
|
||||||
if (name[0] != null) {
|
if (name[0] != null) {
|
||||||
PDOMName caller= nameCache.get(name[1]);
|
PDOMName caller= nameCache.get(name[1]);
|
||||||
IIndexFragmentName fname= createPDOMName(linkage, name[0], caller);
|
IIndexFragmentName fname= createPDOMName(linkage, name[0], caller);
|
||||||
|
@ -380,8 +391,7 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
assert getFirstInclude() == null;
|
assert getFirstInclude() == null;
|
||||||
|
|
||||||
PDOMInclude lastInclude= null;
|
PDOMInclude lastInclude= null;
|
||||||
for (int i = 0; i < includeInfos.length; i++) {
|
for (final IncludeInformation info : includeInfos) {
|
||||||
final IncludeInformation info= includeInfos[i];
|
|
||||||
final PDOMFile targetFile= (PDOMFile) info.fTargetFile;
|
final PDOMFile targetFile= (PDOMFile) info.fTargetFile;
|
||||||
|
|
||||||
PDOMInclude pdomInclude = new PDOMInclude(pdom, info.fStatement, this, targetFile);
|
PDOMInclude pdomInclude = new PDOMInclude(pdom, info.fStatement, this, targetFile);
|
||||||
|
@ -463,7 +473,9 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
int nameOffset= name.getNodeOffset();
|
int nameOffset= name.getNodeOffset();
|
||||||
if (nameOffset >= offset) {
|
if (nameOffset >= offset) {
|
||||||
if (nameOffset + name.getNodeLength() <= offset+length) {
|
if (nameOffset + name.getNodeLength() <= offset+length) {
|
||||||
result.add(name.getDefinition());
|
if (name.isMacroDefinition()) {
|
||||||
|
result.add(name.getDefinition());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorUndefStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexMacro;
|
import org.eclipse.cdt.core.index.IIndexMacro;
|
||||||
|
@ -56,12 +57,13 @@ public class PDOMMacro implements IIndexMacro, IIndexFragmentBinding, IASTFileLo
|
||||||
|
|
||||||
private static final int RECORD_SIZE = 34;
|
private static final int RECORD_SIZE = 34;
|
||||||
private static final char[][] UNINITIALIZED= {};
|
private static final char[][] UNINITIALIZED= {};
|
||||||
|
private static final char[] UNINITIALIZED1= {};
|
||||||
|
|
||||||
private final PDOM fPDOM;
|
private final PDOM fPDOM;
|
||||||
private final int fRecord;
|
private final int fRecord;
|
||||||
|
|
||||||
private char[][] fParameterList= UNINITIALIZED;
|
private char[][] fParameterList= UNINITIALIZED;
|
||||||
private char[] fExpansion;
|
private char[] fExpansion= UNINITIALIZED1;
|
||||||
private PDOMMacroContainer fContainer;
|
private PDOMMacroContainer fContainer;
|
||||||
private PDOMMacroDefinitionName fDefinition;
|
private PDOMMacroDefinitionName fDefinition;
|
||||||
|
|
||||||
|
@ -70,34 +72,43 @@ public class PDOMMacro implements IIndexMacro, IIndexFragmentBinding, IASTFileLo
|
||||||
fRecord = record;
|
fRecord = record;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMMacro(PDOM pdom, PDOMMacroContainer container, IASTPreprocessorMacroDefinition macro, PDOMFile file) throws CoreException {
|
|
||||||
final Database db= pdom.getDB();
|
|
||||||
|
|
||||||
fPDOM = pdom;
|
public PDOMMacro(PDOM pdom, PDOMMacroContainer container, IASTPreprocessorMacroDefinition macro, PDOMFile file) throws CoreException {
|
||||||
fRecord = db.malloc(RECORD_SIZE);
|
this(pdom, container, file, macro.getName());
|
||||||
fContainer= container;
|
|
||||||
|
|
||||||
final IASTName name = macro.getName();
|
final IASTName name = macro.getName();
|
||||||
final IASTFileLocation fileloc = name.getFileLocation();
|
|
||||||
final IMacroBinding binding= (IMacroBinding) name.getBinding();
|
final IMacroBinding binding= (IMacroBinding) name.getBinding();
|
||||||
final char[][] params= binding.getParameterList();
|
final char[][] params= binding.getParameterList();
|
||||||
|
|
||||||
db.putInt(fRecord + CONTAINER, container.getRecord());
|
final Database db= pdom.getDB();
|
||||||
db.putInt(fRecord + FILE, file.getRecord());
|
|
||||||
db.putInt(fRecord + EXPANSION, db.newString(binding.getExpansionImage()).getRecord());
|
db.putInt(fRecord + EXPANSION, db.newString(binding.getExpansionImage()).getRecord());
|
||||||
db.putInt(fRecord + NAME_OFFSET, fileloc.getNodeOffset());
|
|
||||||
db.putShort(fRecord + NAME_LENGTH, (short) fileloc.getNodeLength());
|
|
||||||
|
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
StringBuilder buf= new StringBuilder();
|
StringBuilder buf= new StringBuilder();
|
||||||
for (int i= 0; i < params.length; i++) {
|
for (char[] param : params) {
|
||||||
buf.append(params[i]);
|
buf.append(param);
|
||||||
buf.append(',');
|
buf.append(',');
|
||||||
}
|
}
|
||||||
db.putInt(fRecord + PARAMETERS, db.newString(buf.toString().toCharArray()).getRecord());
|
db.putInt(fRecord + PARAMETERS, db.newString(buf.toString().toCharArray()).getRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
fContainer.addDefinition(this);
|
container.addDefinition(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PDOMMacro(PDOM pdom, PDOMMacroContainer container, IASTPreprocessorUndefStatement undef, PDOMFile file) throws CoreException {
|
||||||
|
this(pdom, container, file, undef.getMacroName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private PDOMMacro(PDOM pdom, PDOMMacroContainer container, PDOMFile file, IASTName name) throws CoreException {
|
||||||
|
final Database db= pdom.getDB();
|
||||||
|
fPDOM = pdom;
|
||||||
|
fRecord = db.malloc(RECORD_SIZE);
|
||||||
|
fContainer= container;
|
||||||
|
|
||||||
|
final IASTFileLocation fileloc = name.getFileLocation();
|
||||||
|
db.putInt(fRecord + CONTAINER, container.getRecord());
|
||||||
|
db.putInt(fRecord + FILE, file.getRecord());
|
||||||
|
db.putInt(fRecord + NAME_OFFSET, fileloc.getNodeOffset());
|
||||||
|
db.putShort(fRecord + NAME_LENGTH, (short) fileloc.getNodeLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOM getPDOM() {
|
public PDOM getPDOM() {
|
||||||
|
@ -125,7 +136,10 @@ public class PDOMMacro implements IIndexMacro, IIndexFragmentBinding, IASTFileLo
|
||||||
nextName.setPrevInContainer(prevName);
|
nextName.setPrevInContainer(prevName);
|
||||||
|
|
||||||
|
|
||||||
getExpansionInDB().delete();
|
final IString expansion = getExpansionInDB();
|
||||||
|
if (expansion != null) {
|
||||||
|
expansion.delete();
|
||||||
|
}
|
||||||
final IString params = getParamListInDB();
|
final IString params = getParamListInDB();
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
params.delete();
|
params.delete();
|
||||||
|
@ -142,7 +156,7 @@ public class PDOMMacro implements IIndexMacro, IIndexFragmentBinding, IASTFileLo
|
||||||
private IString getExpansionInDB() throws CoreException {
|
private IString getExpansionInDB() throws CoreException {
|
||||||
Database db = fPDOM.getDB();
|
Database db = fPDOM.getDB();
|
||||||
int rec = db.getInt(fRecord + EXPANSION);
|
int rec = db.getInt(fRecord + EXPANSION);
|
||||||
return db.getString(rec);
|
return rec == 0 ? null : db.getString(rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IString getParamListInDB() throws CoreException {
|
private IString getParamListInDB() throws CoreException {
|
||||||
|
@ -215,13 +229,21 @@ public class PDOMMacro implements IIndexMacro, IIndexFragmentBinding, IASTFileLo
|
||||||
return fParameterList;
|
return fParameterList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMacroDefinition() throws CoreException {
|
||||||
|
if (fExpansion == UNINITIALIZED1) {
|
||||||
|
return fPDOM.getDB().getInt(fRecord + EXPANSION) != 0;
|
||||||
|
}
|
||||||
|
return fExpansion != null;
|
||||||
|
}
|
||||||
|
|
||||||
public char[] getExpansionImage() {
|
public char[] getExpansionImage() {
|
||||||
if (fExpansion == null) {
|
if (fExpansion == UNINITIALIZED1) {
|
||||||
try {
|
try {
|
||||||
fExpansion= getExpansionInDB().getChars();
|
final IString expansionInDB = getExpansionInDB();
|
||||||
|
fExpansion= expansionInDB == null ? null : expansionInDB.getChars();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
fExpansion= new char[] {};
|
fExpansion= CharArrayUtils.EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fExpansion;
|
return fExpansion;
|
||||||
|
@ -343,7 +365,10 @@ public class PDOMMacro implements IIndexMacro, IIndexFragmentBinding, IASTFileLo
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IIndexFragmentName getDefinition() {
|
public IIndexFragmentName getDefinition() throws CoreException {
|
||||||
|
if (!isMacroDefinition()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (fDefinition == null) {
|
if (fDefinition == null) {
|
||||||
fDefinition= new PDOMMacroDefinitionName(this);
|
fDefinition= new PDOMMacroDefinitionName(this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue