package _VisualDVM.Passes.All;
import Common.Utils.Utils_;
import _VisualDVM.Global;
import _VisualDVM.Passes.Sapfor.SapforAnalysis;
import _VisualDVM.ProjectData.Files.DBProjectFile;
import _VisualDVM.ProjectData.SapforData.LineInfo.FileMetrics;
import _VisualDVM.ProjectData.SapforData.LineInfo.MetricsJson;
public class SPF_GetFileLineInfo extends SapforAnalysis {
    @Override
    public String phase() {
        return "FILE_LINE_INFO";
    }
    @Override
    public void performPreparation() throws Exception {
        super.performPreparation(); //удаление интеррупта.
        target.numLines = 0;
        target.numSPF = 0;
        target.numDVM = 0;
    }
    @Override
    protected void showPreparation() throws Exception {
        Global.mainModule.getUI().getMainWindow().getProjectWindow().getAnalysisWindow().ShowNoMetrics();
    }
    @Override
    protected void unpack(String packed) throws Exception {
        MetricsJson metricsJson = Utils_.gson.fromJson(packed, MetricsJson.class);
        for (FileMetrics fileMetrics : metricsJson.allMetrics) {
            fileMetrics.file = Utils_.toW(fileMetrics.file);
            //--
            DBProjectFile file = target.db.files.Data.get(fileMetrics.file);
            file.lines_count = fileMetrics.linesCount;
            //--
            target.numLines += fileMetrics.linesCount;
            target.numSPF += fileMetrics.numSPF;
            target.numDVM += fileMetrics.numDVM;
            //--
        }
        target.UpdateDVMCount();
        target.UpdateSPFCount();
        target.UpdateLinesCount();
    }
    @Override
    protected void showDone() throws Exception {
        Global.mainModule.getUI().getMainWindow().getProjectWindow().getAnalysisWindow().ShowMetrics();
        super.showDone();
    }
    @Override
    protected void FocusResult() {
        super.FocusResult();
        Global.mainModule.getUI().getMainWindow().getProjectWindow().FocusAnalysis();
    }
}
