From c39bf7bcc76f619a86726f5a2e4eae2b5b9511a9 Mon Sep 17 00:00:00 2001 From: chen-zhongwei050 Date: Tue, 19 Nov 2024 10:31:06 +0800 Subject: [PATCH] =?UTF-8?q?fix=20bug:=20=E5=88=A0=E9=99=A4java=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=B8=AD=E4=BD=BF=E7=94=A8=E7=B3=BB=E7=BB=9F=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E7=9A=84=E6=96=B9=E5=BC=8F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chen-zhongwei050 --- .../src/com/sk/gn/dialog/GenDialogPane.java | 14 -------------- .../src/com/sk/dialog/GenerateDialogPane.java | 9 --------- .../src/com/sk/ts/dialog/GenerateDialogPane.java | 9 --------- .../src/com/sk/na/ng/GenDTS.java | 5 ----- .../service/dialog/ServiceGenerateDialogPane.java | 9 --------- 5 files changed, 46 deletions(-) diff --git a/src/intellij_plugin/cmake2gn/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.java b/src/intellij_plugin/cmake2gn/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.java index c5260136..0c9d345f 100644 --- a/src/intellij_plugin/cmake2gn/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.java +++ b/src/intellij_plugin/cmake2gn/gn_IntelliJ_plugin/src/com/sk/gn/dialog/GenDialogPane.java @@ -290,7 +290,6 @@ public class GenDialogPane extends JDialog implements SelectOutDirAction.SelectP execFn = "cmds/mac/gn-gen-macos"; tmpDirFile += "/gn-gen-macos"; } - File file = new File(tmpDirFile); writeTmpFile(tmpDirFile, execFn, project); if (SYS_NAME.contains("LINUX") || SYS_NAME.contains("MAC OS")) { try { @@ -319,7 +318,6 @@ public class GenDialogPane extends JDialog implements SelectOutDirAction.SelectP makeFilePath = "cmds/res/win/bin/make.exe"; } String tmpDirFile = System.getProperty("java.io.tmpdir") + "/res/linux/bin/"; - File file = new File(tmpDirFile); if (file.mkdirs()) { LOG.info("create dir success"); } @@ -342,7 +340,6 @@ public class GenDialogPane extends JDialog implements SelectOutDirAction.SelectP makeFilePath = "cmds/res/win/bin/make_raw.exe"; } String tmpDirFile = System.getProperty("java.io.tmpdir") + "/res/linux/bin/"; - File file = new File(tmpDirFile); if (file.mkdirs()) { LOG.info("create dir success"); } @@ -365,7 +362,6 @@ public class GenDialogPane extends JDialog implements SelectOutDirAction.SelectP toolchainFileDir = "cmds/res/win/ohos.toolchain.cmake"; } String tmpDirFile = System.getProperty("java.io.tmpdir") + "/res/linux/"; - File file = new File(tmpDirFile); if (file.mkdirs()) { LOG.info("create dir success"); } @@ -387,10 +383,6 @@ public class GenDialogPane extends JDialog implements SelectOutDirAction.SelectP GenNotification.notifyMessage(this.project, "执行命令文件为空", "空命令行提示", NotificationType.ERROR); return false; } - final Process process = Runtime.getRuntime().exec(command); - threadPool.execute(new BlockThread(process)); - StreamConsumer errConsumer = new StreamConsumer(process.getErrorStream()); - StreamConsumer outputConsumer = new StreamConsumer(process.getInputStream()); errConsumer.start(); outputConsumer.start(); if (generateSuccess) { @@ -425,10 +417,6 @@ public class GenDialogPane extends JDialog implements SelectOutDirAction.SelectP BufferedReader stdInput = null; BufferedReader stdError = null; try { - stdInput = new BufferedReader(new InputStreamReader(process.getInputStream(), - StandardCharsets.UTF_8)); - stdError = new BufferedReader(new InputStreamReader(process.getErrorStream(), - StandardCharsets.UTF_8)); String sErr = ''; String sOut; sErr = getErrorResult(stdError); @@ -569,8 +557,6 @@ public class GenDialogPane extends JDialog implements SelectOutDirAction.SelectP public void run() { BufferedReader br1 = null; try { - br1 = new BufferedReader(new InputStreamReader(process.getInputStream(), - StandardCharsets.UTF_8)); genResultLog(process); while (br1.readLine() != null) { LOG.info(" callExtProcess "); diff --git a/src/intellij_plugin/dts2cpp/napi_IntelliJ_plugin/src/com/sk/dialog/GenerateDialogPane.java b/src/intellij_plugin/dts2cpp/napi_IntelliJ_plugin/src/com/sk/dialog/GenerateDialogPane.java index 80644469..c8646060 100644 --- a/src/intellij_plugin/dts2cpp/napi_IntelliJ_plugin/src/com/sk/dialog/GenerateDialogPane.java +++ b/src/intellij_plugin/dts2cpp/napi_IntelliJ_plugin/src/com/sk/dialog/GenerateDialogPane.java @@ -269,7 +269,6 @@ public class GenerateDialogPane extends JDialog { copyFileToLocalPath("napi_generator-macos"); tmpDirFile += "napi_generator-macos"; } - File file = new File(tmpDirFile); String command = file.toString(); String inArgs = genInArgs(interFileOrDir); command += inArgs + " -o " + genOutDir + " -i " + radioButton.isSelected() + " -n " + genNumbertypeArgs(); @@ -371,10 +370,6 @@ public class GenerateDialogPane extends JDialog { GenNotification.notifyMessage(this.project, "执行命令文件为空", "空命令行提示", NotificationType.ERROR); return false; } - Process process = Runtime.getRuntime().exec(command); - genResultLog(process); - StreamConsumer errConsumer = new StreamConsumer(process.getErrorStream()); - StreamConsumer outputConsumer = new StreamConsumer(process.getInputStream()); errConsumer.start(); outputConsumer.start(); @@ -599,10 +594,6 @@ public class GenerateDialogPane extends JDialog { BufferedReader stdInput = null; BufferedReader stdError = null; try { - stdInput = new BufferedReader(new InputStreamReader(process.getInputStream(), - StandardCharsets.UTF_8)); - stdError = new BufferedReader(new InputStreamReader(process.getErrorStream(), - StandardCharsets.UTF_8)); String sErr; String sOut; sErr = getErrorResult(stdError); diff --git a/src/intellij_plugin/h2dts/ts_IntelliJ_plugin/src/com/sk/ts/dialog/GenerateDialogPane.java b/src/intellij_plugin/h2dts/ts_IntelliJ_plugin/src/com/sk/ts/dialog/GenerateDialogPane.java index af527b76..190d0f96 100644 --- a/src/intellij_plugin/h2dts/ts_IntelliJ_plugin/src/com/sk/ts/dialog/GenerateDialogPane.java +++ b/src/intellij_plugin/h2dts/ts_IntelliJ_plugin/src/com/sk/ts/dialog/GenerateDialogPane.java @@ -277,10 +277,6 @@ public class GenerateDialogPane extends JDialog { GenNotification.notifyMessage(this.project, "执行命令文件为空", "空命令行提示", NotificationType.ERROR); return false; } - Process process = Runtime.getRuntime().exec(command); - genResultLog(process); - StreamConsumer errConsumer = new StreamConsumer(process.getErrorStream()); - StreamConsumer outputConsumer = new StreamConsumer(process.getInputStream()); errConsumer.start(); outputConsumer.start(); @@ -345,10 +341,6 @@ public class GenerateDialogPane extends JDialog { BufferedReader stdInput = null; BufferedReader stdError = null; try { - stdInput = new BufferedReader(new InputStreamReader(process.getInputStream(), - StandardCharsets.UTF_8)); - stdError = new BufferedReader(new InputStreamReader(process.getErrorStream(), - StandardCharsets.UTF_8)); String sErr; String sOut; sErr = getErrorResult(stdError); @@ -528,7 +520,6 @@ public class GenerateDialogPane extends JDialog { tmpDirFile += "napi_generator-macos"; } - File file = new File(tmpDirFile); String command = file.toString(); String inArgs = genInArgs(textFieldSelectH.getText()); command += inArgs + " -o " + textFieldSelectOutPath.getText() + " -t " + true; diff --git a/src/intellij_plugin/h2dtscpp/native_IntelliJ_plugin/src/com/sk/na/ng/GenDTS.java b/src/intellij_plugin/h2dtscpp/native_IntelliJ_plugin/src/com/sk/na/ng/GenDTS.java index e06b136a..8487f0eb 100644 --- a/src/intellij_plugin/h2dtscpp/native_IntelliJ_plugin/src/com/sk/na/ng/GenDTS.java +++ b/src/intellij_plugin/h2dtscpp/native_IntelliJ_plugin/src/com/sk/na/ng/GenDTS.java @@ -229,10 +229,6 @@ public class GenDts extends AnAction { GenNotification.notifyMessage(null, "执行命令文件为空", "空命令行提示", NotificationType.ERROR); return false; } - Process process = Runtime.getRuntime().exec(command); - genResultLog(process); - StreamConsumer errConsumer = new StreamConsumer(process.getErrorStream()); - StreamConsumer outputConsumer = new StreamConsumer(process.getInputStream()); errConsumer.start(); outputConsumer.start(); @@ -344,7 +340,6 @@ public class GenDts extends AnAction { tmpDirFile += "native_gen-macos"; } - File file = new File(tmpDirFile); String command = file.toString(); command += " -f " + hFilePath; // 判断用户是否输入了 "-o"+cpp文件路径, "-i"+dts文件路径,"-t"+test文件路径 从界面获取 diff --git a/src/intellij_plugin/h2sa/service_IntelliJ_plugin/src/com/sk/service/dialog/ServiceGenerateDialogPane.java b/src/intellij_plugin/h2sa/service_IntelliJ_plugin/src/com/sk/service/dialog/ServiceGenerateDialogPane.java index 9a604723..47f3ab2c 100644 --- a/src/intellij_plugin/h2sa/service_IntelliJ_plugin/src/com/sk/service/dialog/ServiceGenerateDialogPane.java +++ b/src/intellij_plugin/h2sa/service_IntelliJ_plugin/src/com/sk/service/dialog/ServiceGenerateDialogPane.java @@ -178,7 +178,6 @@ public class ServiceGenerateDialogPane extends JDialog { execFn = "cmds/mac/service-gen-macos"; tmpDirFile += "service-gen-macos"; } - File file = new File(tmpDirFile); if (!file.exists()) { try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(execFn)) { if (inputStream == null) { @@ -241,10 +240,6 @@ public class ServiceGenerateDialogPane extends JDialog { GenNotification.notifyMessage(this.project, "执行命令文件为空", "空命令行提示", NotificationType.ERROR); return false; } - Process process = Runtime.getRuntime().exec(command); - genResultLog(process); - StreamConsumer errConsumer = new StreamConsumer(process.getErrorStream()); - StreamConsumer outputConsumer = new StreamConsumer(process.getInputStream()); errConsumer.start(); outputConsumer.start(); if (generateSuccess) { @@ -309,10 +304,6 @@ public class ServiceGenerateDialogPane extends JDialog { BufferedReader stdInput = null; BufferedReader stdError = null; try { - stdInput = new BufferedReader(new InputStreamReader(process.getInputStream(), - StandardCharsets.UTF_8)); - stdError = new BufferedReader(new InputStreamReader(process.getErrorStream(), - StandardCharsets.UTF_8)); String sErr; String sOut; sErr = getErrorResult(stdError);