-
Notifications
You must be signed in to change notification settings - Fork 629
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
main: add nulltag/z, a new extra #4152
Conversation
masatake
commented
Dec 8, 2024
•
edited
Loading
edited
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4152 +/- ##
=======================================
Coverage 85.90% 85.90%
=======================================
Files 239 239
Lines 58733 58797 +64
=======================================
+ Hits 50453 50509 +56
- Misses 8280 8288 +8 ☔ View full report in Codecov by Sentry. |
5b2636b
to
0d23879
Compare
Ah, OK, I just noticed this PR - probably a better approach than #4152. We'll probably want to disable this warning in Geany too. |
I will try merging #4153 to this pull request to demonstrate how to use tagEntryInfo::allowNullTag. |
38097fe
to
5b29668
Compare
0f7c699
to
8ce3dcf
Compare
After taking time to implement null tags, I found that ctags could not record null tags. When sorting, null tags come before pseudo tags.
These pull requests implement null tags on the u-tags output format. If we choose xref and/or json, maybe ctags can record null tags. However, I have to rewrite many codes in this pull request. |
We have the man page for the format already. Signed-off-by: Masatake YAMATO <[email protected]>
… section of ctags(1). Signed-off-by: Masatake YAMATO <[email protected]>
Signed-off-by: Masatake YAMATO <[email protected]>
The original code assumed using "L:" as the last column. This change fixes the wrong assumption. Signed-off-by: Masatake YAMATO <[email protected]>
…ame as that of tagWriter definition
This is preparation for "null tag support". Signed-off-by: Masatake YAMATO <[email protected]>
We have allowNullTag in parserDefinition already. However, we may lose the chance of signs of bugs if we turn parserDefinition::allowNullTag on. With tagEntryInfo:allowNullTag, we can write a null tag without losing the chance. Signed-off-by: Masatake YAMATO <[email protected]>
Just a question - are null tags actually needed? I haven't followed the discussion around them so I maybe missed something but at lest for Geany, the only missing piece would be to have some way to disable the warnings in the terminal when there is an attempt to generate such tags. I think null tags are rare enough and not useful for anything like navigation or completion so IMO not worth the necessary work to support them. |
Close universal-ctags#4151. Consider a parser attempting to emit a null tag, a tag whose name is the empty string '\0'. Original Behavior: It warns "ignoring null tag..." if both parserDefinition::allowNullTag and tagEntryInfo::allowNullTag are unset. It does not warn if either parserDefinition::allowNullTag or tagEntryInfo::allowNullTag is set. It does not emit the null tag, even if allowNullTag is set. With This Change: The code now emits the null tag if: Either parserDefinition::allowNullTag or tagEntryInfo::allowNullTag is set, The --extras=+z (or --extras=+{nulltag}) option is specified, and The output format supports to emit null tags. The xref and json output formats support to emit null tags. Signed-off-by: Masatake YAMATO <[email protected]>
In javascript it is legal to have e.g. {"": false}. With the original code the parser attempts to generate the tag for the empty string which produces warning. With setting allowNullTag member of tagEntryInfo, the parser can generate such tags without producing warnings. Actual tag emission is controlled by --extras=+{nulltag}. This commit is based on the commit in universal-ctags#4153. Co-Author: Masatake YAMATO <[email protected]>
In the original code, the names output of formats are defined in main/options.c; processOutputFormat maps a name output of a format to a writer. This is a preparation for implementing --list-output-format option.
Signed-off-by: Masatake YAMATO <[email protected]>
Signed-off-by: Masatake YAMATO <[email protected]>
We cannot support null tags in the u-ctags and e-ctags output formats. As I wrote, null tags can cause trouble in the sorting process. One quick way to suppress the null tag warning is to use "2> /dev/null." However, this approach is too rough. Thinking about finer-grained control and splitting responsibilities in parsers, main, and output writers, it looks good to me to support null tags explicitly. |
I meant it for Geany so users don't see these warnings which they don't know what they are about. |
With this request, a parser can make a valid null tag by setting 1 to tagEntryInfo::allowNullTag. Based on #4153, I made the JavaScript parser utilize this new feature. As a result, the warning reported in #4134 is gone. Though a parser makes a null tag, ctags emits it only when (1) a user sets @techee |
The only objective I had was to get rid of the NULL tag warnings but the way I understand the code the warning will be emitted when NULL tags are disabled. So by default it will do the opposite of what I wanted to achieve. But if I understand it correctly, if I change the writer that Geany uses so it declares that Geany supports NULL tags, the warning should go away and in Geany we could simply just filter out the generated NULL tags. Am I right? |
ctags warned when a parser makes a null tag. With this pull request, ctags warns when a parser makes a null tag without setting 1 to allowNullTag in tagEntryInfo. The default value of allowNullTag is 0. So, a parser must set 1 to allowNullTag explicitly to suppress the warning. See makeJsNullTag in parsers/jscript.c in 3ef7832. |
OK, in that case it's what I wanted. I thought that it's the writer from which the null tag support is taken but apparently not. Thanks. |
If I wrote these things to ctags(1) and the document that will be uploaded to docs.ctags.io. |
About the versioning, I will release 6.2 soon after solving the nominated issues and merging the nominated pull requests. I wrote about the allowNulTag member in the hacking guide. We don't have to think about readtags because {e,u}-ctags writers don't support emitting null tags. Now we are ready for #4157. |