Class DataClumpTracker

java.lang.Object
org.ek9lang.compiler.phase5.DataClumpTracker

class DataClumpTracker extends Object
Tracks function/method/constructor parameter signatures for data clump detection (E11053). A data clump occurs when the same group of 4+ parameters (by type and name) appears in 3+ callable signatures within a module, signalling a missing record abstraction.

Thread-safe: designed to be used during parallel file processing where multiple PreIRListener instances (one per file) share a single DataClumpTracker.

Based on Martin Fowler's "Refactoring" (1999): data clumps are groups of data that always appear together — they should be extracted into their own object.

Complexity: O(S) where S = total signatures recorded — linear collection phase.

  • Constructor Details

    • DataClumpTracker

      DataClumpTracker()
  • Method Details

    • recordSignature

      void recordSignature(String moduleName, String callableName, List<ISymbol> params, IToken token)
      Record a callable's parameter signature for a specific module. Only records if the callable has at least 4 parameters with resolved types.
      Parameters:
      moduleName - the module containing the callable
      callableName - the name of the function/method/constructor
      params - the parameter symbols
      token - the source token for error reporting
    • getSignatures

      List<DataClumpTracker.SignatureRecord> getSignatures(String moduleName)
      Get a snapshot copy of signatures for a specific module.
      Parameters:
      moduleName - the module to query
      Returns:
      list of signature records (may be empty, never null)
    • isExempt

      static boolean isExempt(String moduleName)
      Check if a module is exempt from data clump checking. Built-in modules (org.ek9.*) are exempt because their parameter patterns are intentional and part of the language runtime design.
      Parameters:
      moduleName - the module to check
      Returns:
      true if exempt (built-in modules)