def _collect_completions_from_ast(ast, completion_context, collector): from robotframework_ls.impl import ast_utils ast = completion_context.get_ast() for variable_node_info in ast_utils.iter_variables(ast): if collector.accepts(variable_node_info.node.name): variable_node = variable_node_info.node variable_found = _VariableFound(variable_node.name, variable_node.value) collector.on_variable(variable_found)
def _collect_completions_from_ast(ast, completion_context, collector): from robotframework_ls.impl import ast_utils from robot.api import Token ast = completion_context.get_ast() for variable_node_info in ast_utils.iter_variables(ast): variable_node = variable_node_info.node token = variable_node.get_token(Token.VARIABLE) if token is None: continue name = token.value if name.endswith("="): name = name[:-1].rstrip() if collector.accepts(name): variable_found = _VariableFoundFromToken( completion_context, token, variable_node.value, variable_name=name ) collector.on_variable(variable_found)
def get_all_variables(self): from robotframework_ls.impl import ast_utils ast = self.get_ast() return tuple(ast_utils.iter_variables(ast))