mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
uses builder api to get include paths
This commit is contained in:
parent
5374d486e7
commit
2b119fa9e9
1 changed files with 19 additions and 36 deletions
|
@ -27,13 +27,14 @@ import org.eclipse.ui.IEditorDescriptor;
|
|||
import org.eclipse.ui.IEditorRegistry;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import org.eclipse.cdt.internal.core.CommonMkInfo;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.dialogs.ElementListSelectionDialog;
|
||||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
||||
import org.eclipse.cdt.internal.ui.CPlugin;
|
||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.builder.ICBuilder;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
||||
|
@ -83,48 +84,30 @@ public class OpenIncludeAction extends Action {
|
|||
|
||||
if (fileToOpen != null) {
|
||||
EditorUtility.openInEditor(fileToOpen);
|
||||
//IWorkbenchWindow window= CPlugin.getActiveWorkbenchWindow();
|
||||
//if (window != null) {
|
||||
// IWorkbenchPage p= window.getActivePage();
|
||||
// if (p != null) {
|
||||
// p.openEditor(fileToOpen);
|
||||
// }
|
||||
//}
|
||||
} else { // Try to get via the include path.
|
||||
|
||||
|
||||
CommonMkInfo mk = null;
|
||||
if (res != null)
|
||||
mk = new CommonMkInfo(res.getProject().getLocation());
|
||||
else
|
||||
mk = new CommonMkInfo();
|
||||
IPath[] paths = mk.getIncludePaths();
|
||||
|
||||
|
||||
ICBuilder[] builders = CCorePlugin.getDefault().getBuilders(res.getProject());
|
||||
|
||||
IPath includePath = null;
|
||||
for (int i = 0; i < paths.length; i++) {
|
||||
if (res != null) {
|
||||
// We've already scan the project.
|
||||
if (paths[i].isPrefixOf(res.getProject().getLocation()))
|
||||
continue;
|
||||
}
|
||||
IPath path = paths[i].append(include.getElementName());
|
||||
if (path.toFile().exists()) {
|
||||
includePath = path;
|
||||
break;
|
||||
for( int j = 0; includePath == null && j < builders.length; j++ ) {
|
||||
IPath[] paths = builders[j].getIncludePaths();
|
||||
|
||||
for (int i = 0; i < paths.length; i++) {
|
||||
if (res != null) {
|
||||
// We've already scan the project.
|
||||
if (paths[i].isPrefixOf(res.getProject().getLocation()))
|
||||
continue;
|
||||
}
|
||||
IPath path = paths[i].append(include.getElementName());
|
||||
if (path.toFile().exists()) {
|
||||
includePath = path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (includePath != null) {
|
||||
EditorUtility.openInEditor(includePath);
|
||||
//IStorage s = new FileStorage(includePath);
|
||||
//IEditorInput ei = new ExternalEditorInput(s);
|
||||
//IWorkbenchWindow window= CPlugin.getActiveWorkbenchWindow();
|
||||
//if (window != null) {
|
||||
// IWorkbenchPage p = window.getActivePage();
|
||||
// if (p != null) {
|
||||
// p.openEditor(ei, getEditorID(include.getName()));
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
|
|
Loading…
Add table
Reference in a new issue