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;
}
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++) {

View file

@ -71,7 +71,7 @@ public class BasicIncludeBrowserTest extends IncludeBrowserBaseTest {
// #include "user.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);
try {
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.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);