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 f6f5c398adb..e82066e8d80 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 @@ -181,25 +181,12 @@ public class CIndex implements IIndex { return null; } IIndexFragmentInclude fragmentInclude = (IIndexFragmentInclude) include; - IIndexFragment frag= fragmentInclude.getFragment(); - if (isPrimaryFragment(frag)) { - IIndexFile result= fragmentInclude.getIncludes(); - if (result != null) { - return result; - } + IIndexFragmentFile result= fragmentInclude.getIncludes(); + if (result != null && result.hasNames()) { + return result; } - IIndexFileLocation location= include.getIncludesLocation(); - for (int i = 0; i < fPrimaryFragmentCount; i++) { - IIndexFragment otherFrag = fFragments[i]; - if (otherFrag != frag) { - IIndexFile result= otherFrag.getFile(location); - if (result != null) { - return result; - } - } - } - return null; + return getFile(include.getIncludesLocation()); } public IIndexInclude[] findIncludedBy(IIndexFile file) throws CoreException { @@ -253,20 +240,17 @@ public class CIndex implements IIndex { List nextLevel= depth != 0 ? new LinkedList() : null; for (Iterator it= in.iterator(); it.hasNext(); ) { IIndexFragmentFile file = (IIndexFragmentFile) it.next(); - IIndexFragment frag= file.getIndexFragment(); - if (isPrimaryFragment(frag)) { - IIndexInclude[] includes= file.getIncludes(); - for (int k= 0; k < includes.length; k++) { - IIndexInclude include = includes[k]; - IIndexFileLocation target= include.getIncludesLocation(); - Object key= target != null ? (Object) target : include.getName(); - if (handled.add(key)) { - out.add(include); - if (depth != 0) { - IIndexFile includedByFile= resolveInclude(include); - if (includedByFile != null) { - nextLevel.add(includedByFile); - } + IIndexInclude[] includes= file.getIncludes(); + for (int k= 0; k < includes.length; k++) { + IIndexInclude include = includes[k]; + IIndexFileLocation target= include.getIncludesLocation(); + Object key= target != null ? (Object) target : include.getName(); + if (handled.add(key)) { + out.add(include); + if (depth != 0) { + IIndexFile includedByFile= resolveInclude(include); + if (includedByFile != null) { + nextLevel.add(includedByFile); } } } @@ -405,16 +389,7 @@ public class CIndex implements IIndex { System.arraycopy(fFragments, 0, result, 0, fPrimaryFragmentCount); return result; } - - private boolean isPrimaryFragment(IIndexFragment frag) { - for (int i = 0; i < fPrimaryFragmentCount; i++) { - if (frag == fFragments[i]) { - return true; - } - } - return false; - } - + public IIndexFragmentBinding[] findEquivalentBindings(IBinding binding) throws CoreException { List result = new ArrayList(); for (int i = 0; i < fFragments.length; i++) { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java index 83d2cd16fc8..281db2ae657 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/includebrowser/BasicIncludeBrowserTest.java @@ -71,7 +71,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest { // #include "user.h" // #include - public void _testInclusionAccrossProjects() throws Exception { + public void testInclusionAccrossProjects() throws Exception { ICProject op= CProjectHelper.createCCProject("__ibTest_other__", "bin", IPDOMManager.ID_FAST_INDEXER); try { IndexerPreferences.set(op.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true"); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java index c6cb3cd1f8c..dd6731e3674 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBContentProvider.java @@ -23,7 +23,7 @@ import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IIndexInclude; -import org.eclipse.cdt.core.index.IIndexManager; +import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.ui.CUIPlugin; @@ -79,8 +79,8 @@ public class IBContentProvider extends AsyncTreeContentProvider { IIndex index; try { - index = CCorePlugin.getIndexManager().getIndex(project, - fComputeIncludedBy ? IIndexManager.ADD_DEPENDENT : IIndexManager.ADD_DEPENDENCIES); + ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects(); + index= CCorePlugin.getIndexManager().getIndex(scope); index.acquireReadLock(); } catch (CoreException e) { CUIPlugin.getDefault().log(e);