|
60 | 60 | def after_last_dot(name): |
61 | 61 | return name.rstrip('.').rsplit('.')[-1] |
62 | 62 |
|
63 | | -def get_completer(cursor_offset, current_line, locals_, argspec, full_code, mode, complete_magic_methods): |
| 63 | +def get_completer(cursor_offset, current_line, locals_, argspec, current_block, |
| 64 | + mode, complete_magic_methods): |
64 | 65 | """Returns a list of matches and a class for what kind of completion is happening |
65 | 66 |
|
66 | 67 | If no completion type is relevant, returns None, None |
67 | 68 |
|
68 | | - argspec is an output of inspect.getargspec |
| 69 | + Params: |
| 70 | + cursor_offset is the current cursor column |
| 71 | + current_line is a string of the current line |
| 72 | + locals_ is a dictionary of the environment |
| 73 | + argspec is an inspect.ArgSpec instance for the current function where |
| 74 | + the cursor is |
| 75 | + current_block is the possibly multiline not-yet-evaluated block of |
| 76 | + code which the current line is part of |
| 77 | + mode is one of SIMPLE, SUBSTRING or FUZZY - ways to find matches |
| 78 | + complete_magic_methods is a bool of whether we ought to complete |
| 79 | + double underscore methods like __len__ in method signatures |
69 | 80 | """ |
70 | 81 |
|
71 | | - kwargs = {'locals_':locals_, 'argspec':argspec, 'full_code':full_code, |
| 82 | + kwargs = {'locals_':locals_, 'argspec':argspec, 'current_block':current_block, |
72 | 83 | 'mode':mode, 'complete_magic_methods':complete_magic_methods} |
73 | 84 |
|
74 | 85 | # mutually exclusive if matches: If one of these returns [], try the next one |
@@ -220,11 +231,11 @@ def format(cls, match): |
220 | 231 | class MagicMethodCompletion(BaseCompletionType): |
221 | 232 | locate = staticmethod(lineparts.current_method_definition_name) |
222 | 233 | @classmethod |
223 | | - def matches(cls, cursor_offset, line, full_code, **kwargs): |
| 234 | + def matches(cls, cursor_offset, line, current_block, **kwargs): |
224 | 235 | r = cls.locate(cursor_offset, line) |
225 | 236 | if r is None: |
226 | 237 | return None |
227 | | - if 'class' not in full_code: |
| 238 | + if 'class' not in current_block: |
228 | 239 | return None |
229 | 240 | start, end, word = r |
230 | 241 | return [name for name in MAGIC_METHODS if name.startswith(word)] |
|
0 commit comments