/**
 * Constant pool plugin: cross-references static final constants.
 */

import { readFileSync } from "node:fs";
import type { TSTree } from "../scanner/parser";
import type { GraphEdge, GraphNode } from "../types";
import type { PatternPlugin } from "./base";

export class ConstantPoolPlugin implements PatternPlugin {
  readonly name = "constant_pool";

  matches(_tree: TSTree, filePath: string): boolean {
    try {
      const source = readFileSync(filePath, "utf-8");
      const count = (source.match(/static final String/g) || []).length;
      return count > 10;
    } catch {
      return false;
    }
  }

  extract(_tree: TSTree, _filePath: string): (GraphNode | GraphEdge)[] {
    // MVP: detection and marking only.
    return [];
  }
}
