|
36 | 36 | import java.util.Map; |
37 | 37 |
|
38 | 38 | public class CallHierarchyBrowser extends CallHierarchyBrowserBase { |
39 | | - private static final Logger LOG = Logger.getInstance(CallHierarchyBrowser.class); |
| 39 | + private static final Logger LOG = Logger.getInstance(CallHierarchyBrowser.class); |
40 | 40 |
|
41 | | - public CallHierarchyBrowser(@Nonnull Project project, @Nonnull PsiMethod method) { |
42 | | - super(project, method); |
43 | | - } |
44 | | - |
45 | | - @Override |
46 | | - protected void createTrees(@Nonnull final Map<String, JTree> type2TreeMap) { |
47 | | - ActionGroup group = (ActionGroup)ActionManager.getInstance().getAction(IdeActions.GROUP_CALL_HIERARCHY_POPUP); |
48 | | - final JTree tree1 = createTree(false); |
49 | | - PopupHandler.installPopupHandler(tree1, group, ActionPlaces.CALL_HIERARCHY_VIEW_POPUP, ActionManager.getInstance()); |
50 | | - final BaseOnThisMethodAction baseOnThisMethodAction = new BaseOnThisMethodAction(); |
51 | | - baseOnThisMethodAction |
52 | | - .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_CALL_HIERARCHY).getShortcutSet(), tree1); |
53 | | - type2TreeMap.put(CALLEE_TYPE, tree1); |
| 41 | + public CallHierarchyBrowser(@Nonnull Project project, @Nonnull PsiMethod method) { |
| 42 | + super(project, method); |
| 43 | + } |
54 | 44 |
|
55 | | - final JTree tree2 = createTree(false); |
56 | | - PopupHandler.installPopupHandler(tree2, group, ActionPlaces.CALL_HIERARCHY_VIEW_POPUP, ActionManager.getInstance()); |
57 | | - baseOnThisMethodAction |
58 | | - .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_CALL_HIERARCHY).getShortcutSet(), tree2); |
59 | | - type2TreeMap.put(CALLER_TYPE, tree2); |
60 | | - } |
| 45 | + @Override |
| 46 | + protected void createTrees(@Nonnull Map<String, JTree> type2TreeMap) { |
| 47 | + ActionGroup group = (ActionGroup)ActionManager.getInstance().getAction(IdeActions.GROUP_CALL_HIERARCHY_POPUP); |
| 48 | + JTree tree1 = createTree(false); |
| 49 | + PopupHandler.installPopupHandler(tree1, group, ActionPlaces.CALL_HIERARCHY_VIEW_POPUP, ActionManager.getInstance()); |
| 50 | + BaseOnThisMethodAction baseOnThisMethodAction = new BaseOnThisMethodAction(); |
| 51 | + baseOnThisMethodAction |
| 52 | + .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_CALL_HIERARCHY).getShortcutSet(), tree1); |
| 53 | + type2TreeMap.put(CALLEE_TYPE, tree1); |
61 | 54 |
|
62 | | - @Override |
63 | | - protected PsiElement getElementFromDescriptor(@Nonnull HierarchyNodeDescriptor descriptor) { |
64 | | - if (descriptor instanceof CallHierarchyNodeDescriptor) { |
65 | | - CallHierarchyNodeDescriptor nodeDescriptor = (CallHierarchyNodeDescriptor)descriptor; |
66 | | - return nodeDescriptor.getEnclosingElement(); |
| 55 | + JTree tree2 = createTree(false); |
| 56 | + PopupHandler.installPopupHandler(tree2, group, ActionPlaces.CALL_HIERARCHY_VIEW_POPUP, ActionManager.getInstance()); |
| 57 | + baseOnThisMethodAction |
| 58 | + .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_CALL_HIERARCHY).getShortcutSet(), tree2); |
| 59 | + type2TreeMap.put(CALLER_TYPE, tree2); |
67 | 60 | } |
68 | | - return null; |
69 | | - } |
70 | 61 |
|
71 | | - @Override |
72 | | - protected PsiElement getOpenFileElementFromDescriptor(@Nonnull HierarchyNodeDescriptor descriptor) { |
73 | | - if (descriptor instanceof CallHierarchyNodeDescriptor) { |
74 | | - CallHierarchyNodeDescriptor nodeDescriptor = (CallHierarchyNodeDescriptor)descriptor; |
75 | | - return nodeDescriptor.getTargetElement(); |
| 62 | + @Override |
| 63 | + protected PsiElement getElementFromDescriptor(@Nonnull HierarchyNodeDescriptor descriptor) { |
| 64 | + if (descriptor instanceof CallHierarchyNodeDescriptor nodeDescriptor) { |
| 65 | + return nodeDescriptor.getEnclosingElement(); |
| 66 | + } |
| 67 | + return null; |
76 | 68 | } |
77 | | - return null; |
78 | | - } |
79 | 69 |
|
80 | | - @Override |
81 | | - protected boolean isApplicableElement(@Nonnull final PsiElement element) { |
82 | | - return element instanceof PsiMethod; |
83 | | - } |
84 | | - |
85 | | - @Override |
86 | | - protected HierarchyTreeStructure createHierarchyTreeStructure(@Nonnull final String typeName, @Nonnull final PsiElement psiElement) { |
87 | | - if (CALLER_TYPE.equals(typeName)) { |
88 | | - return new CallerMethodsTreeStructure(myProject, (PsiMethod)psiElement, getCurrentScopeType()); |
| 70 | + @Override |
| 71 | + protected PsiElement getOpenFileElementFromDescriptor(@Nonnull HierarchyNodeDescriptor descriptor) { |
| 72 | + if (descriptor instanceof CallHierarchyNodeDescriptor nodeDescriptor) { |
| 73 | + return nodeDescriptor.getTargetElement(); |
| 74 | + } |
| 75 | + return null; |
89 | 76 | } |
90 | | - else if (CALLEE_TYPE.equals(typeName)) { |
91 | | - return new CalleeMethodsTreeStructure(myProject, (PsiMethod)psiElement, getCurrentScopeType()); |
| 77 | + |
| 78 | + @Override |
| 79 | + protected boolean isApplicableElement(@Nonnull PsiElement element) { |
| 80 | + return element instanceof PsiMethod; |
92 | 81 | } |
93 | | - else { |
94 | | - LOG.error("unexpected type: " + typeName); |
95 | | - return null; |
| 82 | + |
| 83 | + @Override |
| 84 | + protected HierarchyTreeStructure createHierarchyTreeStructure(@Nonnull String typeName, @Nonnull PsiElement psiElement) { |
| 85 | + if (CALLER_TYPE.equals(typeName)) { |
| 86 | + return new CallerMethodsTreeStructure(myProject, (PsiMethod)psiElement, getCurrentScopeType()); |
| 87 | + } |
| 88 | + else if (CALLEE_TYPE.equals(typeName)) { |
| 89 | + return new CalleeMethodsTreeStructure(myProject, (PsiMethod)psiElement, getCurrentScopeType()); |
| 90 | + } |
| 91 | + else { |
| 92 | + LOG.error("unexpected type: " + typeName); |
| 93 | + return null; |
| 94 | + } |
96 | 95 | } |
97 | | - } |
98 | 96 |
|
99 | | - @Override |
100 | | - protected Comparator<NodeDescriptor> getComparator() { |
101 | | - return JavaHierarchyUtil.getComparator(myProject); |
102 | | - } |
| 97 | + @Override |
| 98 | + protected Comparator<NodeDescriptor> getComparator() { |
| 99 | + return JavaHierarchyUtil.getComparator(myProject); |
| 100 | + } |
103 | 101 |
|
104 | | - public static final class BaseOnThisMethodAction extends CallHierarchyBrowserBase.BaseOnThisMethodAction { |
105 | | - } |
| 102 | + public static final class BaseOnThisMethodAction extends CallHierarchyBrowserBase.BaseOnThisMethodAction { |
| 103 | + } |
106 | 104 | } |
0 commit comments