/**
 * EJB component pattern plugin: detects ServiceComponentRequestInvoker patterns.
 */

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

export class EJBComponentPlugin implements PatternPlugin {
  readonly name = "ejb_component";

  matches(_tree: TSTree, filePath: string): boolean {
    try {
      const source = readFileSync(filePath);
      return (
        source.includes("ServiceComponentRequestInvoker") ||
        source.includes("AbstractCommonComponent")
      );
    } catch {
      return false;
    }
  }

  extract(_tree: TSTree, _filePath: string): (GraphNode | GraphEdge)[] {
    // MVP: detect presence only. Full extraction is post-MVP.
    return [];
  }
}
