or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/maven-net-sourceforge-pmd--pmd-julia

Julia language module for PMD static code analyzer, providing Copy-Paste-Detector (CPD) support for Julia source code analysis

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

To install, run

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

index.mddocs/

PMD Julia Language Module

PMD Julia is a Java library that provides Julia language support for PMD's Copy-Paste-Detector (CPD) functionality. It enables static code analysis and duplicate code detection for Julia source files (.jl extension) by integrating with PMD's extensible language architecture through ANTLR-based parsing.

Package Information

  • Package Name: pmd-julia
  • Group ID: net.sourceforge.pmd
  • Artifact ID: pmd-julia
  • Package Type: maven
  • Language: Java
  • Installation: Add dependency to Maven pom.xml:
<dependency>
    <groupId>net.sourceforge.pmd</groupId>
    <artifactId>pmd-julia</artifactId>
    <version>7.13.0</version>
</dependency>

Core Imports

import net.sourceforge.pmd.lang.julia.JuliaLanguageModule;
import net.sourceforge.pmd.lang.julia.cpd.JuliaCpdLexer;
import net.sourceforge.pmd.cpd.CpdLexer;
import net.sourceforge.pmd.lang.LanguagePropertyBundle;
import net.sourceforge.pmd.lang.LanguageRegistry;

Basic Usage

import net.sourceforge.pmd.lang.julia.JuliaLanguageModule;
import net.sourceforge.pmd.cpd.CpdLexer;
import net.sourceforge.pmd.lang.LanguagePropertyBundle;

// Get the Julia language module instance
JuliaLanguageModule juliaModule = JuliaLanguageModule.getInstance();

// Create a CPD lexer for Julia source code analysis
LanguagePropertyBundle bundle = // ... configure as needed
CpdLexer lexer = juliaModule.createCpdLexer(bundle);

// Use the lexer for tokenizing Julia code for duplicate detection
// The lexer will parse .jl files and generate tokens for CPD analysis

Architecture

The PMD Julia module is built around PMD's language extension architecture:

  • Language Module: JuliaLanguageModule extends CpdOnlyLanguageModuleBase to register Julia as a supported language
  • CPD Integration: Uses ANTLR-generated lexer for tokenization and duplicate code detection
  • Language Registry: Integrates with PMD's LanguageRegistry.CPD for language discovery
  • File Association: Automatically handles .jl file extensions for Julia source code

Capabilities

Language Module Management

Core functionality for registering and managing Julia language support within PMD.

/**
 * Main language module for Julia support in PMD.
 * Extends CpdOnlyLanguageModuleBase to provide Julia language integration.
 */
public class JuliaLanguageModule extends CpdOnlyLanguageModuleBase {
    /**
     * Creates a new Julia Language instance.
     * Configures language with ID "julia", name "Julia", and ".jl" file extension.
     */
    public JuliaLanguageModule();
    
    /**
     * Gets the singleton instance of the Julia language module.
     * @return JuliaLanguageModule instance from the CPD language registry
     */
    public static JuliaLanguageModule getInstance();
    
    /**
     * Creates a CPD lexer for Julia source code analysis.
     * @param bundle Language property configuration bundle
     * @return CpdLexer instance specifically configured for Julia tokenization
     */
    @Override
    public CpdLexer createCpdLexer(LanguagePropertyBundle bundle);
}

Copy-Paste Detection

Tokenization functionality for duplicate code detection in Julia source files.

/**
 * Julia tokenizer for copy-paste detection.
 * Extends AntlrCpdLexer to provide ANTLR-based tokenization.
 * Note: Previously called JuliaTokenizer in PMD 6.
 */
public class JuliaCpdLexer extends AntlrCpdLexer {
    /**
     * Creates a lexer instance for the given character stream.
     * @param charStream Input character stream containing Julia source code
     * @return Lexer instance configured for Julia language tokenization
     */
    @Override
    protected Lexer getLexerForSource(CharStream charStream);
}

Types

Core PMD Integration Types

These types are provided by PMD core and used by the Julia module:

/**
 * Base class for language modules that only support CPD functionality.
 */
abstract class CpdOnlyLanguageModuleBase {
    /**
     * Constructor for CPD-only language modules.
     * @param metadata Language metadata configuration
     */
    protected CpdOnlyLanguageModuleBase(LanguageMetadata metadata);
}

/**
 * Language property configuration bundle.
 */
interface LanguagePropertyBundle {
    // Implementation provided by PMD core
}

/**
 * Interface for CPD lexers that tokenize source code.
 */
interface CpdLexer {
    // Implementation provided by PMD core
}

/**
 * ANTLR-based CPD lexer base class.
 */
abstract class AntlrCpdLexer implements CpdLexer {
    // Implementation provided by PMD core
}

/**
 * Base interface for PMD language implementations.
 */
interface Language {
    // Implementation provided by PMD core
}

/**
 * Language registry for PMD language modules.
 */
class LanguageRegistry {
    /**
     * Registry instance for CPD-only languages.
     */
    public static final LanguageRegistry CPD;
    
    /**
     * Gets a language module by its identifier.
     * @param id Language identifier (e.g., "julia")
     * @return Language module instance or null if not found
     */
    public Language getLanguageById(String id);
}

ANTLR Integration Types

/**
 * Language metadata configuration for PMD language modules.
 */
class LanguageMetadata {
    /**
     * Creates language metadata with specified ID.
     * @param id Language identifier (e.g., "julia")
     * @return LanguageMetadata builder for further configuration
     */
    public static LanguageMetadata withId(String id);
    
    /**
     * Sets the display name for the language.
     * @param name Human-readable language name
     * @return LanguageMetadata builder for method chaining
     */
    public LanguageMetadata name(String name);
    
    /**
     * Sets file extensions associated with the language.
     * @param extensions File extensions without dots (e.g., "jl")
     * @return Configured LanguageMetadata instance
     */
    public LanguageMetadata extensions(String... extensions);
}

/**
 * ANTLR character stream interface for input processing.
 */
interface CharStream {
    // Implementation provided by ANTLR runtime
}

/**
 * ANTLR lexer base class for tokenization.
 */
abstract class Lexer {
    // Implementation provided by ANTLR runtime
}

/**
 * ANTLR-generated lexer for Julia language tokenization.
 * This class is generated from the Julia.g4 grammar file.
 */
class JuliaLexer extends Lexer {
    /**
     * Creates a Julia lexer for the given character stream.
     * @param input Character stream containing Julia source code
     */
    public JuliaLexer(CharStream input);
}

Deprecated AST Classes

Note: The following AST classes are deprecated since PMD 7.8.0 and will be removed with no replacement. They were ANTLR-generated classes that were never intended for public use.

Parser Classes

The following parser and AST classes are available but deprecated:

/**
 * ANTLR-generated parser for Julia language.
 * @deprecated Since 7.8.0. Will be removed with no replacement.
 */
@Deprecated
public class JuliaParser extends Parser {
    // Various parsing methods for Julia syntax elements
    // Implementation is ANTLR-generated and not intended for direct use
}

Visitor Pattern Classes

/**
 * Visitor interface for Julia parse tree traversal.
 * @param <T> Return type of visit operations
 * @deprecated Since 7.8.0. Will be removed with no replacement.
 */
@Deprecated
public interface JuliaVisitor<T> extends ParseTreeVisitor<T> {
    // Visit methods for all Julia AST node types
}

/**
 * Base visitor implementation with default behaviors.
 * @param <T> Return type of visit operations
 * @deprecated Since 7.8.0. Will be removed with no replacement.
 */
@Deprecated
public class JuliaBaseVisitor<T> extends AbstractParseTreeVisitor<T> 
    implements JuliaVisitor<T> {
    // Default implementations for all visit methods
}

Listener Pattern Classes

/**
 * Listener interface for Julia parse tree events.
 * @deprecated Since 7.8.0. Will be removed with no replacement.
 */
@Deprecated
public interface JuliaListener extends ParseTreeListener {
    // Enter/exit methods for all Julia AST node types
}

/**
 * Base listener implementation with empty default methods.
 * @deprecated Since 7.8.0. Will be removed with no replacement.
 */
@Deprecated
public class JuliaBaseListener implements JuliaListener {
    // Empty default implementations for all listener methods
}

Dependencies

The Julia language module requires the following dependencies:

  • PMD Core: net.sourceforge.pmd:pmd-core - Core PMD functionality and language framework
  • ANTLR Runtime: org.antlr:antlr4-runtime - ANTLR parser runtime for Julia grammar processing

File Extensions

  • .jl - Julia source files supported by the language module

Error Handling

The module integrates with PMD's error handling mechanisms. Parsing errors and lexing issues are reported through PMD's standard error reporting system. No specific exceptions are thrown by the public API - errors are handled internally by the ANTLR lexer and PMD framework.

Build Integration

The module includes Maven build configuration with:

  • ANTLR4 Maven plugin for grammar generation
  • Custom ANT tasks for CPD language registration
  • Resource filtering for language metadata

This module is designed for integration into larger PMD-based static analysis workflows and CI/CD pipelines for Julia code quality assessment.