конвертация стандартных тестов на стороне сервера. стало быстрее.

This commit is contained in:
2023-11-25 16:51:35 +03:00
parent f0fd9335c4
commit 93ccdc3522
5 changed files with 64 additions and 156 deletions

View File

@@ -6,9 +6,7 @@ import Common.UI.UI;
import Common.Utils.Utils;
import GlobalData.Settings.SettingName;
import ProjectData.Files.DBProjectFile;
import ProjectData.Files.FileState;
import ProjectData.Files.LanguageStyle;
import ProjectData.Project.db_project_info;
import Repository.Component.OSDComponent;
import Repository.Component.Visualizer_2;
import Visual_DVM_2021.Passes.PassCode_2021;
@@ -124,17 +122,6 @@ public abstract class Sapfor extends OSDComponent {
PassCode_2021.SPF_ResolveCommonBlockConflicts
};
}
public static Vector<PassCode_2021> getAllTransformationsCodes() {
Vector<PassCode_2021> res = new Vector<>();
Collections.addAll(res, getLoopsTransformationsCodes());
Collections.addAll(res, getPrivatesTransformationsCodes());
Collections.addAll(res, getProceduresTransformationsCodes());
Collections.addAll(res, getDVMTransformationsCodes());
Collections.addAll(res, getIntervalsTransformationsCodes());
Collections.addAll(res, getRegionsTransformationsCodes());
Collections.addAll(res, getPreparationTransformationsCodes());
return res;
}
//<editor-fold desc="компонент">
@Override
public void GetVersionInfo() {
@@ -407,90 +394,6 @@ public abstract class Sapfor extends OSDComponent {
// res.add(PassCode_2021.SPF_InsertIncludesPass);
return res;
}
//--
public int getTextMaxDim(File testFile, db_project_info target) {
int res = Constants.Nan;
LinkedHashMap<String, DBProjectFile> files = null;
if (testFile != null) {
DBProjectFile dbProjectFile = new DBProjectFile(testFile, target);
files = new LinkedHashMap<>();
files.put(dbProjectFile.name, dbProjectFile);
} else
files = target.db.files.Data;
Vector<String> projLines = new Vector<>();
try {
target.CreateParserOptionsDirs();
//-----
Restart();
cd(target.Home);
//-----
//<editor-fold desc="создание proj">
for (DBProjectFile f : files.values()) {
if (f.isActiveProgram()) {
projLines.add(Utils.toU(f.file.getAbsolutePath()));
f.CreateParserOptions();
}
}
FileUtils.writeLines(target.getProjFile(), projLines, false);
//</editor-fold>
//-----
RunAnalysis(
"SPF_ParseFilesWithOrder",
-Global.messagesServer.getPort(),
Global.packSapforSettings(),
target.getProjFile().getAbsolutePath());
if (errorCode >= 0) {
projLines.clear();
int goodCount = 0;
int badCount = 0;
for (DBProjectFile f : files.values())
if (f.isActive()) f.state = FileState.OK;
for (DBProjectFile f : files.values()) {
f.ReadParseMessagesNoSave(files);
if (f.isActive()) {
switch (f.state) {
case OK:
case HasNotes:
case HasWarnings:
if (f.isActiveProgram())
projLines.add(Utils.toU(f.getDepFile().getAbsolutePath()));
goodCount++;
break;
case HasErrors:
badCount++;
break;
default:
break;
}
}
}
FileUtils.writeLines(target.getProjFile(), projLines, false);
if (badCount > 0) return res;
if (goodCount == 0) return res;
} else return res;
//---
Restart();
cd(target.Home);
///---
RunAnalysis(
"SPF_GetMaxMinBlockDistribution",
-Global.messagesServer.getPort(),
Global.packSapforSettings(),
target.getProjFile().getAbsolutePath());
if ((errorCode < 0) || target.hasErrorMessages(getOutputMessage()))
return res;
//--
System.out.println(Utils.Brackets(getResult()));
String[] data = getResult().split(" ");
target.CreateParserOptionsDirs(); // теперь очистка.
return Integer.parseInt(data[data.length - 1]);
///---
} catch (Exception ex) {
ex.printStackTrace();
}
return res;
}
//--
//------------------------------------------------------------------------------------------------------------------
public String getConsoleFlags() throws Exception {
Vector<String> res = new Vector<>();
@@ -601,10 +504,10 @@ public abstract class Sapfor extends OSDComponent {
Constants.err_file);
}
public static File temp_copy = null;
public static File getTempCopy() throws Exception {
public static File getTempCopy(File src) throws Exception {
if (temp_copy == null || !temp_copy.exists()) {
temp_copy = Utils.getTempFileName("SAPFOR" + (Global.isWindows ? ".exe" : ""));
FileUtils.copyFile(Current.getSapfor().getFile(), temp_copy);
FileUtils.copyFile(src, temp_copy);
temp_copy.setExecutable(true);
}
return temp_copy;