def get_ast_current_section(self) -> Any: """ :rtype: robot.parsing.model.blocks.Section|NoneType """ from robotframework_ls.impl import ast_utils ast = self.get_ast() section = ast_utils.find_section(ast, self.sel.line) return section
def test_find_token(workspace): """ :param WorkspaceFixture workspace: """ from robotframework_ls.impl import ast_utils workspace.set_root("case1") doc = workspace.get_doc("case1.robot") section = ast_utils.find_section(doc.get_ast(), 3) assert section.header.name == "Test Cases" token_info = ast_utils.find_token(section, 4, 1) assert token_info.token.type == token_info.token.TESTCASE_NAME assert token_info.token.value == "User can call library" token_info = ast_utils.find_token(section, 5, 7) assert token_info.token.type == token_info.token.KEYWORD assert token_info.token.value == "verify model" token_info = ast_utils.find_token(section, 50, 70) assert token_info is None