1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 162747, IIndex.findIncludes()

This commit is contained in:
Markus Schorn 2006-10-30 16:00:37 +00:00
parent 0f94639612
commit 229bbeea3d
2 changed files with 10 additions and 4 deletions

View file

@ -44,7 +44,7 @@ public class IncludesTests extends PDOMTestBase {
pdom.releaseReadLock();
}
public void test1() throws Exception {
public void testIncludedBy() throws Exception {
IPath loc = project.getProject().getLocation().append("I2.h");
IIndexFile file = pdom.getFile(loc);
assertNotNull(file);
@ -52,4 +52,11 @@ public class IncludesTests extends PDOMTestBase {
assertEquals(9, allIncludedBy.length); // i.e. all of them
}
public void testIncludes() throws Exception {
IPath loc = project.getProject().getLocation().append("I1.cpp");
IIndexFile file = pdom.getFile(loc);
assertNotNull(file);
IIndexInclude[] allIncludesTo= pdom.findIncludes(file, -1);
assertEquals(2, allIncludesTo.length); // i.e. I1.h, I2.h
}
}

View file

@ -241,11 +241,10 @@ public class CIndex implements IIndex {
public IIndexInclude[] findIncludes(IIndexFile file, int depth) throws CoreException {
List result= new ArrayList();
findIncludes(Collections.singletonList(file), result, depth, new HashSet());
result= result.subList(1, result.size());
return (IIndexInclude[]) result.toArray(new IIndexInclude[result.size()]);
}
public void findIncludes(List in, List out, int depth, HashSet handled) throws CoreException {
private void findIncludes(List in, List out, int depth, HashSet handled) throws CoreException {
List nextLevel= depth != 0 ? new LinkedList() : null;
for (Iterator it= in.iterator(); it.hasNext(); ) {
IIndexFragmentFile file = (IIndexFragmentFile) it.next();