Skip to content

Commit d3312e5

Browse files
authored
Moving debugger action groups from plugin.xml to classes (#227)
* Removing deprecated unused action groups: "Debugger.EvaluationDialogPopup", "Debugger.FramePanelPopup", "Debugger.InspectPanelPopup", "Debugger.WatchesPanelPopup". Removing DebuggerAction.isContextView() related to these groups. Removing ToggleFieldBreakpointAction functionality related to this isContextView() check. * Moving debugger action groups from plugin.xml to classes.
1 parent 31b8149 commit d3312e5

8 files changed

Lines changed: 182 additions & 211 deletions

File tree

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,13 @@
4343
import java.awt.event.MouseEvent;
4444
import java.util.ArrayList;
4545
import java.util.List;
46-
import java.util.Set;
4746

4847
/**
4948
* Class DebuggerAction
5049
*
5150
* @author Jeka
5251
*/
5352
public abstract class DebuggerAction extends AnAction {
54-
private static final Set<String> POPUP_PLACES = Set.of(
55-
DebuggerActions.EVALUATION_DIALOG_POPUP,
56-
DebuggerActions.FRAME_PANEL_POPUP,
57-
DebuggerActions.WATCH_PANEL_POPUP,
58-
DebuggerActions.INSPECT_PANEL_POPUP
59-
);
60-
6153
private static final DebuggerTreeNodeImpl[] EMPTY_TREE_NODE_ARRAY = new DebuggerTreeNodeImpl[0];
6254

6355
protected DebuggerAction(@Nonnull LocalizeValue text) {
@@ -129,10 +121,6 @@ public static DebuggerStateManager getContextManager(DataContext dataContext) {
129121
return panel == null ? null : panel.getContextManager();
130122
}
131123

132-
public static boolean isContextView(AnActionEvent e) {
133-
return POPUP_PLACES.contains(e.getPlace());
134-
}
135-
136124
public static Disposable installEditAction(JTree tree, String actionName) {
137125
DoubleClickListener listener = new DoubleClickListener() {
138126
@Override

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@
2222
*/
2323
public interface DebuggerActions extends XDebuggerActions {
2424
String POP_FRAME = "Debugger.PopFrame";
25-
String EVALUATION_DIALOG_POPUP = "Debugger.EvaluationDialogPopup";
26-
String FRAME_PANEL_POPUP = "Debugger.FramePanelPopup";
27-
String INSPECT_PANEL_POPUP = "Debugger.InspectPanelPopup";
2825
String THREADS_PANEL_POPUP = "Debugger.ThreadsPanelPopup";
29-
String WATCH_PANEL_POPUP = "Debugger.WatchesPanelPopup";
3026
String REMOVE_WATCH = "Debugger.RemoveWatch";
3127
String NEW_WATCH = "Debugger.NewWatch";
3228
String EDIT_WATCH = "Debugger.EditWatch";
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2013-2025 consulo.io
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.intellij.java.debugger.impl.actions;
17+
18+
import consulo.annotation.component.ActionImpl;
19+
import consulo.annotation.component.ActionParentRef;
20+
import consulo.annotation.component.ActionRef;
21+
import consulo.annotation.component.ActionRefAnchor;
22+
import consulo.application.dumb.DumbAware;
23+
import consulo.localize.LocalizeValue;
24+
import consulo.ui.ex.action.AnSeparator;
25+
import consulo.ui.ex.action.DefaultActionGroup;
26+
27+
/**
28+
* @author UNV
29+
* @since 2025-10-30
30+
*/
31+
@ActionImpl(
32+
id = "JavaCompileGroup",
33+
children = {
34+
@ActionRef(type = ToggleMethodBreakpointAction.class),
35+
@ActionRef(type = ToggleFieldBreakpointAction.class),
36+
@ActionRef(type = AnSeparator.class)
37+
},
38+
parents = {
39+
@ActionParentRef(value = @ActionRef(id = "ProjectViewCompileGroup"), anchor = ActionRefAnchor.FIRST),
40+
@ActionParentRef(value = @ActionRef(id = "StructureViewCompileGroup"), anchor = ActionRefAnchor.FIRST)
41+
}
42+
)
43+
public class JavaCompileGroup extends DefaultActionGroup implements DumbAware {
44+
public JavaCompileGroup() {
45+
super(LocalizeValue.empty(), false);
46+
}
47+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2013-2025 consulo.io
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.intellij.java.debugger.impl.actions;
17+
18+
import consulo.annotation.component.ActionImpl;
19+
import consulo.annotation.component.ActionParentRef;
20+
import consulo.annotation.component.ActionRef;
21+
import consulo.application.dumb.DumbAware;
22+
import consulo.localize.LocalizeValue;
23+
import consulo.ui.ex.action.AnSeparator;
24+
import consulo.ui.ex.action.DefaultActionGroup;
25+
26+
/**
27+
* @author UNV
28+
* @since 2025-10-30
29+
*/
30+
@ActionImpl(
31+
id = "EditorPopupMenuDebugJava",
32+
children = {
33+
@ActionRef(type = AnSeparator.class),
34+
@ActionRef(type = ToggleFieldBreakpointAction.class),
35+
@ActionRef(type = AnSeparator.class)
36+
},
37+
parents = @ActionParentRef(@ActionRef(id = "EditorPopupMenuDebug"))
38+
)
39+
public class JavaEditorPopupMenuDebugGroup extends DefaultActionGroup implements DumbAware {
40+
public JavaEditorPopupMenuDebugGroup() {
41+
super(LocalizeValue.empty(), false);
42+
}
43+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2013-2025 consulo.io
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.intellij.java.debugger.impl.actions;
17+
18+
import consulo.annotation.component.ActionImpl;
19+
import consulo.annotation.component.ActionRef;
20+
import consulo.application.dumb.DumbAware;
21+
import consulo.localize.LocalizeValue;
22+
import consulo.ui.ex.action.AnSeparator;
23+
import consulo.ui.ex.action.DefaultActionGroup;
24+
25+
/**
26+
* @author UNV
27+
* @since 2025-10-30
28+
*/
29+
@ActionImpl(
30+
id = DebuggerActions.THREADS_PANEL_POPUP,
31+
children = {
32+
//@ActionRef(type = ResumeThreadAction.class),
33+
//@ActionRef(type = FreezeThreadAction.class),
34+
@ActionRef(type = InterruptThreadAction.class),
35+
//@ActionRef(id = "Debugger.ShowFrame"),
36+
@ActionRef(id = DebuggerActions.POP_FRAME),
37+
//@ActionRef(id = DebuggerActions.EDIT_FRAME_SOURCE),
38+
//@ActionRef(id = "Debugger.EditTypeSource"),
39+
//@ActionRef(id = "EditSource"),
40+
@ActionRef(type = AnSeparator.class),
41+
@ActionRef(type = ExportThreadsAction.class),
42+
@ActionRef(type = AnSeparator.class),
43+
@ActionRef(type = CustomizeThreadsViewAction.class)
44+
}
45+
)
46+
public class JavaThreadsPanelPopupGroup extends DefaultActionGroup implements DumbAware {
47+
public JavaThreadsPanelPopupGroup() {
48+
super(LocalizeValue.empty(), false);
49+
}
50+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2013-2025 consulo.io
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.intellij.java.debugger.impl.actions;
17+
18+
import consulo.annotation.component.ActionImpl;
19+
import consulo.annotation.component.ActionRef;
20+
import consulo.application.dumb.DumbAware;
21+
import consulo.localize.LocalizeValue;
22+
import consulo.ui.ex.action.AnSeparator;
23+
import consulo.ui.ex.action.DefaultActionGroup;
24+
25+
/**
26+
* @author UNV
27+
* @since 2025-10-30
28+
*/
29+
@ActionImpl(
30+
id = DebuggerActions.REPRESENTATION_LIST,
31+
children = {
32+
@ActionRef(type = CreateRendererAction.class),
33+
@ActionRef(type = AnSeparator.class),
34+
@ActionRef(type = AutoRendererAction.class)
35+
}
36+
)
37+
public class RepresentationGroup extends DefaultActionGroup implements DumbAware {
38+
public RepresentationGroup() {
39+
super(LocalizeValue.empty(), false);
40+
}
41+
}

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

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -16,43 +16,34 @@
1616
package com.intellij.java.debugger.impl.actions;
1717

1818
import com.intellij.java.debugger.SourcePosition;
19-
import com.intellij.java.debugger.engine.DebuggerUtils;
2019
import com.intellij.java.debugger.impl.DebuggerContextImpl;
2120
import com.intellij.java.debugger.impl.DebuggerManagerEx;
22-
import com.intellij.java.debugger.impl.DebuggerSession;
23-
import com.intellij.java.debugger.impl.InstanceFilter;
2421
import com.intellij.java.debugger.impl.engine.DebugProcessImpl;
2522
import com.intellij.java.debugger.impl.engine.SourcePositionProvider;
2623
import com.intellij.java.debugger.impl.engine.events.DebuggerContextCommandImpl;
2724
import com.intellij.java.debugger.impl.ui.breakpoints.Breakpoint;
2825
import com.intellij.java.debugger.impl.ui.breakpoints.BreakpointManager;
2926
import com.intellij.java.debugger.impl.ui.breakpoints.FieldBreakpoint;
30-
import com.intellij.java.debugger.impl.ui.impl.watch.DebuggerTree;
3127
import com.intellij.java.debugger.impl.ui.impl.watch.DebuggerTreeNodeImpl;
3228
import com.intellij.java.debugger.impl.ui.impl.watch.FieldDescriptorImpl;
3329
import com.intellij.java.debugger.localize.JavaDebuggerLocalize;
3430
import com.intellij.java.language.impl.JavaClassFileType;
3531
import com.intellij.java.language.impl.JavaFileType;
36-
import com.intellij.java.language.psi.PsiClass;
3732
import com.intellij.java.language.psi.PsiField;
3833
import consulo.annotation.access.RequiredReadAction;
3934
import consulo.annotation.component.ActionImpl;
4035
import consulo.codeEditor.Editor;
4136
import consulo.dataContext.DataContext;
4237
import consulo.document.Document;
4338
import consulo.fileEditor.FileEditorManager;
44-
import consulo.internal.com.sun.jdi.Field;
45-
import consulo.internal.com.sun.jdi.ObjectReference;
4639
import consulo.language.psi.PsiDocumentManager;
4740
import consulo.language.psi.PsiElement;
4841
import consulo.language.psi.PsiFile;
49-
import consulo.language.psi.scope.GlobalSearchScope;
5042
import consulo.project.Project;
5143
import consulo.ui.annotation.RequiredUIAccess;
5244
import consulo.ui.ex.action.ActionPlaces;
5345
import consulo.ui.ex.action.AnAction;
5446
import consulo.ui.ex.action.AnActionEvent;
55-
import consulo.ui.ex.action.Presentation;
5647
import consulo.util.lang.ref.SimpleReference;
5748
import consulo.virtualFileSystem.VirtualFile;
5849
import consulo.virtualFileSystem.fileType.FileType;
@@ -93,19 +84,6 @@ public void actionPerformed(AnActionEvent e) {
9384
if (breakpoint == null) {
9485
FieldBreakpoint fieldBreakpoint = manager.addFieldBreakpoint(document, offset);
9586
if (fieldBreakpoint != null) {
96-
if (DebuggerAction.isContextView(e)) {
97-
DebuggerTreeNodeImpl selectedNode = DebuggerAction.getSelectedNode(e.getDataContext());
98-
if (selectedNode != null && selectedNode.getDescriptor() instanceof FieldDescriptorImpl fieldDescriptor) {
99-
ObjectReference object = fieldDescriptor.getObject();
100-
if (object != null) {
101-
long id = object.uniqueID();
102-
InstanceFilter[] instanceFilters = new InstanceFilter[]{InstanceFilter.create(Long.toString(id))};
103-
fieldBreakpoint.setInstanceFilters(instanceFilters);
104-
fieldBreakpoint.setInstanceFiltersEnabled(true);
105-
}
106-
}
107-
}
108-
10987
Editor editor = e.getData(Editor.KEY);
11088
if (editor != null) {
11189
manager.editBreakpoint(fieldBreakpoint, editor);
@@ -122,31 +100,7 @@ public void actionPerformed(AnActionEvent e) {
122100
@Override
123101
@RequiredUIAccess
124102
public void update(@Nonnull AnActionEvent event) {
125-
SourcePosition place = getPlace(event);
126-
boolean toEnable = place != null;
127-
128-
Presentation presentation = event.getPresentation();
129-
if (POPUP_PLACES.contains(event.getPlace())) {
130-
presentation.setVisible(toEnable);
131-
}
132-
else if (DebuggerAction.isContextView(event)) {
133-
presentation.setTextValue(JavaDebuggerLocalize.actionAddFieldWatchpointText());
134-
Project project = event.getData(Project.KEY);
135-
if (project != null && place != null) {
136-
Document document = PsiDocumentManager.getInstance(project).getDocument(place.getFile());
137-
if (document != null) {
138-
int offset = place.getOffset();
139-
BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(project).getBreakpointManager();
140-
Breakpoint fieldBreakpoint =
141-
offset >= 0 ? breakpointManager.findBreakpoint(document, offset, FieldBreakpoint.CATEGORY) : null;
142-
if (fieldBreakpoint != null) {
143-
presentation.setEnabled(false);
144-
return;
145-
}
146-
}
147-
}
148-
}
149-
presentation.setVisible(toEnable);
103+
event.getPresentation().setVisible(getPlace(event) != null);
150104
}
151105

152106
@Nullable
@@ -187,30 +141,6 @@ public void threadAction() {
187141
}
188142
}
189143

190-
if (DebuggerAction.isContextView(event)) {
191-
DebuggerTree tree = event.getData(DebuggerTree.DATA_KEY);
192-
if (tree != null && tree.getSelectionPath() != null) {
193-
DebuggerTreeNodeImpl node = (DebuggerTreeNodeImpl) tree.getSelectionPath().getLastPathComponent();
194-
if (node != null && node.getDescriptor() instanceof FieldDescriptorImpl fieldDescriptor) {
195-
Field field = fieldDescriptor.getField();
196-
DebuggerSession session = tree.getDebuggerContext().getDebuggerSession();
197-
PsiClass psiClass = DebuggerUtils.findClass(
198-
field.declaringType().name(),
199-
project,
200-
session != null ? session.getSearchScope() : GlobalSearchScope.allScope(project)
201-
);
202-
if (psiClass != null) {
203-
psiClass = (PsiClass) psiClass.getNavigationElement();
204-
PsiField psiField = psiClass.findFieldByName(field.name(), true);
205-
if (psiField != null) {
206-
return SourcePosition.createFromElement(psiField);
207-
}
208-
}
209-
}
210-
}
211-
return null;
212-
}
213-
214144
Editor editor = event.getData(Editor.KEY);
215145
if (editor == null) {
216146
editor = FileEditorManager.getInstance(project).getSelectedTextEditor();

0 commit comments

Comments
 (0)