Previous: Window-managers and ECB, Up: Tips and tricks


10.16 Using semanticdb to jump to type-tags defined in other files

In OO-languages like CLOS, eieio and C++ there can be type-tags in the method-buffer which are somehow virtual because there is no definition in the current source-file. But such a virtual type collects all its outside defined members like methods in C++ which are defined in the *.cc file whereas the class-definition is defined in the associated header-file. ECB uses semanticdb to open the definition-file of such a tag and to jump to the definition of this tag. Same for parent-tags in the methods-buffer. This feature can only work correctly if semanticdb is well configured!

Here is a C++-example:

This class is defined in a file ParentClass.h:

   class ParentClass
   {
   protected:
     int p;
   };

This class is defined in a file ClassWithExternals.h

   #include "ParentClass.h"
   
   class ClassWithExternals : public ParentClass
   {
   private:
     int i;
   
   public:
     ClassWithExternals();
     ~ClassWithExternals();
   };

Both the constructor and the destructor of the class “ClassWithExternals” are defined in a file ClassWithExternals.cc:

   #include "test.h"
   
   ClassWithExternals::ClassWithExternals(int i,
                                          boolean b,
                                          char c)
   {
     return;
   }
   
   void
   ClassWithExternals::~ClassWithExternals()
   {
     return;
   }

ECB displays the contents of ClassWithExternals.cc in its methods-buffer like follows:

   [-] [Includes]
    `- test.h
   [-] ClassWithExternals
    |  +ClassWithExternals (+i:int, +b:class boolean, +c:char):ClassWithExternals
    `- +~ClassWithExternals ():void

Both the constructor and the destructor of the class “ClassWithExternals” are grouped under their class-type. ECB now uses semanticdb to jump to the definition of class “ClassWithExternals” when you click onto the type-node “ClassWithExternals” in the methods-buffer.

The contents of ClassWithExternals.h are displayed like follows:

   [-] [Includes]
    `- ParentClass.h
   [-] ClassWithExternals:class
    |  [-] [Parents]
    |   `- ParentClass
    |  [-] [Variables]
    |   `- -i:int
    |  +ClassWithExternals ():ClassWithExternals
    |  +~ClassWithExternals ():void
    `- [+] [Misc]

ECB uses semanticdb to jump to the definition of the class “ParentClass” when you click onto the node “ParentClass”.

To enable this feature global-semanticdb-minor-mode must be enabled and semanticdb must be correctly configured. This means mainly that the option semanticdb-project-roots must be setup well. See the manual of semanticdb for further informations about this.