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
Feature Request: Perl Attributes with (has) #2067
Comments
@dtikhonov, could you look at this? |
Moose et al. are just modules and |
...I'm very interested in this topic. Past 3 years, I have improved ctags to handle DSLs. See http://docs.ctags.io/en/latest/running-multi-parsers.html?highlight=subparser#tagging-definitions-of-higher-upper-level-language-sub-base about my vision. Moose subparser can run on Perl parser.
When the Perl parser finds a keyword "use", Perl parser notifies it to registered subparsers. The Moose subparser pushes the "Point" to scope stack. About C++ parser, I have already implemented this idea. To implement a subparser, I have to get permission from the maintainer of its base parser. If there is confliction between a parser maintainer and me, who wants to introduce a subparser to the parser, I will withdraw from implementing the subparser because having a parser maintainer is the most important thing in the u-ctags project. @dtikhonov, if you are interested in the idea of implementing Moose as a subparser, let me know. Thank you for reading. |
I realize it's a function, under the hood. But, that's an implementation detail. In the same sense, packages are "classes" when you're programming in object oriented fashion, and "subs" are methods. All of that nomenclature changes when you use Object Oriented perl, but in each case you could make use of the non-OO terminology. In all the above cases though there are added complexities in inferring which paradigm the user has written the code for. That said, "has" lacks those complexities. If you see it you have two possible interpretations (a) you're calling a function "has" in which case the desired behavior would be to not do anything, as we do now; or, (b) you're using a Moose-esque attribute declaration. The "Moose et al" quote from your response shows how strong that convention is in Perl to use these module-builder frameworks (which embrace I am not saying we could not have any false-positives, but I don't know of anyone who has published a module that does not follow this convention and it stands to help a lot of people. Moreover, I truly doubt that this ctags is theoretically sound rather than just practical. |
@masatake the subparser idea sounds better and more complete than my implementation, and perl actually already does something similar by testing against https://github.com/universal-ctags/ctags/blob/master/parsers/perl.c#L348 I guess the problem there is that you'd have to enumerate the list of modules that trigger the Moose-parser which wouldn't be too bad. You'd also have to assume that no one is running a subclass of Moose which be tricky, but if they were doing that the worse case scenario is they'd lose the Moose-subparser. And, I'm OK with that -- it wouldn't be any worse than what they have that. If you want help writing a C parser for Moose, I can help out with that too. I'm almost of the mind set that this kind of static-parser for Perl and Moose would be useful outside of ctags too. Currently parsing perl is insecure, and there are no guarantees. This would allow other projects to securely run test coverage on Perl, for example. |
@masatake, Perl 5 is such a slow-moving target that there is not much to maintain, so my job as the maintainer of @EvanCarroll, code talks: feel free to take a shot at it. I am not married to |
Cool, cool. I'll see what I can get done this weekend then. I'll check out the work on the subparser framework too. |
A prototype works. I'm focusing on TypeScript parser. So I will not work on #2070 for awhile.
|
That was fast! 👍 |
@masatake impressive. Is there any more work to do? I see you've implemented |
That is the I would like to know :-). |
@masatake cool deal, I reviewed the patch with github. If you can't get around to it, I'll take a look this weekend. =) But you'll probably have it done in 0.0001 seconds. |
It is not true. To improve the parser, we need 4 things: knowledge about ctags internal API, knowledge about the target language, Moose, time, and passion:-P. I don't have knowledge about Moose. This one is the most important. Don't you expect ctags capture such rules? These requests from a person who knows the target language are needed to grow this project. I can implement some of them. You can implement other ones. We can implement later if such requests are. We can extend the current implementation to support Mouse, Moo, and Mo. We can do anything you |
Sorry, I found you gave me important comments in #2070 already. Thank you. |
Currently Perl is extended with Moose, Mouse, Moo, and Mo, and the like. These modules all have one commonality -- their attribute selectors are established with
has
. I believe we can make the assumption that anything that follows the Moose-established convention of,has $name|@$names => %options
is a properly formed attribute for one of the many object build systems out there.We'd have to cover things like
The text was updated successfully, but these errors were encountered: