universal-ctags / citre

A superior code reading & auto-completion tool with pluggable backends.
GNU General Public License v3.0
326 stars 26 forks source link

C: lost information about typeref #87

Closed masatake closed 3 years ago

masatake commented 3 years ago

In C language, struct tags and type names defined with typedef have different namespaces.

struct kvm;
struct A;
typedef struct A kvm;
struct foo {
  struct
  kvm *bar; /* @ */
};

int bar;

When pressing M-. on bar at "@" line, xref shows:

/tmp/bar.c
6: (member/kvm *@struct:foo) kvm *bar;
9: (variable/int) int bar;

The user may think the "bar" is typed with "kvm". It is not true; "bar" is typed with "struct kvm"

Code readers well optimized for C language utilize the difference between "kvm " and "struct kvm " as hints. They expect:

/tmp/bar.c
6: (member/struct:kvm *@struct:foo) kvm *bar;
9: (variable/int) int bar;

or

/tmp/bar.c
6: (member/struct kvm *@struct:foo) kvm *bar;
9: (variable/int) int bar;

ctags provides enough information:

bar bar.c   /^  kvm *bar;$/;"   m   struct:foo  typeref:struct:kvm *    file:

citre may drop the first element of typeref:.

The case that a client tool should drop the first element is when the first element is "typename". "typename" is a placeholder. So you can drop it.

AmaiKinono commented 3 years ago

I see. Thanks for the report.