MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeText-parser / match_from_span

Function match_from_span

src/codetext/parser/language_parser.py:159–169  ·  view source on GitHub ↗
(node, blob: str)

Source from the content-addressed store, hash-verified

157
158
159def match_from_span(node, blob: str) -> str:
160 # logger.warn('From version 0.0.6, we move `match_from_span` to `get_node_text`')
161 lines = blob.split('\n')
162 line_start = node.start_point[0]
163 line_end = node.end_point[0]
164 char_start = node.start_point[1]
165 char_end = node.end_point[1]
166 if line_start != line_end:
167 return '\n'.join([lines[line_start][char_start:]] + lines[line_start+1:line_end] + [lines[line_end][:char_end]])
168 else:
169 return lines[line_start][char_start:char_end]
170
171
172def match_from_spans(nodes, blob: str) -> str:

Callers 1

tokenize_codeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected