Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Linux Tools Project/Libhover/Developers Guide"
(→Libhover Extension) |
(→Libhover Extension) |
||
Line 22: | Line 22: | ||
*id - unique id for this extension (required)<br> | *id - unique id for this extension (required)<br> | ||
− | *name - name of the extension (required) | + | *name - name of the extension (required) |
− | *library - details of the library (1 or more) | + | *library - details of the library (1 or more) |
− | ** docs - URL location of external help documentation (optional) | + | **docs - URL location of external help documentation (optional) |
− | ** location - location of libhover binary data (either URL or relative location to plug-in) (required) | + | **location - location of libhover binary data (either URL or relative location to plug-in) (required) |
− | ** name - name that will appear in the C/C++ Documentation page for this hover help (required) | + | **name - name that will appear in the C/C++ Documentation page for this hover help (required) |
− | ** type - one of (C, C++, or ASM) (required) | + | **type - one of (C, C++, or ASM) (required) |
+ | |||
+ | Note that the location can be specified local to the plug-in that declares the extension. This obviously saves time when accessing the data before a hover event. | ||
+ | |||
+ | == Libhover Data == | ||
+ | |||
+ | So what is Libhover data? Libhover data is merely a Java serialized class that is stored in binary format. Java serialization allows one to save and restore a class to/from a file. The Libhover class is really org.eclipse.linuxtools.cdt.libhover.LibhoverInfo:<br> | ||
+ | |||
+ | public class LibHoverInfo implements Serializable { | ||
+ | |||
+ | private static final long serialVersionUID = 1L; | ||
+ | public HashMap<String, ClassInfo> classes = new HashMap<String, ClassInfo>(); | ||
+ | public HashMap<String, TypedefInfo> typedefs = new HashMap<String, TypedefInfo>(); | ||
+ | public TreeMap<String, FunctionInfo> functions = new TreeMap<String, FunctionInfo>(); | ||
+ | } | ||
+ | <br> | ||
+ | The class is just a collection of Maps from name to C++ class, name to C++ typedef, and name to C function. A C library hover info will only fill in the last map whereas a C++ library hover info will typically only fill in the first two. | ||
+ | |||
+ | The three classes are as follows: |
Revision as of 19:42, 23 February 2011
Introduction
The Libhover plug-in from the Linux Tools project provides a common interface for supplying C and C++ hover help for libraries. The plug-in uses a CDT (C/C++ Developer Tools) Help extension to register itself with the CDT. When a C or C++ file is presented in the editor and a hover event occurs, the CDT will call the Libhover plug-in to get information. In turn, the Libhover plug-in supplies its own extension which allows the end-user to specify a set of valid hovers to use. Each hover library can be enabled or disabled for a C/C++ project via the Project->Properties->C/C++ General->Documentation page. There a list of the valid hovers are shown and the user can check or un-check them as desired. Note that Libhover help suppliers set the language of the hover help and so a C project will ignore any C++ hover libraries. For a C++ project, both C and C++ library hovers are valid so they will all appear on the Documentation page.
Libhover Extension
The Libhover plug-in adds a new org.eclipse.linuxtools.cdt.libhover.library extension to be used in a plug-in. Let's examine an example which specifies libhover help for the glibc C Library:
<extension id="library" name="Glibc C Library" point="org.eclipse.linuxtools.cdt.libhover.library"> <library docs="http://www.gnu.org/software/libc/manual/html_node/index.html" location="./data/glibc-2.7-2.libhover" name="glibc library" type="C"> </library> </extension>
Fields are as follows:
- id - unique id for this extension (required)
- name - name of the extension (required)
- library - details of the library (1 or more)
- docs - URL location of external help documentation (optional)
- location - location of libhover binary data (either URL or relative location to plug-in) (required)
- name - name that will appear in the C/C++ Documentation page for this hover help (required)
- type - one of (C, C++, or ASM) (required)
Note that the location can be specified local to the plug-in that declares the extension. This obviously saves time when accessing the data before a hover event.
Libhover Data
So what is Libhover data? Libhover data is merely a Java serialized class that is stored in binary format. Java serialization allows one to save and restore a class to/from a file. The Libhover class is really org.eclipse.linuxtools.cdt.libhover.LibhoverInfo:
public class LibHoverInfo implements Serializable {
private static final long serialVersionUID = 1L;
public HashMap<String, ClassInfo> classes = new HashMap<String, ClassInfo>(); public HashMap<String, TypedefInfo> typedefs = new HashMap<String, TypedefInfo>(); public TreeMap<String, FunctionInfo> functions = new TreeMap<String, FunctionInfo>();
}
The class is just a collection of Maps from name to C++ class, name to C++ typedef, and name to C function. A C library hover info will only fill in the last map whereas a C++ library hover info will typically only fill in the first two.
The three classes are as follows: