From 229bbeea3d5e515c97e7e217a53bee72c13bc157 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Mon, 30 Oct 2006 16:00:37 +0000 Subject: [PATCH] Fix for 162747, IIndex.findIncludes() --- .../cdt/internal/pdom/tests/IncludesTests.java | 11 +++++++++-- .../org/eclipse/cdt/internal/core/index/CIndex.java | 3 +-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IncludesTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IncludesTests.java index 5cbc3a1cc84..f281fdec060 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IncludesTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/IncludesTests.java @@ -44,12 +44,19 @@ 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); IIndexInclude[] allIncludedBy = pdom.findIncludedBy(file, -1); 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 + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java index d9fc72947d7..fd54aa5ee81 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CIndex.java @@ -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();