<s> import sublime <EOL> import sublime_plugin <EOL> import re , os <EOL> completions = [ ] <EOL> SETTINGS = sublime . load_settings ( '<STR_LIT>' ) <EOL> def add_methods ( cfc_file , hint_text ) : <EOL> with open ( cfc_file , '<STR_LIT:r>' ) as f : <EOL> read_data = f . read ( ) <EOL> methods = [ ] <EOL> method_lines = re . findall ( '<STR_LIT>' , read_data ) <EOL> for l in method_lines : <EOL> l = re . sub ( "<STR_LIT>" , "<STR_LIT:U+0020>" , l ) <EOL> s = re . search ( '<STR_LIT>' , l ) <EOL> if s : <EOL> methods . append ( s . group ( ) . strip ( ) ) <EOL> for c in methods : <EOL> snippet = c <EOL> params = re . sub ( "<STR_LIT>" , "<STR_LIT>" , snippet , <NUM_LIT:1> ) [ : - <NUM_LIT:1> ] . split ( "<STR_LIT:U+002C>" ) <EOL> num = <NUM_LIT:1> <EOL> if len ( params [ <NUM_LIT:0> ] ) : <EOL> for p in params : <EOL> snippet = snippet . replace ( p , '<STR_LIT>' + str ( num ) + '<STR_LIT::>' + p + '<STR_LIT:}>' ) <EOL> num = num + <NUM_LIT:1> <EOL> c = re . sub ( "<STR_LIT>" , "<STR_LIT>" , c ) <EOL> completions . append ( ( c + "<STR_LIT>" + hint_text , snippet ) ) <EOL> class MethodsAutoComplete ( sublime_plugin . EventListener ) : <EOL> def on_query_completions ( self , view , prefix , locations ) : <EOL> if not view . match_selector ( locations [ <NUM_LIT:0> ] , <EOL> "<STR_LIT>" ) : <EOL> return [ ] <EOL> if not SETTINGS . get ( "<STR_LIT>" ) : <EOL> return <EOL> _completions = [ ] <EOL> try : <EOL> cfc_region = view . find_by_selector ( "<STR_LIT>" ) [ <NUM_LIT:0> ] <EOL> except IndexError : <EOL> cfc_region = "<STR_LIT>" <EOL> if len ( cfc_region ) : <EOL> extendspath = view . substr ( cfc_region ) . replace ( "<STR_LIT:.>" , "<STR_LIT:/>" ) <EOL> this_file = view . file_name ( ) <EOL> dir_len = this_file . rfind ( '<STR_LIT:/>' ) <EOL> if not dir_len > <NUM_LIT:0> : <EOL> dir_len = this_file . rfind ( '<STR_LIT:\\>' ) <EOL> this_dir = this_file [ : ( dir_len + <NUM_LIT:1> ) ] <EOL> cfc_file = this_dir + extendspath + "<STR_LIT>" <EOL> if not os . path . isfile ( cfc_file ) : <EOL> for folder in sublime . active_window ( ) . folders ( ) : <EOL> if os . path . isfile ( folder + "<STR_LIT:/>" + extendspath + "<STR_LIT>" ) : <EOL> cfc_file = folder + "<STR_LIT:/>" + extendspath + "<STR_LIT>" <EOL> break <EOL> try : <EOL> add_methods ( cfc_file , view . substr ( cfc_region ) . split ( "<STR_LIT:.>" ) [ - <NUM_LIT:1> ] ) <EOL> except UnboundLocalError : <EOL> pass <EOL> except IOError : <EOL> pass <EOL> add_methods ( view . file_name ( ) , "<STR_LIT>" ) <EOL> _completions . extend ( completions ) <EOL> del completions [ : ] <EOL> return _completions </s>
