Grammar-Kit icon indicating copy to clipboard operation
Grammar-Kit copied to clipboard

False positive "Unresolved BNF References" for `<<eof>>` if `parserUtilClass` is set

Open VladRassokhin opened this issue 2 years ago • 4 comments
trafficstars

Example: https://github.com/ant-druha/intellij-powershell/blob/7d804d118095392cc7d7f8d97bb0c3135285ca3c/src/main/resources/PowerShell.bnf#L156

Given parserUtilClass="com.intellij.plugin.powershell.lang.parser.PowerShellGeneratedParserUtil"

Inspection reports at e.g. line: private configuration_block_recover ::= !(statement_terminators? ('configuration' | <<eof>> | SQBR_L| statement_stop_tokens))

It seems inspection resolves from parserUtilClass only, without looking up in com.intellij.lang.parser.GeneratedParserUtilBase.

Versions: Build #IU-233.7784, built on September 21, 2023 org.jetbrains.idea.grammar (2022.3.2)

VladRassokhin avatar Sep 21 '23 08:09 VladRassokhin

That could be workaround by PowerShellGeneratedParserUtil extends GeneratedParserUtilBase, but given that parser generator works fine without that, it would be nice to fix inspection as well.

VladRassokhin avatar Sep 21 '23 08:09 VladRassokhin

UPD: Turns out bnf was incorrect indeed. It used parserImports=["static com.intellij.lang.parser.GeneratedParserUtilBase.*;"] trick.

VladRassokhin avatar Sep 21 '23 09:09 VladRassokhin

I think the static import trick is ok. We need to fix the resolution algo...

gregsh avatar Sep 21 '23 09:09 gregsh

Will submit MR shortly

VladRassokhin avatar Sep 21 '23 09:09 VladRassokhin