MCPcopy
hub / github.com/prompt-toolkit/ptpython / get_completions

Method get_completions

src/ptpython/completer.py:150–198  ·  view source on GitHub ↗

Get Python completions.

(
        self, document: Document, complete_event: CompleteEvent
    )

Source from the content-addressed store, hash-verified

148 )
149
150 def get_completions(
151 self, document: Document, complete_event: CompleteEvent
152 ) -> Iterable[Completion]:
153 """
154 Get Python completions.
155 """
156 # If the input starts with an exclamation mark. Use the system completer.
157 if document.text.lstrip().startswith("!"):
158 yield from self._system_completer.get_completions(
159 Document(
160 text=document.text[1:], cursor_position=document.cursor_position - 1
161 ),
162 complete_event,
163 )
164 return
165
166 # Do dictionary key completions.
167 if complete_event.completion_requested or self._complete_python_while_typing(
168 document
169 ):
170 if self.enable_dictionary_completion():
171 has_dict_completions = False
172 for c in self._dictionary_completer.get_completions(
173 document, complete_event
174 ):
175 if c.text not in "[.":
176 # If we get the [ or . completion, still include the other
177 # completions.
178 has_dict_completions = True
179 yield c
180 if has_dict_completions:
181 return
182
183 # Do Path completions (if there were no dictionary completions).
184 if complete_event.completion_requested or self._complete_path_while_typing(
185 document
186 ):
187 yield from self._path_completer.get_completions(document, complete_event)
188
189 # Do Jedi completions.
190 if complete_event.completion_requested or self._complete_python_while_typing(
191 document
192 ):
193 # If we are inside a string, Don't do Jedi completion.
194 if not self._path_completer_grammar.match(document.text_before_cursor):
195 # Do Jedi Python completions.
196 yield from self._jedi_completer.get_completions(
197 document, complete_event
198 )
199
200
201class JediCompleter(Completer):

Callers

nothing calls this directly

Calls 3

get_completionsMethod · 0.45

Tested by

no test coverage detected