bug-global
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ scoping of cross-reference?


From: Iain Woolf
Subject: Re: C++ scoping of cross-reference?
Date: Fri, 8 Jul 2011 16:05:02 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110516 Lightning/1.0b2 Thunderbird/3.1.10

 On 04/05/2011 10:26 PM, Shigio YAMAGUCHI wrote:
> ...
> Could you please review your example so as not to include what is not
> important? If there are such things, it is difficult to understand your
> intention. Thank you in advance.
Hi Shigio,

Sorry for the delay in replying to this thread. I've taken another go at
describing the extended functionality I'd like to see. Please let me
know your comments.

I propose that the gtags database be extended to provide class-qualified
definitions. When searching for a definition, I would like to be able to
optionally specify the class qualifier. For example, consider:

[Class hierarchy]

    class A
      |- class B
           |- class C

[Source files]

    [classA.cc]
    +--------------------------------
    |...
    |class A
        |{
        |  void dump() {...};
        |  void method2() {...};
        |};


    [classB.h]
    +--------------------------------
    |...
    |class B : A
        |{
        |  void dump()  // overrides A::dump()
        |};

    [classB.cc]
    +--------------------------------
    |...
    |void B::dump() {...}

    [classC.cc]
    +--------------------------------
    |...
    |class C : B
        |{
        |  void dump() {...}; // overrides B::dump()
        |}


[Execution image]

        $ global -x dump
    A::dump        classA.cc     50 class A { void dump() {...} }
    B::dump        classB.h     20 class B : A { void dump() }
    B::dump        classB.cc    100 void B::dump() {...}
    C::dump        classC.cc     90 class C : B { void dump() {...} }
    $ _

    $ global -x A::dump
    A::dump        classA.cc     50 class A { void dump() {...} }
        $ _

    $ global -x B::dump
    B::dump        classB.h     20 class B : A { void dump() }
    B::dump        classB.cc    100 void B::dump() {...}
    $ _

    $ global -x C::dump
    C::dump        classC.cc     90 class C : B { void dump() {...} }
    $ _

Possible extension
==================
I propose that global also be extended with a new option which
provides the ability to show derived methods:

  -d    Shows methods derived from given C++ symbol. (Requires gtags
        database built with C++ scoping)

[Execution image]

    $ global -x -d A::dump
    A::dump        classA.cc     50 class A { void dump() {...} }
    B::dump        classB.h     20 class B : A { void dump() }
    B::dump        classB.cc    100 void B::dump() {...}
    C::dump        classC.cc     90 class C : B { void dump() {...} }
        $ _

    $ global -x -d B::dump
    B::dump        classB.h     20 class B : A { void dump() }
    B::dump        classB.cc    100 void B::dump() {...}
    C::dump        classC.cc     90 class C : B { void dump() {...} }
    $ _

    $ global -x -d C::dump
    C::dump        classC.cc     90 class C : B { void dump() {...} }
    $ _

Searching on an inherited, but not derived method
=================================================
If a class inherits a method but does not override/derive it, then it
does not have a gtags symbol for that method:

[Execution image]

     $ global -x B::method2
        $ _


Searching for symbol references
===============================

[Execution image] - should give
...
    $ global -xr B::method2
    B::method2    other.cc     20     b_p->method2();
    B::method2    other.cc     25     local_b.method2();
    $_

It would still be possible to search for references to just method2,
and this would return matches on all classes as it does today.

[Execution image] - should give
...
    $ global -xr method2
    B::method2    other.cc     20     b_p->method2();
    B::method2    other.cc     25     local_b.method2();
        OtherClass::method2  foo.cc      15     bar_p->method2();
    $_


Cheers,

 Iain

-- 
Iain Woolf              W-CDMA Base Software, Alcatel-Lucent
Tel: 613-784-3465 / OnNET 2-825-3465
IM: iwoolf (im.ca.alcatel-lucent.com) / i_woolf (YahooIM)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]