pbackus / dmdtags

Tag generator for D source code
GNU General Public License v3.0
7 stars 1 forks source link

Symbols declared in function scope not tagged #1

Open quickfur opened 2 years ago

quickfur commented 2 years ago

dmdtags does not seem to generate tags for enums declared in function scope, even when the enum name is unique. Example:

void main() {
    enum LocalEnum { A }
}

The generated tags file does not contain LocalEnum.

quickfur commented 2 years ago

Hmm in fact, it seems no function-scope identifiers are tagged at all:

void main() {
    enum LocalEnum { A, B, C };
    void helperFunc() {}
    helperFunc();
}

helperFunc is not tagged.

pbackus commented 2 years ago

This is intentional. ctags does the same thing:

$ cat test.c
int main()
{
    int n;
    return 0;
}
$ ctags -o - test.c 
main    test.c  /^int main()$/;"    f   typeref:typename:int

My justification for copying this behavior is twofold:

  1. If you're looking for the definition of a function-local symbol, you can usually find it easily without using the tags file (because it's in the current function).
  2. If you're looking for the definition of a non-local symbol, you don't want local symbols from other functions clogging up your search results.

That said, universal-ctags does provide local-symbol tags as an opt-in feature, enabled with a command-line option. So adding a similar feature to dmdtags would be reasonable.

quickfur commented 2 years ago

A command-line option for this would be nice.