Skip to content

Commit 860a4bb

Browse files
committed
fix: remove unnecessary Editor class to make it work in jbang again
1 parent 4096097 commit 860a4bb

File tree

2 files changed

+28
-36
lines changed

2 files changed

+28
-36
lines changed

cli/src/main/java/dev/starfix/Editor.java

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,5 @@
77

88
public class Editor{
99

10-
public static void launch_editor(Path directory, String ide, String path, String filePath) throws IOException, InterruptedException {
11-
12-
if(filePath.indexOf("#")>0){
13-
filePath = filePath.replace("#L","#");
14-
// ==== VS CODE ====
15-
// code -g file:line
16-
if(ide.equals("code")||ide.equals("code.cmd")){
17-
filePath = filePath.replace("#",":");
18-
runCommand(directory.getParent(), ide,"-g",path,filePath);
19-
}
20-
// ===== IntelliJ =====
21-
// idea64.exe [--line <number>] [--column <number>] <path ...>
22-
// idea /home/fahad/MyProjects/testings/jbang --line 3 /home/fahad/MyProjects/testings/jbang/otp.java
23-
if(ide.equals("idea")||ide.equals("idea.exe")||ide.equals("idea64.exe")){
24-
String lineNumber = filePath.substring(filePath.lastIndexOf("#")+1);
25-
filePath = filePath.substring(0,filePath.lastIndexOf("#"));
26-
runCommand(directory.getParent(), ide,path,"--line",lineNumber,filePath);
27-
}
28-
// === Eclipse =====
29-
// eclipse.exe file.txt:22
30-
if(ide.equals("eclipse")){
31-
filePath = filePath.replace("#",":");
32-
runCommand(directory.getParent(), ide,path,filePath);
33-
}
34-
35-
}
36-
else{
37-
runCommand(directory.getParent(),ide,path,filePath);// Launching the editor now
38-
}
39-
}
10+
4011
}

cli/src/main/java/dev/starfix/Starfix.java

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.regex.Pattern;
2929
import com.fasterxml.jackson.databind.ObjectMapper;
3030
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
31-
import static dev.starfix.Editor.launch_editor;
3231

3332
@CommandLine.Command(mixinStandardHelpOptions = true)
3433
public class Starfix implements Runnable{
@@ -290,12 +289,34 @@ public void setClone_path(String clone_path) {
290289

291290
}
292291

293-
public static interface IDE {
292+
public static void launch_editor(Path directory, String ide, String path, String filePath) throws IOException, InterruptedException {
294293

295-
}
296-
297-
public static class GenericIDE implements IDE {
294+
if(filePath.indexOf("#")>0){
295+
filePath = filePath.replace("#L","#");
296+
// ==== VS CODE ====
297+
// code -g file:line
298+
if(ide.equals("code")||ide.equals("code.cmd")){
299+
filePath = filePath.replace("#",":");
300+
runCommand(directory.getParent(), ide,"-g",path,filePath);
301+
}
302+
// ===== IntelliJ =====
303+
// idea64.exe [--line <number>] [--column <number>] <path ...>
304+
// idea /home/fahad/MyProjects/testings/jbang --line 3 /home/fahad/MyProjects/testings/jbang/otp.java
305+
if(ide.equals("idea")||ide.equals("idea.exe")||ide.equals("idea64.exe")){
306+
String lineNumber = filePath.substring(filePath.lastIndexOf("#")+1);
307+
filePath = filePath.substring(0,filePath.lastIndexOf("#"));
308+
runCommand(directory.getParent(), ide,path,"--line",lineNumber,filePath);
309+
}
310+
// === Eclipse =====
311+
// eclipse.exe file.txt:22
312+
if(ide.equals("eclipse")){
313+
filePath = filePath.replace("#",":");
314+
runCommand(directory.getParent(), ide,path,filePath);
315+
}
298316

317+
}
318+
else{
319+
runCommand(directory.getParent(),ide,path,filePath);// Launching the editor now
320+
}
299321
}
300-
301322
}

0 commit comments

Comments
 (0)