• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python codeassist.starting_offset函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中rope.contrib.codeassist.starting_offset函数的典型用法代码示例。如果您正苦于以下问题:Python starting_offset函数的具体用法?Python starting_offset怎么用?Python starting_offset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了starting_offset函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: complete

def complete(dot=False):
    """ Ctrl+Space completion.

    :return bool: success

    """
    row, col = env.cursor
    source, offset = env.get_offset_params()

    cline = env.current.line[:col]
    env.debug('dot completion', cline)
    if FROM_RE.match(cline) or cline.endswith('..') or cline.endswith('\.'):
        return env.stop("")

    proposals = get_proporsals(source, offset, dot=dot)
    if not proposals:
        return False

    prefix = proposals[0]['word']

    # Find common part
    for p in proposals:
        common = len([
            c1 for c1, c2 in zip(prefix, p['word']) if c1 == c2 and c1 != ' '
        ])
        prefix = prefix[:common]
    s_offset = codeassist.starting_offset(source, offset)
    p_prefix = prefix[offset - s_offset:]
    line = env.lines[row - 1]
    cline = line[:col] + p_prefix + line[col:]
    if cline != line:
        env.curbuf[row - 1] = env.prepare_value(cline, dumps=False)
    env.current.window.cursor = (row, col + len(p_prefix))
    env.run('complete', col - len(prefix) + len(p_prefix) + 1, proposals)
    return True
开发者ID:anto-daniel,项目名称:python-vim,代码行数:35,代码来源:rope.py


示例2: complete

def complete(dot=False):
    """ Ctrl+Space completion.

    :return bool: success

    """
    row, col = env.cursor
    source, offset = env.get_offset_params()
    proposals = get_proporsals(source, offset, dot=dot)
    if not proposals:
        return False

    prefix = proposals[0]['word']

    # Find common part
    for p in proposals:
        common = len([
            c1 for c1, c2 in zip(prefix, p['word']) if c1 == c2 and c1 != ' '
        ])
        prefix = prefix[:common]
    s_offset = codeassist.starting_offset(source, offset)
    p_prefix = prefix[offset - s_offset:]
    line = env.lines[row - 1]
    env.curbuf[row - 1] = line[:col] + p_prefix + line[col:] # noqa
    env.current.window.cursor = (row, col + len(p_prefix))
    env.run('complete', col - len(prefix) + len(p_prefix) + 1, proposals)
    return True
开发者ID:PINKONG,项目名称:python-mode,代码行数:27,代码来源:rope.py


示例3: complete

def complete(dot=False):
    """ Ctrl+Space completion.

    :return bool: success

    """
    row, column = vim.current.window.cursor
    source, offset = get_assist_params((row, column))
    proposals = get_proporsals(source, offset, dot=dot)
    if not proposals:
        return False

    prefix = proposals[0]['word']

    # Find common part
    for p in proposals:
        common = len([
            c1 for c1, c2 in zip(prefix, p['word']) if c1 == c2 and c1 != ' '
        ])
        prefix = prefix[:common]
    s_offset = codeassist.starting_offset(source, offset)
    p_prefix = prefix[offset - s_offset:]
    line = vim.current.buffer[row - 1]
    vim.current.buffer[row - 1] = line[:column] + p_prefix + line[column:] # noqa
    vim.current.window.cursor = (row, column + len(p_prefix))
    vim.command('call complete(%s, %s)' % (
        column - len(prefix) + len(p_prefix) + 1, json.dumps(proposals)))

    return True
开发者ID:egunnar,项目名称:vim-setup,代码行数:29,代码来源:rope.py


示例4: on_select

        def on_select(proposal):
            self.gui.hide()

            edit = self.editor.textbuffer
            start_offset = codeassist.starting_offset(source, offset)

            start = edit.get_iter_at_offset(start_offset)
            end = self.editor.cursor

            edit.delete(start, end)
            edit.insert(start, proposal)
开发者ID:baverman,项目名称:scribes-goodies,代码行数:11,代码来源:__init__.py


示例5: CompletionRequest

  def CompletionRequest(self, request, response):
    """
    Finds completion proposals for the given location in the given source file.
    """

    # Get information out of the request
    project, resource, source, offset = self._Context(request.context)

    # If the cursor is immediately after a comma or open paren, we should look
    # for a calltip first.
    word_finder = worder.Worder(source)
    non_space_offset = word_finder.code_finder._find_last_non_space_char(offset)

    if word_finder.code_finder.code[non_space_offset] in "(,":
      paren_start = word_finder.find_parens_start_from_inside(offset)

      # Get a calltip now
      calltip = codeassist.get_calltip(project, source, paren_start-1,
                                       maxfixes=self.MAXFIXES,
                                       resource=resource,
                                       remove_self=True)
      
      if calltip is not None:
        response.insertion_position = paren_start + 1
        response.calltip = calltip
        return
    
    # Do normal completion if a calltip couldn't be found
    proposals = codeassist.code_assist(project, source, offset,
                                       maxfixes=self.MAXFIXES,
                                       resource=resource)
    proposals = codeassist.sorted_proposals(proposals)

    # Get the position that this completion will start from.
    starting_offset = codeassist.starting_offset(source, offset)
    response.insertion_position = starting_offset
    
    # Construct the response protobuf
    for proposal in proposals:
      proposal_pb = response.proposal.add()
      proposal_pb.name = proposal.name

      docstring = proposal.get_doc()

      if proposal.type in self.PROPOSAL_TYPES:
        proposal_pb.type = self.PROPOSAL_TYPES[proposal.type]

      if proposal.scope in self.PROPOSAL_SCOPES:
        proposal_pb.scope = self.PROPOSAL_SCOPES[proposal.scope]

      if docstring is not None:
        proposal_pb.docstring = docstring
开发者ID:davidsansome,项目名称:pyqtc,代码行数:52,代码来源:__main__.py


示例6: starting_offset

 def starting_offset(self):
     return codeassist.starting_offset(self.source, self.offset)
开发者ID:armike,项目名称:emacs,代码行数:2,代码来源:interface.py


示例7: test_completion_result

 def test_completion_result(self):
     code = 'my_global = 10\nt = my'
     self.assertEquals(len(code) - 2, starting_offset(code, len(code)))
开发者ID:FredSanders,项目名称:emacs.d,代码行数:3,代码来源:codeassisttest.py


示例8: test_result_start_offset_for_dotted_completions

 def test_result_start_offset_for_dotted_completions(self):
     code = 'class Sample(object):\n    def method1(self):\n        pass\n' \
            'Sample.me'
     self.assertEquals(len(code) - 2, starting_offset(code, len(code)))
开发者ID:FredSanders,项目名称:emacs.d,代码行数:4,代码来源:codeassisttest.py


示例9: starting_offset

 def starting_offset(self):
     if self._starting_offset is None:
         self._starting_offset = codeassist.starting_offset(self.source,
                                                            self.offset)
     return self._starting_offset
开发者ID:novakps,项目名称:emacs-starter-kit,代码行数:5,代码来源:interface.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python move.create_move函数代码示例发布时间:2022-05-27
下一篇:
Python compat.get_concrete_model函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap