diff --git a/core/deployment/src/main/java/io/quarkus/deployment/console/ConsoleProcessor.java b/core/deployment/src/main/java/io/quarkus/deployment/console/ConsoleProcessor.java index ee2838f948177..a2e6f064bcf4b 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/console/ConsoleProcessor.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/console/ConsoleProcessor.java @@ -142,43 +142,47 @@ public void accept(Throwable throwable, StackTraceElement stackTraceElement) { } exceptionsConsoleContext.reset( - new ConsoleCommand('x', "Open last exception in IDE", new ConsoleCommand.HelpState(new Supplier() { - @Override - public String get() { - return MessageFormat.RED; - } - }, new Supplier() { - @Override - public String get() { - StackTraceElement throwable = lastUserCode.get(); - if (throwable == null) { - return "none"; - } - return throwable.getFileName() + ":" + throwable.getLineNumber(); - } - }), new Runnable() { - @Override - public void run() { - StackTraceElement throwable = lastUserCode.get(); - if (throwable == null) { - return; - } - String className = throwable.getClassName(); - String file = throwable.getFileName(); - if (className.contains(".")) { - file = className.substring(0, className.lastIndexOf('.') + 1).replace('.', File.separatorChar) - + file; - } - Path fileName = Ide.findSourceFile(file); - if (fileName == null) { - log.error("Unable to find file: " + file); - return; - } - List args = ideSupport.getIde().createFileOpeningArgs(fileName.toAbsolutePath().toString(), - "" + throwable.getLineNumber()); - launchInIDE(ideSupport.getIde(), args); - } - })); + new ConsoleCommand('x', "Open last exception (or project) in IDE", + new ConsoleCommand.HelpState(new Supplier() { + @Override + public String get() { + return MessageFormat.RED; + } + }, new Supplier() { + @Override + public String get() { + StackTraceElement throwable = lastUserCode.get(); + if (throwable == null) { + return "none"; + } + return throwable.getFileName() + ":" + throwable.getLineNumber(); + } + }), new Runnable() { + @Override + public void run() { + StackTraceElement throwable = lastUserCode.get(); + if (throwable == null) { + launchInIDE(ideSupport.getIde(), List.of(".")); + return; + } + String className = throwable.getClassName(); + String file = throwable.getFileName(); + if (className.contains(".")) { + file = className.substring(0, className.lastIndexOf('.') + 1).replace('.', + File.separatorChar) + + file; + } + Path fileName = Ide.findSourceFile(file); + if (fileName == null) { + log.error("Unable to find file: " + file); + return; + } + List args = ideSupport.getIde().createFileOpeningArgs( + fileName.toAbsolutePath().toString(), + "" + throwable.getLineNumber()); + launchInIDE(ideSupport.getIde(), args); + } + })); } protected void launchInIDE(Ide ide, List args) {