Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ada : Output internal 'separate'-tag by default. #2943

Closed
koenmeersman opened this issue Apr 6, 2021 · 1 comment
Closed

Ada : Output internal 'separate'-tag by default. #2943

koenmeersman opened this issue Apr 6, 2021 · 1 comment

Comments

@koenmeersman
Copy link
Contributor


The name of the parser: Ada

The command line you used to run ctags:

./ctags -f - input.adb

The content of input file:

    with Ada.Text_IO;

    separate (Buffer);

    package body Test is
      procedure Inner is separate;
    begin
      null;
    end Test;

The tags output you are not satisfied with:

Buffer  input.adb       /^separate (Buffer);$/;"        S
Test    input.adb       /^package body Test is$/;"      p       

The tags output you expect: No tag for 'separate (Buffer)'

    Test    input.adb       /^package body Test is$/;"      p       

The version of ctags:

./ctags --version 
Universal Ctags 5.9.0(12564cf), Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Apr  5 2021, 18:37:43
  URL: https://ctags.io/
  Optional compiled features: +wildcards, +regex, +iconv, +option-directory, +xpath, +packcc

How do you get ctags binary: downloaded git head, and builded manually


Some comments:

$ ./ctags --list-kinds-full='Ada'  shows:
   #LETTER NAME        ENABLED REFONLY NROLES MASTER DESCRIPTION
   S       separate    yes     no      0      NONE   (ctags internal use)

The description says it is '(ctags internal use)' and ENABLED is yes, what makes these tags are outputed by default. Looks a bit odd to output 'ctags internal use'-tags by default.

When reading the code: ada.c

        else if(adaKeywordCmp(ADA_KEYWORD_SEPARATE))
        {
          /* skip any possible whitespace */
          skipWhiteSpace();

          /* skip over the "(" until we hit the tag */
          if(exception != EXCEPTION_EOF && line[pos] == '(')
          {
            movePos(1);
            skipWhiteSpace();

            /* get length of tag */
            for(i = 1; (pos + i) < lineLen && line[pos + i] != ')' &&
                !isspace(line[pos + i]); i++);

>            /* if this is a separate declaration, all it really does is create
>             * a false high level token for everything in this file to belong
>             * to... But we don't know what kind it is, so we declare it as
>             * ADA_KIND_SEPARATE, which will cause it not to be placed in
>             * the tag file, and the item in this file will be printed as
>             * separate:<name> instead of package:<name> or whatever the
>             * parent kind really is (assuming the ctags option will be on
>             * for printing such info to the tag file) */
             
            token = newAdaToken(&line[pos], i, ADA_KIND_SEPARATE, false,
                                parent);

            /* since this is a false top-level token, set parent to be
             * token */
            parent = token;
            token = NULL;

            /* skip past the ')' */
            skipPast(")");
          } /* if(line[pos] == '(') */
          else
          {
            /* move to the end of this statement */
            skipPast(";");
          }
        } /* else if(adaKeywordCmp(ADA_KEYWORD_SEPARATE)) */

So it looks like the code (ada.c) assumes a tag for separate is not placed in the tags file (unless the ctags option will be on for printing such info to the tag file)

Looks like this change was introduced 4 years ago by: #1584 (but I may be wrong, as I have not much experience with git/github.

    static kindDefinition AdaKinds[] =
      ....
      { true,   'S', "separate",    "(ctags internal use)" }

Was this intentional to activate the output separate tags by default, or a mistake?

I would have expected to see a:

     { false, 'S', "separate",    "(ctags internal use)" }

As workaround we add option:

--kinds-Ada="-{separate}"

But I wonder if it is not better to a change this in ada.c?

If you can confirm this is a mistake, then I'll create a pull request (i.e. update code + add a test) when I find the time. (probably during a bad-weather weekend)

@masatake
Copy link
Member

When I worked at #1584, I didn't understand Ada at all.

https://stackoverflow.com/questions/28008052/how-do-i-use-separate-keyword

I read this.

separate (Buffer);

Now I think I understand.
Buffer is a reference to a package named Buffer.
So it should be captured as a reference tag.
Tagging it is important because Buffer is a parent scope of Test.
Without tagging Buffer, the scope field of Test cannot be filled.
However, Buffer in separate(Buffer) is not a definition.
There might be a dilemma.

The reference tag is for removing the dilemma.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants