Exemplo n.º 1
0
 def test_calltip(self):
     spinner = AsyncSpinner(self, callback=partial(setattr, self, "trg"))
     with spinner:
         self.buf.preceding_trg_from_pos(self.positions[2],
                                         self.positions[3], spinner)
     self.assertIsNotNone(self.trg)
     self.assertEqual(self.trg.form, TRG_FORM_CALLTIP)
     spinner = AsyncSpinner(self)
     with spinner:
         handler = UIHandler(spinner)
         self.buf.async_eval_at_trg(self.trg, handler,
                                    Ci.koICodeIntelBuffer.EVAL_SILENT)
     calltip, calltip_pos = unmark_text(dedent("""
         pformat(object, <1>indent=1<2>, width=80, depth=None)
         Format a Python object into a pretty-printed representation.
         """).strip())
     self.assertEqual(handler.calltip, calltip)
     with spinner:
         positions = []
         def callback(start, end):
             positions[:] = [start, end]
         spinner.callback = callback
         self.buf.get_calltip_arg_range(self.trg.pos,
                                        calltip,
                                        self.positions[3],
                                        spinner)
     self.assertEquals(positions, [calltip_pos[1], calltip_pos[2]],
                       "Unexpected calltip range positions; should cover "
                       "second argument")
Exemplo n.º 2
0
 def test_unicode_in_defn(self):
     self.doc.buffer, self.positions = unmark_text(dedent(u"""
         #Ůɳíčóďé<3>
         my $pCnt = 0;<1>
         # Some filler text to make sure we do not accidentally find the
         # previous definition
         $p<2>Cnt++;
         """).strip())
     self.assertGreater(self.positions[3], len("#Unicode"),
                        "Unicode positions are character positions "
                        "instead of byte positions")
     spinner = AsyncSpinner(self, callback=partial(setattr, self, "trg"))
     with spinner:
         self.buf.defn_trg_from_pos(self.positions[2], spinner)
     self.assertIsNotNone(self.trg)
     self.assertEqual(self.trg.form, TRG_FORM_DEFN)
     handler = UIHandler(spinner)
     with spinner:
         spinner.callback = None
         self.buf.async_eval_at_trg(self.trg, handler,
                                    Ci.koICodeIntelBuffer.EVAL_SILENT)
     self.assertEqual(len(handler.defns), 1)
     self.assertEqual(handler.defns[0].lang, "Perl")
     self.assertEqual(handler.defns[0].name, "$pCnt")
     self.assertEqual([handler.defns[0].line],
                      lines_from_pos(self.doc.buffer, [self.positions[1]]))
     self.assertEqual(handler.defns[0].ilk, "variable")
Exemplo n.º 3
0
 def test_completion(self):
     spinner = AsyncSpinner(self, callback=partial(setattr, self, "trg"))
     with spinner:
         self.buf.trg_from_pos(self.positions[1], True, spinner)
     self.assertIsNotNone(self.trg)
     self.assertEqual(self.trg.form, TRG_FORM_CPLN)
     # don't really care about the rest of the internals of the trigger
     # as long as it actually works...
     spinner = AsyncSpinner(self)
     with spinner:
         handler = UIHandler(spinner)
         self.buf.async_eval_at_trg(self.trg, handler,
                                    Ci.koICodeIntelBuffer.EVAL_SILENT)
     self.assertIn(UIHandler.AutoCompleteInfo("sys", "module"),
                   handler.completions)
Exemplo n.º 4
0
 def _doEval(self, markedup_content, lang=None, implicit=True):
     self.doc.buffer, self.positions = unmark_text(
         dedent(markedup_content).strip())
     spinner = AsyncSpinner(self, callback=partial(setattr, self, "trg"))
     with spinner:
         self.buf.trg_from_pos(self.positions["pos"], implicit, spinner)
     self.assertIsNotNone(self.trg)
     # don't really care about the rest of the internals of the trigger
     # as long as it actually works...
     spinner = AsyncSpinner(self)
     with spinner:
         handler = UIHandler(spinner)
         self.buf.async_eval_at_trg(self.trg, handler,
                                    Ci.koICodeIntelBuffer.EVAL_SILENT)
     return handler
Exemplo n.º 5
0
 def test_completion_stale(self):
     """Test that we ignore stale triggers"""
     spinner = AsyncSpinner(self, callback=partial(setattr, self, "trg"))
     with spinner:
         self.buf.trg_from_pos(self.positions[1], True, spinner)
     self.assertIsNotNone(self.trg)
     self.assertEqual(self.trg.form, TRG_FORM_CPLN)
     self.doc.buffer += "\n#Modified buffer"
     # don't really care about the rest of the internals of the trigger
     # as long as it actually works...
     spinner = AsyncSpinner(self, timeout=None)
     with spinner:
         handler = UIHandler(spinner)
         self.buf.async_eval_at_trg(self.trg, handler,
                                    Ci.koICodeIntelBuffer.EVAL_SILENT)
     self.assertEquals(handler.completions, [])
Exemplo n.º 6
0
 def test_defn(self):
     spinner = AsyncSpinner(self, callback=partial(setattr, self, "trg"))
     with spinner:
         self.buf.defn_trg_from_pos(self.positions[3], spinner)
     self.assertIsNotNone(self.trg)
     self.assertEqual(self.trg.form, TRG_FORM_DEFN)
     handler = UIHandler(spinner)
     with spinner:
         spinner.callback = None
         self.buf.async_eval_at_trg(self.trg, handler,
                                    Ci.koICodeIntelBuffer.EVAL_SILENT)
     self.assertEqual(len(handler.defns), 1)
     self.assertEqual(handler.defns[0].lang, "Python")
     self.assertEqual(handler.defns[0].name, "indent")
     self.assertEqual([handler.defns[0].line],
                      lines_from_pos(self.doc.buffer, [self.positions[5]]))
     self.assertEqual(handler.defns[0].ilk, "variable")