1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 20:05:35 +02:00

Fix for 187965: Open include command should never display a dialog

This commit is contained in:
Anton Leherbauer 2007-05-21 08:59:15 +00:00
parent 4aad19fb50
commit 8d8105f635

View file

@ -79,15 +79,22 @@ public class OpenIncludeAction extends Action {
} }
public void run() { public void run() {
ICElement include= getIncludeStatement(fSelectionProvider.getSelection()); IInclude include= getIncludeStatement(fSelectionProvider.getSelection());
if (include == null) { if (include == null) {
return; return;
} }
try { try {
IResource res = include.getUnderlyingResource(); IResource res = include.getUnderlyingResource();
ArrayList filesFound = new ArrayList(4); ArrayList/*<IPath>*/ filesFound = new ArrayList(4);
if (res != null) { String fullFileName= include.getFullFileName();
if (fullFileName != null) {
IPath fullPath= new Path(fullFileName);
if (fullPath.isAbsolute() && fullPath.toFile().exists()) {
filesFound.add(fullPath);
}
}
if (filesFound.isEmpty() && res != null) {
IProject proj = res.getProject(); IProject proj = res.getProject();
String includeName = include.getElementName(); String includeName = include.getElementName();
// Search in the scannerInfo information // Search in the scannerInfo information
@ -101,12 +108,11 @@ public class OpenIncludeAction extends Action {
if (info != null) { if (info != null) {
IExtendedScannerInfo scanInfo = new ExtendedScannerInfo(info); IExtendedScannerInfo scanInfo = new ExtendedScannerInfo(info);
boolean isSystemInclude = include instanceof IInclude boolean isSystemInclude = include.isStandard();
&& ((IInclude) include).isStandard();
if (!isSystemInclude) { if (!isSystemInclude) {
// search in current directory // search in current directory
IPath location= ((IInclude)include).getTranslationUnit().getLocation(); IPath location= include.getTranslationUnit().getLocation();
if (location != null) { if (location != null) {
String currentDir= location.removeLastSegments(1).toOSString(); String currentDir= location.removeLastSegments(1).toOSString();
findFile(new String[] { currentDir }, includeName, filesFound); findFile(new String[] { currentDir }, includeName, filesFound);
@ -270,13 +276,13 @@ public class OpenIncludeAction extends Action {
} }
private static ICElement getIncludeStatement(ISelection sel) { private static IInclude getIncludeStatement(ISelection sel) {
if (!sel.isEmpty() && sel instanceof IStructuredSelection) { if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
List list= ((IStructuredSelection)sel).toList(); List list= ((IStructuredSelection)sel).toList();
if (list.size() == 1) { if (list.size() == 1) {
Object element= list.get(0); Object element= list.get(0);
if (element instanceof ICElement && ((ICElement)element).getElementType() == ICElement.C_INCLUDE) { if (element instanceof IInclude) {
return (ICElement)element; return (IInclude)element;
} }
} }
} }