예제 #1
0
    def process_args(self, stack):
        """
        Looks for the mutation name token in the stack and filter seen arguments.
        """
        dot_op = self._toks(stack, before="mut_arguments")
        toks = [t.value for t in Stack.flatten(dot_op)]
        mut_name = toks.pop()
        # remove '.' from mut_name (.<mut_name>)
        expr = "".join(toks[:-1])

        # second or further arguments -> filter used arguments
        prev_args = Stack.find_all_until(stack,
                                         "mut_arguments", ["dot_expr"],
                                         start=1,
                                         offset=3)
        # '(' (<name> ':' <expr>)*
        prev_args = [*prev_args]

        args = self.args(expr, mut_name, prev_args)

        seen = {}
        for arg in args:
            arg_name = arg.name.lower()
            if arg_name in seen:
                continue
            seen[arg_name] = True
            # ignore previously used args
            if arg_name not in prev_args:
                yield arg
예제 #2
0
 def process_name(self, stack):
     """
     Extract previous token for mutation completion.
     """
     dot_op = self._toks(stack)
     toks = [t.value for t in Stack.flatten(dot_op)]
     # always remove the final dot
     assert toks[-1] == "."
     expr = "".join(toks[:-1])
     yield from self.dot.complete(expr)