@@ -69,8 +69,8 @@ def get_completer(cursor_offset, current_line, locals_, argspec, full_code, mode
6969 'mode' :mode , 'complete_magic_methods' :complete_magic_methods }
7070
7171 # mutually exclusive matchers: if one returns [], don't go on
72- for completer in [ImportCompletion , FilenameCompletion ,
73- MagicMethodCompletion , GlobalCompletion ]:
72+ for completer in [StringLiteralAttrCompletion , ImportCompletion ,
73+ FilenameCompletion , MagicMethodCompletion , GlobalCompletion ]:
7474 matches = completer .matches (cursor_offset , current_line , ** kwargs )
7575 if matches is not None :
7676 return sorted (set (matches )), completer
@@ -315,6 +315,20 @@ def matches(cls, cursor_offset, line, argspec, **kwargs):
315315 return matches
316316 locate = staticmethod (lineparts .current_word )
317317
318+ class StringLiteralAttrCompletion (BaseCompletionType ):
319+ locate = staticmethod (lineparts .current_string_literal_attr )
320+ @classmethod
321+ def matches (cls , cursor_offset , line , ** kwargs ):
322+ r = cls .locate (cursor_offset , line )
323+ if r is None :
324+ return None
325+ start , end , word = r
326+ attrs = dir ('' )
327+ matches = [att for att in attrs if att .startswith (word )]
328+ if not word .startswith ('_' ):
329+ return [match for match in matches if not match .startswith ('_' )]
330+ return matches
331+
318332class SafeEvalFailed (Exception ):
319333 """If this object is returned, safe_eval failed"""
320334 # Because every normal Python value is a possible return value of safe_eval
0 commit comments