ant-druha / intellij-powershell

Adds PowerShell language support to IntelliJ-based IDEs.
https://plugins.jetbrains.com/plugin/10249-powershell
Apache License 2.0
72 stars 20 forks source link

Null-coalescing operator in `param()` causes syntax highlighting to break #184

Closed samcarswell closed 6 months ago

samcarswell commented 7 months ago

Using a null-coalescing operator in param() causes syntax highlighting to break with the following error: ')', ',', '-f', <comment>, NLS or OP_C expected, got '??'

This causes the remainder of the file to not have syntax highlighting as well: image

I'm not sure if this is actually an issue with the code here or with a dependency (eg. PSScriptAnalyzer. Let me know if that's the case and I'll open a PR in the relevant repo.

Rider 2023.3.3 intellij-powershell 2.3.1

ForNeVeR commented 7 months ago

I believe that currently we rely on our own lexer and parser generated from src/main/resources/_PowerShellLexer.flex and src/main/resources/PowerShell.bnf, respectively.

There's an IntelliJ plugin to generate the lexer/parser in src/main/gen from these files. I have also just noted that we don't have the generation process documented anywhere. Will add to my notes to document the process and also look into automating it to avoid committing the generated files to the repository.

ForNeVeR commented 7 months ago

Ah, and also it's on my radar that we have quite a bunch of issues with the current parser implementation. I am planning to dive into it as one of my next tasks in the plugin, though I cannot promise when it will happen. So, if you are familiar with the parsers and can help with this issue, you are of course very welcome.

ForNeVeR commented 6 months ago

FYI, thanks to this request, I've updated the documentation and the code generator to work automatically on build. You no longer require arcane knowledge of how to use the IntelliJ Grammar-Kit plugin to generate the files.

Only the arcane knowledge of how to actually write the lexer and parser definitions is now required 😅

(Which still is a lot to ask from a contributor; so I still hope to start tackling these tasks myself eventually.)

samcarswell commented 6 months ago

Thanks for following up about this issue @ForNeVeR. I did have a look at the code, but I don't have enough lexer/parser knowledge to have made the change unfortunately 😅.

Thanks again!

ForNeVeR commented 6 months ago

Not sure if coincidence or not, but I actually was preparing a fix for the issue while you sent the comment about it :)