Previous: Updating for ind. buffers, Up: The Methods window


6.6.6 Jumping to the definition of external types

There are two common types of “external” tags displayed in the method-window, mostly with object oriented programing-languages:

  1. parent-types

    Tags which represent the type of a parent-class (which can be defined in the same file but which is more often defined in another file). All parents (regardless if defined internaly or externaly) of a type will be displayed under a bucket “[Parents]” in the methods-window of ECB.

  2. “virtual” types

    In OO-languages like CLOS, eieio and C++ there can be nodes with 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.

In both cases the user wants to jump to the definition of the type if he clicks onto the related node in the methods-window of ECB.

Here is a C++-example for “virtual” types (2) and parent types (1) which explains this in detail:

Let's say this class is defined in a file ParentClass.h:

   class ParentClass
   {
   protected:
     int p;
   };

Let's say 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 implemented 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. But this class-type “ClassWithExternals” is represented by a so called “virtual” or “faux” node-tag, i.e. there is no real tag in the current source-buffer for this tag.

If a user now clicks onto the node of “ClassWithExternals” then he wants to jump to the right location in the right file where “ClassWithExternals” is defined. ECB now uses now some smart mechanisms (see below) to do this. In case of success (means ECB has found the definition) it opens the right file and point will stay at beginning of the definition of the type “ClassWithExternals”.

The contents of ClassWithExternals.h are then displayed like follows:

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

Now let's play it again: Now we want to go to the definition of the parent-type “ParentClass” when we click onto the related node under the bucket “[Parents]”. Again ECB uses its smartness to jump to the definition of the class “ParentClass” when you click onto the node “ParentClass”.

Now lets explain the precondition which must be fulfilled so ECB can do its job: