From ae8eabebfaba65c5ff32c154d127d0decff76b92 Mon Sep 17 00:00:00 2001 From: Kshitiz-Mhto Date: Wed, 1 Feb 2023 18:46:22 +0545 Subject: [PATCH 1/3] support for IDE -> sublime, PyCharm, Atom --- cli/src/main/java/dev/starfix/Starfix.java | 68 ++++++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/cli/src/main/java/dev/starfix/Starfix.java b/cli/src/main/java/dev/starfix/Starfix.java index b4f7397..95d9485 100644 --- a/cli/src/main/java/dev/starfix/Starfix.java +++ b/cli/src/main/java/dev/starfix/Starfix.java @@ -180,6 +180,12 @@ void defaultConfig() { ide = "idea"; }else if(Files.exists(Paths.get(sub_path+"/eclipse"))){ ide = "eclipse"; + }else if(Files.exists(Paths.get(sub_path+"/atom"))){ + ide="atom"; + }else if(Files.exists(Paths.get(sub_path+"/subl"))){ + ide="subl"; + }else if(Files.exists(Paths.get(sub_path+"/pycharm")) || Files.exists(Paths.get(sub_path+"/pycharm.sh")) ){ + ide="pycharm"; } } } @@ -223,7 +229,7 @@ public void editConfig() throws Exception { int id = 0; while (true) { System.out.println( - "\n--------Chose the preferred IDE --------\n 1.for vscode \n 2.for eclipse \n 3.for IntelliJ_IDEA \n 4.for Other(You'll have to enter launch command)"); + "\n--------Chose the preferred IDE --------\n 1.for vscode \n 2.for eclipse \n 3.for IntelliJ_IDEA \n 4.for sublime_text \n 5.for atom \n 6.for PyCharm \n 7.for Other(You'll have to enter launch command)"); String ideInput = reader.readLine().trim(); if(ideInput==null || ideInput.isEmpty()){ System.out.println("Empty/blank input provided - reseting to existing/default setting"); @@ -243,13 +249,26 @@ public void editConfig() throws Exception { System.out.println("\n--------Selected IDE:IntelliJ_IDEA--------"); break; }else if (id == 4) { + ide = isWindows() ?"subl.exe":"subl"; + System.out.println("\n--------Selected IDE:Sublime_Text--------"); + break; + }else if (id == 5) { + ide = isWindows() ?"atom.exe":"atom"; + System.out.println("\n--------Selected IDE:Atom--------"); + break; + }else if (id == 6) { + ide = isWindows() ?"pycharm.exe":"pycharm"; + System.out.println("\n--------Selected IDE:PyCharm--------"); + break; + } else if(id == 7){ System.out.println("Enter launch command "); ide = reader.readLine(); System.out.println("\n--------Launch command: "+ide); break; - } else + } else{ System.out.println("\n--------Invalid Input!! Try Again--------"); - + } + } // -----------Now we'll get preferred clone path on local file system from @@ -418,6 +437,15 @@ public static IDE getIDE(String ide){ case "eclipse": case "eclipse.exe": return new Eclipse(); + case "subl": + case "subl.exe": + return new SublimeText(); + case "atom": + case "atom.exe": + return new Atom(); + case "pycharm": + case "pycharm64.exe": + return new PyCharm(); default: return new CustomIDE(); } @@ -425,7 +453,6 @@ public static IDE getIDE(String ide){ } public static class VsCode extends IDE{ - public void launch_editor(Path directory, String ide, String path, String filePath) throws IOException, InterruptedException { if(filePath.indexOf("#")>0){ // code -g file:line @@ -466,6 +493,39 @@ public void launch_editor(Path directory, String ide, String path, String fileP } } + public static class SublimeText extends IDE{ + + public void launch_editor(Path directory, String ide, String path, String filePath) throws IOException, InterruptedException { + if(filePath.indexOf("#")>0){ + // subl file:line_number + filePath = filePath.replace("#L",":"); + } + runCommand(directory.getParent(),ide,path,filePath); + } + } + + public static class Atom extends IDE{ + + public void launch_editor(Path directory, String ide, String path, String filePath) throws IOException, InterruptedException { + if(filePath.indexOf("#")>0){ + // atom file:line_number + filePath = filePath.replace("#L",":"); + } + runCommand(directory.getParent(),ide,path,filePath); + } + } + + public static class PyCharm extends IDE{ + + public void launch_editor(Path directory, String ide, String path, String filePath) throws IOException, InterruptedException { + if(filePath.indexOf("#")>0){ + // atom file:line_number + filePath = filePath.replace("#L",":"); + } + runCommand(directory.getParent(),ide,path,filePath); + } + } + public static class CustomIDE extends IDE{ public void launch_editor(Path directory, String ide, String path, String filePath) throws IOException, InterruptedException { From 7fe5570a75c02bae66790b1a53baa169723faf8a Mon Sep 17 00:00:00 2001 From: Kshitiz-Mhto Date: Sun, 5 Feb 2023 13:57:33 +0545 Subject: [PATCH 2/3] fixed pycharm support --- cli/src/main/java/dev/starfix/Starfix.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cli/src/main/java/dev/starfix/Starfix.java b/cli/src/main/java/dev/starfix/Starfix.java index 95d9485..117806a 100644 --- a/cli/src/main/java/dev/starfix/Starfix.java +++ b/cli/src/main/java/dev/starfix/Starfix.java @@ -519,10 +519,15 @@ public static class PyCharm extends IDE{ public void launch_editor(Path directory, String ide, String path, String filePath) throws IOException, InterruptedException { if(filePath.indexOf("#")>0){ - // atom file:line_number - filePath = filePath.replace("#L",":"); + filePath = filePath.replace("#L","#"); + // pycharm64.exe [--line ] [--column ] + // pycharm ~ --line 40 ~Main.java + String lineNumber = filePath.substring(filePath.lastIndexOf("#")+1); + filePath = filePath.substring(0,filePath.lastIndexOf("#")); + runCommand(directory.getParent(), ide,path,"--line",lineNumber,filePath); + } else{ + runCommand(directory.getParent(),ide,path,filePath); } - runCommand(directory.getParent(),ide,path,filePath); } } From e24461ce409dfff3153079bfc8947417c517d758 Mon Sep 17 00:00:00 2001 From: Kshitiz-Mhto Date: Sun, 5 Feb 2023 14:25:59 +0545 Subject: [PATCH 3/3] added default configuration for new editors/ide in windows --- cli/src/main/java/dev/starfix/Starfix.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cli/src/main/java/dev/starfix/Starfix.java b/cli/src/main/java/dev/starfix/Starfix.java index 117806a..1a4f9a9 100644 --- a/cli/src/main/java/dev/starfix/Starfix.java +++ b/cli/src/main/java/dev/starfix/Starfix.java @@ -167,6 +167,12 @@ void defaultConfig() { ide = "code.cmd"; } else if(path_env.contains("IntelliJ IDEA")){ // If PATH has IntelliJ ide = "idea64.exe"; + }else if(path_env.contains("Sublime Text")){ // If PATH has Sublime Text + ide = "subl.exe"; + }else if(path_env.contains("PyCharm")){ // If PATH has PyCharm + ide = "pycharm64.exe"; + }else if(path_env.contains("Atom")){ // If PATH has Atom + ide = "atom.exe"; } } @@ -257,7 +263,7 @@ public void editConfig() throws Exception { System.out.println("\n--------Selected IDE:Atom--------"); break; }else if (id == 6) { - ide = isWindows() ?"pycharm.exe":"pycharm"; + ide = isWindows() ?"pycharm64.exe":"pycharm"; System.out.println("\n--------Selected IDE:PyCharm--------"); break; } else if(id == 7){