MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _complete_expression

Method _complete_expression

tools/python-3.11.9-amd64/Lib/pdb.py:551–574  ·  view source on GitHub ↗
(self, text, line, begidx, endidx)

Source from the content-addressed store, hash-verified

549 if bp is not None and str(i).startswith(text)]
550
551 def _complete_expression(self, text, line, begidx, endidx):
552 # Complete an arbitrary expression.
553 if not self.curframe:
554 return []
555 # Collect globals and locals. It is usually not really sensible to also
556 # complete builtins, and they clutter the namespace quite heavily, so we
557 # leave them out.
558 ns = {**self.curframe.f_globals, **self.curframe_locals}
559 if '.' in text:
560 # Walk an attribute chain up to the last part, similar to what
561 # rlcompleter does. This will bail if any of the parts are not
562 # simple attribute access, which is what we want.
563 dotted = text.split('.')
564 try:
565 obj = ns[dotted[0]]
566 for part in dotted[1:-1]:
567 obj = getattr(obj, part)
568 except (KeyError, AttributeError):
569 return []
570 prefix = '.'.join(dotted[:-1]) + '.'
571 return [prefix + n for n in dir(obj) if n.startswith(dotted[-1])]
572 else:
573 # Complete a simple name.
574 return [n for n in ns.keys() if n.startswith(text)]
575
576 # Command definitions, called by cmdloop()
577 # The argument is the remaining string on the command line

Callers 1

_complete_locationMethod · 0.95

Calls 4

startswithMethod · 0.80
splitMethod · 0.45
joinMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected