PMD JSP language module providing static code analysis capabilities for JavaServer Pages files with lexical analysis, AST parsing, and rule-based code quality checks.
—
The JSP Language Module registers JSP as a supported language in the PMD framework and provides configuration for file extensions and copy-paste detection capabilities.
Main class that registers JSP language with PMD framework.
public class JspLanguageModule extends SimpleLanguageModuleBase implements CpdCapableLanguage {
public JspLanguageModule();
public static JspLanguageModule getInstance();
public CpdLexer createCpdLexer(LanguagePropertyBundle bundle);
}Usage:
import net.sourceforge.pmd.lang.jsp.JspLanguageModule;
import net.sourceforge.pmd.lang.LanguageRegistry;
// Get the JSP language module instance
JspLanguageModule jspModule = JspLanguageModule.getInstance();
// Or get via language registry
JspLanguageModule module = (JspLanguageModule) LanguageRegistry.PMD.getLanguageById("jsp");Methods:
getInstance(): Returns the singleton instance of the JSP language modulecreateCpdLexer(LanguagePropertyBundle): Creates a lexer for copy-paste detectionFile Extensions:
.jsp: JavaServer Pages.jspx: JSP XML format.jspf: JSP fragment files.tag: JSP tag filesLanguage Versions:
Language version handler that provides parser instances.
public class JspHandler extends AbstractPmdLanguageVersionHandler {
public Parser getParser();
}Usage:
import net.sourceforge.pmd.lang.jsp.JspHandler;
import net.sourceforge.pmd.lang.jsp.ast.JspParser;
JspHandler handler = new JspHandler();
Parser parser = handler.getParser(); // Returns JspParser instanceMethods:
getParser(): Returns a new JspParser instance for parsing JSP filesThe language module is automatically registered with PMD through the service loader mechanism:
File: /META-INF/services/net.sourceforge.pmd.lang.Language
net.sourceforge.pmd.lang.jsp.JspLanguageModuleThis enables PMD to automatically discover and load the JSP language support when the module is on the classpath.
The JSP language module integrates with PMD's core framework:
import net.sourceforge.pmd.lang.jsp.JspLanguageModule;
import net.sourceforge.pmd.cpd.CpdLexer;
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
// Get language module
JspLanguageModule module = JspLanguageModule.getInstance();
// Create CPD lexer for duplicate detection
LanguagePropertyBundle bundle = // ... PMD configuration
CpdLexer lexer = module.createCpdLexer(bundle);import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.Language;
// Check if JSP language is available
Language jspLang = LanguageRegistry.PMD.getLanguageById("jsp");
if (jspLang != null) {
System.out.println("JSP language supported");
System.out.println("Extensions: " + jspLang.getExtensions());
}The language module provides the foundation for all JSP analysis capabilities in PMD, enabling the framework to recognize JSP files and route them to the appropriate parser and rules.
Install with Tessl CLI
npx tessl i tessl/maven-net-sourceforge-pmd--pmd-jsp