CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-net-sourceforge-pmd--pmd-jsp

PMD JSP language module providing static code analysis capabilities for JavaServer Pages files with lexical analysis, AST parsing, and rule-based code quality checks.

Pending
Overview
Eval results
Files

language-module.mddocs/

Language Module

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.

Language Registration

JspLanguageModule

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 module
  • createCpdLexer(LanguagePropertyBundle): Creates a lexer for copy-paste detection

File Extensions:

  • .jsp: JavaServer Pages
  • .jspx: JSP XML format
  • .jspf: JSP fragment files
  • .tag: JSP tag files

Language Versions:

  • Version 2: Legacy JSP
  • Version 3: Default version (modern JSP)

JspHandler

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 instance

Methods:

  • getParser(): Returns a new JspParser instance for parsing JSP files

Service Registration

The 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.JspLanguageModule

This enables PMD to automatically discover and load the JSP language support when the module is on the classpath.

Integration with PMD Framework

The JSP language module integrates with PMD's core framework:

  1. Language Registry: Automatically registers JSP language with ID "jsp"
  2. File Processing: Associates JSP file extensions with the language
  3. Parser Integration: Provides JSP parser through the handler
  4. CPD Integration: Enables copy-paste detection for JSP files
  5. Rule Processing: Enables JSP-specific rules to be applied to JSP files

Examples

Basic Language Module Usage

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);

Programmatic Integration

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

docs

ast-node-types.md

copy-paste-detection.md

index.md

jsp-parser-ast.md

language-module.md

rule-development.md

visitor-pattern.md

tile.json