예제 #1
0
파일: vim.py 프로젝트: damiendoligez/spdiff
 def vim_complete(self, server, temp_buffer_filename, offset):
     buffer = open(temp_buffer_filename).read()
     offset = int(offset) - 1
     from rope.ide.codeassist import PythonCodeAssist
     from rope.base.project import Project
     p = Project(self.svc.boss.cmd('buffer', 'get_current').directory)
     c = PythonCodeAssist(p)
     co = c.assist(buffer, offset).completions
     print co
     for comp in co:
         self.svc._com.add_completion(server, comp.name)
     # do this a few times
     #self.svc._com.add_completion(server, 'banana')
     pass
예제 #2
0
파일: vim.py 프로젝트: 9060/spdiff
 def vim_complete(self, server, temp_buffer_filename, offset):
     buffer = open(temp_buffer_filename).read()
     offset = int(offset) - 1
     from rope.ide.codeassist import PythonCodeAssist
     from rope.base.project import Project
     p = Project(self.svc.boss.cmd('buffer', 'get_current').directory)
     c = PythonCodeAssist(p)
     co = c.assist(buffer, offset).completions
     print co
     for comp in co:
         self.svc._com.add_completion(server, comp.name)
     # do this a few times
     #self.svc._com.add_completion(server, 'banana')
     pass
예제 #3
0
    def complete(self):
        if TM_PROJECT_DIRECTORY is None:
            return ''
        #from rope.contrib import autoimport
        project = Project(TM_PROJECT_DIRECTORY)
        #autoimport = autoimport.AutoImport(project)
        resource = project.get_resource(TM_FILEPATH.replace(TM_PROJECT_DIRECTORY, '')[1:])
        #project.validate(self.project_path)
        caret_index = self.source.find(TM_CURRENT_LINE) + TM_LINE_INDEX
        try:
            proposals = codeassist.code_assist(project, self.source, caret_index, resource)
        except:
            ass = PythonCodeAssist(project)
            proposals = ass.assist(self.source, caret_index, resource)
        try:
            if len(proposals) == 0:
                return ''
        except:
            return ''
        if len(proposals) == 1:
            selection = proposals[0].name
        else:
            proposals = codeassist.sorted_proposals(proposals)
            #autoimport.generate_cache()
            #autoimport.generate_modules_cache(modules)
            #project.pycore.analyze_module(resource)
            names = [proposal.name for proposal in proposals]
            #if self.starting.strip() and '.' not in self.expression:
            #        import_assists = self.autoimport.import_assist(self.starting)
            #        names.extend(x[0] + ' : ' + x[1] for x in import_assists)

            #plist = "{ menuItems=(%s);}"
            selection = dialog.menu(names)
            if selection is None:
                return ''
        if TM_CURRENT_WORD is None:
            return selection
        else:
            return selection.replace(TM_CURRENT_WORD, '')