Skip to content

[apex] Support per-file language version #7093

Open

Description

@adangel

Is your feature request related to a problem? Please describe.
#6991 introduced ASTApexFile#getApiVersion(), which reads the corresponding
-meta.xml file of the current Apex source file.

This information should be wired into PMD's mechanism to select which rules should be executed for each file by using the "minimumLanguageVersion" and "maximumLanguageVersion" rule attributes.

E.g. the new rule ApexUnitTestClassShouldHaveRunRelevantTestsAnnotation should only be run for Apex 66.0+.

Also note, that we don't differ here between API version and language (grammar) version. The parser will probably parse always the latest features.

Describe the solution you'd like

  • needs tests
  • needs to handle the absence of -meta.xml files gracefully
  • node.getRoot().getAstInfo().getTextDocument().getLanguageVersion() should be equal to ASTApexFile#getApiVersion()
  • TODO?

Describe alternatives you've considered

Additional context
See https://github.com/pmd/pmd/pull/6991/changes#r3835718604

Activity

  1. added
    an:enhancement
    on Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    an:enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions