or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

ast-parsing.mdindex.mdlanguage-module.mdrule-development.mdtype-analysis.md
tile.json

tessl/maven-net-sourceforge-pmd--pmd-visualforce

PMD language module that provides static code analysis capabilities for Salesforce Visualforce pages and components

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/net.sourceforge.pmd/pmd-visualforce@7.13.x

To install, run

npx @tessl/cli install tessl/maven-net-sourceforge-pmd--pmd-visualforce@7.13.0

index.mddocs/

PMD Visualforce

PMD Visualforce is a specialized language module for PMD that enables static code analysis of Salesforce Visualforce markup files (.page and .component). It extends PMD's core functionality to parse and analyze Visualforce pages and components, providing developers with code quality analysis capabilities specific to Visualforce development within the Salesforce ecosystem.

Package Information

  • Package Name: net.sourceforge.pmd:pmd-visualforce
  • Package Type: Maven library
  • Language: Java
  • Installation: Add dependency to your Maven project:
<dependency>
    <groupId>net.sourceforge.pmd</groupId>
    <artifactId>pmd-visualforce</artifactId>
    <version>7.13.0</version>
</dependency>

Core Imports

import net.sourceforge.pmd.lang.visualforce.VfLanguageModule;
import net.sourceforge.pmd.lang.visualforce.ast.*;
import net.sourceforge.pmd.lang.visualforce.rule.AbstractVfRule;

Basic Usage

import net.sourceforge.pmd.lang.visualforce.VfLanguageModule;
import net.sourceforge.pmd.lang.visualforce.ast.VfParser;
import net.sourceforge.pmd.lang.visualforce.VfLanguageProperties;

// Get the Visualforce language module instance
VfLanguageModule languageModule = VfLanguageModule.getInstance();

// Create parser with properties
VfLanguageProperties properties = new VfLanguageProperties();
VfParser parser = new VfParser(properties);

// Parse Visualforce content (typically done by PMD framework)
// ASTCompilationUnit ast = parser.parse(visualforceContent);

Architecture

PMD Visualforce follows PMD's standard language module architecture:

  • Language Module: VfLanguageModule registers the language with PMD and provides core services
  • Parser Infrastructure: VfParser and VfHandler handle parsing Visualforce markup into AST
  • AST Hierarchy: 20+ specialized node types representing different Visualforce constructs
  • Rule Framework: AbstractVfRule base class for creating custom analysis rules
  • Type System: Integration with Salesforce metadata for type-aware analysis
  • CPD Support: VfCpdLexer enables copy-paste detection in Visualforce files

The package integrates seamlessly with PMD's analysis engine and depends on the Apex language module for comprehensive Salesforce analysis workflows.

Capabilities

Language Module Setup

Core language module registration and configuration for integrating Visualforce analysis into PMD.

public class VfLanguageModule extends SimpleLanguageModuleBase implements CpdCapableLanguage {
    public static VfLanguageModule getInstance();
    public CpdLexer createCpdLexer(LanguagePropertyBundle bundle);
    public LanguagePropertyBundle newPropertyBundle();
}

public class VfLanguageProperties extends LanguagePropertyBundle {
    public static final PropertyDescriptor<List<String>> APEX_DIRECTORIES_DESCRIPTOR;
    public static final PropertyDescriptor<List<String>> OBJECTS_DIRECTORIES_DESCRIPTOR;
}

Language Module Setup

AST Parsing and Node Types

Complete Abstract Syntax Tree generation with specialized node types for parsing and representing Visualforce markup structures.

public final class VfParser extends JjtreeParserAdapter<ASTCompilationUnit> {
    public VfParser(VfLanguageProperties vfProperties);
}

public interface VfNode extends JjtreeNode<VfNode> {}

public final class ASTCompilationUnit extends AbstractVfNode implements RootNode {
    public AstInfo<ASTCompilationUnit> getAstInfo();
}

public final class ASTElement extends AbstractVfNode {
    public boolean isHasNamespacePrefix();
    public String getName();
    public boolean isEmpty();
    public boolean isUnclosed();
}

AST Parsing and Node Types

Rule Development Framework

Infrastructure for creating custom PMD rules to analyze Visualforce code quality and security issues.

public abstract class AbstractVfRule extends AbstractRule implements VfVisitor<Object, Object> {
    public void apply(Node target, RuleContext ctx);
    public Object visitNode(Node node, Object param);
}

public abstract class VfVisitorBase<P, R> extends AstVisitorBase<P, R> implements VfVisitor<P, R> {}

Rule Development Framework

Type Analysis and Salesforce Integration

Type system integration with Salesforce metadata for context-aware analysis of Visualforce expressions and data binding.

public enum DataType {
    AutoNumber, Checkbox, Currency, Date, DateTime, Email, Text, /* ... */;
    
    public final boolean requiresEscaping;
    
    public static DataType fromString(String value);
    public static DataType fromTypeName(String value);
}

public class VfExpressionTypeVisitor {
    // Internal visitor for adding type information to AST
}

Type Analysis and Salesforce Integration

Types

// Core AST interfaces
public interface VfNode extends JjtreeNode<VfNode> {}

public interface VfVisitor<P, R> {
    R visit(ASTCompilationUnit node, P data);
    R visit(ASTElement node, P data);
    R visit(ASTElExpression node, P data);
    R visit(ASTAttribute node, P data);
    // ... visitor methods for all AST node types
}

// Language properties
public class VfLanguageProperties extends LanguagePropertyBundle {
    public VfLanguageProperties();
}

// Rule context
public abstract class AbstractVfRule extends AbstractRule implements VfVisitor<Object, Object> {}