Skip to content

Grammar-Kit generates unnecessary annotations for custom methods (IntelliJ IDEA 2025.1.2+) #401

@mlytvyn

Description

@mlytvyn

Hello,

Having the following BNF file flexibleSearch.bnf Grammar-Kit generates non-compilable code with unnecessary @NotNull / @Nullable annotations for custom methods implemented in the Mixin or psiImplUtilClass in IntelliJ IDEA 2025.1.2+.

In addition to that code style for those generated methods is different and missing new lines.

Code generated via IntelliJ IDEA 2023.3.8 (version from the latest master branch) looks good and compilable.

BNF rule

y_column_name ::= ORDER | IDENTIFIER {
    mixin="com.intellij.idea.plugin.hybris.flexibleSearch.psi.impl.FlexibleSearchYColumnNameMixin"
    methods=[getTableToAlias getTableAliases]
}

PSI Util method

fun getTableAliases(element: PsiElement): Collection<FlexibleSearchTableAliasName> {
...
}
2023.3.8 generated code
public interface FlexibleSearchYColumnName extends PsiElement {

  @Nullable
  Pair<FlexibleSearchDefinedTableName, FlexibleSearchTableAliasName> getTableToAlias();

  @NotNull
  Collection<FlexibleSearchTableAliasName> getTableAliases();

}
2025.1.2+ generated code
public interface FlexibleSearchYColumnName extends PsiElement {

  @Nullable Pair<@NotNull FlexibleSearchDefinedTableName, @Nullable FlexibleSearchTableAliasName> getTableToAlias();

  @NotNull Collection<@NotNull FlexibleSearchTableAliasName> getTableAliases();

}

Same happens for methods implemented in the Mixin, f.e. FlexibleSearchBindParameterMixin.

Method implemented in the Mixin

override fun getItemType(): TSGlobalMetaClassifier<out DomElement>? = ....
2025.1.2+ generated code
public interface FlexibleSearchBindParameter extends PsiElement {

  @NotNull
  List<FlexibleSearchExtParameterName> getExtParameterNameList();

  @Nullable
  PsiElement getNamedParameter();

  @Nullable FlexibleSearchExpression getExpression();

  @Nullable TSGlobalMetaClassifier<? extends @NotNull DomElement> getItemType();

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions