Camelcade / Perl5-IDEA

Perl5 plugins for IntelliJ IDEA
https://plugins.jetbrains.com/plugin/7796-perl/
Other
408 stars 76 forks source link

Some subs are not resolved in some XS modules (and also in sophisticated PP modules like AnyEvent) #2175

Open aldem opened 4 years ago

aldem commented 4 years ago

Not sure if this is already known issue, but I could not find a ticket... sorry if this is already covered :)

Digest::MD5 subs like md5, md5_hex are not resolved and reported as undefined. There are other modules with similar issues but right now I could not remember which.

What is interesting - subs are available when auto completing imports:

image

but not when trying to call them, i.e. Digest::MD5:: does not show anything for completion:

image

while reference to md5 alone (when imported explicitly) does autocomplete:

image

More intriguing is that explicit reference as `Digest::MD5::md5() is recognized properly (despite there is no autocomplete):

image

And finally... a bit different issue is with AnyEvent, some subs like condvar are not visible too - those which are instantiated "magically" through direct or indirect manipulation of symbol tables or similar tricks - I guess this could be only catched by snapshotting symbol tables (like with xsubs).

hurricup commented 4 years ago

Regarding XS, check this one: https://github.com/Camelcade/Perl5-IDEA/issues/1576#issuecomment-617873987

And tricky pp subs may not be handled if plugin don't know about them. I'm implementing things, but you know, it's a perl. Plugin won't ever be perfect for every possible syntax.

hurricup commented 4 years ago

Imports and exports are hardcoded in the plugin for some modules requested by users.

aldem commented 4 years ago

What about snapshotting differences in symbol tables before and after module load - after parsing, i.e. use the result as the last resort? This should work for any module type type, in theory.

hurricup commented 4 years ago

I thought about that. But such table should be rebuilt too often. But as optional thing, probably viable.

aldem commented 4 years ago

Even if it will be done on demand (Tools/Perl5/Re-Generate...) it could help a lot.

hurricup commented 4 years ago

Btw, for now you may generate it yourself by adjusting https://github.com/Camelcade/Perl5-IDEA/blob/master/plugin/scripts/xs_parser_simple.pl

miken32 commented 3 years ago

Sorry I'm not well-versed with Perl, but can you clarify if your last comment means there's some way to resolve this problem?

Screen Shot 2021-04-16 at 11 59 55 AM

And if so, what is it? Thanks.

hurricup commented 3 years ago

It can solve XS problems (it should at least). Described action runs the script which attempts to introspect installed XS modules and built a stub file with empty declarations. There is no way atm to automatically solve tricky declarations problems. If they are from some wide-used library, you may submit an issue and i'll try to implement support for it.