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

Using include browser across projects.

This commit is contained in:
Markus Schorn 2007-11-28 11:35:46 +00:00
parent 8c2d3a947d
commit e371aed0ca
3 changed files with 20 additions and 45 deletions

View file

@ -181,25 +181,12 @@ public class CIndex implements IIndex {
return null; return null;
} }
IIndexFragmentInclude fragmentInclude = (IIndexFragmentInclude) include; IIndexFragmentInclude fragmentInclude = (IIndexFragmentInclude) include;
IIndexFragment frag= fragmentInclude.getFragment(); IIndexFragmentFile result= fragmentInclude.getIncludes();
if (isPrimaryFragment(frag)) { if (result != null && result.hasNames()) {
IIndexFile result= fragmentInclude.getIncludes();
if (result != null) {
return result; return result;
} }
}
IIndexFileLocation location= include.getIncludesLocation(); return getFile(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;
} }
public IIndexInclude[] findIncludedBy(IIndexFile file) throws CoreException { public IIndexInclude[] findIncludedBy(IIndexFile file) throws CoreException {
@ -253,8 +240,6 @@ public class CIndex implements IIndex {
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();
IIndexFragment frag= file.getIndexFragment();
if (isPrimaryFragment(frag)) {
IIndexInclude[] includes= file.getIncludes(); IIndexInclude[] includes= file.getIncludes();
for (int k= 0; k < includes.length; k++) { for (int k= 0; k < includes.length; k++) {
IIndexInclude include = includes[k]; IIndexInclude include = includes[k];
@ -271,7 +256,6 @@ public class CIndex implements IIndex {
} }
} }
} }
}
if (depth == 0 || nextLevel.isEmpty()) { if (depth == 0 || nextLevel.isEmpty()) {
return; return;
} }
@ -406,15 +390,6 @@ public class CIndex implements IIndex {
return result; 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 { public IIndexFragmentBinding[] findEquivalentBindings(IBinding binding) throws CoreException {
List result = new ArrayList(); List result = new ArrayList();
for (int i = 0; i < fFragments.length; i++) { for (int i = 0; i < fFragments.length; i++) {

View file

@ -71,7 +71,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
// #include "user.h" // #include "user.h"
// #include <system.h> // #include <system.h>
public void _testInclusionAccrossProjects() throws Exception { public void testInclusionAccrossProjects() throws Exception {
ICProject op= CProjectHelper.createCCProject("__ibTest_other__", "bin", IPDOMManager.ID_FAST_INDEXER); ICProject op= CProjectHelper.createCCProject("__ibTest_other__", "bin", IPDOMManager.ID_FAST_INDEXER);
try { try {
IndexerPreferences.set(op.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true"); IndexerPreferences.set(op.getProject(), IndexerPreferences.KEY_INDEX_ALL_FILES, "true");

View file

@ -23,7 +23,7 @@ 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;
import org.eclipse.cdt.core.index.IIndexInclude; 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.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
@ -79,8 +79,8 @@ public class IBContentProvider extends AsyncTreeContentProvider {
IIndex index; IIndex index;
try { try {
index = CCorePlugin.getIndexManager().getIndex(project, ICProject[] scope= CoreModel.getDefault().getCModel().getCProjects();
fComputeIncludedBy ? IIndexManager.ADD_DEPENDENT : IIndexManager.ADD_DEPENDENCIES); index= CCorePlugin.getIndexManager().getIndex(scope);
index.acquireReadLock(); index.acquireReadLock();
} catch (CoreException e) { } catch (CoreException e) {
CUIPlugin.getDefault().log(e); CUIPlugin.getDefault().log(e);