mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-18 13:45:45 +02:00
Fallback to a search on the project.
This commit is contained in:
parent
a289e10de1
commit
6a5352c615
1 changed files with 21 additions and 11 deletions
|
@ -23,6 +23,8 @@ import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.IResourceProxy;
|
||||||
|
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
@ -83,7 +85,8 @@ public class OpenIncludeAction extends Action {
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
String[] includePaths = info.getIncludePaths();
|
String[] includePaths = info.getIncludePaths();
|
||||||
findFile(includePaths, includeName, filesFound);
|
findFile(includePaths, includeName, filesFound);
|
||||||
} else {
|
}
|
||||||
|
if (filesFound.size() == 0) {
|
||||||
// Fall back and search the project
|
// Fall back and search the project
|
||||||
findFile(proj, new Path(includeName), filesFound);
|
findFile(proj, new Path(includeName), filesFound);
|
||||||
}
|
}
|
||||||
|
@ -125,17 +128,24 @@ public class OpenIncludeAction extends Action {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void findFile(IContainer parent, IPath name, ArrayList list) throws CoreException {
|
/**
|
||||||
IResource found= parent.findMember(name);
|
* Recuse in the project.
|
||||||
if (found != null && found.getType() == IResource.FILE) {
|
* @param parent
|
||||||
list.add(found.getLocation());
|
* @param name
|
||||||
}
|
* @param list
|
||||||
IResource[] children= parent.members();
|
* @throws CoreException
|
||||||
for (int i= 0; i < children.length; i++) {
|
*/
|
||||||
if (children[i] instanceof IContainer) {
|
private void findFile(IContainer parent, final IPath name, final ArrayList list) throws CoreException {
|
||||||
findFile((IContainer)children[i], name, list);
|
parent.accept(new IResourceProxyVisitor() {
|
||||||
|
|
||||||
|
public boolean visit(IResourceProxy proxy) throws CoreException {
|
||||||
|
if (proxy.getType() == IResource.FILE && proxy.getName().equalsIgnoreCase(name.lastSegment())) {
|
||||||
|
list.add(proxy.requestResource().getLocation());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue