<s> import csv <EOL> import os <EOL> import os . path <EOL> import shutil <EOL> import sublime <EOL> import sublime_plugin <EOL> import subprocess <EOL> import time <EOL> import sys <EOL> from os . path import dirname , realpath <EOL> dist_dir = os . path . dirname ( os . path . abspath ( __file__ ) ) <EOL> sys . path . insert ( <NUM_LIT:0> , dist_dir ) <EOL> if int ( sublime . version ( ) ) >= <NUM_LIT> : <EOL> from diff_match_patch . python3 . diff_match_patch import diff_match_patch <EOL> else : <EOL> from diff_match_patch . python2 . diff_match_patch import diff_match_patch <EOL> def getSetting ( view , settings , key , default ) : <EOL> local = '<STR_LIT>' + key <EOL> return view . settings ( ) . get ( local , settings . get ( key , default ) ) <EOL> def dofmt ( eself , eview , sgter = None , src = None , force = False ) : <EOL> self = eself <EOL> view = eview <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> additional_extensions = getSetting ( view , s , "<STR_LIT>" , [ ] ) <EOL> autoimport = getSetting ( view , s , "<STR_LIT>" , True ) <EOL> debug = getSetting ( view , s , "<STR_LIT>" , False ) <EOL> enable_auto_align = getSetting ( view , s , "<STR_LIT>" , False ) <EOL> ignore_list = getSetting ( view , s , "<STR_LIT>" , "<STR_LIT>" ) <EOL> indent_with_space = getSetting ( view , s , "<STR_LIT>" , False ) <EOL> psr1 = getSetting ( view , s , "<STR_LIT>" , False ) <EOL> psr1_naming = getSetting ( view , s , "<STR_LIT>" , psr1 ) <EOL> psr2 = getSetting ( view , s , "<STR_LIT>" , False ) <EOL> smart_linebreak_after_curly = getSetting ( view , s , "<STR_LIT>" , True ) <EOL> skip_if_ini_missing = getSetting ( view , s , "<STR_LIT>" , False ) <EOL> visibility_order = getSetting ( view , s , "<STR_LIT>" , False ) <EOL> yoda = getSetting ( view , s , "<STR_LIT>" , False ) <EOL> readini = getSetting ( view , s , "<STR_LIT>" , False ) <EOL> php55compat = getSetting ( view , s , "<STR_LIT>" , False ) <EOL> passes = getSetting ( view , s , "<STR_LIT>" , [ ] ) <EOL> excludes = getSetting ( view , s , "<STR_LIT>" , [ ] ) <EOL> php_bin = getSetting ( view , s , "<STR_LIT>" , "<STR_LIT>" ) <EOL> formatter_path = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> if php55compat is True : <EOL> formatter_path = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> config_file = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> dirnm = "<STR_LIT>" <EOL> uri = "<STR_LIT>" <EOL> if force is False : <EOL> uri = view . file_name ( ) <EOL> dirnm , sfn = os . path . split ( uri ) <EOL> ext = os . path . splitext ( uri ) [ <NUM_LIT:1> ] [ <NUM_LIT:1> : ] <EOL> if "<STR_LIT>" != ext and not ext in additional_extensions : <EOL> if debug : <EOL> print ( "<STR_LIT>" ) <EOL> return False <EOL> if "<STR_LIT>" != ignore_list : <EOL> if type ( ignore_list ) is not list : <EOL> ignore_list = ignore_list . split ( "<STR_LIT:U+0020>" ) <EOL> for v in ignore_list : <EOL> pos = uri . find ( v ) <EOL> if - <NUM_LIT:1> != pos and v != "<STR_LIT>" : <EOL> if debug : <EOL> print ( "<STR_LIT>" ) <EOL> return False <EOL> if not os . path . isfile ( php_bin ) and not php_bin == "<STR_LIT>" : <EOL> print ( "<STR_LIT>" + php_bin ) <EOL> if int ( sublime . version ( ) ) >= <NUM_LIT> : <EOL> sublime . error_message ( "<STR_LIT>" + php_bin ) <EOL> if dirnm != "<STR_LIT>" : <EOL> oracleDirNm = dirnm <EOL> while oracleDirNm != "<STR_LIT:/>" : <EOL> oracleFname = oracleDirNm + os . path . sep + "<STR_LIT>" <EOL> if os . path . isfile ( oracleFname ) : <EOL> break <EOL> origOracleDirNm = oracleDirNm <EOL> oracleDirNm = os . path . dirname ( oracleDirNm ) <EOL> if origOracleDirNm == oracleDirNm : <EOL> break <EOL> if not os . path . isfile ( oracleFname ) : <EOL> if debug : <EOL> print ( "<STR_LIT>" ) <EOL> oracleFname = None <EOL> else : <EOL> if debug : <EOL> print ( "<STR_LIT>" + oracleFname ) <EOL> if readini : <EOL> iniDirNm = dirnm <EOL> while iniDirNm != "<STR_LIT:/>" : <EOL> iniFname = iniDirNm + os . path . sep + "<STR_LIT>" <EOL> if os . path . isfile ( iniFname ) : <EOL> break <EOL> originiDirNm = iniDirNm <EOL> iniDirNm = os . path . dirname ( iniDirNm ) <EOL> if originiDirNm == iniDirNm : <EOL> break <EOL> if os . path . isfile ( iniFname ) : <EOL> if debug : <EOL> print ( "<STR_LIT>" + iniFname ) <EOL> config_file = iniFname <EOL> elif skip_if_ini_missing : <EOL> if debug : <EOL> print ( "<STR_LIT>" ) <EOL> return False <EOL> else : <EOL> oracleFname = None <EOL> cmd_ver = [ php_bin , '<STR_LIT>' ] ; <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_ver , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_ver , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False ) <EOL> res , err = p . communicate ( ) <EOL> print ( "<STR_LIT>" , cmd_ver ) <EOL> print ( "<STR_LIT>" , res . decode ( '<STR_LIT:utf-8>' ) ) <EOL> print ( "<STR_LIT>" , err . decode ( '<STR_LIT:utf-8>' ) ) <EOL> if php55compat is False and ( '<STR_LIT>' in res . decode ( '<STR_LIT:utf-8>' ) or '<STR_LIT>' in err . decode ( '<STR_LIT:utf-8>' ) or '<STR_LIT>' in res . decode ( '<STR_LIT:utf-8>' ) or '<STR_LIT>' in err . decode ( '<STR_LIT:utf-8>' ) or '<STR_LIT>' in res . decode ( '<STR_LIT:utf-8>' ) or '<STR_LIT>' in err . decode ( '<STR_LIT:utf-8>' ) ) : <EOL> sublime . message_dialog ( '<STR_LIT>' ) <EOL> return False <EOL> if debug : <EOL> s = debugEnvironment ( php_bin , formatter_path ) <EOL> print ( s ) <EOL> lintret = <NUM_LIT:1> <EOL> if "<STR_LIT>" in passes : <EOL> lintret = <NUM_LIT:0> <EOL> else : <EOL> cmd_lint = [ php_bin , "<STR_LIT>" , "<STR_LIT>" ] ; <EOL> if src is None : <EOL> cmd_lint . append ( uri ) <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_lint , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_lint , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False ) <EOL> else : <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_lint , stdin = subprocess . PIPE , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_lint , stdin = subprocess . PIPE , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False ) <EOL> p . stdin . write ( src . encode ( '<STR_LIT:utf-8>' ) ) <EOL> lint_out , lint_err = p . communicate ( ) <EOL> lintret = p . returncode <EOL> if ( lintret == <NUM_LIT:0> ) : <EOL> cmd_fmt = [ php_bin ] <EOL> if not debug : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if psr1 : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> cmd_fmt . append ( formatter_path ) <EOL> cmd_fmt . append ( "<STR_LIT>" + config_file ) <EOL> if psr1 : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if psr1_naming : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if psr2 : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if indent_with_space is True : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> elif indent_with_space > <NUM_LIT:0> : <EOL> cmd_fmt . append ( "<STR_LIT>" + str ( indent_with_space ) ) <EOL> if enable_auto_align : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if visibility_order : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if smart_linebreak_after_curly : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if yoda : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if sgter is not None : <EOL> cmd_fmt . append ( "<STR_LIT>" + sgter ) <EOL> cmd_fmt . append ( "<STR_LIT>" + sgter ) <EOL> if autoimport is True and oracleFname is not None : <EOL> cmd_fmt . append ( "<STR_LIT>" + oracleFname ) <EOL> if len ( passes ) > <NUM_LIT:0> : <EOL> cmd_fmt . append ( "<STR_LIT>" + '<STR_LIT:U+002C>' . join ( passes ) ) <EOL> if len ( excludes ) > <NUM_LIT:0> : <EOL> cmd_fmt . append ( "<STR_LIT>" + '<STR_LIT:U+002C>' . join ( excludes ) ) <EOL> if debug : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if sgter is None : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if src is None : <EOL> cmd_fmt . append ( uri ) <EOL> else : <EOL> cmd_fmt . append ( "<STR_LIT:->" ) <EOL> if debug : <EOL> print ( "<STR_LIT>" , cmd_fmt ) <EOL> if src is None : <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_fmt , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_fmt , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False ) <EOL> else : <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_fmt , stdin = subprocess . PIPE , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_fmt , stdin = subprocess . PIPE , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False ) <EOL> if src is not None : <EOL> p . stdin . write ( src . encode ( '<STR_LIT:utf-8>' ) ) <EOL> res , err = p . communicate ( ) <EOL> if debug : <EOL> print ( "<STR_LIT>" , p . returncode ) <EOL> print ( "<STR_LIT>" , err . decode ( '<STR_LIT:utf-8>' ) ) <EOL> if p . returncode != <NUM_LIT:0> : <EOL> return '<STR_LIT>' <EOL> if sgter is not None : <EOL> sublime . set_timeout ( revert_active_window , <NUM_LIT:50> ) <EOL> return res . decode ( '<STR_LIT:utf-8>' ) <EOL> else : <EOL> sublime . status_message ( "<STR_LIT>" ) <EOL> if debug : <EOL> print ( "<STR_LIT>" , lint_out ) <EOL> def dogeneratephpdoc ( eself , eview ) : <EOL> self = eself <EOL> view = eview <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> additional_extensions = s . get ( "<STR_LIT>" , [ ] ) <EOL> autoimport = s . get ( "<STR_LIT>" , True ) <EOL> debug = s . get ( "<STR_LIT>" , False ) <EOL> enable_auto_align = s . get ( "<STR_LIT>" , False ) <EOL> ignore_list = s . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> indent_with_space = s . get ( "<STR_LIT>" , False ) <EOL> psr1 = s . get ( "<STR_LIT>" , False ) <EOL> psr1_naming = s . get ( "<STR_LIT>" , psr1 ) <EOL> psr2 = s . get ( "<STR_LIT>" , False ) <EOL> smart_linebreak_after_curly = s . get ( "<STR_LIT>" , True ) <EOL> visibility_order = s . get ( "<STR_LIT>" , False ) <EOL> yoda = s . get ( "<STR_LIT>" , False ) <EOL> passes = s . get ( "<STR_LIT>" , [ ] ) <EOL> php_bin = s . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> formatter_path = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> php55compat = s . get ( "<STR_LIT>" , False ) <EOL> if php55compat is True : <EOL> formatter_path = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> config_file = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> uri = view . file_name ( ) <EOL> dirnm , sfn = os . path . split ( uri ) <EOL> ext = os . path . splitext ( uri ) [ <NUM_LIT:1> ] [ <NUM_LIT:1> : ] <EOL> if "<STR_LIT>" != ext and not ext in additional_extensions : <EOL> print ( "<STR_LIT>" ) <EOL> sublime . status_message ( "<STR_LIT>" ) <EOL> return False <EOL> if not os . path . isfile ( php_bin ) and not php_bin == "<STR_LIT>" : <EOL> print ( "<STR_LIT>" + php_bin ) <EOL> if int ( sublime . version ( ) ) >= <NUM_LIT> : <EOL> sublime . error_message ( "<STR_LIT>" + php_bin ) <EOL> if debug : <EOL> print ( "<STR_LIT>" , uri ) <EOL> if enable_auto_align : <EOL> print ( "<STR_LIT>" ) <EOL> else : <EOL> print ( "<STR_LIT>" ) <EOL> cmd_lint = [ php_bin , "<STR_LIT>" , uri ] ; <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_lint , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_lint , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False ) <EOL> lint_out , lint_err = p . communicate ( ) <EOL> if ( p . returncode == <NUM_LIT:0> ) : <EOL> cmd_fmt = [ php_bin ] <EOL> if not debug : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> cmd_fmt . append ( formatter_path ) <EOL> cmd_fmt . append ( "<STR_LIT>" + config_file ) <EOL> if psr1 : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if psr1_naming : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if psr2 : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if indent_with_space : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> elif indent_with_space > <NUM_LIT:0> : <EOL> cmd_fmt . append ( "<STR_LIT>" + str ( indent_with_space ) ) <EOL> if enable_auto_align : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if visibility_order : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> passes . append ( "<STR_LIT>" ) <EOL> if len ( passes ) > <NUM_LIT:0> : <EOL> cmd_fmt . append ( "<STR_LIT>" + '<STR_LIT:U+002C>' . join ( passes ) ) <EOL> cmd_fmt . append ( uri ) <EOL> uri_tmp = uri + "<STR_LIT>" <EOL> if debug : <EOL> print ( "<STR_LIT>" , cmd_fmt ) <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_fmt , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_fmt , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False ) <EOL> res , err = p . communicate ( ) <EOL> print ( "<STR_LIT>" , err . decode ( '<STR_LIT:utf-8>' ) ) <EOL> sublime . set_timeout ( revert_active_window , <NUM_LIT:50> ) <EOL> else : <EOL> print ( "<STR_LIT>" , lint_out ) <EOL> def doreordermethod ( eself , eview ) : <EOL> self = eself <EOL> view = eview <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> additional_extensions = s . get ( "<STR_LIT>" , [ ] ) <EOL> autoimport = s . get ( "<STR_LIT>" , True ) <EOL> debug = s . get ( "<STR_LIT>" , False ) <EOL> enable_auto_align = s . get ( "<STR_LIT>" , False ) <EOL> ignore_list = s . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> indent_with_space = s . get ( "<STR_LIT>" , False ) <EOL> psr1 = s . get ( "<STR_LIT>" , False ) <EOL> psr1_naming = s . get ( "<STR_LIT>" , psr1 ) <EOL> psr2 = s . get ( "<STR_LIT>" , False ) <EOL> smart_linebreak_after_curly = s . get ( "<STR_LIT>" , True ) <EOL> visibility_order = s . get ( "<STR_LIT>" , False ) <EOL> yoda = s . get ( "<STR_LIT>" , False ) <EOL> passes = s . get ( "<STR_LIT>" , [ ] ) <EOL> php_bin = s . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> formatter_path = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> php55compat = s . get ( "<STR_LIT>" , False ) <EOL> if php55compat is True : <EOL> formatter_path = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> config_file = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> uri = view . file_name ( ) <EOL> dirnm , sfn = os . path . split ( uri ) <EOL> ext = os . path . splitext ( uri ) [ <NUM_LIT:1> ] [ <NUM_LIT:1> : ] <EOL> if "<STR_LIT>" != ext and not ext in additional_extensions : <EOL> print ( "<STR_LIT>" ) <EOL> sublime . status_message ( "<STR_LIT>" ) <EOL> return False <EOL> if not os . path . isfile ( php_bin ) and not php_bin == "<STR_LIT>" : <EOL> print ( "<STR_LIT>" + php_bin ) <EOL> if int ( sublime . version ( ) ) >= <NUM_LIT> : <EOL> sublime . error_message ( "<STR_LIT>" + php_bin ) <EOL> if debug : <EOL> print ( "<STR_LIT>" , uri ) <EOL> if enable_auto_align : <EOL> print ( "<STR_LIT>" ) <EOL> else : <EOL> print ( "<STR_LIT>" ) <EOL> cmd_lint = [ php_bin , "<STR_LIT>" , uri ] ; <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_lint , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_lint , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False ) <EOL> lint_out , lint_err = p . communicate ( ) <EOL> if ( p . returncode == <NUM_LIT:0> ) : <EOL> cmd_fmt = [ php_bin ] <EOL> if not debug : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> cmd_fmt . append ( formatter_path ) <EOL> cmd_fmt . append ( "<STR_LIT>" + config_file ) <EOL> if psr1 : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if psr1_naming : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if psr2 : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if indent_with_space : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> elif indent_with_space > <NUM_LIT:0> : <EOL> cmd_fmt . append ( "<STR_LIT>" + str ( indent_with_space ) ) <EOL> if enable_auto_align : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> if visibility_order : <EOL> cmd_fmt . append ( "<STR_LIT>" ) <EOL> passes . append ( "<STR_LIT>" ) <EOL> if len ( passes ) > <NUM_LIT:0> : <EOL> cmd_fmt . append ( "<STR_LIT>" + '<STR_LIT:U+002C>' . join ( passes ) ) <EOL> cmd_fmt . append ( uri ) <EOL> uri_tmp = uri + "<STR_LIT>" <EOL> if debug : <EOL> print ( "<STR_LIT>" , cmd_fmt ) <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_fmt , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_fmt , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False ) <EOL> res , err = p . communicate ( ) <EOL> print ( "<STR_LIT>" , err . decode ( '<STR_LIT:utf-8>' ) ) <EOL> sublime . set_timeout ( revert_active_window , <NUM_LIT:50> ) <EOL> else : <EOL> print ( "<STR_LIT>" , lint_out ) <EOL> def dorefactor ( eself , eview , refactor_from = None , refactor_to = None ) : <EOL> self = eself <EOL> view = eview <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> debug = s . get ( "<STR_LIT>" , False ) <EOL> psr1 = s . get ( "<STR_LIT>" , False ) <EOL> psr1_naming = s . get ( "<STR_LIT>" , psr1 ) <EOL> psr2 = s . get ( "<STR_LIT>" , False ) <EOL> indent_with_space = s . get ( "<STR_LIT>" , False ) <EOL> enable_auto_align = s . get ( "<STR_LIT>" , False ) <EOL> visibility_order = s . get ( "<STR_LIT>" , False ) <EOL> autoimport = s . get ( "<STR_LIT>" , True ) <EOL> short_array = s . get ( "<STR_LIT>" , False ) <EOL> merge_else_if = s . get ( "<STR_LIT>" , False ) <EOL> php_bin = s . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> refactor_path = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> additional_extensions = s . get ( "<STR_LIT>" , [ ] ) <EOL> uri = view . file_name ( ) <EOL> dirnm , sfn = os . path . split ( uri ) <EOL> ext = os . path . splitext ( uri ) [ <NUM_LIT:1> ] [ <NUM_LIT:1> : ] <EOL> if "<STR_LIT>" != ext and not ext in additional_extensions : <EOL> print ( "<STR_LIT>" ) <EOL> sublime . status_message ( "<STR_LIT>" ) <EOL> return False <EOL> if not os . path . isfile ( php_bin ) and not php_bin == "<STR_LIT>" : <EOL> print ( "<STR_LIT>" + php_bin ) <EOL> if int ( sublime . version ( ) ) >= <NUM_LIT> : <EOL> sublime . error_message ( "<STR_LIT>" + php_bin ) <EOL> cmd_lint = [ php_bin , "<STR_LIT>" , uri ] ; <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_lint , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_lint , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False ) <EOL> lint_out , lint_err = p . communicate ( ) <EOL> if ( p . returncode == <NUM_LIT:0> ) : <EOL> cmd_refactor = [ php_bin ] <EOL> if not debug : <EOL> cmd_refactor . append ( "<STR_LIT>" ) <EOL> cmd_refactor . append ( refactor_path ) <EOL> cmd_refactor . append ( "<STR_LIT>" + refactor_from ) <EOL> cmd_refactor . append ( "<STR_LIT>" + refactor_to ) <EOL> cmd_refactor . append ( uri ) <EOL> uri_tmp = uri + "<STR_LIT>" <EOL> if debug : <EOL> print ( "<STR_LIT>" , cmd_refactor ) <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_refactor , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_refactor , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = dirnm , shell = False ) <EOL> res , err = p . communicate ( ) <EOL> print ( "<STR_LIT>" , err . decode ( '<STR_LIT:utf-8>' ) ) <EOL> if int ( sublime . version ( ) ) < <NUM_LIT> : <EOL> with open ( uri_tmp , '<STR_LIT>' ) as f : <EOL> f . write ( res ) <EOL> else : <EOL> with open ( uri_tmp , '<STR_LIT>' ) as f : <EOL> f . write ( res ) <EOL> if debug : <EOL> print ( "<STR_LIT>" , len ( res ) , "<STR_LIT>" ) <EOL> shutil . move ( uri_tmp , uri ) <EOL> sublime . set_timeout ( revert_active_window , <NUM_LIT:50> ) <EOL> else : <EOL> print ( "<STR_LIT>" , lint_out ) <EOL> def debugEnvironment ( php_bin , formatter_path ) : <EOL> ret = "<STR_LIT>" <EOL> cmd_ver = [ php_bin , "<STR_LIT>" ] ; <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_ver , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_ver , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False ) <EOL> res , err = p . communicate ( ) <EOL> ret += ( "<STR_LIT>" + res . decode ( '<STR_LIT:utf-8>' ) ) <EOL> if err . decode ( '<STR_LIT:utf-8>' ) : <EOL> ret += ( "<STR_LIT>" + err . decode ( '<STR_LIT:utf-8>' ) ) <EOL> ret += "<STR_LIT:\n>" <EOL> cmd_ver = [ php_bin , "<STR_LIT>" ] ; <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_ver , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_ver , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False ) <EOL> res , err = p . communicate ( ) <EOL> if res . decode ( '<STR_LIT:utf-8>' ) . find ( "<STR_LIT>" ) != - <NUM_LIT:1> : <EOL> ret += ( "<STR_LIT>" ) <EOL> else : <EOL> ret += ( "<STR_LIT>" + res . decode ( '<STR_LIT:utf-8>' ) ) <EOL> if err . decode ( '<STR_LIT:utf-8>' ) : <EOL> ret += ( "<STR_LIT>" + err . decode ( '<STR_LIT:utf-8>' ) ) <EOL> ret += "<STR_LIT:\n>" <EOL> cmd_ver = [ php_bin , formatter_path , "<STR_LIT>" ] ; <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_ver , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_ver , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False ) <EOL> res , err = p . communicate ( ) <EOL> ret += ( "<STR_LIT>" + res . decode ( '<STR_LIT:utf-8>' ) ) <EOL> if err . decode ( '<STR_LIT:utf-8>' ) : <EOL> ret += ( "<STR_LIT>" + err . decode ( '<STR_LIT:utf-8>' ) ) <EOL> ret += "<STR_LIT:\n>" <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> php55compat = s . get ( "<STR_LIT>" , False ) <EOL> ret += "<STR_LIT>" <EOL> if php55compat : <EOL> ret += "<STR_LIT>" <EOL> else : <EOL> ret += "<STR_LIT>" <EOL> ret += "<STR_LIT:\n>" <EOL> return ret <EOL> def revert_active_window ( ) : <EOL> sublime . active_window ( ) . active_view ( ) . run_command ( "<STR_LIT>" ) <EOL> sublime . active_window ( ) . active_view ( ) . run_command ( "<STR_LIT>" ) <EOL> def lookForOracleFile ( view ) : <EOL> uri = view . file_name ( ) <EOL> oracleDirNm , sfn = os . path . split ( uri ) <EOL> originalDirNm = oracleDirNm <EOL> while oracleDirNm != "<STR_LIT:/>" : <EOL> oracleFname = oracleDirNm + os . path . sep + "<STR_LIT>" <EOL> if os . path . isfile ( oracleFname ) : <EOL> return True <EOL> origOracleDirNm = oracleDirNm <EOL> oracleDirNm = os . path . dirname ( oracleDirNm ) <EOL> if origOracleDirNm == oracleDirNm : <EOL> return False <EOL> return False <EOL> def outputToPanel ( name , eself , eedit , message ) : <EOL> eself . output_view = eself . view . window ( ) . get_output_panel ( name ) <EOL> eself . view . window ( ) . run_command ( "<STR_LIT>" , { "<STR_LIT>" : "<STR_LIT>" + name } ) <EOL> eself . output_view . set_read_only ( False ) <EOL> eself . output_view . insert ( eedit , eself . output_view . size ( ) , message ) <EOL> eself . output_view . set_read_only ( True ) <EOL> def hidePanel ( name , eself , eedit ) : <EOL> eself . output_view = eself . view . window ( ) . get_output_panel ( name ) <EOL> eself . view . window ( ) . run_command ( "<STR_LIT>" , { "<STR_LIT>" : "<STR_LIT>" + name } ) <EOL> class phpfmt ( sublime_plugin . EventListener ) : <EOL> def on_pre_save ( self , view ) : <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> format_on_save = s . get ( "<STR_LIT>" , True ) <EOL> if format_on_save : <EOL> view . run_command ( '<STR_LIT>' ) <EOL> class AnalyseThisCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> if not lookForOracleFile ( self . view ) : <EOL> sublime . active_window ( ) . active_view ( ) . run_command ( "<STR_LIT>" ) <EOL> return False <EOL> lookTerm = ( self . view . substr ( self . view . word ( self . view . sel ( ) [ <NUM_LIT:0> ] . a ) ) ) <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> php_bin = s . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> oraclePath = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> uri = self . view . file_name ( ) <EOL> dirNm , sfn = os . path . split ( uri ) <EOL> ext = os . path . splitext ( uri ) [ <NUM_LIT:1> ] [ <NUM_LIT:1> : ] <EOL> oracleDirNm = dirNm <EOL> while oracleDirNm != "<STR_LIT:/>" : <EOL> oracleFname = oracleDirNm + os . path . sep + "<STR_LIT>" <EOL> if os . path . isfile ( oracleFname ) : <EOL> break <EOL> origOracleDirNm = oracleDirNm <EOL> oracleDirNm = os . path . dirname ( oracleDirNm ) <EOL> if origOracleDirNm == oracleDirNm : <EOL> break <EOL> cmdOracle = [ php_bin ] <EOL> cmdOracle . append ( oraclePath ) <EOL> cmdOracle . append ( "<STR_LIT>" ) <EOL> cmdOracle . append ( lookTerm ) <EOL> print ( cmdOracle ) <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmdOracle , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = oracleDirNm , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmdOracle , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = oracleDirNm , shell = False ) <EOL> res , err = p . communicate ( ) <EOL> print ( "<STR_LIT>" + res . decode ( '<STR_LIT:utf-8>' ) ) <EOL> print ( "<STR_LIT>" + err . decode ( '<STR_LIT:utf-8>' ) ) <EOL> outputToPanel ( "<STR_LIT>" , self , edit , "<STR_LIT>" + res . decode ( '<STR_LIT:utf-8>' ) ) ; <EOL> lastCalltip = "<STR_LIT>" <EOL> class CalltipCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> global lastCalltip <EOL> uri = self . view . file_name ( ) <EOL> dirnm , sfn = os . path . split ( uri ) <EOL> ext = os . path . splitext ( uri ) [ <NUM_LIT:1> ] [ <NUM_LIT:1> : ] <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> additional_extensions = s . get ( "<STR_LIT>" , [ ] ) <EOL> if "<STR_LIT>" != ext and not ext in additional_extensions : <EOL> return False <EOL> if not lookForOracleFile ( self . view ) : <EOL> return False <EOL> lookTerm = ( self . view . substr ( self . view . word ( self . view . sel ( ) [ <NUM_LIT:0> ] . a ) ) ) <EOL> if lastCalltip == lookTerm : <EOL> return False <EOL> lastCalltip = lookTerm <EOL> php_bin = s . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> oraclePath = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> uri = self . view . file_name ( ) <EOL> dirNm , sfn = os . path . split ( uri ) <EOL> ext = os . path . splitext ( uri ) [ <NUM_LIT:1> ] [ <NUM_LIT:1> : ] <EOL> oracleDirNm = dirNm <EOL> while oracleDirNm != "<STR_LIT:/>" : <EOL> oracleFname = oracleDirNm + os . path . sep + "<STR_LIT>" <EOL> if os . path . isfile ( oracleFname ) : <EOL> break <EOL> origOracleDirNm = oracleDirNm <EOL> oracleDirNm = os . path . dirname ( oracleDirNm ) <EOL> if origOracleDirNm == oracleDirNm : <EOL> break <EOL> cmdOracle = [ php_bin ] <EOL> cmdOracle . append ( oraclePath ) <EOL> cmdOracle . append ( "<STR_LIT>" ) <EOL> cmdOracle . append ( lookTerm ) <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmdOracle , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = oracleDirNm , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmdOracle , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = oracleDirNm , shell = False ) <EOL> res , err = p . communicate ( ) <EOL> output = res . decode ( '<STR_LIT:utf-8>' ) ; <EOL> self . view . set_status ( "<STR_LIT>" , output ) <EOL> class DebugEnvCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> php55compat = s . get ( "<STR_LIT>" , False ) <EOL> php_bin = s . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> formatter_path = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> if php55compat is True : <EOL> formatter_path = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> s = debugEnvironment ( php_bin , formatter_path ) <EOL> sublime . message_dialog ( s ) <EOL> class FmtNowCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> vsize = self . view . size ( ) <EOL> src = self . view . substr ( sublime . Region ( <NUM_LIT:0> , vsize ) ) <EOL> if not src . strip ( ) : <EOL> return <EOL> src = dofmt ( self , self . view , None , src , True ) <EOL> if src is False or src == "<STR_LIT>" : <EOL> return False <EOL> _ , err = merge ( self . view , vsize , src , edit ) <EOL> print ( err ) <EOL> class TogglePassMenuCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> php_bin = s . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> formatter_path = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> php55compat = s . get ( "<STR_LIT>" , False ) <EOL> if php55compat is True : <EOL> formatter_path = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> cmd_passes = [ php_bin , formatter_path , '<STR_LIT>' ] ; <EOL> print ( cmd_passes ) <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_passes , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_passes , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False ) <EOL> out , err = p . communicate ( ) <EOL> descriptions = out . decode ( "<STR_LIT:utf-8>" ) . strip ( ) . split ( os . linesep ) <EOL> def on_done ( i ) : <EOL> if i >= <NUM_LIT:0> : <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> passes = s . get ( '<STR_LIT>' , [ ] ) <EOL> chosenPass = descriptions [ i ] . split ( '<STR_LIT:U+0020>' ) <EOL> option = chosenPass [ <NUM_LIT:0> ] <EOL> passDesc = option <EOL> if option in passes : <EOL> passes . remove ( option ) <EOL> msg = "<STR_LIT>" + passDesc + "<STR_LIT>" <EOL> print ( msg ) <EOL> sublime . status_message ( msg ) <EOL> else : <EOL> passes . append ( option ) <EOL> msg = "<STR_LIT>" + passDesc + "<STR_LIT>" <EOL> print ( msg ) <EOL> sublime . status_message ( msg ) <EOL> s . set ( '<STR_LIT>' , passes ) <EOL> sublime . save_settings ( '<STR_LIT>' ) <EOL> self . view . window ( ) . show_quick_panel ( descriptions , on_done , sublime . MONOSPACE_FONT ) <EOL> class ToggleExcludeMenuCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> php_bin = s . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> formatter_path = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> php55compat = s . get ( "<STR_LIT>" , False ) <EOL> if php55compat is True : <EOL> formatter_path = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> cmd_passes = [ php_bin , formatter_path , '<STR_LIT>' ] ; <EOL> print ( cmd_passes ) <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmd_passes , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmd_passes , stdout = subprocess . PIPE , stderr = subprocess . PIPE , shell = False ) <EOL> out , err = p . communicate ( ) <EOL> descriptions = out . decode ( "<STR_LIT:utf-8>" ) . strip ( ) . split ( os . linesep ) <EOL> def on_done ( i ) : <EOL> if i >= <NUM_LIT:0> : <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> excludes = s . get ( '<STR_LIT>' , [ ] ) <EOL> chosenPass = descriptions [ i ] . split ( '<STR_LIT:U+0020>' ) <EOL> option = chosenPass [ <NUM_LIT:0> ] <EOL> passDesc = option <EOL> if option in excludes : <EOL> excludes . remove ( option ) <EOL> msg = "<STR_LIT>" + passDesc + "<STR_LIT>" <EOL> print ( msg ) <EOL> sublime . status_message ( msg ) <EOL> else : <EOL> excludes . append ( option ) <EOL> msg = "<STR_LIT>" + passDesc + "<STR_LIT>" <EOL> print ( msg ) <EOL> sublime . status_message ( msg ) <EOL> s . set ( '<STR_LIT>' , excludes ) <EOL> sublime . save_settings ( '<STR_LIT>' ) <EOL> self . view . window ( ) . show_quick_panel ( descriptions , on_done , sublime . MONOSPACE_FONT ) <EOL> class ToggleCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit , option ) : <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> options = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> } <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> value = s . get ( option , False ) <EOL> if value : <EOL> s . set ( option , False ) <EOL> msg = "<STR_LIT>" + options [ option ] + "<STR_LIT>" <EOL> print ( msg ) <EOL> sublime . status_message ( msg ) <EOL> else : <EOL> s . set ( option , True ) <EOL> msg = "<STR_LIT>" + options [ option ] + "<STR_LIT>" <EOL> print ( msg ) <EOL> sublime . status_message ( msg ) <EOL> sublime . save_settings ( '<STR_LIT>' ) <EOL> class RefactorCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> def execute ( text ) : <EOL> self . token_to = text <EOL> dorefactor ( self , self . view , self . token_from , self . token_to ) <EOL> def askForToTokens ( text ) : <EOL> self . token_from = text <EOL> self . view . window ( ) . show_input_panel ( '<STR_LIT>' + text + '<STR_LIT>' , '<STR_LIT>' , execute , None , None ) <EOL> uri = self . view . file_name ( ) <EOL> dirnm , sfn = os . path . split ( uri ) <EOL> ext = os . path . splitext ( uri ) [ <NUM_LIT:1> ] [ <NUM_LIT:1> : ] <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> additional_extensions = s . get ( "<STR_LIT>" , [ ] ) <EOL> if "<STR_LIT>" != ext and not ext in additional_extensions : <EOL> print ( "<STR_LIT>" ) <EOL> sublime . status_message ( "<STR_LIT>" ) <EOL> return False <EOL> s = "<STR_LIT>" <EOL> for region in self . view . sel ( ) : <EOL> if not region . empty ( ) : <EOL> s = self . view . substr ( region ) <EOL> self . view . window ( ) . show_input_panel ( '<STR_LIT>' , s , askForToTokens , None , None ) <EOL> class OrderMethodCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> doreordermethod ( self , self . view ) <EOL> class GeneratePhpdocCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> dogeneratephpdoc ( self , self . view ) <EOL> class SgterSnakeCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> dofmt ( self , self . view , '<STR_LIT>' ) <EOL> class SgterCamelCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> dofmt ( self , self . view , '<STR_LIT>' ) <EOL> class SgterGoCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> dofmt ( self , self . view , '<STR_LIT>' ) <EOL> class BuildOracleCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> def buildDB ( ) : <EOL> if self . msgFile is not None : <EOL> self . msgFile . window ( ) . run_command ( '<STR_LIT>' ) <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> php_bin = s . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> oraclePath = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> cmdOracle = [ php_bin ] <EOL> cmdOracle . append ( oraclePath ) <EOL> cmdOracle . append ( "<STR_LIT>" ) <EOL> cmdOracle . append ( self . dirNm ) <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmdOracle , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = self . dirNm , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmdOracle , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = self . dirNm , shell = False ) <EOL> res , err = p . communicate ( ) <EOL> print ( "<STR_LIT>" + res . decode ( '<STR_LIT:utf-8>' ) ) <EOL> print ( "<STR_LIT>" + err . decode ( '<STR_LIT:utf-8>' ) ) <EOL> sublime . status_message ( "<STR_LIT>" ) <EOL> def askForDirectory ( text ) : <EOL> self . dirNm = text <EOL> if int ( sublime . version ( ) ) >= <NUM_LIT> : <EOL> sublime . set_timeout_async ( buildDB , <NUM_LIT:0> ) <EOL> else : <EOL> sublime . set_timeout ( buildDB , <NUM_LIT:50> ) <EOL> view = self . view <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> php_bin = s . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> uri = view . file_name ( ) <EOL> oracleDirNm , sfn = os . path . split ( uri ) <EOL> originalDirNm = oracleDirNm <EOL> while oracleDirNm != "<STR_LIT:/>" : <EOL> oracleFname = oracleDirNm + os . path . sep + "<STR_LIT>" <EOL> if os . path . isfile ( oracleFname ) : <EOL> break <EOL> origOracleDirNm = oracleDirNm <EOL> oracleDirNm = os . path . dirname ( oracleDirNm ) <EOL> if origOracleDirNm == oracleDirNm : <EOL> break <EOL> self . msgFile = None <EOL> if not os . path . isfile ( oracleFname ) : <EOL> print ( "<STR_LIT>" ) <EOL> self . msgFile = self . view . window ( ) . open_file ( os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:message>" ) ) <EOL> self . msgFile . set_read_only ( True ) <EOL> self . view . window ( ) . show_input_panel ( '<STR_LIT>' , originalDirNm , askForDirectory , None , None ) <EOL> else : <EOL> print ( "<STR_LIT>" + oracleFname ) <EOL> print ( "<STR_LIT>" + oracleDirNm ) <EOL> self . dirNm = oracleDirNm <EOL> if int ( sublime . version ( ) ) >= <NUM_LIT> : <EOL> sublime . set_timeout_async ( buildDB , <NUM_LIT:0> ) <EOL> else : <EOL> sublime . set_timeout ( buildDB , <NUM_LIT:50> ) <EOL> class IndentWithSpacesCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> def setIndentWithSpace ( text ) : <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> v = text . strip ( ) <EOL> if not v : <EOL> v = False <EOL> else : <EOL> v = int ( v ) <EOL> s . set ( "<STR_LIT>" , v ) <EOL> sublime . save_settings ( '<STR_LIT>' ) <EOL> sublime . status_message ( "<STR_LIT>" ) <EOL> sublime . active_window ( ) . active_view ( ) . run_command ( "<STR_LIT>" ) <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> spaces = s . get ( "<STR_LIT>" , <NUM_LIT:4> ) <EOL> if not spaces : <EOL> spaces = "<STR_LIT>" <EOL> spaces = str ( spaces ) <EOL> self . view . window ( ) . show_input_panel ( '<STR_LIT>' , spaces , setIndentWithSpace , None , None ) <EOL> class PHPFmtComplete ( sublime_plugin . EventListener ) : <EOL> def on_query_completions ( self , view , prefix , locations ) : <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> autocomplete = s . get ( "<STR_LIT>" , False ) <EOL> if autocomplete is False : <EOL> return [ ] <EOL> pos = locations [ <NUM_LIT:0> ] <EOL> scopes = view . scope_name ( pos ) . split ( ) <EOL> if not ( '<STR_LIT>' in scopes or '<STR_LIT>' in scopes ) : <EOL> return [ ] <EOL> print ( "<STR_LIT>" + prefix ) ; <EOL> comps = [ ] <EOL> uri = view . file_name ( ) <EOL> dirNm , sfn = os . path . split ( uri ) <EOL> ext = os . path . splitext ( uri ) [ <NUM_LIT:1> ] [ <NUM_LIT:1> : ] <EOL> oracleDirNm = dirNm <EOL> while oracleDirNm != "<STR_LIT:/>" : <EOL> oracleFname = oracleDirNm + os . path . sep + "<STR_LIT>" <EOL> if os . path . isfile ( oracleFname ) : <EOL> break <EOL> origOracleDirNm = oracleDirNm <EOL> oracleDirNm = os . path . dirname ( oracleDirNm ) <EOL> if origOracleDirNm == oracleDirNm : <EOL> break <EOL> if not os . path . isfile ( oracleFname ) : <EOL> sublime . status_message ( "<STR_LIT>" ) <EOL> return [ ] <EOL> if prefix in "<STR_LIT>" : <EOL> ns = dirNm . replace ( oracleDirNm , '<STR_LIT>' ) . replace ( '<STR_LIT:/>' , '<STR_LIT:\\>' ) <EOL> if ns . startswith ( '<STR_LIT:\\>' ) : <EOL> ns = ns [ <NUM_LIT:1> : ] <EOL> comps . append ( ( <EOL> '<STR_LIT>' % ( "<STR_LIT>" , ns , "<STR_LIT>" ) , <EOL> '<STR_LIT>' % ( "<STR_LIT>" , ns ) , <EOL> ) ) <EOL> if prefix in "<STR_LIT:class>" : <EOL> print ( "<STR_LIT>" ) <EOL> className = sfn . split ( "<STR_LIT:.>" ) [ <NUM_LIT:0> ] <EOL> comps . append ( ( <EOL> '<STR_LIT>' % ( "<STR_LIT:class>" , className , "<STR_LIT:class>" ) , <EOL> '<STR_LIT>' % ( "<STR_LIT:class>" , className ) , <EOL> ) ) <EOL> php_bin = s . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> oraclePath = os . path . join ( dirname ( realpath ( sublime . packages_path ( ) ) ) , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> cmdOracle = [ php_bin ] <EOL> cmdOracle . append ( oraclePath ) <EOL> cmdOracle . append ( "<STR_LIT>" ) <EOL> cmdOracle . append ( prefix ) <EOL> print ( cmdOracle ) <EOL> if os . name == '<STR_LIT>' : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( cmdOracle , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = oracleDirNm , shell = False , startupinfo = startupinfo ) <EOL> else : <EOL> p = subprocess . Popen ( cmdOracle , stdout = subprocess . PIPE , stderr = subprocess . PIPE , cwd = oracleDirNm , shell = False ) <EOL> res , err = p . communicate ( ) <EOL> print ( "<STR_LIT>" + err . decode ( '<STR_LIT:utf-8>' ) ) <EOL> f = res . decode ( '<STR_LIT:utf-8>' ) . split ( '<STR_LIT:\n>' ) <EOL> reader = csv . reader ( f , delimiter = '<STR_LIT:U+002C>' ) <EOL> for row in reader : <EOL> if len ( row ) > <NUM_LIT:0> : <EOL> if "<STR_LIT:class>" == row [ <NUM_LIT:3> ] : <EOL> comps . append ( ( <EOL> '<STR_LIT>' % ( row [ <NUM_LIT:1> ] , row [ <NUM_LIT:0> ] , "<STR_LIT:class>" ) , <EOL> '<STR_LIT>' % ( row [ <NUM_LIT:1> ] ) , <EOL> ) ) <EOL> comps . append ( ( <EOL> '<STR_LIT>' % ( row [ <NUM_LIT:0> ] , row [ <NUM_LIT:0> ] , "<STR_LIT:class>" ) , <EOL> '<STR_LIT>' % ( row [ <NUM_LIT:0> ] ) , <EOL> ) ) <EOL> if "<STR_LIT>" == row [ <NUM_LIT:3> ] : <EOL> comps . append ( ( <EOL> '<STR_LIT>' % ( row [ <NUM_LIT:1> ] , row [ <NUM_LIT:2> ] , "<STR_LIT>" ) , <EOL> '<STR_LIT:%s>' % ( row [ <NUM_LIT:0> ] . replace ( '<STR_LIT:$>' , '<STR_LIT>' ) ) , <EOL> ) ) <EOL> return comps <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> version = s . get ( '<STR_LIT:version>' , <NUM_LIT:1> ) <EOL> s . set ( '<STR_LIT:version>' , version ) <EOL> sublime . save_settings ( '<STR_LIT>' ) <EOL> if version == <NUM_LIT:2> : <EOL> print ( "<STR_LIT>" ) <EOL> s . set ( '<STR_LIT:version>' , <NUM_LIT:3> ) <EOL> sublime . save_settings ( '<STR_LIT>' ) <EOL> if version == <NUM_LIT:3> : <EOL> print ( "<STR_LIT>" ) <EOL> s . set ( '<STR_LIT:version>' , <NUM_LIT:4> ) <EOL> passes = s . get ( '<STR_LIT>' , [ ] ) <EOL> passes . append ( "<STR_LIT>" ) <EOL> s . set ( '<STR_LIT>' , passes ) <EOL> sublime . save_settings ( '<STR_LIT>' ) <EOL> def _ct_poller ( ) : <EOL> s = sublime . load_settings ( '<STR_LIT>' ) <EOL> if s . get ( "<STR_LIT>" , False ) : <EOL> try : <EOL> view = sublime . active_window ( ) . active_view ( ) <EOL> view . run_command ( '<STR_LIT>' ) <EOL> except Exception : <EOL> pass <EOL> sublime . set_timeout ( _ct_poller , <NUM_LIT> ) <EOL> _ct_poller ( ) <EOL> class PhpFmtCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> vsize = self . view . size ( ) <EOL> src = self . view . substr ( sublime . Region ( <NUM_LIT:0> , vsize ) ) <EOL> if not src . strip ( ) : <EOL> return <EOL> src = dofmt ( self , self . view , None , src ) <EOL> if src is False or src == "<STR_LIT>" : <EOL> return False <EOL> _ , err = merge ( self . view , vsize , src , edit ) <EOL> print ( err ) <EOL> class MergeException ( Exception ) : <EOL> pass <EOL> def _merge ( view , size , text , edit ) : <EOL> def ss ( start , end ) : <EOL> return view . substr ( sublime . Region ( start , end ) ) <EOL> dmp = diff_match_patch ( ) <EOL> diffs = dmp . diff_main ( ss ( <NUM_LIT:0> , size ) , text , False ) <EOL> dmp . diff_cleanupEfficiency ( diffs ) <EOL> i = <NUM_LIT:0> <EOL> dirty = False <EOL> for d in diffs : <EOL> k , s = d <EOL> l = len ( s ) <EOL> if k == <NUM_LIT:0> : <EOL> l = len ( s ) <EOL> if ss ( i , i + l ) != s : <EOL> raise MergeException ( '<STR_LIT>' , dirty ) <EOL> i += l <EOL> else : <EOL> dirty = True <EOL> if k > <NUM_LIT:0> : <EOL> view . insert ( edit , i , s ) <EOL> i += l <EOL> else : <EOL> if ss ( i , i + l ) != s : <EOL> raise MergeException ( '<STR_LIT>' , dirty ) <EOL> view . erase ( edit , sublime . Region ( i , i + l ) ) <EOL> return dirty <EOL> def merge ( view , size , text , edit ) : <EOL> vs = view . settings ( ) <EOL> ttts = vs . get ( "<STR_LIT>" ) <EOL> vs . set ( "<STR_LIT>" , False ) <EOL> origin_src = view . substr ( sublime . Region ( <NUM_LIT:0> , view . size ( ) ) ) <EOL> if not origin_src . strip ( ) : <EOL> return ( False , '<STR_LIT>' ) <EOL> try : <EOL> dirty = False <EOL> err = '<STR_LIT>' <EOL> if size < <NUM_LIT:0> : <EOL> size = view . size ( ) <EOL> dirty = _merge ( view , size , text , edit ) <EOL> except MergeException as ex : <EOL> dirty = True <EOL> err = "<STR_LIT>" % ex [ <NUM_LIT:0> ] <EOL> view . replace ( edit , sublime . Region ( <NUM_LIT:0> , view . size ( ) ) , origin_src ) <EOL> except Exception as ex : <EOL> err = "<STR_LIT>" % ex <EOL> finally : <EOL> vs . set ( "<STR_LIT>" , ttts ) <EOL> return ( dirty , err ) </s>
