Skip to content

Commit

Permalink
WIP fix some tests
Browse files Browse the repository at this point in the history
Signed-off-by: David Thompson <davthomp@redhat.com>
  • Loading branch information
datho7561 committed Oct 13, 2022
1 parent ef551b8 commit e9a9243
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 8 deletions.
4 changes: 4 additions & 0 deletions microprofile.jdt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/org.eclipse.lsp4mp.jdt.core/
/org.eclipse.lsp4mp.jdt.site/
/org.eclipse.lsp4mp.jdt.test/
/org.eclipse.lsp4mp.jdt.tp/
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public List<? extends CodeAction> getCodeActions(JavaCodeActionContext context,
codeAction.setKind(CodeActionKind.QuickFix);
codeAction.setDiagnostics(Arrays.asList(diagnostic));
codeAction.setData(new CodeActionResolveData(context.getUri(), getParticipantId(), null,
context.getParams().isResolveSupported(), context.getParams().isCommandConfigurationUpdateSupported()));
context.getParams().isResourceOperationSupported(), context.getParams().isCommandConfigurationUpdateSupported()));
return Collections.singletonList(codeAction);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected void insertAnnotation(Diagnostic diagnostic, JavaCodeActionContext con
Map<String, Object> extendedData = new HashMap<>();
extendedData.put(ANNOTATION_KEY, annotations);
codeAction.setData(new CodeActionResolveData(context.getUri(), getParticipantId(), extendedData,
context.getParams().isResolveSupported(), context.getParams().isCommandConfigurationUpdateSupported()));
context.getParams().isResourceOperationSupported(), context.getParams().isCommandConfigurationUpdateSupported()));

codeActions.add(codeAction);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.internal.corext.dom.Bindings;
import org.eclipse.lsp4j.CodeAction;
import org.eclipse.lsp4j.CodeActionKind;
Expand Down Expand Up @@ -56,12 +58,12 @@ public String getParticipantId() {
@Override
public List<? extends CodeAction> getCodeActions(JavaCodeActionContext context, Diagnostic diagnostic,
IProgressMonitor monitor) throws CoreException {

ExtendedCodeAction codeAction = new ExtendedCodeAction("Let " + context.getASTRoot().getTypeRoot().getElementName() + " implement @" + MicroProfileHealthConstants.HEALTH_CHECK_INTERFACE_NAME);
IBinding binding = getBinding(context.getCoveringNode());
ExtendedCodeAction codeAction = new ExtendedCodeAction("Let '" + binding.getName() + "' implement '@" + MicroProfileHealthConstants.HEALTH_CHECK_INTERFACE_NAME + "'");
codeAction.setRelevance(0);
codeAction.setDiagnostics(Collections.singletonList(diagnostic));
codeAction.setKind(CodeActionKind.QuickFix);
codeAction.setData(new CodeActionResolveData(context.getUri(), getParticipantId(), null, context.getParams().isResolveSupported(), context.getParams().isCommandConfigurationUpdateSupported()));
codeAction.setData(new CodeActionResolveData(context.getUri(), getParticipantId(), null, context.getParams().isResourceOperationSupported(), context.getParams().isCommandConfigurationUpdateSupported()));

return Collections.singletonList(codeAction);
}
Expand Down Expand Up @@ -90,5 +92,12 @@ public CodeAction resolveCodeAction(JavaCodeActionResolveContext context) {

return context.getUnresolved();
}

private static IBinding getBinding(ASTNode node) {
if (node.getParent() instanceof VariableDeclarationFragment) {
return ((VariableDeclarationFragment) node.getParent()).resolveBinding();
}
return Bindings.getBindingOfParentType(node);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public List<? extends CodeAction> getCodeActions(JavaCodeActionContext context,
codeAction.setDiagnostics(Collections.singletonList(diagnostic));
codeAction.setKind(CodeActionKind.QuickFix);
codeAction.setData(new CodeActionResolveData(context.getUri(), getParticipantId(), null,
context.getParams().isResolveSupported(), context.getParams().isCommandConfigurationUpdateSupported()));
context.getParams().isResourceOperationSupported(), context.getParams().isCommandConfigurationUpdateSupported()));

return Collections.singletonList(codeAction);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.eclipse.lsp4mp.commons.MicroProfileJavaDefinitionParams;
import org.eclipse.lsp4mp.commons.MicroProfileJavaDiagnosticsParams;
import org.eclipse.lsp4mp.commons.MicroProfileJavaHoverParams;
import org.eclipse.lsp4mp.jdt.core.PropertiesManagerForJava;
import org.eclipse.lsp4mp.jdt.core.java.diagnostics.IJavaErrorCode;
import org.eclipse.lsp4mp.jdt.core.utils.IJDTUtils;
import org.junit.Assert;
Expand All @@ -73,6 +72,8 @@ public static MicroProfileJavaCodeActionParams createCodeActionParams(String uri
MicroProfileJavaCodeActionParams codeActionParams = new MicroProfileJavaCodeActionParams(textDocument, range,
context);
codeActionParams.setResourceOperationSupported(true);
codeActionParams.setCommandConfigurationUpdateSupported(true);
codeActionParams.setResolveSupported(false);
return codeActionParams;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ public void ImplementHealthCheck() throws Exception {

String uri = javaFile.getLocation().toFile().toURI().toString();
MicroProfileJavaCodeActionParams codeActionParams = createCodeActionParams(uri, d);
codeActionParams.setResourceOperationSupported(true);
codeActionParams.setCommandConfigurationUpdateSupported(true);
assertJavaCodeAction(codeActionParams, utils, //
ca(uri, "Let 'DontImplementHealthCheck' implement 'org.eclipse.microprofile.health.HealthCheck'", d, //
ca(uri, "Let 'DontImplementHealthCheck' implement '@HealthCheck'", d, //
te(2, 50, 9, 37, "\r\n\r\n" + //
"import org.eclipse.microprofile.health.HealthCheck;\r\n" + //
"import org.eclipse.microprofile.health.HealthCheckResponse;\r\n" + //
Expand Down

0 comments on commit e9a9243

Please sign in to comment.