troizet opened a new pull request, #8142:
URL: https://github.com/apache/netbeans/pull/8142

   #### Example:
   
   
https://github.com/user-attachments/assets/47939763-1f6d-484d-a2c7-22fc5fc4716f
   
   #### Algorithm Description:
   Each time a file is opened or edited, it checks for test methods in the file 
and uses 
[`TestMethodController.setTestMethods`](https://github.com/apache/netbeans/blob/master/ide/gsf.testrunner.ui/src/org/netbeans/modules/gsf/testrunner/ui/api/TestMethodController.java)
 to create annotations that use the 
[`RunDebugTestGutterAction.java`](https://github.com/apache/netbeans/blob/master/ide/gsf.testrunner.ui/src/org/netbeans/modules/gsf/testrunner/ui/annotation/RunDebugTestGutterAction.java)
 action to execute the test method.
   
   #### Peculiarities of implementation:
   - The implementation was done by analogy with the implementation of 
annotations for java 
([ComputeTestMethodsImpl.java](https://github.com/apache/netbeans/blob/master/java/java.testrunner.ui/src/org/netbeans/modules/java/testrunner/ui/ComputeTestMethodsImpl.java)).
   
   - Due to the fact that I have not found an analog of 
`EditorAwareJavaSourceTaskFactory` for php, I decided to make a binding to the 
event of getting the focus of the editor tab and changes in the edited document.
   The php project [opening 
hook](https://github.com/apache/netbeans/blob/b5560425963730402b5cfdc15cd2a92c862a8a60/php/php.project/src/org/netbeans/modules/php/project/PhpProject.java#L809)
 seemed to me to be a less appropriate place to register a listener. Since 
events are handled for each editor tab regardless of the project and file type, 
I made the `ComputeTestMethodAnnotations` class a singleton to avoid having to 
register the listener multiple times if multiple php projects are open.
   
   -  
[`TestMethodController.setTestMethods`](https://github.com/apache/netbeans/blob/master/ide/gsf.testrunner.ui/src/org/netbeans/modules/gsf/testrunner/ui/api/TestMethodController.java)
 implements all the work of creating an annotation to run a test method. 
   Apparently, this method should update the list of annotations at each call 
of this method, when the passed collection of methods changes. Вut I didn't 
manage to achieve correct work in this case. While debugging the 
[ComputeTestMethodsImpl.java](https://github.com/apache/netbeans/blob/master/java/java.testrunner.ui/src/org/netbeans/modules/java/testrunner/ui/ComputeTestMethodsImpl.java)
 class for java, I noticed that the method is called twice: first for an empty 
collection, 
   then for a collection with new computed methods. 
   So I made the method call first with the empty collection, to clear the 
annotation list, then already with the method collection.
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to