MCPcopy Index your code
hub / github.com/RustPython/RustPython / _complete_expression

Method _complete_expression

Lib/pdb.py:500–523  ·  view source on GitHub ↗
(self, text, line, begidx, endidx)

Source from the content-addressed store, hash-verified

498 if bp is not None and str(i).startswith(text)]
499
500 def _complete_expression(self, text, line, begidx, endidx):
501 # Complete an arbitrary expression.
502 if not self.curframe:
503 return []
504 # Collect globals and locals. It is usually not really sensible to also
505 # complete builtins, and they clutter the namespace quite heavily, so we
506 # leave them out.
507 ns = {**self.curframe.f_globals, **self.curframe_locals}
508 if '.' in text:
509 # Walk an attribute chain up to the last part, similar to what
510 # rlcompleter does. This will bail if any of the parts are not
511 # simple attribute access, which is what we want.
512 dotted = text.split('.')
513 try:
514 obj = ns[dotted[0]]
515 for part in dotted[1:-1]:
516 obj = getattr(obj, part)
517 except (KeyError, AttributeError):
518 return []
519 prefix = '.'.join(dotted[:-1]) + '.'
520 return [prefix + n for n in dir(obj) if n.startswith(dotted[-1])]
521 else:
522 # Complete a simple name.
523 return [n for n in ns.keys() if n.startswith(text)]
524
525 # Command definitions, called by cmdloop()
526 # The argument is the remaining string on the command line

Callers 1

_complete_locationMethod · 0.95

Calls 6

getattrFunction · 0.85
dirFunction · 0.85
splitMethod · 0.45
joinMethod · 0.45
startswithMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected