def get_context(filename: str, source: str, line: int, context_size: int = 5) -> str:ext = filename.split('.')[-1]lang_map = {'go': tsgo.language(),'js': tsjavascript.language(),'php': tsphp.language.php(),'py': tspython.language(),'ts': tstypescript.language_typescript(),'yaml': tsyaml.language(),}if ext not in lang_map:return get_region(source, line, context_size)lang = Language(lang_map[ext])parser = Parser(lang)tree = parser.parse(source.encode('utf8'))query = lang.query('(_) @node')matches = [m['node'][0]for _, m in query.matches(tree.root_node)if m['node'][0].start_point[0] == line]if not matches:return get_region(source, line, context_size)# Find the parent class, method, function, variable declaration or export statementparent = matches[0].parentwhile (parent is not Noneand parent.type not in [tree.root_node.type,'class_declaration','method_declaration','function_declaration','var_declaration','export_statement',]):parent = parent.parentif parent is not None and parent.text is not None:context = parent.text.decode('utf8')if len(context) > 100 and len(context.split('\n')) < context_size * 2:return contextreturn get_region(source, line, context_size)