Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not remove the just-added annotation from the list of annotations. #8201

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Jan 27, 2025

Here:
#8142 (comment)
was a note that TestMethodController.setTestMethods must first be called with an empty list, and only then with the real values. Looking at the code, the issue is that first the new annotations are added, and then the old ones are removed. And when one annotation replaces another on the same line, the removal will remove registration of the newly-added annotation in the annotationLines/TestMethodAnnotation.DOCUMENT_ANNOTATION_LINES_KEY map.

This was not obvious for Java, as Java support runs several providers, and calls setTestMethods after running each provider (passing cumulative results into the method). As a consequence, in many cases, the setTestMethods was first called with an empty list, effectively replicating the PHP workaround.

The proposal here is to:

  • first remove and then add annotations, which should avoid the above problem
  • for Java, collect the test methods, and call setTestMethods only once
  • remove the workaround from PHP.

@lahodaj lahodaj added this to the NB26 milestone Jan 27, 2025
@lahodaj lahodaj requested review from troizet and dbalek January 27, 2025 15:56
@lahodaj lahodaj added PHP [ci] enable extra PHP tests (php/php.editor) Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) labels Jan 27, 2025
@apache apache locked and limited conversation to collaborators Jan 27, 2025
@lahodaj lahodaj added the VSCode Extension [ci] enable VSCode Extension tests label Jan 27, 2025
@apache apache unlocked this conversation Jan 27, 2025
Copy link
Member

@tmysik tmysik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PHP fix.

CC @junichi11 @troizet

@junichi11
Copy link
Member

junichi11 commented Jan 27, 2025

I fixed ComputeTestMethodAnnotations against the delivery branch: #8196
So, can't we include this PR in NB25?

@troizet
Copy link
Collaborator

troizet commented Jan 27, 2025

I quickly tested it. Unfortunately, the problem is not completely solved. When renaming a method, the annotations are updated, but not when moving the method to another line.

Also, while I was playing around with renaming a method and moving it to another line, I ran into a bug where when a method is renamed, the action still shows the old method name.
2025-01-28 02-05-32

@tmysik
Copy link
Member

tmysik commented Jan 27, 2025

@lahodaj please, see the bug above (see the screenshot). thank you

@junichi11
Copy link
Member

junichi11 commented Jan 27, 2025

Example to reproduce it with PHP:

  1. Download composer.phar
  2. Set PHP interpreter (Options > PHP > General)

nb-php-gh8201-01

  1. Set the composer.phar (Options > PHP > Frameworks & Tools > Composer)

nb-php-gh8201-02

  1. Create a sample project

    • File > New Project > Samples > PHP > Calculator - PHPUnit Sample Application
  2. Right-click the php project > Composer > Install (dev)

  3. Open Test Files: src/CalculatorTest.php

@ebarboni ebarboni added the do not merge Don't merge this PR, it is not ready or just demonstration purposes. label Jan 28, 2025
@ebarboni
Copy link
Contributor

this PR should be resynchronized after #8205 is in on master as #8196 will conflict.

@junichi11
Copy link
Member

I've verified it is fixed:

nb-gh-8201-verification

Thank you!

Copy link
Collaborator

@troizet troizet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works. Thank you very much!

@mbien
Copy link
Member

mbien commented Jan 30, 2025

regarding #8201 (comment)

just to be sure: is NB26 correct or is this meant for NB25/delivery?

If the target is changed, this would need to be rebased too, since the branch is post spec version bump to avoid it creating a huge merge commit. + tests need to run again and according to our rules it would need one new approval.

Its all doable - but someone would have to decide what to do ;)

@lahodaj
Copy link
Contributor Author

lahodaj commented Jan 30, 2025

I apologize for belated comment, I planned to do this sooner. If the original patch would have worked, I would have been tempted to push it to NB25. But the current patch could probably use some baking time, so I'd prefer NB 26. Unless PHP needs the fix, but I suspect it is OK with the current workaround.

My understanding is that #8196 is not yet in master - I'll wait for that, rebase, and if all goes well, I'll merge this PR to master.

@lahodaj
Copy link
Contributor Author

lahodaj commented Jan 30, 2025

And thanks for the testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Don't merge this PR, it is not ready or just demonstration purposes. Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) PHP [ci] enable extra PHP tests (php/php.editor) VSCode Extension [ci] enable VSCode Extension tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants