public List<CodeAction> getCodeActions(TextDocumentInfo doc, Diagnostic problem) throws Exception { CodeActionContext context = new CodeActionContext(ImmutableList.of(problem)); List<Either<Command, org.eclipse.lsp4j.CodeAction>> actions = getServer().getTextDocumentService().codeAction(new CodeActionParams(doc.getId(), problem.getRange(), context)).get(); return actions.stream() .map(e -> e.getLeft()) .map((command) -> new CodeAction(this, command)) .collect(Collectors.toList()); }
CodeActionContext clone(CodeActionContext codeActionContext) { if (codeActionContext == null) { return null; } List<Diagnostic> diagnostics = codeActionContext.getDiagnostics(); List<String> only = codeActionContext.getOnly(); CodeActionContext cloned = new CodeActionContext(); cloned.setDiagnostics(cloneD(diagnostics)); cloned.setOnly(only == null ? null : new ArrayList<>(only)); return cloned; }