Camelcade / Perl5-IDEA

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

Syntax::Keyword::Try require redundant semicolon #2424

Open eitankeren opened 3 years ago

eitankeren commented 3 years ago

The syntax check mark an error if Syntax::Keyword::Try; is used without ending ";" while they aren't needed, see example below.

use Syntax::Keyword::Try;

try { attempt_a_thing(); return "success"; } catch ($e) { warn "It failed - $e"; return "failure"; };

The catch block do not need the ending semicolon signed but without it the Perl syntax checker will raise an error.

hurricup commented 3 years ago

The reason is that there are lot of different try-catch implementation. Some of them require semi others - don't. Plugin supports some of them, but it's not possible to say which one is used in particular file. So there is a heuristic. And it fails sometime. I don't see how I can distinct this approach from another one.

eitankeren commented 3 years ago

Clear.

if you can link the Try/Cache module importation to the correct syntax that may be nice as this one is among the more popular one used by the Perl community together with Tiny::Try.

Thanks allot for your fast response, Your contribution to the community is very much appreciated!

-- Eitan

hurricup commented 3 years ago

The problem is that it may be used indirectly or in some tricky way. I don't really remember atm what problems I had, but it was a real headache :)

Here is the list of modules that should work correctly: https://github.com/Camelcade/Perl5-IDEA/blob/master/plugin/core/grammar/Perl5.bnf#L681

hurricup commented 3 years ago

I'll recheck the code, but can't give you exact estimation.

eitankeren commented 3 years ago

Ok, thanks allot for your efforts!

akarelas commented 2 years ago

Maybe could add a per-project setting that lets us choose which Try library we're using?

That way we could have next and redo inside try or catch blocks, if we choose say Syntax::Keyword::Try without a red underline