def set_completions(self, completions, go_to_first=True, go_to_last=False):
        """
        Start completions. (Generate list of completions and initialize.)
        """
        assert not (go_to_first and go_to_last)

        # Generate list of all completions.
        if completions is None:
            if self.completer:
                completions = list(self.completer.get_completions(
                    self.document,
                    CompleteEvent(completion_requested=True)
                ))
            else:
                completions = []

        # Set `complete_state`.
        if completions:
            self.complete_state = CompletionState(
                original_document=self.document,
                current_completions=completions)
            if go_to_first:
                self.go_to_completion(0)
            elif go_to_last:
                self.go_to_completion(len(completions) - 1)
            else:
                self.go_to_completion(None)

        else:
            self.complete_state = None
Start completions. (Generate list of completions and initialize.)