mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 08:45:44 +02:00
Allow Include Browser to work accross projects.
This commit is contained in:
parent
9cb27b5066
commit
8ea9103fcf
2 changed files with 53 additions and 23 deletions
|
@ -101,11 +101,16 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
||||||
catch (CoreException e) {
|
catch (CoreException e) {
|
||||||
CUIPlugin.getDefault().log(e.getStatus());
|
CUIPlugin.getDefault().log(e.getStatus());
|
||||||
}
|
}
|
||||||
|
catch (InterruptedException e) {
|
||||||
|
CUIPlugin.getDefault().log(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NO_CHILDREN;
|
return NO_CHILDREN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void setComputeIncludedBy(boolean value) {
|
public void setComputeIncludedBy(boolean value) {
|
||||||
fComputeIncludedBy = value;
|
fComputeIncludedBy = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,11 @@
|
||||||
package org.eclipse.cdt.internal.ui.missingapi;
|
package org.eclipse.cdt.internal.ui.missingapi;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -20,6 +25,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
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;
|
||||||
|
@ -75,27 +81,40 @@ public class CIndexQueries {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CIndexQueries() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public IPDOMInclude[] findIncludedBy(ITranslationUnit tu, IProgressMonitor pm) throws CoreException {
|
public IPDOMInclude[] findIncludedBy(ITranslationUnit tu, IProgressMonitor pm) throws CoreException, InterruptedException {
|
||||||
|
HashMap result= new HashMap();
|
||||||
|
LinkedList projects= new LinkedList(Arrays.asList(CoreModel.getDefault().getCModel().getCProjects()));
|
||||||
ICProject cproject= tu.getCProject();
|
ICProject cproject= tu.getCProject();
|
||||||
if (cproject != null) {
|
if (cproject != null) {
|
||||||
|
projects.remove(cproject);
|
||||||
|
projects.addFirst(cproject);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Iterator iter = projects.iterator(); iter.hasNext();) {
|
||||||
|
cproject = (ICProject) iter.next();
|
||||||
PDOM pdom= (PDOM) CCorePlugin.getPDOMManager().getPDOM(cproject);
|
PDOM pdom= (PDOM) CCorePlugin.getPDOMManager().getPDOM(cproject);
|
||||||
if (pdom != null) {
|
if (pdom != null) {
|
||||||
|
pdom.acquireReadLock();
|
||||||
|
try {
|
||||||
PDOMFile fileTarget= pdom.getFile(locationForTU(tu));
|
PDOMFile fileTarget= pdom.getFile(locationForTU(tu));
|
||||||
if (fileTarget != null) {
|
if (fileTarget != null) {
|
||||||
ArrayList result= new ArrayList();
|
|
||||||
PDOMInclude include= fileTarget.getFirstIncludedBy();
|
PDOMInclude include= fileTarget.getFirstIncludedBy();
|
||||||
while (include != null) {
|
while (include != null) {
|
||||||
result.add(new IPDOMInclude(include));
|
PDOMFile file= include.getIncludedBy();
|
||||||
|
String path= file.getFileName().getString();
|
||||||
|
result.put(path, new IPDOMInclude(include));
|
||||||
include= include.getNextInIncludedBy();
|
include= include.getNextInIncludedBy();
|
||||||
}
|
}
|
||||||
return (IPDOMInclude[]) result.toArray(new IPDOMInclude[result.size()]);
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
pdom.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return EMPTY_INCLUDES;
|
Collection includes= result.values();
|
||||||
|
return (IPDOMInclude[]) includes.toArray(new IPDOMInclude[includes.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IPath locationForTU(ITranslationUnit tu) {
|
private IPath locationForTU(ITranslationUnit tu) {
|
||||||
|
@ -106,11 +125,13 @@ public class CIndexQueries {
|
||||||
return tu.getPath();
|
return tu.getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPDOMInclude[] findIncludesTo(ITranslationUnit tu, IProgressMonitor pm) throws CoreException {
|
public IPDOMInclude[] findIncludesTo(ITranslationUnit tu, IProgressMonitor pm) throws CoreException, InterruptedException {
|
||||||
ICProject cproject= tu.getCProject();
|
ICProject cproject= tu.getCProject();
|
||||||
if (cproject != null) {
|
if (cproject != null) {
|
||||||
PDOM pdom= (PDOM) CCorePlugin.getPDOMManager().getPDOM(cproject);
|
PDOM pdom= (PDOM) CCorePlugin.getPDOMManager().getPDOM(cproject);
|
||||||
if (pdom != null) {
|
if (pdom != null) {
|
||||||
|
pdom.acquireReadLock();
|
||||||
|
try {
|
||||||
PDOMFile fileTarget= pdom.getFile(locationForTU(tu));
|
PDOMFile fileTarget= pdom.getFile(locationForTU(tu));
|
||||||
if (fileTarget != null) {
|
if (fileTarget != null) {
|
||||||
ArrayList result= new ArrayList();
|
ArrayList result= new ArrayList();
|
||||||
|
@ -122,6 +143,10 @@ public class CIndexQueries {
|
||||||
return (IPDOMInclude[]) result.toArray(new IPDOMInclude[result.size()]);
|
return (IPDOMInclude[]) result.toArray(new IPDOMInclude[result.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
pdom.releaseReadLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return EMPTY_INCLUDES;
|
return EMPTY_INCLUDES;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue