77import com .intellij .notification .Notifications ;
88import com .intellij .openapi .actionSystem .ActionManager ;
99import com .intellij .openapi .actionSystem .ActionPopupMenu ;
10+ import com .intellij .openapi .application .ApplicationManager ;
1011import com .intellij .openapi .editor .Document ;
1112import com .intellij .openapi .fileEditor .FileDocumentManager ;
1213import com .intellij .openapi .fileEditor .FileEditorManager ;
1314import com .intellij .openapi .fileEditor .FileEditorManagerEvent ;
1415import com .intellij .openapi .fileEditor .FileEditorManagerListener ;
16+ import com .intellij .openapi .progress .ProgressIndicator ;
17+ import com .intellij .openapi .progress .ProgressManager ;
18+ import com .intellij .openapi .progress .Task ;
1519import com .intellij .openapi .project .Project ;
1620import com .intellij .openapi .ui .MessageType ;
1721import com .intellij .openapi .ui .popup .Balloon ;
@@ -107,6 +111,7 @@ public void mouseClicked(MouseEvent e) {
107111
108112 //Get PSI element location
109113 PsiFile [] files = FilenameIndex .getFilesByName (project , method .getFileName (), GlobalSearchScope .allScope (project ));
114+
110115 boolean methodFound = false ;
111116
112117 for (PsiFile file : files ) {
@@ -116,9 +121,7 @@ public void mouseClicked(MouseEvent e) {
116121 for (PsiClass psiClass : psiJavaFile .getClasses ()) {
117122 for (PsiMethod psiMethod : psiClass .getMethods ()) {
118123
119-
120- if (PsiTraversal .getMethodSignature (psiMethod ).equals (method .getSignature (true ))) {
121- System .out .println (PsiTraversal .getMethodSignature (psiMethod ) + ">>>>" + method .getSignature (true ));
124+ if (Objects .equals (PsiTraversal .getMethodSignature (psiMethod ), method .getSignature (true ))) {
122125
123126 methodFound = true ;
124127 FileEditorManager .getInstance (project ).openFile (psiJavaFile .getVirtualFile (), true , true );
@@ -147,9 +150,20 @@ public void mouseClicked(MouseEvent e) {
147150 @ Override
148151 public void notifyFileChange (String fileName ) {
149152
150- JSONFileLoader .setConfigurationFile (fileName );
151- JSONFileLoader .loadInitialFile ();
152- loadMethods ();
153+ ProgressManager .getInstance ().run (new Task .Backgroundable (project , resource .getString ("Status.ImportFile" )) {
154+ @ Override
155+ public void run (@ NotNull ProgressIndicator progressIndicator ) {
156+
157+ ApplicationManager .getApplication ().runReadAction (new Runnable () {
158+ public void run () {
159+ JSONFileLoader .setConfigurationFile (fileName );
160+ JSONFileLoader .loadInitialFile ();
161+ loadMethods ();
162+ }
163+ });
164+ }
165+ });
166+
153167 DaemonCodeAnalyzer .getInstance (project ).restart ();
154168 }
155169 });
@@ -159,8 +173,20 @@ public void notifyFileChange(String fileName) {
159173 @ Override
160174 public void notifyFileChange (String fileName ) {
161175
162- JSONFileLoader .loadUpdatedFile (fileName );
163- loadMethods ();
176+ ProgressManager .getInstance ().run (new Task .Backgroundable (project , resource .getString ("Status.ImportFile" )) {
177+ @ Override
178+ public void run (@ NotNull ProgressIndicator progressIndicator ) {
179+
180+ ApplicationManager .getApplication ().runReadAction (new Runnable () {
181+ public void run () {
182+ JSONFileLoader .loadUpdatedFile (fileName );
183+ loadMethods ();
184+ }
185+ });
186+ }
187+ });
188+
189+ DaemonCodeAnalyzer .getInstance (project ).restart ();
164190 }
165191 });
166192
@@ -200,8 +226,7 @@ public void afterAction(MethodWrapper newMethod) {
200226 @ Override
201227 public void afterAction (ArrayList <MethodWrapper > methods ) {
202228
203- System .out .println ("n=mi get " +methods .size ());
204- for (MethodWrapper method : methods ){
229+ for (MethodWrapper method : methods ) {
205230 JSONFileLoader .addMethod (method );
206231 addNode (method );
207232 }
@@ -342,7 +367,7 @@ private DefaultMutableTreeNode searchNode(DefaultMutableTreeNode root, String me
342367 return null ;
343368 }
344369
345- private void addNode (MethodWrapper method ){
370+ private void addNode (MethodWrapper method ) {
346371 DefaultMutableTreeNode root = (DefaultMutableTreeNode ) getModel ().getRoot ();
347372 DefaultMutableTreeNode newMethodNode = new DefaultMutableTreeNode (method );
348373
0 commit comments