carbonblack / intellij-rpmspec

An IntelliJ plugin for RPM SPEC file support
Apache License 2.0
11 stars 4 forks source link

Conditional macro expansion is not correctly parsed #9

Closed iammattcoleman closed 2 years ago

iammattcoleman commented 2 years ago

I have a spec file with conditionals for handling distribution-specific requirements. One difference between distributions is that some of them require specifying a minimum version for some packages.

When building for those distributions, macros are defined named packagename_ver. Then, the dependencies for those packages are as follows:

Requires: packagename %{?packagename_ver:>= %{packagename_ver}}

I.E. If the packagename_ver macro is defined as 1.2.3, then it should expand to...

Requires: packagename >= 1.2.3

...and if it isn't defined, it will expand to just...

Requires: packagename

The issue I'm having is that the RPM Spec File plugin doesn't support these conditional expansions. For those lines, it emits the following error during code analysis:

Error:(122, 45) RpmSpecTokenType.!, RpmSpecTokenType.%, RpmSpecTokenType.(, RpmSpecTokenType.), RpmSpecTokenType.<, RpmSpecTokenType.>, RpmSpecTokenType.?, RpmSpecTokenType.BOOL_LITERAL, RpmSpecTokenType.CODE, RpmSpecTokenType.COMMENT, RpmSpecTokenType.FILES_DIRECTIVE_TOKEN, RpmSpecTokenType.FLOAT_LITERAL, RpmSpecTokenType.IDENTIFIER, RpmSpecTokenType.INTEGER_LITERAL, RpmSpecTokenType.\ or RpmSpecTokenType.if expected, got '='
tlusk commented 2 years ago

@iammattcoleman version 2.0.1 with a fix for this issue has been pushed to the Jetbrains marketplace. It should be live within a couple days.