1 /**
2 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3 */
4 package net.sourceforge.pmd.lang;
5
6 import java.util.List;
7
8 /**
9 * Interface each Language implementation has to implement. It is used by the
10 * LanguageRregistry to access constants and implementation classes in order to
11 * provide support for the language.
12 * <p>
13 * The following are key components of a Language in PMD:
14 * <ul>
15 * <li>Name - Full name of the Language</li>
16 * <li>Short name - The common short form of the Language</li>
17 * <li>Terse name - The shortest and simplest possible form of the Language
18 * name, generally used for Rule configuration</li>
19 * <li>Extensions - File extensions associated with the Language</li>
20 * <li>Rule Chain Visitor - The RuleChainVisitor implementation used for this
21 * Language</li>
22 * <li>Versions - The LanguageVersions associated with the Language</li>
23 * </ul>
24 *
25 * @see LanguageVersion
26 * @see LanguageVersionDiscoverer
27 */
28 public interface Language {
29
30 String LANGUAGE_MODULES_CLASS_NAMES_PROPERTY = "languageModulesClassNames";
31
32 /**
33 * Get the full name of this Language. This is generally the name of this
34 * Language without the use of acronyms.
35 * @return The full name of this Language.
36 */
37 String getName();
38
39 /**
40 * Get the short name of this Language. This is the commonly used short
41 * form of this Language's name, perhaps an acronym.
42 * @return The short name of this Language.
43 */
44 String getShortName();
45
46 /**
47 * Get the terse name of this Language. This is used for Rule configuration.
48 * @return The terse name of this Language.
49 */
50 String getTerseName();
51
52 /**
53 * Get the list of file extensions associated with this Language.
54 * @return List of file extensions.
55 */
56 List<String> getExtensions();
57
58 /**
59 * Returns whether the given Language handles the given file extension.
60 * The comparison is done ignoring case.
61 * @param extension A file extension.
62 * @return <code>true</code> if this Language handles this extension, <code>false</code> otherwise.
63 */
64 boolean hasExtension(String extension);
65
66 /**
67 * Get the RuleChainVisitor implementation class used when visiting the AST
68 * structure for this Rules for this Language.
69 * @return The RuleChainVisitor class.
70 * @see net.sourceforge.pmd.lang.rule.RuleChainVisitor
71 */
72 Class<?> getRuleChainVisitorClass();
73
74 /**
75 * Gets the list of supported LanguageVersion for this Language.
76 * @return The LanguageVersion for this Language.
77 */
78 List<LanguageVersion> getVersions();
79
80 boolean hasVersion(String version);
81
82 /**
83 * Get the LanguageVersion for the version string from this Language.
84 * @param version The language version string.
85 * @return The corresponding LanguageVersion, <code>null</code> if the
86 * version string is not recognized.
87 */
88 LanguageVersion getVersion(String version);
89
90 /**
91 * Get the current PMD defined default LanguageVersion for this Language.
92 * This is an arbitrary choice made by the PMD product, and can change
93 * between PMD releases. Every Language has a default version.
94 * @return The current default LanguageVersion for this Language.
95 */
96 LanguageVersion getDefaultVersion();
97
98 }