Skip to content

Commit e5c2c6f

Browse files
committed
Fixing localization of ExportThreadsAction and ThreadDumpAction.
1 parent 2b3abd5 commit e5c2c6f

4 files changed

Lines changed: 41 additions & 40 deletions

File tree

java-debugger-api/src/main/resources/LOCALIZE-LIB/en_US/com.intellij.java.debugger.JavaDebuggerLocalize.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ action.show.watches.text.hide:
3434
text: Hide Watches
3535
action.show.watches.text.show:
3636
text: Show Watches
37+
action.thread.dump.text:
38+
text: Get Thread Dump
39+
action.thread.dump.description:
40+
text: Get stacktraces of all the threads within JVM at current moment
3741
action.watch.method.return.value.description:
3842
text: Enables watching last executed method return value
3943
action.watches.method.return.value.disable:

java-debugger-impl/src/main/java/com/intellij/java/debugger/impl/actions/ExportThreadsAction.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.intellij.java.debugger.impl.DebuggerSession;
2121
import com.intellij.java.debugger.impl.ui.ExportDialog;
2222
import consulo.platform.Platform;
23+
import consulo.platform.base.icon.PlatformIconGroup;
2324
import consulo.platform.base.localize.ActionLocalize;
2425
import consulo.project.Project;
2526
import consulo.ui.annotation.RequiredUIAccess;
@@ -41,6 +42,10 @@
4142
* @author Jeka
4243
*/
4344
public class ExportThreadsAction extends AnAction {
45+
public ExportThreadsAction() {
46+
super(ActionLocalize.actionExportthreadsText(), ActionLocalize.actionExportthreadsDescription(), PlatformIconGroup.actionsExport());
47+
}
48+
4449
@Override
4550
@RequiredUIAccess
4651
public void actionPerformed(@Nonnull AnActionEvent e) {

java-debugger-impl/src/main/java/com/intellij/java/debugger/impl/actions/ThreadDumpAction.java

Lines changed: 30 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
import com.intellij.java.debugger.impl.jdi.VirtualMachineProxyImpl;
2525
import com.intellij.java.debugger.localize.JavaDebuggerLocalize;
2626
import com.intellij.java.execution.unscramble.ThreadDumpParser;
27-
import consulo.application.Application;
2827
import consulo.execution.debug.XDebugSession;
2928
import consulo.execution.unscramble.ThreadState;
3029
import consulo.internal.com.sun.jdi.*;
3130
import consulo.localize.LocalizeValue;
31+
import consulo.platform.base.icon.PlatformIconGroup;
3232
import consulo.project.Project;
3333
import consulo.ui.annotation.RequiredUIAccess;
3434
import consulo.ui.ex.action.AnAction;
@@ -49,6 +49,14 @@
4949
* @author Sascha Weinreuter
5050
*/
5151
public class ThreadDumpAction extends AnAction {
52+
public ThreadDumpAction() {
53+
super(
54+
JavaDebuggerLocalize.actionThreadDumpText(),
55+
JavaDebuggerLocalize.actionThreadDumpDescription(),
56+
PlatformIconGroup.actionsDump()
57+
);
58+
}
59+
5260
@Override
5361
@RequiredUIAccess
5462
public void actionPerformed(AnActionEvent e) {
@@ -75,7 +83,7 @@ protected void action() throws Exception {
7583
DebuggerUtilsEx.addThreadDump(project, threads, xSession.getUI(), session);
7684
}
7785
},
78-
Application.get().getNoneModalityState()
86+
project.getApplication().getNoneModalityState()
7987
);
8088
}
8189
finally {
@@ -257,45 +265,29 @@ public static String renderObject(ObjectReference monitor) {
257265
}
258266

259267
private static String threadStatusToJavaThreadState(int status) {
260-
switch (status) {
261-
case ThreadReference.THREAD_STATUS_MONITOR:
262-
return Thread.State.BLOCKED.name();
263-
case ThreadReference.THREAD_STATUS_NOT_STARTED:
264-
return Thread.State.NEW.name();
265-
case ThreadReference.THREAD_STATUS_RUNNING:
266-
return Thread.State.RUNNABLE.name();
267-
case ThreadReference.THREAD_STATUS_SLEEPING:
268-
return Thread.State.TIMED_WAITING.name();
269-
case ThreadReference.THREAD_STATUS_WAIT:
270-
return Thread.State.WAITING.name();
271-
case ThreadReference.THREAD_STATUS_ZOMBIE:
272-
return Thread.State.TERMINATED.name();
273-
case ThreadReference.THREAD_STATUS_UNKNOWN:
274-
return "unknown";
275-
default:
276-
return "undefined";
277-
}
268+
return switch (status) {
269+
case ThreadReference.THREAD_STATUS_MONITOR -> Thread.State.BLOCKED.name();
270+
case ThreadReference.THREAD_STATUS_NOT_STARTED -> Thread.State.NEW.name();
271+
case ThreadReference.THREAD_STATUS_RUNNING -> Thread.State.RUNNABLE.name();
272+
case ThreadReference.THREAD_STATUS_SLEEPING -> Thread.State.TIMED_WAITING.name();
273+
case ThreadReference.THREAD_STATUS_WAIT -> Thread.State.WAITING.name();
274+
case ThreadReference.THREAD_STATUS_ZOMBIE -> Thread.State.TERMINATED.name();
275+
case ThreadReference.THREAD_STATUS_UNKNOWN -> "unknown";
276+
default -> "undefined";
277+
};
278278
}
279279

280280
private static String threadStatusToState(int status) {
281-
switch (status) {
282-
case ThreadReference.THREAD_STATUS_MONITOR:
283-
return "waiting for monitor entry";
284-
case ThreadReference.THREAD_STATUS_NOT_STARTED:
285-
return "not started";
286-
case ThreadReference.THREAD_STATUS_RUNNING:
287-
return "runnable";
288-
case ThreadReference.THREAD_STATUS_SLEEPING:
289-
return "sleeping";
290-
case ThreadReference.THREAD_STATUS_WAIT:
291-
return "waiting";
292-
case ThreadReference.THREAD_STATUS_ZOMBIE:
293-
return "zombie";
294-
case ThreadReference.THREAD_STATUS_UNKNOWN:
295-
return "unknown";
296-
default:
297-
return "undefined";
298-
}
281+
return switch (status) {
282+
case ThreadReference.THREAD_STATUS_MONITOR -> "waiting for monitor entry";
283+
case ThreadReference.THREAD_STATUS_NOT_STARTED -> "not started";
284+
case ThreadReference.THREAD_STATUS_RUNNING -> "runnable";
285+
case ThreadReference.THREAD_STATUS_SLEEPING -> "sleeping";
286+
case ThreadReference.THREAD_STATUS_WAIT -> "waiting";
287+
case ThreadReference.THREAD_STATUS_ZOMBIE -> "zombie";
288+
case ThreadReference.THREAD_STATUS_UNKNOWN -> "unknown";
289+
default -> "undefined";
290+
};
299291
}
300292

301293
public static String renderLocation(Location location) {

plugin/src/main/resources/META-INF/plugin.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@
136136
<add-to-group group-id="DebugMainMenu" anchor="after" relative-to-action="ToggleLineBreakpoint"/>
137137
</group>
138138

139-
<action id="ExportThreads" class="com.intellij.java.debugger.impl.actions.ExportThreadsAction" icon="consulo.platform.base.PlatformIconGroup@actions.export">
139+
<action id="ExportThreads" class="com.intellij.java.debugger.impl.actions.ExportThreadsAction">
140140
<add-to-group group-id="RunMenu" anchor="last"/>
141141
</action>
142-
<action id="DumpThreads" class="com.intellij.java.debugger.impl.actions.ThreadDumpAction" text="Take a thread dump" icon="consulo.platform.base.PlatformIconGroup@actions.dump">
142+
<action id="DumpThreads" class="com.intellij.java.debugger.impl.actions.ThreadDumpAction">
143143
<add-to-group group-id="RunMenu" anchor="last"/>
144144
</action>
145145

0 commit comments

Comments
 (0)