-
Notifications
You must be signed in to change notification settings - Fork 624
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
reftag in scheme (Was: adding reference tag function) #569
base: master
Are you sure you want to change the base?
Conversation
Now, it works in combination with GNU GLOBAL. o makeSimpleReferenceTag() function This function makes a reference tag. Now ctags prints it only when the -x option and --gtags option (explained later) are specified. Basically, you may use the function for all symbols except for definitions. o Modified scheme parser (parsers/scheme.c) This is an example parser to show the usage of makeSimpleReferenceTag() function. o --gtags option and test If this option is specified with the -x option, ctags also prints reference tags as well as definition tags with a type string at the head of each output. The type string is one of the following: D definition R reference GNU GLOBAL understand this format since global-6.2.6. Since modified ctags is upper compatible, if you don't use the --gtags option, its output is same as the original.
http://sourceforge.net/p/ctags/mailman/message/30020186/ Before starting working on this patches(I'm bit busy now.) I have two questions.
I have been working -X and --list-fields options. -X is extended and customizable version of -x. Here is pseudo output:
global can use either tags output or -x/X optout. Again, I'm busy now and there are too many issues. However, I will work on this issue. so please, wait. |
We have to work on three areas.
|
Because the cxref format was enough, and is available in older ctags too.
Of course!
You are right. It is really great.
Just no problem. Thank you for thinking of my suggestion. |
@shigio, I have written some important building blocks for implementing "reference tag". Consider follwoing small C code is given as input for ctags.
Which one should be reported as "reference tag" ? |
Though I don't know whether it's helpful, I will explain in case (Meaning of mark) I regarded '#include' as a mistake of '#define'. #define [D]PRINT([R]X) [R]printf("%d\n", ([R]X)) struct [D]point { int [D*]x, [D*]y; }; int [D*]result; void [D]len(int [D*]a, int [D*]b) { [R]result = [R]a * [R]a + [R]b * [R]b; } void [D]print_length (void) { struct [R]point [D*]p; [R]p.[R]x = [R]getInt(); [R]p.[R]y = [R]getInt(); [R]len([R]p.[R]x, [R]p.[R]y); [R]PRINT([R]result); } About [D], there seems to be no room of argument. [Treatment of variable definitions] Reason 1: Reason 2: However, please note that GLOBAL can't classify the type of symbols, [Treatment of references with no definition] Though such symbols are written to the reference tag file (GRTAGS), they $ global -x printf # not found by definition search |
@shigio, thank you. Very informative. I will think more about ctags side specification. |
(Private study note). We can think about a concept, "kinds" in referencing(let's call rkind). C:
a and c are lvalue reference. Python:
x is ??? reference. C
X in "undefine" reference. Providing kinds for reference may be quite useful for making a upper layer tool. There will be some common rkinds like value and lvalue. Many interesting things are in rkinds if we have enough time. Even about scope, I cannot explain what it is well. More rich model of source must be defined. |
Temporarily I should not think about rkind. Instead I can introduce generic rkind called "unknown" When we introduce the reference field, some of existing tags and/or kinds should be marked as reference.
X should be makred as reference. Do I make sense? I would like to solve https://sourceforge.net/p/ctags/bugs/368/ . input.h
expected tags (--field=+r, here r mean reference):
One of comments may be that "reference" is overkill for solving this. As @b4n wrote in #221 , introducing another kind like 'u' for undef is enough. However "reference" tag is too attractive for me. |
Implemented. I used 'ref:' as the name for field.
|
I think that this is exactly what is proposed in #80. But we still need a temporary memory database to store the tags to make the dual pass work. |
@vhda, thank you. I read #80 again. I think we can do something without memory database.
Now you can ctags as
Do I make sense? Of course it is cool if we can remove these manual steps. However, these manual steps are helpful for use to develop ctags. Other tools than ctags can generate hits. Do I make sense? Or Don't I misunderstand your idea? |
I think that's acceptable as a first approach. If I remember correctly we also discussed a similar solution for my "daemon mode" enhancement proposal. But if we implement this "hints" feature, then we should create a 6.0 release afterwards, as that feature is enough to make every ctags user migrate to u-ctags! ;) Unfortunately I have zero free time at the moment, so I'm not sure I can help in the implementation of this solution. But if you keep me up to date I can try to help you review it. |
( |
I will reserver |
One more:
|
Random thought: if we used the "normal" tags output format, wouldn't we be able to reuse the already at least part of the available |
I think mine is better. Mine is tightly integrated with field descriptors and is extensible. |
The initial version of |
@masatake regarding this specific PR, does it make sense to depend on gtags for "reference" identification? Or will we start implementing this as "typeref" in the parsers? |
@vhda, sorry to be late. I got the same health trouble again. I think universal ctags should provide "interface" about reference: the tags format and command line. About tags format "ref:" field may be needed. However, I'm still thinking what is the best. typeref field is very related to your plan, multi-path parser for multi-file(MPMF). My understanding of MPMF is that typeref and MPMF is for "definition", not "reference". Consider following short C program:
As this example shows MP/MPMF is meaningful on definition tag. It may be meaningful on reference tag, too but you don't have to wait for introducing reference tag releated code for implementing MPMF. When we introduce the interface for reference, the next step is implementation. My understanding is that ctags is a provider of tags file, and gtags is consumer of tags file. So we should not depend on gtags. Do I answer to your question well? |
@vhda, I think I misunderstood what you wrote. You used "typeref". I guessed you used it as field name. |
@shigio, I didn't see conigure of GLOBAL yet but, I recommend you to check
I would like to include reference/role feature to the initial release of universal-ctags. |
TODO: wirte more based on universal-ctags#569. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
This is based on a pull request (universal-ctags#569) submitted by @shigio on universal-ctags#569. The patch is at shigio@f9faf95
TODO: wirte more based on universal-ctags#569. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
I kept this optn till reviewing/merging scheme related code of the original PR. |
os: mac os 10.11.5 I tried gun global and universal ctags together with a big project, postgresql. Then gtags call ctags by (from It looks good. @shigio @masatake How is this feather now? Is there something wrong in my operation? |
Nothing wrong in your operation. |
Hi @masatake,
How can I realize "a tag doesn't have a specialized role"? Or should I always code as follows?
If roleIndex == -1 means 'generic', it may be convenient.
What do you think? |
Currently, a parser author must define R_SCHEME_GENERIC. -1 is reserved as
You can define a macro defining a macro for defining a generic role:
|
I understood. Shigio |
Sorry for the posts all over the place but I was trying to understand to improve the Clojure parses and stumbled across this one as well. the concept of a reference applies also to Clojure when top level (def foo "a")
(def bar (str "a" foo)) So I was wondering if this patch is ready and what to do for pushing it in. |
At last! It's what I was searching for several days.. Thanks a lot @masatake! Will it works for shell function calls interpreted as references? I'm waiting for a news eagerly. PS: |
Hello,
This pull request is to add a new ability which generates reference tags.
Now, it works in combination with GNU GLOBAL(*1).
By this modification, we become to be able to write a parser which treats
reference tags with a little burden. The parser is applicable in both of
ctags (definitions) and GNU GLOBAL (definitions and references).
What is included?
The modification includes the following.
makeSimpleReferenceTag() function
This function makes a reference tag. Now ctags prints it only when
the -x option and --gtags option (explained later) are specified.
Basically, you may use the function for all symbols except for
definitions.
Modified scheme parser (parsers/scheme.c)
This is an example parser to show the usage of makeSimpleReferenceTag()
function.
--gtags option and test
If this option is specified with the -x option, ctags also prints
reference tags as well as definition tags with a type string at the
head of each output. The type string is one of the following:
D definition
R reference
GNU GLOBAL understand this format since global-6.2.6.
Since modified ctags is upper compatible, if you don't use the
--gtags option, its output is same as the original.
How to write a parser using makeSimpleReferenceTag()?
Here is an example in parsers/scheme.c.
You can use makeSimpleReferenceTag() instead of makeSimpleTag()
for reference tags.
[Tmain/gtags-option.d/input.scm]
(Build of ctags)
You need to use --enable-gtags option for the configure script.
Without --gtags, it's same as the original.
With --gtags - also print references tags with a type string
for each output.
How does it work via GNU GLOBAL?
(Build of GNU GLOBAL)
You may use --with-exuberant-ctags option for the configure script.
It's usually recognized automatically though.
Preparations to use ctags as a plug-in parser of GLOBAL.
Make tag files - gtags invokes ctags internally
Print all definitions ('.*' is a regular expression which means ALL.)
Print all references to defined symbols
Print all references to undefined symbols
I believe this pull request adds new possibility to ctags, and is harmless.
I also believe it brings profit to both of ctags users and GLOBAL users.
Best Regards,
Shigio