Bug 175762 - OpenIncludeAction only looks in system include directories, not local includes
Summary: OpenIncludeAction only looks in system include directories, not local includes
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 4.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 4.0 M6   Edit
Assignee: Anton Leherbauer CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-02-27 18:11 EST by Warren Paul CLA
Modified: 2009-01-09 15:04 EST (History)
0 users

See Also:


Attachments
patch file. (1.84 KB, patch)
2007-02-27 18:12 EST, Warren Paul CLA
bjorn.freeman-benson: iplog+
Details | Diff
another patch to correct search order (2.10 KB, patch)
2007-03-19 14:49 EDT, Ed Swartz CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Warren Paul CLA 2007-02-27 18:11:51 EST
Build ID: M20060921-0945

Steps To Reproduce:
1. If you have more than one header file of the same name under the project root, the OpenIncludeAction will put them all in a list dialog and ask you to pick a file.
2.  That's normally OK, but if only one of those files is in an include path then you shouldn't get the dialog at all.  It should just open that file.


More information:
The problem is that OpenIncludeAction looks in system include directories and if not found just searches the whole project.

The attached patch checks in the user include paths if not found in the system include paths, and then falls back to the whole project if still not found.
Comment 1 Warren Paul CLA 2007-02-27 18:12:21 EST
Created attachment 59929 [details]
patch file.
Comment 2 Anton Leherbauer CLA 2007-03-02 09:42:54 EST
Good catch! Thanks for the patch, I applied it to HEAD.
Comment 3 Warren Paul CLA 2007-03-19 14:45:19 EDT
There is another problem with this if there is a header of the same name in both the user and system include paths.  The wrong file can be opened.  There needs to be a check for the type of include I believe.
Comment 4 Ed Swartz CLA 2007-03-19 14:49:20 EDT
Created attachment 61322 [details]
another patch to correct search order

The previous patch was not quite correct.  This patch amends its behavior (it can be applied on top and is not a replacement).  

The current behavior doesn't distinguish #include <...> from #include "...", and always searches system directories first, so it can find the incorrect version of a header (e.g. when the user has an override).

A test is, add a stddef.h file to a project include directory and have a source file with:

#include "stddef.h"

This should find the version in the project, not the one in the compiler headers or C library.
Comment 5 Anton Leherbauer CLA 2007-03-20 09:13:06 EDT
While we are at it, the directory of the current file is also part of the "..." search path, right? Could you update the patch to handle this case, too?
Comment 6 Anton Leherbauer CLA 2007-03-23 06:49:30 EDT
Never mind, I did it myself. Please verify. Thanks!
Comment 7 Ed Swartz CLA 2007-03-28 08:51:50 EDT
Sorry, I missed your last question.  I think searching the current directory for "..." includes is okay (and matches the scanner behavior).