Files
VisualSapfor/src/_VisualDVM/Passes/All/SPF_GetGCovInfo.java

104 lines
3.8 KiB
Java
Raw Normal View History

2024-10-14 12:14:01 +03:00
package _VisualDVM.Passes.All;
2024-10-14 15:19:13 +03:00
import Common.Passes.PassState;
import Common.Utils.Utils_;
2024-10-14 15:19:13 +03:00
import Common.Visual.Controls.PassControl;
import Common.Visual.UI;
import _VisualDVM.Global;
2024-10-14 12:14:01 +03:00
import _VisualDVM.Passes.PassCode;
import _VisualDVM.Passes.Sapfor.SilentSapforPass;
2024-10-14 15:19:13 +03:00
import _VisualDVM.ProjectData.Files.DBProjectFile;
import _VisualDVM.ProjectData.SapforData.GCOV.FileGCOVJson;
import _VisualDVM.ProjectData.SapforData.GCOV.GCOVJson;
import _VisualDVM.ProjectData.SapforData.GCOV.LineGCOVJson;
2023-09-17 22:13:42 +03:00
public class SPF_GetGCovInfo extends SilentSapforPass {
@Override
public String getIconPath() {
return "/Common/icons/NotPick.png";
2023-09-17 22:13:42 +03:00
}
protected String getDoneIconPath() {
return "/Common/icons/Pick.png";
2023-09-17 22:13:42 +03:00
}
@Override
public boolean hasStats() {
2023-09-17 22:13:42 +03:00
return true;
}
@Override
protected boolean canStart(Object... args) throws Exception {
if (UI.Question("Все анализы будут сброшены.Продолжить")) {
2023-09-17 22:13:42 +03:00
SPF_ParseFilesWithOrder.silent = true;
2024-10-14 15:19:13 +03:00
return super.canStart(args) && Global.mainModule.getPass(PassCode.GCOV).Do() && Global.mainModule.getPass(PassCode.SPF_ParseFilesWithOrder).Do();
2023-09-17 22:13:42 +03:00
}
return false;
}
@Override
protected void performFinish() throws Exception {
SPF_ParseFilesWithOrder.silent = false;
super.performFinish();
}
@Override
protected void performPreparation() throws Exception {
sapfor.cd(target.Home);
target.CleanInterruptFile();
}
@Override
protected void body() throws Exception {
sapfor.RunAnalysis(
getSapforPassName(),
-Global.messagesServer.getPort(),
target.sapforProperties.pack(),
2023-09-17 22:13:42 +03:00
target.getProjFile().getAbsolutePath());
}
@Override
protected void performDone() throws Exception {
if (!sapfor.getResult().isEmpty())
unpack(sapfor.getResult());
}
protected void unpack(String packed) throws Exception {
GCOVJson allJson = Utils_.gson.fromJson(packed, GCOVJson.class);
// System.out.println("packed="+ Utils_.Brackets(packed));
// System.out.println(allJson.allGCov.size());
for (FileGCOVJson fileJson: allJson.allGCov){
fileJson.file = Utils_.toW(fileJson.file);
//--
DBProjectFile projectFile = target.db.files.get(fileJson.file);
for (LineGCOVJson lineJson: fileJson.lines){
if (lineJson.line > 0) {
int v_line = lineJson.line - 1;
long v_execution = (lineJson.execution >= 0) ? lineJson.execution : 0;
// System.out.println("line="+v_line+"/"+v_execution);
if (!projectFile.gcov_info.line_info.containsKey(v_line)) {
projectFile.gcov_info.add_line(v_line, v_execution);
// System.out.println("+");
}
}
}
//завешение настроек.
projectFile.gcov_info.setup();
}
2023-09-17 22:13:42 +03:00
}
@Override
public void Reset() {
if (state == PassState.Done) {
state = PassState.Inactive;
2024-10-14 15:19:13 +03:00
for (PassControl control : controls)
2023-09-17 22:13:42 +03:00
control.setIcon(getIconPath());
}
}
@Override
protected void showDone() throws Exception {
if (Global.mainModule.HasFile())
Global.mainModule.getFile().form.ShowGCOV();
2024-10-14 15:19:13 +03:00
for (PassControl control : controls)
2023-09-17 22:13:42 +03:00
control.setIcon(getDoneIconPath());
}
@Override
protected void FocusResult() {
if (Global.mainModule.HasFile())
Global.mainModule.getFile().form.FocusGCOVLog();
2023-09-17 22:13:42 +03:00
}
@Override
protected boolean isGoodCode() {
return sapfor.getErrorCode() > 0;
}
2023-09-17 22:13:42 +03:00
}