Package net.sourceforge.pmd.lang
Interface Language
-
- All Superinterfaces:
Comparable<Language>
- All Known Implementing Classes:
BaseLanguageModule
,PlainTextLanguage
public interface Language extends Comparable<Language>
Represents a language module, and provides access to language-specific functionality. You can get a language instance fromLanguageRegistry
. Using a language involves first selecting the relevantLanguageVersion
for the sources, and accessing implemented services throughLanguageVersion.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
-
-
Field Summary
Fields Modifier and Type Field Description static String
LANGUAGE_MODULES_CLASS_NAMES_PROPERTY
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description LanguageVersion
getDefaultVersion()
Returns the default language version for this language.List<String>
getExtensions()
Returns the list of file extensions associated with this language.String
getName()
Returns the full name of this Language.Class<?>
getRuleChainVisitorClass()
Deprecated.Will be removed in PMD 7, avoid using thisString
getShortName()
Returns the short name of this language.String
getTerseName()
Returns the terse name of this language.LanguageVersion
getVersion(String version)
Returns the language version with the given version string.List<LanguageVersion>
getVersions()
Returns an ordered list of supported versions for this language.boolean
hasExtension(String extensionWithoutDot)
Returns whether this language handles the given file extension.boolean
hasVersion(String version)
Returns true if a language version with the given version string is registered.-
Methods inherited from interface java.lang.Comparable
compareTo
-
-
-
-
Field Detail
-
LANGUAGE_MODULES_CLASS_NAMES_PROPERTY
static final String LANGUAGE_MODULES_CLASS_NAMES_PROPERTY
- See Also:
- Constant Field Values
-
-
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 thisGet 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.
-
-