Package net.sourceforge.pmd.lang
Class LanguageModuleBase.LanguageMetadata
java.lang.Object
net.sourceforge.pmd.lang.LanguageModuleBase.LanguageMetadata
- Enclosing class:
- LanguageModuleBase
Metadata about a language, basically a builder pattern for the
language instance.
Some of the metadata are mandatory:
- The id (
withId(String)) - The display name (
name(String)) - The file extensions (
extensions(String, String...)
-
Method Summary
Modifier and TypeMethodDescriptionaddAllVersionsOf(Language language) Add all the versions of the given language, including the default version.addDefaultVersion(String name, String... aliases) Add a new version by its name and make it the default version.addVersion(String name, String... aliases) Add a new version by its name.asDialectOf(String baseLanguageId) Defines the language as a dialect of another language.Record that this language depends on another language, identified by its id.extensions(String extensionWithoutPeriod, String... others) Record the extensions assigned to the language.extensions(Collection<String> extensions) Record the extensions assigned to the language.Record the display name of the language.Record the short name of the language.Factory method to create an ID.
-
Method Details
-
withId
Factory method to create an ID.- Parameters:
id- The language id. Must be usable as a Java package name segment, ie be lowercase, alphanumeric, starting with a letter.- Returns:
- A builder for language metadata
- Throws:
IllegalArgumentException- If the parameter is not a valid IDNullPointerException- If the parameter is null
-
name
Record the display name of the language. This also serves as the short name ifshortName(String)is not called.- Parameters:
name- Display name of the language- Throws:
NullPointerException- If the parameter is nullIllegalArgumentException- If the parameter is not a valid language name
-
shortName
Record the short name of the language.- Parameters:
shortName- Short name of the language- Throws:
NullPointerException- If the parameter is nullIllegalArgumentException- If the parameter is not a valid language name
-
extensions
public LanguageModuleBase.LanguageMetadata extensions(String extensionWithoutPeriod, String... others) Record the extensions assigned to the language. Extensions should not start with a period..- Parameters:
extensionWithoutPeriod- First extensionsothers- Other extensions (optional)- Throws:
NullPointerException- If any extension is null
-
extensions
Record the extensions assigned to the language. Extensions should not start with a period.. At least one extension must be provided.- Parameters:
extensions- the extensions- Throws:
NullPointerException- If any extension is nullIllegalArgumentException- If no extensions are provided
-
addVersion
Add a new version by its name.- Parameters:
name- Version name. Must contain no spaces.aliases- Additional names that are mapped to this version. Must contain no spaces.- Throws:
NullPointerException- If any parameter is nullIllegalArgumentException- If the name or aliases are empty or contain spaces
-
addDefaultVersion
Add a new version by its name and make it the default version.- Parameters:
name- Version name. Must contain no spaces.aliases- Additional names that are mapped to this version. Must contain no spaces.- Throws:
NullPointerException- If any parameter is nullIllegalArgumentException- If the name or aliases are empty or contain spaces
-
addAllVersionsOf
Add all the versions of the given language, including the default version.- Parameters:
language- Other language- Throws:
NullPointerException- If any parameter is nullIllegalArgumentException- If the name or aliases are empty or contain spaces
-
asDialectOf
Defines the language as a dialect of another language.- Experimental Status:
- Since 7.13.0. See [core] Support language dialects #5438.
- Parameters:
baseLanguageId- The id of the base language this is a dialect of.- Returns:
- A new dialect language metadata model.
-
dependsOnLanguage
Record that this language depends on another language, identified by its id. This means anyLanguageProcessorRegistrythat contains a processor for this language is asserted upon construction to also contain a processor for the language depended on.- Parameters:
id- ID of the language to depend on.- Throws:
NullPointerException- If any parameter is nullIllegalArgumentException- If the name is not a valid language Id
-