1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

Fix for 175762: OpenIncludeAction only looks in system include directories, not local includes

This commit is contained in:
Anton Leherbauer 2007-03-23 10:49:39 +00:00
parent a392abe467
commit 31f276dafa

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2006 IBM Corporation and others.
* Copyright (c) 2005, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -10,6 +10,7 @@
* QNX Software System
* Sergey Prigogin, Google - https://bugs.eclipse.org/bugs/show_bug.cgi?id=13221
* Ed Swartz (Nokia)
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.editor;
@ -43,6 +44,7 @@ import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IInclude;
import org.eclipse.cdt.core.parser.ExtendedScannerInfo;
import org.eclipse.cdt.core.parser.IExtendedScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfo;
@ -96,26 +98,39 @@ public class OpenIncludeAction extends Action {
if (info == null) {
info = provider.getScannerInformation(proj);
}
if (info != null) {
// search in system includes
String[] includePaths = info.getIncludePaths();
findFile(includePaths, includeName, filesFound);
}
if (filesFound.size() == 0) {
// search in local includes
if (info != null) {
IExtendedScannerInfo scanInfo = new ExtendedScannerInfo(info);
boolean isSystemInclude = include instanceof IInclude
&& ((IInclude) include).isStandard();
if (!isSystemInclude) {
// search in current directory
IPath location= ((IInclude)include).getTranslationUnit().getLocation();
if (location != null) {
String currentDir= location.removeLastSegments(1).toOSString();
findFile(new String[] { currentDir }, includeName, filesFound);
}
if (filesFound.isEmpty()) {
// search in "..." include directories
String[] localIncludePaths = scanInfo.getLocalIncludePath();
findFile(localIncludePaths, includeName, filesFound);
}
}
if (filesFound.size() == 0) {
if (filesFound.isEmpty()) {
// search in <...> include directories
String[] includePaths = scanInfo.getIncludePaths();
findFile(includePaths, includeName, filesFound);
}
}
if (filesFound.isEmpty()) {
// Fall back and search the project
findFile(proj, new Path(includeName), filesFound);
}
}
}
}
IPath fileToOpen;
int nElementsFound= filesFound.size();
if (nElementsFound == 0) {