Bug 292229 - include file completion ignores files without file extension
Summary: include file completion ignores files without file extension
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: 6.0.1   Edit
Hardware: PC Linux
: P3 normal with 2 votes (vote)
Target Milestone: 9.3.0   Edit
Assignee: Nathan Ridge CLA
QA Contact: Anton Leherbauer CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-14 05:21 EDT by Alex Richardson CLA
Modified: 2017-02-07 20:47 EST (History)
4 users (show)

See Also:


Attachments
List of Qt headers (25.09 KB, text/plain)
2009-10-22 08:54 EDT, Alex Richardson CLA
no flags Details
List of KDE headers (19.90 KB, text/plain)
2009-10-22 08:55 EDT, Alex Richardson CLA
no flags Details
Bundle to register Qt and KDE headers as "cxxHeader" content-type (10.66 KB, application/java-archive)
2009-10-26 04:00 EDT, Anton Leherbauer CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Richardson CLA 2009-10-14 05:21:32 EDT
User-Agent:       Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.3) Gecko/20090909 SUSE/3.5.3-3.1 Firefox/3.5.3
Build Identifier: Build id: I20090917-0100

Content assist with #include ignores files without a file extension.
This is quite annoying since I do a lot of Qt/KDE development and those header files are mostly without a file extension (i.e. #inlude <QString> or #include <KDebug>)

It is impossible to create a wildcard string for include files like "Q*" or "K*",
since you aren't allowed to create one without a file extension.

Searching for files without a file extension would also remove the need to define all the STL headers in General->Content Types-> C++ Headers

Reproducible: Always
Comment 1 Markus Schorn CLA 2009-10-14 06:54:32 EDT
(In reply to comment #0)
The InclusionProposal computer should be changed in order to allow files without extension. The content type for the stl-headers still makes sense because it determines the editor that will be used to present the file.
Comment 2 Markus Schorn CLA 2009-10-21 09:10:41 EDT
Hmm, when proposing the files without extension we end up proposing things like 'Makefile', 'Readme' and other useless files. I tend to think that we
should leave the implementation as it is.
Comment 3 Alex Richardson CLA 2009-10-21 12:39:42 EDT
(In reply to comment #2)
> Hmm, when proposing the files without extension we end up proposing things like
> 'Makefile', 'Readme' and other useless files. I tend to think that we
> should leave the implementation as it is.

How about limiting completion to external include files?
Files in workspace would only be autocompleted if they have the correct suffix.
So any files in /usr/include would be autocompleted since this directory should only contain headers anyway.

Another alternative would be to allow patterns like "Q*" or "K*" for header files, forcing a file extension is IMHO stupid anyway. This would stop files like Makefile etc showing up and it would also solve my problem.
Problem could be that this would require changes outside of the CDT but I have no idea there.
Comment 4 Anton Leherbauer CLA 2009-10-22 03:32:49 EDT
(In reply to comment #3)
> Another alternative would be to allow patterns like "Q*" or "K*" for header
> files, forcing a file extension is IMHO stupid anyway. This would stop files
> like Makefile etc showing up and it would also solve my problem.
> Problem could be that this would require changes outside of the CDT but I have
> no idea there.

See bug 263316.

The proper solution for now is to add all Qt/KDE headers as C++ content type as we do already with the C++ STL headers.  We won't include this list in CDT, but could this not be included in the Qt Eclipse integration that Nokia provides?
In any case, if you provide a list of relevant file names, I'd be willing to create a plug-in which you can drop in your installation.
Comment 5 Alex Richardson CLA 2009-10-22 08:54:04 EDT
(In reply to comment #4)
> The proper solution for now is to add all Qt/KDE headers as C++ content type as
> we do already with the C++ STL headers.  We won't include this list in CDT, but
> could this not be included in the Qt Eclipse integration that Nokia provides?
> In any case, if you provide a list of relevant file names, I'd be willing to
> create a plug-in which you can drop in your installation.

I agree this should be part of the Qt integration, as far as I know they wanted to move it to an open development process, like the Qt library, but until then I don't think that will change.
Comment 6 Alex Richardson CLA 2009-10-22 08:54:33 EDT
Created attachment 150234 [details]
List of Qt headers
Comment 7 Alex Richardson CLA 2009-10-22 08:55:20 EDT
Created attachment 150235 [details]
List of KDE headers

This is not a complete list, but all of those installed on my PC
Comment 8 Anton Leherbauer CLA 2009-10-26 04:00:21 EDT
Created attachment 150487 [details]
Bundle to register Qt and KDE headers as "cxxHeader" content-type

Drop this jar in the dropins folder of your Eclipse installation.
Comment 9 Alex Richardson CLA 2009-10-26 09:35:59 EDT
Thank you very much, works perfectly.
Comment 10 Anton Leherbauer CLA 2009-10-27 04:02:35 EDT
Ok, that's all we can do for now.
Comment 11 Alex Richardson CLA 2013-07-23 09:07:02 EDT
Now that there is a Qt integration plugin in CDT, wouldn't it make sense to add that list there? It seems there is no bugzilla category for it, though.

Also this workaround is not quite sufficient: every time a new Qt version (or anything else that uses CamelCase headers) is out this plugin has to be updated.

Is it not possible to consider files without an extension in the include completion due to underlying eclipse restrictions?
I don't mind if file associations don't work (i.e. headers without an extension don't get opened in CDT editor) but it would be EXTREMELY useful to consider them when pressing Ctrl+Space after #include <
Comment 12 Pavel Mendl CLA 2014-02-14 12:31:45 EST
I second this, it is REALLY annoying that headers without a file extension are not recognised. I am currently trying to make some patch to the KDE plasmoid, which has includes without extension inside the code. I am getting plenty of parse errors about not found types, which are defined inside the no-ext headers. I obviously can not change oficial version repo to use extensions ;-) .

For some reason (time gap since patch till my 3.8 Eclipse version ?) the above mentioned workaround does not work even if the dropped jar appears as Resolved in the Eclipse startup log.
Comment 13 Hedayat Vatankhah CLA 2014-09-19 11:59:58 EDT
It might seem weird, but IMHO suggesting files like Readme and Makefile is not that bad. The user will start typing some first letters and the list will be considerably filtered. And also, you are already forced to include all directories in your proposal list anyway.

A (somewhat) conservative suggestion would be to list ALL files in registered include directories into the proposal list (not only the ones without suffix, but also the ones with ANY suffix).

But I'd even suggest including all possible files without considering their extension completely. Because it is legimitate in C/C++, and a user might really want to include "Readme". Another example would be including .xpm files, which is completely reasonable (as they are actually C code defining variable). And personally have included even some .cpp files (I don't remember why, but it can be reasonable when you have a number of functions which might/might not be compiled as inline). 

If you'd like to help the developer to find its way among (probably) many suggestions, you can add some high level ordering: first, order files with matching case (so, when you start your header file name with "Q", Qt standard header files will appear first while they don't have any extensions; but if you type "q" header files with .h extension will appear first), then the files with recognized header extensions (e.g. .h & .hpp), then the files with no extensions, and finally files with other extensions. 

Note that it is all about header file completion; so it shouldn't affect how such files are opened in Eclipse (as a side note, eclipse already opens Qt standard header files as C/C++ code when they are opened using F3, which is IMHO great!).
Comment 14 Eclipse Genie CLA 2017-01-17 21:56:58 EST
New Gerrit change created: https://git.eclipse.org/r/88920
Comment 15 Eclipse Genie CLA 2017-01-17 21:57:04 EST
New Gerrit change created: https://git.eclipse.org/r/88919
Comment 16 Nathan Ridge CLA 2017-01-17 22:00:43 EST
Here's what I implemented:

  - Files that are not known to be C/C++ header files are
    now considered for inclusion proposals, but ranked below
    files that are known to be C/C++ header files.

  - Files that are known to be C/C++ *source* files are
    still excluded, as are files with names beginning with a
    '.' (as we almost certainly want to exclude things like
    .project, .cproject, and similar).
Comment 19 Nathan Ridge CLA 2017-01-24 16:29:55 EST
Fixed for 9.3.
Comment 20 Nathan Ridge CLA 2017-02-07 20:47:36 EST
Mentioned in the 9.3 N&N: https://wiki.eclipse.org/CDT/User/NewIn93#Included_files_with_no_file_extension