当前位置: 首页>>代码示例>>Python>>正文


Python TextRange.expand方法代码示例

本文整理汇总了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)
开发者ID:RohanVB,项目名称:coala,代码行数:19,代码来源:SourceRange.py

示例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)
开发者ID:nishant-mor,项目名称:coala,代码行数:8,代码来源:TextRangeTest.py

示例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)
开发者ID:nishant-mor,项目名称:coala,代码行数:8,代码来源:TextRangeTest.py


注:本文中的coalib.results.TextRange.TextRange.expand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。