-
Notifications
You must be signed in to change notification settings - Fork 631
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
Enable/Disable static fields like pattern field in json output mode (Was: How to generate tree like structure from the ctags output) #2065
Comments
No stable way because the semantics of the scope field is not well defined.
What you get from ctags:
pattern fields are truncated to make reading easier. I should provide an option to hide pattern fields, BTW. Step1. Pick an item which has no scope field from 5 items are in the list. I wonder whether this algorithm is applicable to the other languages. In some languages, scope fields are filled with full qualified names. Separators combine a parent name and the name of its child are not always '.'. |
Thanks for the response! I think the seperators used by various languages are not very big problem, Will try with your approach. |
@masatake Let me know when you add this option, which will reduce some overhead in vista.vim as I currently have to keep the whole raw tag list in memory for vista.vim, although it's fine in most time. |
It works.
|
Ideally, field related code and writer related code should be separated. |
Close universal-ctags#2065. The tags format must include name, input, and pattern fields. When running ctags, disabling them are not allowed. To implement this rule, "fixed" fields were introduced to field.c. However, this rule is applicable only to the ctags writer. The other writer like json-writer doesn't need to follow the rule. The fixed field is implemented in field.c. Now, it moves to writer-ctags.c. As the result, json-writer can print the result with disabling "name", "input", and/or "pattern". Signed-off-by: Masatake YAMATO <[email protected]>
Close universal-ctags#2065. The tags format must include name, input, and pattern fields. When running ctags, disabling them are not allowed. To implement this rule, "fixed" fields were introduced to field.c. However, this rule is applicable only to the ctags writer. The other writer like json-writer doesn't need to follow the rule. The fixed field is implemented in field.c. Now, it moves to writer-ctags.c. As the result, json-writer can print the result with disabling "name", "input", and/or "pattern". Signed-off-by: Masatake YAMATO <[email protected]>
Close universal-ctags#2065. The tags format must include name, input, and pattern fields. When running ctags, disabling them are not allowed. To implement this rule, "fixed" fields were introduced to field.c. However, this rule is applicable only to the ctags writer. The other writer like json-writer doesn't need to follow the rule. The fixed field is implemented in field.c. Now, it moves to writer-ctags.c. As the result, json-writer can print the result with disabling "name", "input", and/or "pattern". Signed-off-by: Masatake YAMATO <[email protected]>
Close universal-ctags#2065. The tags format must include name, input, and pattern fields. When running ctags, disabling them are not allowed. To implement this rule, "fixed" fields were introduced to field.c. However, this rule is applicable only to the ctags writer. The other writer like json-writer doesn't need to follow the rule. The fixed field is implemented in field.c. Now, it moves to writer-ctags.c. As the result, json-writer can print the result with disabling "name", "input", and/or "pattern". Signed-off-by: Masatake YAMATO <[email protected]>
@masatake Concerning my initial question, I believe I have made some progress but another question also comes up: is there any definite way I can use to see if a tag has children or not, e.g., each variable doesn't have any children. |
There is no way. You can know whether an entry in a file has children or not after reading all entries in the file. |
@masatake Is that possible to add a new field The source file is https://github.com/paritytech/substrate/blob/3ec6247e44/srml/staking/src/lib.rs $ ctags --format=2 --excmd=pattern --fields=nksSaf --extras= --file-scope=yes --sort=no --append=no --language-force=rust --rust-kinds=cPstvfgieMnm --output-format=json -f- lib.rs The nested display generated at the moment: As you can see, However, if the original tag info of |
I don't know well about vim. So show the Rust input, the current tags output, and the tags that you expect. |
Ok. $ cd /tmp
$ curl -O https://raw.githubusercontent.com/paritytech/substrate/3ec6247e44ba8656007fbf75295d6d373b955846/srml/staking/src/lib.rs
$ ctags --format=2 --excmd=pattern --fields=nksSaf --extras= --file-scope=yes --sort=no --append=no --language-force=rust --rust-kinds=cPstvfgieMnm --output-format=json -f- lib.rs There are several implementation for the first one is from https://github.com/paritytech/substrate/blob/3ec6247e44/srml/staking/src/lib.rs#L757, its pattern is
then next three implementations for
These implementations have the same name and kind, but different pattern. Without a new field like For instance, if I know the pattern of scope, I can precisely tell {"_type": "tag", "name": "on_session_change", "path": "lib.rs", "pattern": "/^\tfn on_session_change(elapsed: T::Moment, should_reward: bool) {$/", "line": 1041, "signature": "(elapsed: T::Moment, should_reward: bool)", "kind": "method", "scope": "Module", "scopeKind": "implementation", "scopePattern": "/^impl<T: Trait> OnSessionChange<T::Moment> for Module {$/"} Besides the |
I feel you are going in the wrong direction. What we have to think about is Rust and how ctags models language objects in Rust. I don't know Rust. Let's allow me to use a simplified input. foo.rst
The current ctags implementation emits two tag entries for If you have time and want to fix this issue completely, please, read more. The current rust parser captures Module in line 3. This is what we should fix. So we can give X as a scope for Y. The biggest issue is that what kind of name the rust parser should use for the tag taken from line 3? I discussed this topic with @ithinuel. However, we cannot find an acceptable one. At that time, we discussed only how the name should be. Now I think I have to think about kind for the name, too. If we can only 'c/class' for the name, we have to rather make the name for capturing longer.
How do you call this? How do you answer a question "what is X?" ? |
If you are not interested in Rust itself, use the line: field. It will be the simplest solution. |
Here X is a trait implementation attached to Module. How about introducing
|
Thanks for your time, seemingly not easy to find a quick solution. I'm actually not a master of Rust/C language, sorry for can't help more. The approach I'm using for building the nested structure is to gather all potential root items first, and then find all it's descendants, so even using the heuristic way you mentioned to find the exact parent, I have to redesign the current code, and that will result in some more computation obviously. Anyhow, I'll see what I can do. Thanks again! |
Missing your last comment :(.
I think that's doable. IMHO the relation is that |
* Supprt nested display Update Fix t:vista.raw_by_kind Made a progress! Cleanup Cleanup default.vim and improve syntax Avoid E315 error autocmd is neccesary and use ~ as protected symbol Bright back autocmd since noautocmd is enough >.. * Avoid duplicate children * Improve algorithm * Don't highlight nearest tag when in non-normal mode * Fix duplicate parent line * Clean up * Add scope seperator * Nit * Disable CursorHold and CursorHoldI * Fix auto highlight of the nearest tag * Decorate kind * Also decorate kind for the scopeless * Fix tag highlighting in cmdline * Fix echoing scope * Change g:vista_ctags_renderer to g:vista#renderer#ctags * Mind the gap * Nit * Update doc * Auto highlight in vista sidebar * Update new screenshot * Fix url * Add new screencast * Update ISSUE_TEMPLATE * Refactor s:DescendentsOf * Alleviate the issue of implementing multiple times for a class * Fix universal-ctags/ctags#2065 (comment) * Update new screencast
(
Thank you for contacting us.
If you are reporting an issue with the parsing output, please fill
the following template. As your custom CTags configuration can
affect results, please always use
--options=NONE
as the firstoption when running
ctags
.Otherwise, delete the template and write your issue from scratch.
Examples may help developers understanding your issue better.
Use GitHub web interface and markdown notation.
Using mail results broken text rendering that makes
the developers go crazy.
)
The name of the parser: any one
The command line you used to run ctags:
The content of input file
test.py
:The tags output you:
My question is how to generate a tree like structure from the output above? Ref to (liuchengxu/vista.vim#30) I did try to search for some document about how the scoped tags are related, e.g., how to get all the members/methods of a class, but no luck. I know the tagbar code could a reference, but I also would like to hear some instructions from the official. Thanks!
The version of ctags:
How do you get ctags binary:
The text was updated successfully, but these errors were encountered: