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

[RFC] readtags: supports multiple tag files #4068

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

masatake
Copy link
Member

@masatake masatake commented Sep 5, 2024

This pull request implements the ideas I wrote in universal-ctags/citre#178.

Example sessions:

With this pull request, readtags can take multiple -t option. So you can find a tag in multiple files at once. Using multiple threads is future work.

This pull request adds !_READTAGS_INCLUDE directive. If a tag file is specified with the pseudo tag, readtags reads the tas file, too, as if the tag file is specified with -t on the command line.

This pull request adds -X/--generate-aggregate-tag-file option to readtags. With the option, readtags generate an aggregate tag file enumerating all tag files specified with -t on the command line.

$ ./readtags -t podman.tags -t glibc.tags -t coreutils832.tags -X           
!_READTAGS_INCLUDE	podman.tags	//
!_READTAGS_INCLUDE	glibc.tags	//
!_READTAGS_INCLUDE	coreutils832.tags	//
!_TAG_FILE_FORMAT	2	//
!_TAG_FILE_SORTED	1	//
!_TAG_OUTPUT_EXCMD	pattern	//
!_TAG_OUTPUT_FILESEP	slash	//
!_TAG_OUTPUT_MODE	u-ctags	//
!_TAG_OUTPUT_VERSION	0.0	/current.age/
!_TAG_PATTERN_LENGTH_LIMIT	0	//
!_TAG_PROC_CWD	/home/yamato/var/ctags-github	//
!_TAG_PROGRAM_AUTHOR	Universal Ctags Team	//
!_TAG_PROGRAM_NAME	readtags	/with -X option/
!_TAG_PROGRAM_URL	https://ctags.io/	/official site/
!_TAG_PROGRAM_VERSION	0.0.0	/TODO/

Copy link

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 84.34783% with 18 lines in your changes missing coverage. Please review.

Project coverage is 85.53%. Comparing base (5039ab9) to head (953f035).
Report is 73 commits behind head on master.

Files with missing lines Patch % Lines
extra-cmds/readtags-cmd.c 84.34% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4068      +/-   ##
==========================================
+ Coverage   85.51%   85.53%   +0.02%     
==========================================
  Files         237      237              
  Lines       57030    57030              
==========================================
+ Hits        48769    48782      +13     
+ Misses       8261     8248      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

The original code called findTag or listTags directly in the process
of command line parsing. This change introduces new data structure
named actionSpec. During parsing command line, readtags builds an
actionSpec. After parsing readtags takes an action based on the
actionSpec.

Signed-off-by: Masatake YAMATO <[email protected]>
  $ ~/bin/ctags -o podman.tags -R ~/var/podman
  $ ~/bin/ctags -o glibc.tags -R ~/var/glibc
  $ ~/bin/ctags -o coreutils832.tags -R /srv/sources9c/sources/c/coreutils/8.32-31.el9--srpm/pre-build/coreutils-8.32
  $ ./readtags -A -Q '(and (eq? $name "main") (#/.*user.*/ $input))' -t podman.tags -t glibc.tags -t coreutils832.tags -l
  main	/srv/sources9c/sources/c/coreutils/8.32-31.el9--srpm/pre-build/coreutils-8.32/gnulib-tests/test-userspec.c	/^main (void)$/
  main	/srv/sources9c/sources/c/coreutils/8.32-31.el9--srpm/pre-build/coreutils-8.32/lib/getusershell.c	/^main (void)$/
  main	/srv/sources9c/sources/c/coreutils/8.32-31.el9--srpm/pre-build/coreutils-8.32/lib/userspec.c	/^main (int argc, char **argv)$/
  main	/srv/sources9c/sources/c/coreutils/8.32-31.el9--srpm/pre-build/coreutils-8.32/src/users.c	/^main (int argc, char **argv)$/
  $ ./readtags -A -Q '(and (eq? $name "main") (#/.*container.*/ $input))' -t podman.tags -t glibc.tags -t coreutils832.tags -l
  main	/home/yamato/var/glibc/support/echo-container.c	/^main (int argc, const char **argv)$/
  main	/home/yamato/var/glibc/support/shell-container.c	/^main (int argc, const char **argv)$/
  main	/home/yamato/var/glibc/support/test-container.c	/^main (int argc, char **argv)$/
  main	/home/yamato/var/glibc/support/true-container.c	/^main (void)$/
  $ ./readtags -A -Q '(not (#/.*_test.*/ $input))' -t podman.tags -t glibc.tags -t coreutils832.tags rootless
  rootless	/home/yamato/var/podman/pkg/rootless/rootless.go	/^package rootless$/
  rootless	/home/yamato/var/podman/pkg/rootless/rootless_freebsd.go	/^package rootless$/
  rootless	/home/yamato/var/podman/pkg/rootless/rootless_linux.go	/^package rootless$/
  rootless	/home/yamato/var/podman/pkg/rootless/rootless_unsupported.go	/^package rootless$/
  rootless	/home/yamato/var/podman/vendor/github.com/containers/image/v5/internal/rootless/rootless.go	/^package rootless$/

Signed-off-by: Masatake YAMATO <[email protected]>
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

Successfully merging this pull request may close these issues.

1 participant