package click.kamil.springstatemachineexporter.analysis.enricher;

import click.kamil.springstatemachineexporter.analysis.model.AnalysisResult;
import click.kamil.springstatemachineexporter.analysis.model.TriggerPoint;
import click.kamil.springstatemachineexporter.analysis.service.CodebaseIntelligenceProvider;
import click.kamil.springstatemachineexporter.ast.common.CodebaseContext;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class TriggerEnricher implements AnalysisEnricher {

    @Override
    public void enrich(AnalysisResult result, CodebaseContext context, CodebaseIntelligenceProvider intelligence) {
        log.info("Enriching {} with triggers", result.getName());
        
        List<TriggerPoint> triggers = intelligence.findTriggerPoints();
        
        // Initially, we just add all triggers found in the codebase to the metadata.
        // In later steps of Phase 2, we will filter them by State Machine ID.
        result.addMetadata(click.kamil.springstatemachineexporter.analysis.model.CodebaseMetadata.builder()
                .triggers(triggers)
                .build());
    }
}
