Files
Pierre-Marie de Rodat 4382a22f9c Reorganize the source tree
Move most of "ada/*" to the root directory (this makes sense, as this
repository has been dedicated to Libadalang for years), and rename
"ada/language" to "ada".

TN: T914-010
2020-11-02 16:51:46 +01:00

16 lines
589 B
Python

def src_slice(src_lines, sloc_range):
"""
Given "src_lines", a list of strings representing a source file, return a
string slice that represents the area that "sloc_range" covers.
"""
result = []
for line in range(sloc_range.start.line,
sloc_range.end.line + 1):
low = (sloc_range.start.column - 1
if line == sloc_range.start.line else 0)
high = (sloc_range.end.column - 1
if line == sloc_range.end.line else -1)
result.append(src_lines[line - 1][low:high])
return '\n'.join(result)