'generates command and parameter completions'

def gen_cmd_and_param_completions(self, text):

    temp_command = str(u'')
    txtspt = text.split()
    for word in txtspt:
        if word.startswith(u'-'):
            self._is_command = False
        elif self._is_command:
            temp_command += ((u'    ' + str(word)) if temp_command else str(word))
        mid_val = (text.find(word) + len(word))
        if (self.branch.has_child(word) and (len(text) > mid_val) and text[mid_val].isspace()):
            self.branch = self.branch.get_child(word, self.branch.children)
    if ((len(text) > 0) and text[(-1)].isspace()):
        if in_tree(self.command_tree, temp_command):
            self.curr_command = temp_command
        else:
            self._is_command = False
    else:
        self.curr_command = temp_command
    last_word = txtspt[(-1)]
    if (last_word.startswith(u'-') and (not last_word.startswith(u'--'))):
        self._is_command = False
        if (self.curr_command in self.command_parameters):
            for param in self.command_parameters[self.curr_command]:
                if (self.validate_completion(param, last_word, text) and (not param.startswith(u'--'))):
                    (yield self.yield_param_completion(param, last_word))
    elif last_word.startswith(u'--'):
        self._is_command = False
        if (self.curr_command in self.command_parameters):
            for param in self.command_parameters[self.curr_command]:
                if self.validate_completion(param, last_word, text):
                    (yield self.yield_param_completion(param, last_word))
    if (self.branch.children and self._is_command):
        for kid in self.branch.children:
            if self.validate_completion(kid.data, txtspt[(-1)], text, False):
                (yield Completion(str(kid.data), (- len(txtspt[(-1)]))))
    elif (self._is_command and (self.curr_command.strip() in self.command_parameters)):
        for param in self.command_parameters[self.curr_command.strip()]:
            if param.startswith(u'--'):
                (yield self.yield_param_completion(param, u''))
