Skip to content

Commit

Permalink
Merge pull request #539 from turkeylurkey/fixPR511
Browse files Browse the repository at this point in the history
Remove a quick fix that removes both annotations when the two are mutually exclusive
  • Loading branch information
turkeylurkey authored Nov 15, 2024
2 parents 919bb3f + 13609e1 commit 53d7e0c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 37 deletions.
5 changes: 4 additions & 1 deletion jakarta.jdt/org.eclipse.lsp4jakarta.jdt.core/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,14 @@
<codeAction kind="quickfix"
targetDiagnostic="jakarta-cdi#InvalidProducerMethodParamAnnotation"
class="org.eclipse.lsp4jakarta.jdt.internal.cdi.RemoveProduceAnnotationQuickFix" />
<!-- These quick fixes remove remove the @Disposes annotation as well as the @Observes annotation.
They are mutually exclusive and only one needs to go.
<codeAction kind="quickfix"
targetDiagnostic="jakarta-cdi#InvalidDisposesAnnotationOnMultipleMethodParams"
class="org.eclipse.lsp4jakarta.jdt.internal.cdi.RemoveInvalidProducerParamAnnotationQuickFix" />
<codeAction kind="quickfix"
<codeAction kind="quickfix"
targetDiagnostic="jakarta-cdi#InvalidDisposerMethodParamAnnotation"
class="org.eclipse.lsp4jakarta.jdt.internal.cdi.RemoveInvalidProducerParamAnnotationQuickFix" />
-->
</extension>
</plugin>
Original file line number Diff line number Diff line change
Expand Up @@ -438,42 +438,45 @@ public void producesAndDisposesObservesObservesAsync() throws Exception {

assertJavaCodeAction(codeActionParams8, IJDT_UTILS, ca20, ca21);

JakartaJavaCodeActionParams codeActionParams9 = createCodeActionParams(uri, d9);

TextEdit te22 = te(30, 40, 30, 50, "");
TextEdit te23 = te(30, 64, 30, 74, "");
CodeAction ca22 = ca(uri, "Remove the '@Disposes' modifier from parameter 'name1'", d9, te22);
CodeAction ca23 = ca(uri, "Remove the '@Observes' modifier from parameter 'name2'", d9, te23);

assertJavaCodeAction(codeActionParams9, IJDT_UTILS, ca22, ca23);

JakartaJavaCodeActionParams codeActionParams10 = createCodeActionParams(uri, d10);

TextEdit te24 = te(42, 45, 42, 55, "");
TextEdit te25 = te(42, 69, 42, 84, "");
CodeAction ca24 = ca(uri, "Remove the '@Disposes' modifier from parameter 'name1'", d10, te24);
CodeAction ca25 = ca(uri, "Remove the '@ObservesAsync' modifier from parameter 'name2'", d10, te25);

assertJavaCodeAction(codeActionParams10, IJDT_UTILS, ca24, ca25);

JakartaJavaCodeActionParams codeActionParams11 = createCodeActionParams(uri, d11);

TextEdit te26 = te(48, 53, 48, 63, "");
TextEdit te27 = te(48, 77, 48, 87, "");
TextEdit te28 = te(48, 101, 48, 116, "");
CodeAction ca26 = ca(uri, "Remove the '@Disposes' modifier from parameter 'name1'", d11, te26);
CodeAction ca27 = ca(uri, "Remove the '@Observes' modifier from parameter 'name2'", d11, te27);
CodeAction ca28 = ca(uri, "Remove the '@ObservesAsync' modifier from parameter 'name3'", d11, te28);

assertJavaCodeAction(codeActionParams11, IJDT_UTILS, ca26, ca27, ca28);

JakartaJavaCodeActionParams codeActionParams12 = createCodeActionParams(uri, d12);

TextEdit te30 = te(54, 54, 54, 89, "");
CodeAction ca30 = ca(uri,
"Remove the '@Disposes', '@Observes', '@ObservesAsync' modifier from parameter 'name'", d12, te30);

assertJavaCodeAction(codeActionParams12, IJDT_UTILS, ca30);
/*
* These code actions are disabled until they are fixed
* JakartaJavaCodeActionParams codeActionParams9 = createCodeActionParams(uri, d9);
*
* TextEdit te22 = te(30, 40, 30, 50, "");
* TextEdit te23 = te(30, 64, 30, 74, "");
* CodeAction ca22 = ca(uri, "Remove the '@Disposes' modifier from parameter 'name1'", d9, te22);
* CodeAction ca23 = ca(uri, "Remove the '@Observes' modifier from parameter 'name2'", d9, te23);
*
* assertJavaCodeAction(codeActionParams9, IJDT_UTILS, ca22, ca23);
*
* JakartaJavaCodeActionParams codeActionParams10 = createCodeActionParams(uri, d10);
*
* TextEdit te24 = te(42, 45, 42, 55, "");
* TextEdit te25 = te(42, 69, 42, 84, "");
* CodeAction ca24 = ca(uri, "Remove the '@Disposes' modifier from parameter 'name1'", d10, te24);
* CodeAction ca25 = ca(uri, "Remove the '@ObservesAsync' modifier from parameter 'name2'", d10, te25);
*
* assertJavaCodeAction(codeActionParams10, IJDT_UTILS, ca24, ca25);
*
* JakartaJavaCodeActionParams codeActionParams11 = createCodeActionParams(uri, d11);
*
* TextEdit te26 = te(48, 53, 48, 63, "");
* TextEdit te27 = te(48, 77, 48, 87, "");
* TextEdit te28 = te(48, 101, 48, 116, "");
* CodeAction ca26 = ca(uri, "Remove the '@Disposes' modifier from parameter 'name1'", d11, te26);
* CodeAction ca27 = ca(uri, "Remove the '@Observes' modifier from parameter 'name2'", d11, te27);
* CodeAction ca28 = ca(uri, "Remove the '@ObservesAsync' modifier from parameter 'name3'", d11, te28);
*
* assertJavaCodeAction(codeActionParams11, IJDT_UTILS, ca26, ca27, ca28);
*
* JakartaJavaCodeActionParams codeActionParams12 = createCodeActionParams(uri, d12);
*
* TextEdit te30 = te(54, 54, 54, 89, "");
* CodeAction ca30 = ca(uri,
* "Remove the '@Disposes', '@Observes', '@ObservesAsync' modifier from parameter 'name'", d12, te30);
*
* assertJavaCodeAction(codeActionParams12, IJDT_UTILS, ca30);
*/
}

@Test
Expand Down

0 comments on commit 53d7e0c

Please sign in to comment.