本文整理汇总了Python中coalib.results.TextRange.TextRange.expand方法的典型用法代码示例。如果您正苦于以下问题:Python TextRange.expand方法的具体用法?Python TextRange.expand怎么用?Python TextRange.expand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类coalib.results.TextRange.TextRange
的用法示例。
在下文中一共展示了TextRange.expand方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: expand
# 需要导入模块: from coalib.results.TextRange import TextRange [as 别名]
# 或者: from coalib.results.TextRange.TextRange import expand [as 别名]
def expand(self, file_contents):
"""
Passes a new SourceRange that covers the same area of a file as this
one would. All values of None get replaced with absolute values.
values of None will be interpreted as follows:
self.start.line is None: -> 1
self.start.column is None: -> 1
self.end.line is None: -> last line of file
self.end.column is None: -> last column of self.end.line
:param file_contents: File contents of the applicable file
:return: TextRange with absolute values
"""
tr = TextRange.expand(self, file_contents)
return SourceRange.from_values(self.file, tr.start.line, tr.start.column, tr.end.line, tr.end.column)
示例2: test_expand_none
# 需要导入模块: from coalib.results.TextRange import TextRange [as 别名]
# 或者: from coalib.results.TextRange.TextRange import expand [as 别名]
def test_expand_none(self):
start_position = TextPosition(2, 2)
end_position = TextPosition(3, 2)
file = ["abc\n", "def\n", "ghi\n"]
text_range = TextRange(start_position, end_position)
self.assertEqual(text_range.expand(file), text_range)
示例3: test_expand_full
# 需要导入模块: from coalib.results.TextRange import TextRange [as 别名]
# 或者: from coalib.results.TextRange.TextRange import expand [as 别名]
def test_expand_full(self):
empty_position = TextPosition()
file = ["abc\n", "def\n", "ghi\n"]
empty_range = TextRange(empty_position, empty_position)
full_range = TextRange.from_values(1, 1, 3, 4)
self.assertEqual(empty_range.expand(file), full_range)