Ctags: كيفية تحليل tagname والنوع من إخراج ctags -R -x

تم إنشاؤها على ١٢ مارس ٢٠١٩  ·  8تعليقات  ·  مصدر: universal-ctags/ctags


اسم المحلل اللغوي: أي واحد

سطر الأوامر الذي استخدمته لتشغيل ctags:

$ ctags --options=NONE -R -x

محتوى ملف الإدخال:

$ git clone https://github.com/liuchengxu/vista.vim
$ cd vista.vim
$ ctags --options=NONE -R -x

ناتج العلامات الذي لست راضيًا عنه:

ليس لدي أي فكرة عن كيفية تحليل ناتج ctags -R -x . أريد ترشيح اسم النطاق والنطاق من ناتج ctags -R -x ، لكن لا أعرف كيفية القيام بذلك بشكل صحيح.

إخراج العلامات الذي تتوقعه:

يكون قابلاً للتطبيق إذا كان هناك أيضًا تنسيق محدد لـ ctags -R :

{tagname}<Tab>{tagfile}<Tab>{tagaddress}[;"<Tab>{tagfield}..]

إصدار ctags:

$ ctags --version
Universal Ctags 0.0.0(1208e45), Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Mar 11 2019, 17:01:27
  URL: https://ctags.io/
  Optional compiled features: +wildcards, +regex, +iconv, +option-directory, +xpath, +case-insensitive-filenames, +packcc

كيف تحصل على ثنائي ctags:

brew install ctags على macOS

ال 8 كومينتر

أنا لا أفهم سؤالك.

هل أنت راضٍ عن ناتج ctags -R ؟ إذا كانت الإجابة بنعم ، فلماذا لا تستخدم الخيار -x ؟
أود معرفة خلفية حالة الاستخدام أكثر للإجابة على سؤالك.

أنا لا أعرف سيناريو vim. ومع ذلك ، فيما يتعلق بقراءة vim.c ، المحلل اللغوي vim لـ ctags ، فإنه لا يملأ حقول النطاق. إذا كنت تعتقد أنه خطأ ، فأخبرنا أن المحلل اللغوي vim يملأ حقل النطاق لنوع الإدخال.

آسف لعدم توضيح الأمر.

لماذا استخدم الخيار -x ؟

على الرغم من أن ctags -R سيلبي حاجتي ، إلا أنني لا أرغب في إنشاء ملف العلامات ، لذلك أستخدم الخيار -x .

حالة الاستخدام الخاصة بي.

يدعم vista.vim حاليًا إظهار العلامات في بعض الملفات فقط ، لكن بعض المستخدمين يرغبون في إظهار جميع العلامات في المشروع (https://github.com/liuchengxu/vista.vim/issues/14). حاولت إضافة دعم ctags -R ، لكن لا أعرف كيفية استخراج هذه المخرجات بشكل صحيح.

باختصار ، كيف تستخرج vista#util#Trim ، function ، 18 ، autoload/vista/util.vim ، vista#util#Trim(str) على التوالي؟

ctags -R -x :

...
vista#util#Trim  function     18 autoload/vista/util.vim function! vista#util#Trim(str)
vista#util#Truncate function     13 autoload/vista/util.vim function! vista#util#Truncate(msg) abort
vista#util#Warning function     90 autoload/vista/util.vim function! vista#util#Warning(msg) abort
vista#viewer#Display function     90 autoload/vista/viewer.vim function! vista#viewer#Display(data) abort
vista#viewer#Render function     86 autoload/vista/viewer.vim function! vista#viewer#Render(data) abort
vista#viewer#prefixes function     94 autoload/vista/viewer.vim function! vista#viewer#prefixes() abort

مع الخيار -o - ، ترسل ctags الإخراج إلى stdout مثل:

[yamato@slave]/tmp/vista.vim% u-ctags -R -o - | head 
/   ftplugin/vista.vim  /^nnoremap <buffer> <silent> \/    :<c-u>call vista#finder#fzf#Run()<CR>$/;"    m
<CR>    ftplugin/vista.vim  /^nnoremap <buffer> <silent> <CR> :<c-u>call vista#cursor#FoldOrJump()<CR>$/;"  m
Commands    README.md   /^### Commands$/;"  S
Contributing    README.md   /^## Contributing$/;"   s
Features    README.md   /^## Features$/;"   s
Installation    README.md   /^## Installation$/;"   s
Introduction    README.md   /^## Introduction$/;"   s
License README.md   /^## License$/;"    s
NeoVim  README.md   /^#### NeoVim$/;"   t
Options README.md   /^### Options$/;"   S

يمكنك تخصيص الناتج بخيار --_xformat= :

 u-ctags -R -x --_xformat='TAGNAME:%N @@@ KIND:%K !!! LINE:%n +++ INPUT-FILE:%F === PATTERN:%P' | head
TAGNAME:/ @@@ KIND:map !!! LINE:38 +++ INPUT-FILE:ftplugin/vista.vim === PATTERN:/^nnoremap <buffer> <silent> \/    :<c-u>call vista#finder#fzf#Run()<CR>$/
TAGNAME:<CR> @@@ KIND:map !!! LINE:37 +++ INPUT-FILE:ftplugin/vista.vim === PATTERN:/^nnoremap <buffer> <silent> <CR> :<c-u>call vista#cursor#FoldOrJump()<CR>$/
TAGNAME:Commands @@@ KIND:subsection !!! LINE:101 +++ INPUT-FILE:README.md === PATTERN:/^### Commands$/
TAGNAME:Contributing @@@ KIND:section !!! LINE:164 +++ INPUT-FILE:README.md === PATTERN:/^## Contributing$/
TAGNAME:Features @@@ KIND:section !!! LINE:37 +++ INPUT-FILE:README.md === PATTERN:/^## Features$/
TAGNAME:Installation @@@ KIND:section !!! LINE:69 +++ INPUT-FILE:README.md === PATTERN:/^## Installation$/
TAGNAME:Introduction @@@ KIND:section !!! LINE:25 +++ INPUT-FILE:README.md === PATTERN:/^## Introduction$/
TAGNAME:License @@@ KIND:section !!! LINE:168 +++ INPUT-FILE:README.md === PATTERN:/^## License$/
TAGNAME:NeoVim @@@ KIND:subsubsection !!! LINE:90 +++ INPUT-FILE:README.md === PATTERN:/^#### NeoVim$/
TAGNAME:Options @@@ KIND:subsection !!! LINE:113 +++ INPUT-FILE:README.md === PATTERN:/^### Options$/

راجع http://docs.ctags.io/en/latest/news.html؟highlight=--_xformat#customizing -xref-output.

إذا كنت لا تريد كتابة المحلل اللغوي ، فيمكن أن يكون الخيار --output-format=json :

u-ctags -R --output-format=json | head
{"_type": "tag", "name": "/", "path": "ftplugin/vista.vim", "pattern": "/^nnoremap <buffer> <silent> \\/    :<c-u>call vista#finder#fzf#Run()<CR>$/", "kind": "map"}
{"_type": "tag", "name": "<CR>", "path": "ftplugin/vista.vim", "pattern": "/^nnoremap <buffer> <silent> <CR> :<c-u>call vista#cursor#FoldOrJump()<CR>$/", "kind": "map"}
{"_type": "tag", "name": "Commands", "path": "README.md", "pattern": "/^### Commands$/", "kind": "subsection"}
{"_type": "tag", "name": "Contributing", "path": "README.md", "pattern": "/^## Contributing$/", "kind": "section"}
{"_type": "tag", "name": "Features", "path": "README.md", "pattern": "/^## Features$/", "kind": "section"}
{"_type": "tag", "name": "Installation", "path": "README.md", "pattern": "/^## Installation$/", "kind": "section"}
{"_type": "tag", "name": "Introduction", "path": "README.md", "pattern": "/^## Introduction$/", "kind": "section"}
{"_type": "tag", "name": "License", "path": "README.md", "pattern": "/^## License$/", "kind": "section"}
{"_type": "tag", "name": "NeoVim", "path": "README.md", "pattern": "/^#### NeoVim$/", "kind": "subsubsection"}
{"_type": "tag", "name": "Options", "path": "README.md", "pattern": "/^### Options$/", "kind": "subsection"}

شكرا لك! سأجرب الخيار --_xformat= ، نظرًا لأن ctags المثبت بواسطة المشروب لا يدعم --output-format=json افتراضيًا ، سواء كان brew install ctags أو brew install --HEAD universal-ctags/universal-ctags/universal-ctags .

KazuakiM ، أليس من الممكن ربط ctags بـ libjansson.so.4؟
يحتوي u-ctags على وضع إخراج json. يتوفر إذا كانت u-ctags مرتبطة بـ libjansson.
أخبرني ما إذا كان يجب الإبلاغ عن هذا باعتباره مشكلة جديدة في homebrew-universal-ctags repo.

liuchengxu ، ملف العلامات ، يمكن تحليل التنسيق الأصلي لعلامات ctags مع وظائف في readtags.c.
الأمر readtags و python-ctags3 ، تستخدم مكتبة python readtags.c.

تضمين التغريدة
مرحبًا ، homebrew-universal-ctags يدعم jansson.

$ brew info universal-ctags
universal-ctags/universal-ctags/universal-ctags: HEAD
Maintained ctags implementation
https://github.com/universal-ctags/ctags
Conflicts with:
  ctags (because this formula installs the same executable as the ctags formula)
/usr/local/Cellar/universal-ctags/HEAD-1b747b3 (325 files, 4.3MB) *
  Built from source on 2019-02-02 at 16:45:17
From: https://github.com/universal-ctags/homebrew-universal-ctags/blob/master/universal-ctags.rb
==> Dependencies
Build: autoconf ✔, automake ✔, pkg-config ✔
Optional: jansson ✔, libyaml ✔
==> Options
--with-jansson
        Build with jansson support
--with-libyaml
        Build with libyaml support
--without-doc
        Compile without man pages
--without-xml
        Compile without libxml2
--HEAD
        Install HEAD version
==> Caveats
Under some circumstances, emacs and ctags can conflict. By default,
emacs provides an executable `ctags` that would conflict with the
executable of the same name that ctags provides. To prevent this,
Homebrew removes the emacs `ctags` and its manpage before linking.
However, if you install emacs with the `--keep-ctags` option, then
the `ctags` emacs provides will not be removed. In that case, you
won't be able to install ctags successfully. It will build but not
link.

KazuakiM صيد جيد ، فاتني المساعدة. يحتاج دعم JSON إلى الخيار --with-jansson .

$ brew reinstall --with-jansson universal-ctags/universal-ctags/universal-ctags
هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات

القضايا ذات الصلة

songouyang picture songouyang  ·  15تعليقات

JulienPivard picture JulienPivard  ·  16تعليقات

lvc picture lvc  ·  3تعليقات

trevordmiller picture trevordmiller  ·  9تعليقات

blueyed picture blueyed  ·  4تعليقات