Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 75 additions & 4 deletions cli/src/main/java/dev/starfix/Starfix.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}

Expand All @@ -180,6 +186,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";
}
}
}
Expand Down Expand Up @@ -223,7 +235,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");
Expand All @@ -243,13 +255,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() ?"pycharm64.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
Expand Down Expand Up @@ -418,14 +443,22 @@ 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();
}

}

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
Expand Down Expand Up @@ -466,6 +499,44 @@ 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){
filePath = filePath.replace("#L","#");
// pycharm64.exe [--line <number>] [--column <number>] <path ...>
// 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);
}
}
}

public static class CustomIDE extends IDE{

public void launch_editor(Path directory, String ide, String path, String filePath) throws IOException, InterruptedException {
Expand Down