From eed5a4b812055ce8c0afae58b8411dd4f507abc2 Mon Sep 17 00:00:00 2001 From: Benson Ning Date: Mon, 30 Mar 2020 12:09:39 -0400 Subject: [PATCH] Hide openapi code action if it is not applicable Fixes #280 signed-off-by: bensonn@ca.ibm.com --- .../openapi/java/MicroProfileGenerateOpenAPIOperation.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.core/src/main/java/com/redhat/microprofile/jdt/internal/openapi/java/MicroProfileGenerateOpenAPIOperation.java b/microprofile.jdt/com.redhat.microprofile.jdt.core/src/main/java/com/redhat/microprofile/jdt/internal/openapi/java/MicroProfileGenerateOpenAPIOperation.java index 745c431cc..840246074 100644 --- a/microprofile.jdt/com.redhat.microprofile.jdt.core/src/main/java/com/redhat/microprofile/jdt/internal/openapi/java/MicroProfileGenerateOpenAPIOperation.java +++ b/microprofile.jdt/com.redhat.microprofile.jdt.core/src/main/java/com/redhat/microprofile/jdt/internal/openapi/java/MicroProfileGenerateOpenAPIOperation.java @@ -56,11 +56,9 @@ public List getCodeActions(JavaCodeActionContext context, (TypeDeclaration) type, MicroProfileOpenAPIConstants.OPERATION_ANNOTATION, 0); // Convert the proposal to LSP4J CodeAction CodeAction codeAction = context.convertToCodeAction(proposal); - if (codeAction == null) { // Always show the code action - codeAction = new CodeAction(proposal.getName()); - codeAction.setKind(proposal.getKind()); + if (codeAction != null) { + codeActions.add(codeAction); } - codeActions.add(codeAction); } } return codeActions;