From 0880e0fb958b38d635491587d04e66aee07c7cb0 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi <141303561+anusreelakshmi934@users.noreply.github.com> Date: Thu, 7 Nov 2024 14:19:49 +0530 Subject: [PATCH 1/6] Short name to display --- .../lsp4ij/beanvalidation/BeanValidationQuickFix.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/beanvalidation/BeanValidationQuickFix.java b/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/beanvalidation/BeanValidationQuickFix.java index 7429e4d04..b3c3344cb 100644 --- a/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/beanvalidation/BeanValidationQuickFix.java +++ b/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/beanvalidation/BeanValidationQuickFix.java @@ -81,7 +81,7 @@ public CodeAction resolveCodeAction(JavaCodeActionResolveContext context) { private void removeConstraintAnnotationsCodeActions(Diagnostic diagnostic, JavaCodeActionContext context, List codeActions) { final String annotationName = diagnostic.getData().toString().replace("\"", ""); - final String name = Messages.getMessage("RemoveConstraintAnnotation", annotationName); + final String name = Messages.getMessage("RemoveConstraintAnnotation", annotationName.substring(annotationName.lastIndexOf('.') + 1)); Map extendedData = new HashMap<>(); extendedData.put(ANNOTATION_NAME, annotationName); codeActions.add(JDTUtils.createCodeAction(context, diagnostic, name, getParticipantId(), extendedData)); From 20959f4bbd5d6a51401e665a402b997d107db8f0 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi <141303561+anusreelakshmi934@users.noreply.github.com> Date: Thu, 7 Nov 2024 14:35:32 +0530 Subject: [PATCH 2/6] Removed single quotes --- .../proposal/quickfix/RemoveParamAnnotationQuickFix.java | 4 ++-- .../tools/intellij/lsp4jakarta/messages/messages.properties | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/codeAction/proposal/quickfix/RemoveParamAnnotationQuickFix.java b/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/codeAction/proposal/quickfix/RemoveParamAnnotationQuickFix.java index 45afcc066..8b8dabea5 100644 --- a/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/codeAction/proposal/quickfix/RemoveParamAnnotationQuickFix.java +++ b/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/codeAction/proposal/quickfix/RemoveParamAnnotationQuickFix.java @@ -80,9 +80,9 @@ public List getCodeActions(JavaCodeActionContext context, private String getLabel(PsiParameter parameter,List annotationsToRemove) { final StringBuilder sb = new StringBuilder(); // Java annotations in comma delimited list, assume that is ok. - sb.append("'@").append(getShortName(annotationsToRemove.get(0))).append("'"); + sb.append("@").append(getShortName(annotationsToRemove.get(0))); for (int j = 1; j < annotationsToRemove.size(); ++j) { - sb.append(", '@").append(getShortName(annotationsToRemove.get(j))).append("'"); + sb.append(", @").append(getShortName(annotationsToRemove.get(j))); } return Messages.getMessage("RemoveTheModifierFromParameter", sb.toString(), parameter.getName().toString()); } diff --git a/src/main/resources/io/openliberty/tools/intellij/lsp4jakarta/messages/messages.properties b/src/main/resources/io/openliberty/tools/intellij/lsp4jakarta/messages/messages.properties index 501cec40b..66e26c44e 100644 --- a/src/main/resources/io/openliberty/tools/intellij/lsp4jakarta/messages/messages.properties +++ b/src/main/resources/io/openliberty/tools/intellij/lsp4jakarta/messages/messages.properties @@ -35,7 +35,7 @@ InsertItem = Insert {0} RemoveItem = Remove {0} # RemoveParamAnnotationQuickFix -RemoveTheModifierFromParameter = Remove the {0} modifier from parameter ''{1}'' +RemoveTheModifierFromParameter = Remove the {0} modifier from parameter {1} # RemoveModifierConflictQuickFix RemoveTheModifierFromThisVariable = Remove the ''{0}'' modifier from this variable From 967ed9a4bd8e339f6d899bed6bdc14594c15ac85 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi <141303561+anusreelakshmi934@users.noreply.github.com> Date: Fri, 8 Nov 2024 10:16:24 +0530 Subject: [PATCH 3/6] corrected tests --- .../it/beanvalidation/BeanValidationTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/lsp4jakarta/it/beanvalidation/BeanValidationTest.java b/src/test/java/io/openliberty/tools/intellij/lsp4jakarta/it/beanvalidation/BeanValidationTest.java index 4a9b7ada9..4825eaa88 100644 --- a/src/test/java/io/openliberty/tools/intellij/lsp4jakarta/it/beanvalidation/BeanValidationTest.java +++ b/src/test/java/io/openliberty/tools/intellij/lsp4jakarta/it/beanvalidation/BeanValidationTest.java @@ -183,7 +183,7 @@ public void fieldConstraintValidation() throws Exception { JakartaJavaCodeActionParams codeActionParams = createCodeActionParams(uri, d1); TextEdit te = te(0, 0, 64, 1, newText); - CodeAction ca = ca(uri, "Remove constraint annotation jakarta.validation.constraints.AssertTrue from element", d1, te); + CodeAction ca = ca(uri, "Remove constraint annotation AssertTrue from element", d1, te); assertJavaCodeAction(codeActionParams, utils, ca); @@ -215,7 +215,7 @@ public void fieldConstraintValidation() throws Exception { JakartaJavaCodeActionParams codeActionParams2 = createCodeActionParams(uri, d19); TextEdit te1 = te(0, 0, 64, 1, newText6); TextEdit te2 = te(0, 0, 64, 1, newText7); - CodeAction ca1 = ca(uri, "Remove constraint annotation jakarta.validation.constraints.AssertTrue from element", d19, te1); + CodeAction ca1 = ca(uri, "Remove constraint annotation AssertTrue from element", d19, te1); CodeAction ca2 = ca(uri, "Remove static modifier from element", d19, te2); assertJavaCodeAction(codeActionParams2, utils, ca1, ca2); @@ -250,7 +250,7 @@ public void fieldConstraintValidation() throws Exception { JakartaJavaCodeActionParams codeActionParams3 = createCodeActionParams(uri, d20); TextEdit te3 = te(0, 0, 64, 1, newText8); TextEdit te4 = te(0, 0, 64, 1, newText9); - CodeAction ca3 = ca(uri, "Remove constraint annotation jakarta.validation.constraints.Past from element", d20, te3); + CodeAction ca3 = ca(uri, "Remove constraint annotation Past from element", d20, te3); CodeAction ca4 = ca(uri, "Remove static modifier from element", d20, te4); assertJavaCodeAction(codeActionParams3, utils, ca3, ca4); @@ -271,7 +271,7 @@ public void fieldConstraintValidation() throws Exception { JakartaJavaCodeActionParams codeActionParams4 = createCodeActionParams(uri, d18); TextEdit te5 = te(0, 0, 64, 1, newText10); - CodeAction ca5 = ca(uri, "Remove constraint annotation jakarta.validation.constraints.PositiveOrZero from element", d1, te5); + CodeAction ca5 = ca(uri, "Remove constraint annotation PositiveOrZero from element", d1, te5); assertJavaCodeAction(codeActionParams4, utils, ca5); } @@ -316,7 +316,7 @@ public void methodConstraintValidation() throws Exception { JakartaJavaCodeActionParams codeActionParams = createCodeActionParams(uri, d1); TextEdit te = te(0, 0, 34, 1, newText1); TextEdit te2 = te(0, 0, 34, 1, newText2); - CodeAction ca = ca(uri, "Remove constraint annotation jakarta.validation.constraints.AssertTrue from element", d1, te); + CodeAction ca = ca(uri, "Remove constraint annotation AssertTrue from element", d1, te); CodeAction ca2 = ca(uri, "Remove static modifier from element", d1, te2); assertJavaCodeAction(codeActionParams, utils, ca, ca2); @@ -331,7 +331,7 @@ public void methodConstraintValidation() throws Exception { codeActionParams = createCodeActionParams(uri, d2); te = te(0, 0, 34, 1, newText3); - ca = ca(uri, "Remove constraint annotation jakarta.validation.constraints.AssertTrue from element", d2, te); + ca = ca(uri, "Remove constraint annotation AssertTrue from element", d2, te); assertJavaCodeAction(codeActionParams, utils, ca); @@ -355,7 +355,7 @@ public void methodConstraintValidation() throws Exception { codeActionParams = createCodeActionParams(uri, d3); te = te(0, 0, 34, 1, newText4); te2 = te(0, 0, 34, 1, newText5); - ca = ca(uri, "Remove constraint annotation jakarta.validation.constraints.AssertFalse from element", d3, te); + ca = ca(uri, "Remove constraint annotation AssertFalse from element", d3, te); ca2 = ca(uri, "Remove static modifier from element", d3, te2); assertJavaCodeAction(codeActionParams, utils, ca, ca2); From eacb3a9387075db7c8b204257f55219d69919f2e Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi <141303561+anusreelakshmi934@users.noreply.github.com> Date: Fri, 8 Nov 2024 10:48:15 +0530 Subject: [PATCH 4/6] Update ManagedBeanTest.java --- .../lsp4jakarta/it/cdi/ManagedBeanTest.java | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/test/java/io/openliberty/tools/intellij/lsp4jakarta/it/cdi/ManagedBeanTest.java b/src/test/java/io/openliberty/tools/intellij/lsp4jakarta/it/cdi/ManagedBeanTest.java index 7b4fea4a5..3198f99cf 100644 --- a/src/test/java/io/openliberty/tools/intellij/lsp4jakarta/it/cdi/ManagedBeanTest.java +++ b/src/test/java/io/openliberty/tools/intellij/lsp4jakarta/it/cdi/ManagedBeanTest.java @@ -354,7 +354,7 @@ public void injectAndDisposesObservesObservesAsync() throws Exception { TextEdit te1 = te(0, 0, 55, 0, newText); TextEdit te2 = te(0, 0, 55, 0, newText0); CodeAction ca1 = ca(uri, "Remove @Inject", d1, te1); - CodeAction ca2 = ca(uri, "Remove the '@Disposes' modifier from parameter 'name'", d1, te2); + CodeAction ca2 = ca(uri, "Remove the @Disposes modifier from parameter name", d1, te2); assertJavaCodeAction(codeActionParams1, utils, ca1, ca2); @@ -399,7 +399,7 @@ public void injectAndDisposesObservesObservesAsync() throws Exception { TextEdit te3 = te(0, 0, 55, 0, newText1); TextEdit te4 = te(0, 0, 55, 0, newText2); CodeAction ca3 = ca(uri, "Remove @Inject", d2, te3); - CodeAction ca4 = ca(uri, "Remove the '@Observes' modifier from parameter 'name'", d2, te4); + CodeAction ca4 = ca(uri, "Remove the @Observes modifier from parameter name", d2, te4); assertJavaCodeAction(codeActionParams2, utils, ca3, ca4); @@ -445,7 +445,7 @@ public void injectAndDisposesObservesObservesAsync() throws Exception { TextEdit te5 = te(0, 0, 55, 0, newText19); TextEdit te6 = te(0, 0, 55, 0, newText3); CodeAction ca5 = ca(uri, "Remove @Inject", d3, te5); - CodeAction ca6 = ca(uri, "Remove the '@ObservesAsync' modifier from parameter 'name'", d3, te6); + CodeAction ca6 = ca(uri, "Remove the @ObservesAsync modifier from parameter name", d3, te6); assertJavaCodeAction(codeActionParams3, utils, ca5, ca6); @@ -504,8 +504,8 @@ public void injectAndDisposesObservesObservesAsync() throws Exception { TextEdit te8 = te(0, 0, 55, 0, newText5); TextEdit te9 = te(0, 0, 55, 0, newText6); CodeAction ca7 = ca(uri, "Remove @Inject", d4, te7); - CodeAction ca8 = ca(uri, "Remove the '@Disposes' modifier from parameter 'name1'", d4, te8); - CodeAction ca9 = ca(uri, "Remove the '@Observes' modifier from parameter 'name2'", d4, te9); + CodeAction ca8 = ca(uri, "Remove the @Disposes modifier from parameter name1", d4, te8); + CodeAction ca9 = ca(uri, "Remove the @Observes modifier from parameter name2", d4, te9); assertJavaCodeAction(codeActionParams4, utils, ca7, ca8, ca9); @@ -564,8 +564,8 @@ public void injectAndDisposesObservesObservesAsync() throws Exception { TextEdit te11 = te(0, 0, 55, 0, newText8); TextEdit te12 = te(0, 0, 55, 0, newText9); CodeAction ca10 = ca(uri, "Remove @Inject", d5, te10); - CodeAction ca11 = ca(uri, "Remove the '@Observes' modifier from parameter 'name1'", d5, te11); - CodeAction ca12 = ca(uri, "Remove the '@ObservesAsync' modifier from parameter 'name2'", d5, te12); + CodeAction ca11 = ca(uri, "Remove the @Observes modifier from parameter name1", d5, te11); + CodeAction ca12 = ca(uri, "Remove the @ObservesAsync modifier from parameter name2", d5, te12); assertJavaCodeAction(codeActionParams5, utils, ca10, ca11, ca12); @@ -626,8 +626,8 @@ public void injectAndDisposesObservesObservesAsync() throws Exception { TextEdit te14 = te(0, 0, 55, 0, newText11); TextEdit te15 = te(0, 0, 55, 0, newText12); CodeAction ca13 = ca(uri, "Remove @Inject", d6, te13); - CodeAction ca14 = ca(uri, "Remove the '@Disposes' modifier from parameter 'name1'", d6, te14); - CodeAction ca15 = ca(uri, "Remove the '@ObservesAsync' modifier from parameter 'name2'", d6, te15); + CodeAction ca14 = ca(uri, "Remove the @Disposes modifier from parameter name1", d6, te14); + CodeAction ca15 = ca(uri, "Remove the @ObservesAsync modifier from parameter name2", d6, te15); assertJavaCodeAction(codeActionParams6, utils, ca13, ca14, ca15); @@ -703,9 +703,9 @@ public void injectAndDisposesObservesObservesAsync() throws Exception { TextEdit te18 = te(0, 0, 55, 0, newText15); TextEdit te19 = te(0, 0, 55, 0, newText16); CodeAction ca16 = ca(uri, "Remove @Inject", d7, te16); - CodeAction ca17 = ca(uri, "Remove the '@Disposes' modifier from parameter 'name1'", d7, te17); - CodeAction ca18 = ca(uri, "Remove the '@Observes' modifier from parameter 'name2'", d7, te18); - CodeAction ca19 = ca(uri, "Remove the '@ObservesAsync' modifier from parameter 'name3'", d7, te19); + CodeAction ca17 = ca(uri, "Remove the @Disposes modifier from parameter name1", d7, te17); + CodeAction ca18 = ca(uri, "Remove the @Observes modifier from parameter name2", d7, te18); + CodeAction ca19 = ca(uri, "Remove the @ObservesAsync modifier from parameter name3", d7, te19); assertJavaCodeAction(codeActionParams7, utils, ca16, ca17, ca18, ca19); @@ -748,7 +748,7 @@ public void injectAndDisposesObservesObservesAsync() throws Exception { TextEdit te20 = te(0, 0, 55, 0, newText17); TextEdit te21 = te(0, 0, 55, 0, newText18); CodeAction ca20 = ca(uri, "Remove @Inject", d8, te20); - CodeAction ca21 = ca(uri, "Remove the '@Disposes', '@Observes', '@ObservesAsync' modifier from parameter 'name'", d8, te21); + CodeAction ca21 = ca(uri, "Remove the @Disposes, @Observes, @ObservesAsync modifier from parameter name", d8, te21); assertJavaCodeAction(codeActionParams8, utils, ca20, ca21); } @@ -865,7 +865,7 @@ public void producesAndDisposesObservesObservesAsync() throws Exception { TextEdit te1 = te(0, 0, 58, 0, newText); TextEdit te2 = te(0, 0, 58, 0, newText1); CodeAction ca1 = ca(uri, "Remove @Produces", d1, te1); - CodeAction ca2 = ca(uri, "Remove the '@Disposes' modifier from parameter 'name'", d1, te2); + CodeAction ca2 = ca(uri, "Remove the @Disposes modifier from parameter name", d1, te2); assertJavaCodeAction(codeActionParams1, utils, ca1, ca2); @@ -915,7 +915,7 @@ public void producesAndDisposesObservesObservesAsync() throws Exception { TextEdit te3 = te(0, 0, 58, 0, newText2); TextEdit te4 = te(0, 0, 58, 0, newText3); CodeAction ca3 = ca(uri, "Remove @Produces", d2, te3); - CodeAction ca4 = ca(uri, "Remove the '@Observes' modifier from parameter 'name'", d2, te4); + CodeAction ca4 = ca(uri, "Remove the @Observes modifier from parameter name", d2, te4); assertJavaCodeAction(codeActionParams2, utils, ca3, ca4); @@ -963,7 +963,7 @@ public void producesAndDisposesObservesObservesAsync() throws Exception { TextEdit te5 = te(0, 0, 58, 0, newText4); TextEdit te6 = te(0, 0, 58, 0, newText5); CodeAction ca5 = ca(uri, "Remove @Produces", d3, te5); - CodeAction ca6 = ca(uri, "Remove the '@ObservesAsync' modifier from parameter 'name'", d3, te6); + CodeAction ca6 = ca(uri, "Remove the @ObservesAsync modifier from parameter name", d3, te6); assertJavaCodeAction(codeActionParams3, utils, ca5, ca6); @@ -1026,8 +1026,8 @@ public void producesAndDisposesObservesObservesAsync() throws Exception { TextEdit te8 = te(0, 0, 58, 0, newText7); TextEdit te9 = te(0, 0, 58, 0, newText8); CodeAction ca7 = ca(uri, "Remove @Produces", d4, te7); - CodeAction ca8 = ca(uri, "Remove the '@Disposes' modifier from parameter 'name1'", d4, te8); - CodeAction ca9 = ca(uri, "Remove the '@Observes' modifier from parameter 'name2'", d4, te9); + CodeAction ca8 = ca(uri, "Remove the @Disposes modifier from parameter name1", d4, te8); + CodeAction ca9 = ca(uri, "Remove the @Observes modifier from parameter name2", d4, te9); assertJavaCodeAction(codeActionParams4, utils, ca7, ca8, ca9); @@ -1092,8 +1092,8 @@ public void producesAndDisposesObservesObservesAsync() throws Exception { TextEdit te11 = te(0, 0, 58, 0, newText10); TextEdit te12 = te(0, 0, 58, 0, newText11); CodeAction ca10 = ca(uri, "Remove @Produces", d5, te10); - CodeAction ca11 = ca(uri, "Remove the '@Observes' modifier from parameter 'name1'", d5, te11); - CodeAction ca12 = ca(uri, "Remove the '@ObservesAsync' modifier from parameter 'name2'", d5, te12); + CodeAction ca11 = ca(uri, "Remove the @Observes modifier from parameter name1", d5, te11); + CodeAction ca12 = ca(uri, "Remove the @ObservesAsync modifier from parameter name2", d5, te12); assertJavaCodeAction(codeActionParams5, utils, ca10, ca11, ca12); @@ -1160,8 +1160,8 @@ public void producesAndDisposesObservesObservesAsync() throws Exception { TextEdit te14 = te(0, 0, 58, 0, newText13); TextEdit te15 = te(0, 0, 58, 0, newText14); CodeAction ca13 = ca(uri, "Remove @Produces", d6, te13); - CodeAction ca14 = ca(uri, "Remove the '@Disposes' modifier from parameter 'name1'", d6, te14); - CodeAction ca15 = ca(uri, "Remove the '@ObservesAsync' modifier from parameter 'name2'", d6, te15); + CodeAction ca14 = ca(uri, "Remove the @Disposes modifier from parameter name1", d6, te14); + CodeAction ca15 = ca(uri, "Remove the @ObservesAsync modifier from parameter name2", d6, te15); assertJavaCodeAction(codeActionParams6, utils, ca13, ca14, ca15); @@ -1246,9 +1246,9 @@ public void producesAndDisposesObservesObservesAsync() throws Exception { TextEdit te18 = te(0, 0, 58, 0, newText17); TextEdit te19 = te(0, 0, 58, 0, newText18); CodeAction ca16 = ca(uri, "Remove @Produces", d7, te16); - CodeAction ca17 = ca(uri, "Remove the '@Disposes' modifier from parameter 'name1'", d7, te17); - CodeAction ca18 = ca(uri, "Remove the '@Observes' modifier from parameter 'name2'", d7, te18); - CodeAction ca19 = ca(uri, "Remove the '@ObservesAsync' modifier from parameter 'name3'", d7, te19); + CodeAction ca17 = ca(uri, "Remove the @Disposes modifier from parameter name1", d7, te17); + CodeAction ca18 = ca(uri, "Remove the @Observes modifier from parameter name2", d7, te18); + CodeAction ca19 = ca(uri, "Remove the @ObservesAsync modifier from parameter name3", d7, te19); assertJavaCodeAction(codeActionParams7, utils, ca16, ca17, ca18, ca19); @@ -1296,7 +1296,7 @@ public void producesAndDisposesObservesObservesAsync() throws Exception { TextEdit te20 = te(0, 0, 58, 0, newText19); TextEdit te21 = te(0, 0, 58, 0, newText20); CodeAction ca20 = ca(uri, "Remove @Produces", d8, te20); - CodeAction ca21 = ca(uri, "Remove the '@Disposes', '@Observes', '@ObservesAsync' modifier from parameter 'name'", d8, te21); + CodeAction ca21 = ca(uri, "Remove the @Disposes, @Observes, @ObservesAsync modifier from parameter name", d8, te21); assertJavaCodeAction(codeActionParams8, utils, ca20, ca21); } From 99131c3bd07a69b1cf11513f03b5d2dc00b031c1 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi <141303561+anusreelakshmi934@users.noreply.github.com> Date: Fri, 8 Nov 2024 16:29:59 +0530 Subject: [PATCH 5/6] Changed into getSimpleName method --- .../beanvalidation/BeanValidationQuickFix.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/beanvalidation/BeanValidationQuickFix.java b/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/beanvalidation/BeanValidationQuickFix.java index b3c3344cb..3e980bfe5 100644 --- a/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/beanvalidation/BeanValidationQuickFix.java +++ b/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/beanvalidation/BeanValidationQuickFix.java @@ -81,7 +81,7 @@ public CodeAction resolveCodeAction(JavaCodeActionResolveContext context) { private void removeConstraintAnnotationsCodeActions(Diagnostic diagnostic, JavaCodeActionContext context, List codeActions) { final String annotationName = diagnostic.getData().toString().replace("\"", ""); - final String name = Messages.getMessage("RemoveConstraintAnnotation", annotationName.substring(annotationName.lastIndexOf('.') + 1)); + final String name = Messages.getMessage("RemoveConstraintAnnotation", getSimpleName(annotationName)); Map extendedData = new HashMap<>(); extendedData.put(ANNOTATION_NAME, annotationName); codeActions.add(JDTUtils.createCodeAction(context, diagnostic, name, getParticipantId(), extendedData)); @@ -150,6 +150,17 @@ private void removeStaticModifierCodeActions(Diagnostic diagnostic, JavaCodeActi final String name = Messages.getMessage("RemoveStaticModifier"); codeActions.add(JDTUtils.createCodeAction(context, diagnostic, name, getParticipantId())); } + + /** + * Returns simple name for the given fully qualified name. + */ + protected static String getSimpleName(String fqName) { + int idx = fqName.lastIndexOf('.'); + if (idx != -1 && idx != fqName.length() - 1) { + return fqName.substring(idx + 1); + } + return fqName; + } } From 00520e6b68ab58e97d366eeec8b02522c4f25ae9 Mon Sep 17 00:00:00 2001 From: Anusree Lakshmi <141303561+anusreelakshmi934@users.noreply.github.com> Date: Mon, 11 Nov 2024 15:46:07 +0530 Subject: [PATCH 6/6] use getSimpleName from AbstractDiagnosticsCollector --- .../lsp4ij/AbstractDiagnosticsCollector.java | 2 +- .../beanvalidation/BeanValidationQuickFix.java | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/AbstractDiagnosticsCollector.java b/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/AbstractDiagnosticsCollector.java index 638278b24..7340755bb 100644 --- a/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/AbstractDiagnosticsCollector.java +++ b/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/AbstractDiagnosticsCollector.java @@ -307,7 +307,7 @@ protected static boolean nameEndsWith(String fqName, String name) { * @param fqName a fully qualified name or simple name * @return simple name for given fully qualified name */ - protected static String getSimpleName(String fqName) { + public static String getSimpleName(String fqName) { int idx = fqName.lastIndexOf('.'); if (idx != -1 && idx != fqName.length() - 1) { return fqName.substring(idx + 1); diff --git a/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/beanvalidation/BeanValidationQuickFix.java b/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/beanvalidation/BeanValidationQuickFix.java index 3e980bfe5..6cbd49f74 100644 --- a/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/beanvalidation/BeanValidationQuickFix.java +++ b/src/main/java/io/openliberty/tools/intellij/lsp4jakarta/lsp4ij/beanvalidation/BeanValidationQuickFix.java @@ -16,6 +16,7 @@ import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.psi.*; import com.intellij.psi.util.PsiTreeUtil; +import io.openliberty.tools.intellij.lsp4jakarta.lsp4ij.AbstractDiagnosticsCollector; import io.openliberty.tools.intellij.lsp4jakarta.lsp4ij.JDTUtils; import io.openliberty.tools.intellij.lsp4jakarta.lsp4ij.Messages; import io.openliberty.tools.intellij.lsp4jakarta.lsp4ij.codeAction.proposal.ModifyModifiersProposal; @@ -81,7 +82,7 @@ public CodeAction resolveCodeAction(JavaCodeActionResolveContext context) { private void removeConstraintAnnotationsCodeActions(Diagnostic diagnostic, JavaCodeActionContext context, List codeActions) { final String annotationName = diagnostic.getData().toString().replace("\"", ""); - final String name = Messages.getMessage("RemoveConstraintAnnotation", getSimpleName(annotationName)); + final String name = Messages.getMessage("RemoveConstraintAnnotation", AbstractDiagnosticsCollector.getSimpleName(annotationName)); Map extendedData = new HashMap<>(); extendedData.put(ANNOTATION_NAME, annotationName); codeActions.add(JDTUtils.createCodeAction(context, diagnostic, name, getParticipantId(), extendedData)); @@ -151,16 +152,6 @@ private void removeStaticModifierCodeActions(Diagnostic diagnostic, JavaCodeActi codeActions.add(JDTUtils.createCodeAction(context, diagnostic, name, getParticipantId())); } - /** - * Returns simple name for the given fully qualified name. - */ - protected static String getSimpleName(String fqName) { - int idx = fqName.lastIndexOf('.'); - if (idx != -1 && idx != fqName.length() - 1) { - return fqName.substring(idx + 1); - } - return fqName; - } }