@@ -127,7 +127,36 @@ public void mouseClicked(MouseEvent e) {
127127 if (node != null ) {
128128 Object object = node .getUserObject ();
129129
130- if (object instanceof MethodWrapper ) {
130+ if (object instanceof Pair ) {
131+
132+ Pair classPair = (Pair ) object ;
133+ String classname = classPair .getKey ().toString ();
134+ String simpleClassname = classname .substring (classname .lastIndexOf ("." ) + 1 );
135+
136+ PsiFile [] files = FilenameIndex .getFilesByName (project , simpleClassname + ".java" , GlobalSearchScope .allScope (project ));
137+
138+ boolean methodFound = false ;
139+
140+ for (PsiFile file : files ) {
141+
142+ PsiJavaFile psiJavaFile = (PsiJavaFile ) file ;
143+
144+ if ((psiJavaFile .getPackageName () + "." + simpleClassname ).contentEquals (classname )) {
145+
146+ methodFound = true ;
147+
148+ OpenFileDescriptor fileDescriptor = new OpenFileDescriptor (project , psiJavaFile .getVirtualFile ());
149+ fileDescriptor .navigateInEditor (project , true );
150+ }
151+ }
152+
153+ if (!methodFound ) {
154+ JBPopupFactory .getInstance ().createHtmlTextBalloonBuilder (resource .getString ("Messages.Error.ClassNotFound" ), MessageType .ERROR , null )
155+ .createBalloon ()
156+ .show (JBPopupFactory .getInstance ().guessBestPopupLocation ((JComponent ) e .getComponent ()), Balloon .Position .below );
157+ }
158+
159+ } else if (object instanceof MethodWrapper ) {
131160
132161 MethodWrapper method = (MethodWrapper ) object ;
133162
@@ -504,7 +533,7 @@ private void addNode(MethodWrapper method) {
504533 */
505534 private void loadMethods () {
506535
507- HashMap <String , ArrayList <MethodWrapper >> methods = JSONFileLoader .getMethodsForTree (TREE_FILTERS , currentFile , project );
536+ TreeMap <String , ArrayList <MethodWrapper >> methods = JSONFileLoader .getMethodsForTree (TREE_FILTERS , currentFile , project );
508537
509538 if (methods .size () > 0 ) {
510539
@@ -517,7 +546,11 @@ private void loadMethods() {
517546 methodCount = methods .get (classname ).size ();
518547 totalMethods += methodCount ;
519548
520- for (MethodWrapper method : methods .get (classname )) {
549+ DefaultMutableTreeNode classNode = new DefaultMutableTreeNode (new Pair <>(classname , methodCount ));
550+
551+ ArrayList <MethodWrapper > sortedList = methods .get (classname );
552+ Collections .sort (sortedList );
553+ for (MethodWrapper method : sortedList ) {
521554
522555 classNode .add (addCategoriesToNode (method ));
523556 root .add (classNode );
0 commit comments