Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Linux Tools Project/Libhover/Developers Guide"

(Libhover Extension)
Line 35: Line 35:
 
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>  
 
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 {  
+
&nbsp;&nbsp;&nbsp; public class LibHoverInfo implements Serializable {  
 +
 
 +
&nbsp;&nbsp;&nbsp; private static final long serialVersionUID = 1L;
  
private static final long serialVersionUID = 1L;
 
 
     public HashMap&lt;String, ClassInfo&gt; classes = new HashMap&lt;String, ClassInfo&gt;();  
 
     public HashMap&lt;String, ClassInfo&gt; classes = new HashMap&lt;String, ClassInfo&gt;();  
 
     public HashMap&lt;String, TypedefInfo&gt; typedefs = new HashMap&lt;String, TypedefInfo&gt;();  
 
     public HashMap&lt;String, TypedefInfo&gt; typedefs = new HashMap&lt;String, TypedefInfo&gt;();  
 
     public TreeMap&lt;String, FunctionInfo&gt; functions = new TreeMap&lt;String, FunctionInfo&gt;();  
 
     public TreeMap&lt;String, FunctionInfo&gt; functions = new TreeMap&lt;String, FunctionInfo&gt;();  
}  
+
 
<br>
+
&nbsp;&nbsp;&nbsp; } <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 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:
 
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:

Back to the top