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:
parent
8c2d3a947d
commit
e371aed0ca
3 changed files with 20 additions and 45 deletions
|
@ -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();
|
return result;
|
||||||
if (result != null) {
|
|
||||||
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,20 +240,17 @@ 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();
|
IIndexInclude[] includes= file.getIncludes();
|
||||||
if (isPrimaryFragment(frag)) {
|
for (int k= 0; k < includes.length; k++) {
|
||||||
IIndexInclude[] includes= file.getIncludes();
|
IIndexInclude include = includes[k];
|
||||||
for (int k= 0; k < includes.length; k++) {
|
IIndexFileLocation target= include.getIncludesLocation();
|
||||||
IIndexInclude include = includes[k];
|
Object key= target != null ? (Object) target : include.getName();
|
||||||
IIndexFileLocation target= include.getIncludesLocation();
|
if (handled.add(key)) {
|
||||||
Object key= target != null ? (Object) target : include.getName();
|
out.add(include);
|
||||||
if (handled.add(key)) {
|
if (depth != 0) {
|
||||||
out.add(include);
|
IIndexFile includedByFile= resolveInclude(include);
|
||||||
if (depth != 0) {
|
if (includedByFile != null) {
|
||||||
IIndexFile includedByFile= resolveInclude(include);
|
nextLevel.add(includedByFile);
|
||||||
if (includedByFile != null) {
|
|
||||||
nextLevel.add(includedByFile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -405,16 +389,7 @@ public class CIndex implements IIndex {
|
||||||
System.arraycopy(fFragments, 0, result, 0, fPrimaryFragmentCount);
|
System.arraycopy(fFragments, 0, result, 0, fPrimaryFragmentCount);
|
||||||
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++) {
|
||||||
|
|
|
@ -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");
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Add table
Reference in a new issue