граф процедур в json
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
package _VisualDVM.Passes.All;
|
||||
import Common.Utils.Index;
|
||||
import Common.Utils.Utils_;
|
||||
import Common.Visual.UI;
|
||||
import _VisualDVM.Current;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.Passes.PassCode;
|
||||
@@ -10,9 +8,10 @@ import _VisualDVM.ProjectData.Files.DBProjectFile;
|
||||
import _VisualDVM.ProjectData.SapforData.Functions.FuncCall;
|
||||
import _VisualDVM.ProjectData.SapforData.Functions.FuncInfo;
|
||||
import _VisualDVM.ProjectData.SapforData.Functions.FunctionType;
|
||||
import _VisualDVM.ProjectData.SapforData.Functions.Json.FileFunctionsJson;
|
||||
import _VisualDVM.ProjectData.SapforData.Functions.Json.FunctionsJson;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Vector;
|
||||
public class SPF_GetGraphFunctions extends SapforAnalysis {
|
||||
@Override
|
||||
protected void showPreparation() {
|
||||
@@ -49,43 +48,16 @@ public class SPF_GetGraphFunctions extends SapforAnalysis {
|
||||
@Override
|
||||
protected void unpack(String packed) throws Exception {
|
||||
LinkedHashMap<String, FuncInfo> declarated_functions = new LinkedHashMap<>();
|
||||
String[] splited = packed.split("\\|");
|
||||
Index idx = new Index();
|
||||
// new version of function graph reading, availible from Sapfor version 156
|
||||
int numOfFiles = Integer.parseInt(splited[idx.Inc()]);
|
||||
Vector<String> done_programs = new Vector<>();
|
||||
for (int i = 0; i < numOfFiles; ++i) {
|
||||
String fileName = Utils_.toW(splited[idx.Inc()]);
|
||||
int functions_count = Integer.parseInt(splited[idx.Inc()]);
|
||||
DBProjectFile file = target.db.files.Data.get(fileName);
|
||||
if (!done_programs.contains(fileName)) {
|
||||
int call_count = 0;
|
||||
done_programs.add(fileName);
|
||||
for (int k = 0; k < functions_count; ++k) {
|
||||
String f_name = splited[idx.Inc()];
|
||||
Index calls_number = new Index();
|
||||
//тело функции
|
||||
FuncInfo nf = new FuncInfo(f_name, file, splited[idx.Inc()].split("#"), calls_number);
|
||||
if (nf.isMain()) {
|
||||
file.isMain = 1;
|
||||
target.main_function = nf;
|
||||
target.db.Update(file);
|
||||
}
|
||||
declarated_functions.put(nf.funcName, nf);
|
||||
//--------------------------------
|
||||
file.function_decls.put(nf.funcName, nf);
|
||||
//--------------------------------
|
||||
call_count += calls_number.getValue();
|
||||
for (int j = 0; j < calls_number.getValue(); ++j) {
|
||||
String call_name = splited[idx.Inc()];
|
||||
int c_line = Integer.parseInt(splited[idx.Inc()]);
|
||||
//-
|
||||
FuncCall fc = new FuncCall(file, call_name, c_line);
|
||||
fc.parentLineOffset = nf.line - fc.line;
|
||||
nf.calls.add(fc);
|
||||
}
|
||||
}
|
||||
file.CallGraphTitle = "Объявлений : " + file.function_decls.size() + "; Вызовов : " + call_count;
|
||||
//--
|
||||
FunctionsJson functionsJson = Utils_.gson.fromJson(packed, FunctionsJson.class);
|
||||
for (FileFunctionsJson fileFunctionsJson : functionsJson.allFunctions) {
|
||||
fileFunctionsJson.file = Utils_.toW(fileFunctionsJson.file);
|
||||
DBProjectFile projectFile = target.db.files.get(fileFunctionsJson.file);
|
||||
projectFile.saveFunctions(fileFunctionsJson.functions);
|
||||
//--
|
||||
for (FuncInfo funcInfo: projectFile.function_decls.values()){
|
||||
if (!declarated_functions.containsKey(funcInfo.funcName))
|
||||
declarated_functions.put(funcInfo.funcName, funcInfo);
|
||||
}
|
||||
}
|
||||
//---
|
||||
|
||||
Reference in New Issue
Block a user