Package net.sourceforge.pmd.lang
Class LanguageProcessorRegistry
- java.lang.Object
-
- net.sourceforge.pmd.lang.LanguageProcessorRegistry
-
- All Implemented Interfaces:
AutoCloseable
public final class LanguageProcessorRegistry extends Object implements AutoCloseable
Stores all currently initializedLanguageProcessors during analysis.- Author:
- Clément Fournier
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLanguageProcessorRegistry.LanguageTerminationExceptionAn exception that occurs during the closing of aLanguageProcessor,
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close all processors in this registry.static LanguageProcessorRegistrycreate(LanguageRegistry registry, Map<Language,LanguagePropertyBundle> languageProperties, PmdReporter messageReporter)Create a new instance by creating a processor for each language in the given language registry.static Map<Language,LanguagePropertyBundle>derivePropertiesFromStrings(Map<Language,Properties> stringProperties, PmdReporter reporter)LanguageRegistrygetLanguages()Return the languages that are registered in this instance.@NonNull LanguageProcessorgetProcessor(Language l)Return the processor for a given language.static LanguageProcessorRegistrysingleton(@NonNull LanguageProcessor lp)Create a registry with a single language processor.StringtoString()
-
-
-
Method Detail
-
getLanguages
public LanguageRegistry getLanguages()
Return the languages that are registered in this instance.
-
getProcessor
public @NonNull LanguageProcessor getProcessor(Language l)
Return the processor for a given language.- Parameters:
l- a language- Throws:
IllegalArgumentException- if the language is not part of this registry
-
close
public void close() throws LanguageProcessorRegistry.LanguageTerminationExceptionClose all processors in this registry.- Specified by:
closein interfaceAutoCloseable- Throws:
LanguageProcessorRegistry.LanguageTerminationException- If closing any of the processors threw something
-
singleton
public static LanguageProcessorRegistry singleton(@NonNull LanguageProcessor lp)
Create a registry with a single language processor.- Throws:
IllegalStateException- If the language depends on other languages, as they are then not included in this registry (seeLanguage.getDependencies()).
-
create
public static LanguageProcessorRegistry create(LanguageRegistry registry, Map<Language,LanguagePropertyBundle> languageProperties, PmdReporter messageReporter)
Create a new instance by creating a processor for each language in the given language registry. Each processor is created using the property bundle that is in the map, if present. Language properties are defaulted to environment variables if they are not already overridden.- Throws:
IllegalStateException- If any language in the registry depends on languages that are not found in it, or that could not be instantiated (seeLanguage.getDependencies()).IllegalArgumentException- If some entry in the map maps a language to an incompatible property bundle
-
derivePropertiesFromStrings
public static Map<Language,LanguagePropertyBundle> derivePropertiesFromStrings(Map<Language,Properties> stringProperties, PmdReporter reporter)
-
-