|
28 | 28 | import java.util.regex.Pattern; |
29 | 29 | import com.fasterxml.jackson.databind.ObjectMapper; |
30 | 30 | import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; |
31 | | -import static dev.starfix.Editor.launch_editor; |
32 | 31 |
|
33 | 32 | @CommandLine.Command(mixinStandardHelpOptions = true) |
34 | 33 | public class Starfix implements Runnable{ |
@@ -290,12 +289,34 @@ public void setClone_path(String clone_path) { |
290 | 289 |
|
291 | 290 | } |
292 | 291 |
|
293 | | - public static interface IDE { |
| 292 | + public static void launch_editor(Path directory, String ide, String path, String filePath) throws IOException, InterruptedException { |
294 | 293 |
|
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 | + } |
298 | 316 |
|
| 317 | + } |
| 318 | + else{ |
| 319 | + runCommand(directory.getParent(),ide,path,filePath);// Launching the editor now |
| 320 | + } |
299 | 321 | } |
300 | | - |
301 | 322 | } |
0 commit comments