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:
parent
0f94639612
commit
229bbeea3d
2 changed files with 10 additions and 4 deletions
|
@ -44,12 +44,19 @@ public class IncludesTests extends PDOMTestBase {
|
||||||
pdom.releaseReadLock();
|
pdom.releaseReadLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void test1() throws Exception {
|
public void testIncludedBy() throws Exception {
|
||||||
IPath loc = project.getProject().getLocation().append("I2.h");
|
IPath loc = project.getProject().getLocation().append("I2.h");
|
||||||
IIndexFile file = pdom.getFile(loc);
|
IIndexFile file = pdom.getFile(loc);
|
||||||
assertNotNull(file);
|
assertNotNull(file);
|
||||||
IIndexInclude[] allIncludedBy = pdom.findIncludedBy(file, -1);
|
IIndexInclude[] allIncludedBy = pdom.findIncludedBy(file, -1);
|
||||||
assertEquals(9, allIncludedBy.length); // i.e. all of them
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,11 +241,10 @@ public class CIndex implements IIndex {
|
||||||
public IIndexInclude[] findIncludes(IIndexFile file, int depth) throws CoreException {
|
public IIndexInclude[] findIncludes(IIndexFile file, int depth) throws CoreException {
|
||||||
List result= new ArrayList();
|
List result= new ArrayList();
|
||||||
findIncludes(Collections.singletonList(file), result, depth, new HashSet());
|
findIncludes(Collections.singletonList(file), result, depth, new HashSet());
|
||||||
result= result.subList(1, result.size());
|
|
||||||
return (IIndexInclude[]) result.toArray(new IIndexInclude[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;
|
List nextLevel= depth != 0 ? new LinkedList() : null;
|
||||||
for (Iterator it= in.iterator(); it.hasNext(); ) {
|
for (Iterator it= in.iterator(); it.hasNext(); ) {
|
||||||
IIndexFragmentFile file = (IIndexFragmentFile) it.next();
|
IIndexFragmentFile file = (IIndexFragmentFile) it.next();
|
||||||
|
|
Loading…
Add table
Reference in a new issue