Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] TextHover patch

A patch to provide TextHover capability to CDT is available at

http://people.redhat.com/cmoller/TextHoverPatch/

What it Does:

If a user leaves the pointer on a text string for a couple of seconds, TextHover tries to look up that string in a database of known C/C++ library functions.  If the string is found, information pertaining to that function is  displayed in a popup until the pointer is moved.  This initial release contains databases for the standard C library, glibc, as well as for the GTK+ libraries: GTK, GDK, and GDK-pixbuf; other databases can be easily added.


How it Works:

When getHoverInfo() in DefaultCEditorTextHover() is invoked, completion is attempted using the already-present completion code (CCompletionContributorManager.getDefault()).  If completion returns no results, the string being queried is passed to the new TextHover code which attempts to locate it in any of the available databases implemented as Java properties files.  If the string is found, relevant data is retrived and formatted for display.  The reference is also cached for faster future access.


Patch Details:

The patch is contained in two files: org.eclipse.cdt.ui-TextHover.patch and org.eclipse.cdt.ui-TextHover-new-files.tar.gz.  The patch file itself affects only files in the org.eclipse.cdt.ui directory:

    ChangeLog
    build.properties    -- to include the database property files in cdtui.jar
    plugin.xml            -- to add a text hover extension point
    src/org/eclipse/cdt/internal/ui/editor/DefaultCEditorTextHover.java      -- to invoke text hover

The targz file contains the database property files:

    src/org/eclipse/cdt/internal/ui/GDK-HoverHelp.properties
    src/org/eclipse/cdt/internal/ui/GDK-pixbuf-HoverHelp.properties
    src/org/eclipse/cdt/internal/ui/GTK-HoverHelp.properties
    src/org/eclipse/cdt/internal/ui/glibc-HoverHelp.properties

and the Java implementation of the capability:

    src/org/eclipse/cdt/internal/ui/CTextHover.java
    src/org/eclipse/cdt/internal/ui/CTextHoverContributorManager.java
    src/org/eclipse/cdt/ui/ICTextHover.java


TODO List:

-- The first time text hover is invoked, it reads the properties files which takes significant time (~10s on my 733 MHz P-III), during which the user will probably conclude the lookup has failed.  The first item on the TODO list is to add a progress bar or something similar.
-- The text hover is capable of searching along a path for database property files, and of looking only for a specific subset of such files (e.g., skipping the GTK+ files if the user isn't using GTK+).  The use of a path will alow users to precede the built-in databases with updated ones, or add special purpose databases (e.g., databases of all the internal functions used in a particular aplication, for use by the application developers).  The next item on the TODO list is to add a preferences menu to allow users to specify the path and select needed databases.
-- It may be useful to offer text hover for programming constructs other than functions: structures, unions, enums, typedefs, macros, etc. The third TODO item will be to add this capability.


Chris Moller
Senior Hacker
Red Hat, Inc.

Back to the top