Interface Language

  • All Superinterfaces:
    Comparable<Language>
    All Known Implementing Classes:
    BaseLanguageModule

    public interface Language
    extends Comparable<Language>
    Represents a language module, and provides access to language-specific functionality. You can get a language instance from LanguageRegistry. Using a language involves first selecting the relevant LanguageVersion for the sources, and accessing implemented services through LanguageVersion.getLanguageVersionHandler().

    Language instances must be registered with a service file to be picked up on by the LanguageRegistry.

    The following are key components of a language in PMD:

    • Name - Full name of the language
    • Short name - The common short form of the language
    • Terse name - The shortest and simplest possible form of the language name, generally used for rule configuration
    • Extensions - File extensions associated with the language
    • Versions - The language versions associated with the language
    See Also:
    LanguageVersion, LanguageVersionDiscoverer
    • Method Detail

      • getName

        String getName()
        Returns the full name of this Language. This is generally the name of this language without the use of acronyms, but possibly some capital letters, eg "Java". It's suitable for displaying in a GUI.
        Returns:
        The full name of this language.
      • getShortName

        String getShortName()
        Returns the short name of this language. This is the commonly used short form of this language's name, perhaps an acronym, but possibly with special characters.
        Returns:
        The short name of this language.
      • getTerseName

        String getTerseName()
        Returns the terse name of this language. This is a short, alphanumeric, lowercase name, eg "java". It's used to identify the language in the ruleset XML, and is also in the package name of the language module.
        Returns:
        The terse name of this language.
      • getExtensions

        List<String> getExtensions()
        Returns the list of file extensions associated with this language. This list is unmodifiable. Extensions do not have a '.' prefix.
        Returns:
        A list of file extensions.
      • hasExtension

        boolean hasExtension​(String extensionWithoutDot)
        Returns whether this language handles the given file extension. The comparison is done ignoring case.
        Parameters:
        extensionWithoutDot - A file extension (without '.' prefix)
        Returns:
        true if this language handles the extension, false otherwise.
      • getRuleChainVisitorClass

        @Deprecated
        Class<?> getRuleChainVisitorClass()
        Deprecated.
        Will be removed in PMD 7, avoid using this
        Get the RuleChainVisitor implementation class used when visiting the AST structure for this Rules for this Language.
        Returns:
        The RuleChainVisitor class.
        See Also:
        RuleChainVisitor
      • getVersions

        List<LanguageVersion> getVersions()
        Returns an ordered list of supported versions for this language.
        Returns:
        All supported language versions.
      • hasVersion

        boolean hasVersion​(String version)
        Returns true if a language version with the given version string is registered. Then, getVersion will return a non-null value.
        Parameters:
        version - A version string
        Returns:
        True if the version string is known
      • getVersion

        LanguageVersion getVersion​(String version)
        Returns the language version with the given version string. Returns null if no such version exists.
        Parameters:
        version - A language version string.
        Returns:
        The corresponding LanguageVersion, null if the version string is not recognized.
      • getDefaultVersion

        LanguageVersion getDefaultVersion()
        Returns the default language version for this language. This is an arbitrary choice made by the PMD product, and can change between PMD releases. Every language has a default version.
        Returns:
        The current default language version for this language.