The libhover
plug-in for Eclipse provides plug-and-play hover help support for the GNU C Library and GNU C++ Standard Library. This allows developers to see existing documentation on glibc
and libstdc++
libraries within the Eclipse IDE in a more seamless and convenient manner via hover help and code completion.
C++ Language
Documentation for method completion is not supported for C++; only the prototypes from header files are supplied. In addition, the ability to add header files to the source file is not supported for C++ methods.
For C++ library resources, libhover
has to index the file using the CDT indexer. Indexing parses the given file in context of a build; the build context determines where header files come from and how types, macros, and similar items are resolved. To be able to index a C++ source file, libhover
usually requires an actual build to be performed first, although in some cases it may already know where the header files are located.
A C++ member function name is not enough information to look up its documentation so the libhover
plug-in may require indexing for C++ sources. C++ allows different classes to have members of the same name, and even within a class, members may have the same name but with different method signatures. This requires the class name and parameter signature of the function to be provided to determine exactly which member is being referenced.
In addition, C++ also has type definitions and templated classes. Such information requires parsing an entire file and its associated include
files; libhover
can only do this via indexing.
C Language
For C functions, performing a completion (Ctrl+Space) will provide the list of C functions added to the potential sources (for example, typing prin and then hitting Ctrl+Space will list printf as one of the possible completions) and the documentation is viewed in an additional window, for determining exactly what C function is required.
Figure 1.21. Using Code Completion
C functions can be referenced in their documentation by name alone. As such, libhover
does not have to index C source files in order to provide hover help or code completion. The appropriate header file include statement for a C library function can be automatically added if it is not already present.
Select the C function in the file and use right-click > Source > Add Include to automatically add the required header files to the source. This can also be done using Shift+Ctrl+N.
1.3.1.1. Setup and Usage
Hover help for all installed libhover
libraries is enabled by default, and it can be disabled per project. To disable or enable hover help for a particular project, right-click the project name and click Properties. On the menu that appears, navigate to C/C++ General > Documentation. Check or uncheck a library in the Help books section to enable or disable hover help for that particular library.
Figure 1.22. Enabling/Disabling Hover Help
Disabling hover help from a particular library may be preferable, particularly if multiple libhover
libraries overlap in functionality. For example, if a libhover
plug-in for a C library were manually installed, such as the newlib
C library (note that newlib
C library plug-in is not provided in Red Hat Enterprise Linux 6). The hover help would contain C functions whos names overlap with those in the GNU C library (provided by default). A user would not want both of these hover helps active at once, so disabling one would be practical.
When multiple libhover
libraries are enabled and there exists a functional overlap between libraries, the Help content for the function from the first listed library in the Help books section will appear in hover help (that is, in Figure 1.22, “Enabling/Disabling Hover Help”, glibc
). For code completion, libhover
will offer all possible alternatives from all enabled libhover
libraries.
To use hover help, hover the mouse over a function name or member function name in theC/C++ Editor. After a short time, no more than a few seconds, libhover
will display library documentation on the selected C function or C++ member function.
Figure 1.23. Using Hover Help