Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X will open editor on current working directory as a fallback #33529

Merged
merged 1 commit into from
May 23, 2023
Merged
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
Original file line number Diff line number Diff line change
@@ -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<String>() {
@Override
public String get() {
return MessageFormat.RED;
}
}, new Supplier<String>() {
@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<String> 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<String>() {
@Override
public String get() {
return MessageFormat.RED;
}
}, new Supplier<String>() {
@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<String> args = ideSupport.getIde().createFileOpeningArgs(
fileName.toAbsolutePath().toString(),
"" + throwable.getLineNumber());
launchInIDE(ideSupport.getIde(), args);
}
}));
}

protected void launchInIDE(Ide ide, List<String> args) {