@Test void testCollectCommandsOrActionsPositive() { CodeActionProvider provider = new FindCopybookCommand(); List<Diagnostic> diagnostics = singletonList(COPYBOOK_ERROR); CodeActionParams params = new CodeActionParams( new TextDocumentIdentifier(DOCUMENT_URI), RANGE, new CodeActionContext(diagnostics)); List<Either<Command, CodeAction>> actions = provider.collectCommandsOrActions(params); assertEquals(1, actions.size()); CodeAction action = actions.get(0).getRight(); assertCorrectCodeAction(action); }
@Nonnull @Override public List<Either<Command, CodeAction>> collectCommandsOrActions( @Nonnull CodeActionParams params) { return params.getContext().getDiagnostics().stream() .filter(it -> it.getCode() != null) .filter(it -> MISSING_COPYBOOK.equals(valueOf(it.getCode()))) .map(toCodeAction(params)) .map(Either::<Command, CodeAction>forRight) .collect(toList()); }
FindCopybookCommand implements CodeActionProvider { @Nonnull @Override public List<Either<Command, CodeAction>> collectCommandsOrActions( @Nonnull CodeActionParams params) { return params.getContext().getDiagnostics().stream() .filter(it -> it.getCode() != null) .filter(it -> MISSING_COPYBOOK.equals(valueOf(it.getCode()))) .map(toCodeAction(params)) .map(Either::<Command, CodeAction>forRight) .collect(toList()); } }
FindCopybookCommand implements CodeActionProvider { @Nonnull @Override public List<Either<Command, CodeAction>> collectCommandsOrActions( @Nonnull CodeActionParams params) { return params.getContext().getDiagnostics().stream() .filter(it -> it.getCode() != null) .filter(it -> MISSING_COPYBOOK.equals(valueOf(it.getCode()))) .map(toCodeAction(params)) .map(Either::<Command, CodeAction>forRight) .collect(toList()); }  }
FindCopybookCommand implements CodeActionProvider { @Nonnull @Override public List<Either<Command, CodeAction>> collectCommandsOrActions( @Nonnull CodeActionParams params) { return params.getContext().getDiagnostics().stream() .filter(it -> it.getCode() != null) .filter(it -> MISSING_COPYBOOK.equals(valueOf(it.getCode()))) .map(toCodeAction(params)) .map(Either::<Command, CodeAction>forRight) .collect(toList()); }  @Nonnull @Override List<Either<Command, CodeAction>> collectCommandsOrActions(
      @Nonnull CodeActionParams params); }
FindCopybookCommand implements CodeActionProvider { @Nonnull @Override public List<Either<Command, CodeAction>> collectCommandsOrActions( @Nonnull CodeActionParams params) { return params.getContext().getDiagnostics().stream() .filter(it -> it.getCode() != null) .filter(it -> MISSING_COPYBOOK.equals(valueOf(it.getCode()))) .map(toCodeAction(params)) .map(Either::<Command, CodeAction>forRight) .collect(toList()); }  @Nonnull @Override List<Either<Command, CodeAction>> collectCommandsOrActions(
      @Nonnull CodeActionParams params);  }