Repository navigation
test: provide test case for Jakarta quick fixes - #793
dessina-devasia wants to merge 15 commits into
Conversation
|
@dessina-devasia thanks so much , your test looks very good! Please tell me when you will think your PR will be ready (since the PR is in draft) |
|
sure @angelozerr. Testing is currently in progress, and I'm addressing encountered failures. I will update you once the PR is ready. Thank you! |
e57ec5d to
30619b0
Compare
|
What is the status of this PR @dessina-devasia ? |
|
Hi @angelozerr, I'm encountering an issue at this specific line (https://github.com/redhat-developer/lsp4ij/pull/793/files#diff-08cdc1aaff36adf7f735e4752b512541a3be8e725cfb3d572e6b1446854d19e8R85). I'm unable to retrieve a value from |
You must never creating instance of provider, you need to get the real IJ QuickFixes. I will try to consume |
|
I will try calling |
| var file = myFixture.getFile(); | ||
| int offset = editor.getCaretModel().getOffset(); | ||
|
|
||
| LSPLazyCodeActionProvider provider = new LSPIntentionCodeActionSupport(file); |
There was a problem hiding this comment.
Don't use LSP internal class, you need to test the real IJ Quickfix. I suggest that you call
CodeInsightTestFixtureImpl.getAvailableIntentions(editor, file);
There was a problem hiding this comment.
@angelozerr I've modified as you suggested, still debugging and looking into the potential issue
There was a problem hiding this comment.
@angelozerr I've modified as you suggested, still debugging and looking into the potential issue
I think it is normal that yiu have empty intention actions, because your test is for quick fixes which are generated on validation step.
So you will need to emulate also a publishDiagnostics with the proper diagnostic. It will trigger the IJ annotator which will call your code actions.
After that I think (hope) the list will not empty.
There was a problem hiding this comment.
Updated the code by setting diagnostics, still issue persists. I've tried another approach as well by using myFixture.doHighlighting(), that's also failing. You can find the code as commented
There was a problem hiding this comment.
@angelozerr The reported issue is now resolved, and code actions are loading properly. I retrieved them using the myFixture.doHighlighting() API.
However, there is still an underlying issue - myFixture.launchAction() is not working. The input is correct, but the code action is not being applied, and the editor value is not changing. Is there any alternative for this myFixture.LaunchAction
There was a problem hiding this comment.
Could you check if the extra file that you add is updated?
| @@ -0,0 +1,11 @@ | |||
| package io.openliberty.sample.jakarta.servlet; | |||
There was a problem hiding this comment.
Why you need this file?
There was a problem hiding this comment.
Rather than direct reference from my local file, I thought it will be better to use an absolute path
Refer line https://github.com/redhat-developer/lsp4ij/pull/793/files#diff-e521aa992905ac4dd93cdc8efae852aaaac6f81f2e05b234a409433c7ef8b9b3R82
There was a problem hiding this comment.
Earlier the corresponding line looks like this: 0ec0391#diff-831aa0e00f3317cf6a4848241cf4c7692456654d49e0eb867a621bb321b60844R52
If you want to revert the code, I can do accordingly
There was a problem hiding this comment.
Ok I understand more why you did that, but your very nice assertCodeAction could be used to write another tests and if we use this strategy we will need to have 2 Java file contents (one with String in the test and one with a file). It would be very nice if your test could be done without adding this extra file.
There was a problem hiding this comment.
Modifications done as discussed
|
Thank you @angelozerr. Let me try that as well |
Thanks. Your asset method must have a new parameter with resolved code actions |
|
@angelozerr Resolved all issues related to this PR. Thank you for your support! |
|
,hy you need to update LSP4IJ utils? You should not update it. I dont see resolve codeaction uding in your test to update edit. |
Once the code action is applied by calling The replacement with the new value happens exactly here. It updates only the document, but the text in the editor is not updated. The only change that I've done in LSP4IJUtil is, passed the editor in |
I've used |
|
First you must not update LSPIJUtils. Tests must never impact this utility class.
MockTextDocumentService is a copy/paste from LSP4E and I think there are no test with resolve code action. You will need to update MockTextDocumentService like this: public void setResolveCodeAction(CodeAction resolvedCodeAction) {
this.mockResolvedCodeAction = resolvedCodeAction;
}
@Override
public CompletableFuture<CodeAction> resolveCodeAction(CodeAction unresolved) {
return CompletableFuture.completedFuture(mockResolvedCodeAction);
}But let me some times to give you more explanation. |
|
Ok the first thing which is not good is that your assertApplyCodeAction redo configureByText, it should never done that. The main idea is that your assertCodeActions initialize the editor with configureByText, but assertApplyCodeAction should not updated again the editor. It should just apply the resolved code action. I suggest that you see completion test As you can see the apply completion doesn't reinitialize the editor, it uses the previous completion list which as loaded with assertCompletion. See the test |
|
When your code actions are loaded by assertCodeActions, your "edit" is null. It is because you don't load this edit to have fast performance. When quick fix is applied, the LSP request codeAction/resolve is called to update this edit. You need to emulate that by calling your assertApplyCodeAction with the resolved code action (with the edit). |
@dessina-devasia do you understand what I mean? |
|
Yes @angelozerr. I'm currently working on it. I'll let you know with the update soon. |
|
Ok great. It is not a trivial issue. The main important thing is to understand how lsp codeaction, resolve codeaction are working and your test highlight this mechanism. |
|
Sure @angelozerr. Understood. Thank you for the detailed explanation. Let me check into the resolveCodeAction working as well. |
…eServer and MockTextDocumentService
|
Hi @angelozerr, I've updated the code as per the suggestions. Code is working fine now. Could you please review? |
|
I am sorry again @dessina-devasia but you dont test the QuickFix apply with IJ since you have recoded the apply. You need to apply quick fix like you did before with launchActions. As soon as I will finish my work with DAP support, I will try to help you more with sample code. |
| "message": "The annotation @WebFilter must define the attribute \\u0027urlPatterns\\u0027, \\u0027servletNames\\u0027 or \\u0027value\\u0027." | ||
| } | ||
| ], | ||
| "edit": { |
There was a problem hiding this comment.
Just one question, this JSON content is a copy/paste from the result of codeAction/result response?
No Problem @angelozerr Regarding This is why I previously made some modifications in Could you please let me know if there is any alternative approach for this scenario while applying |
|
To be honnest with you, I need to debug IJ to understand why it doesnt update the editor. Your tentatives will help me a lot. I need to find time to investigate your pr. But for now I am super busy to finish dap support and review existing prs because I would like to create a release asap. |
|
okay @angelozerr |
|
@dessina-devasia as there are so many changes to do in your code, I decided to create a new PR #862 It is working on my local labtop but not in CI build. I don't know why? If you have any questions, don't hesitate. I close your PR and thanks so much to have investigated the write of this test. Your attempt was very helpfull for me. Closed for #862 |
|
Thank you @angelozerr for taking it forward! Your cooperation also helped me a lot in developing this test case. Let me know if you need any help. |
|
You are welcome! As soon as I will find time I will try to investigate why there is a problem on ci build. Any idea are welcome ! |


Uh oh!
There was an error while loading. Please reload this page.