<s> import sublime , sublime_plugin , subprocess , platform , urllib , os <EOL> class JavapCommand ( sublime_plugin . TextCommand ) : <EOL> def run ( self , edit ) : <EOL> filename = self . view . file_name ( ) <EOL> print ( self ) <EOL> print ( filename ) <EOL> decompiled , errormessages = self . decompile ( filename ) <EOL> print ( errormessages ) <EOL> print ( '<STR_LIT>' ) <EOL> self . edit_window ( edit , decompiled , filename ) <EOL> def decompile ( self , filename ) : <EOL> executable = self . get_javap_exec ( ) <EOL> filepath , extension = os . path . splitext ( filename ) <EOL> print ( '<STR_LIT>' ) <EOL> print ( extension ) <EOL> basename = os . path . basename ( filepath ) <EOL> dirname = os . path . dirname ( filepath ) <EOL> command = [ executable , '<STR_LIT:-c>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , dirname , basename ] <EOL> print ( '<STR_LIT>' ) <EOL> print ( command ) <EOL> return self . exec_command ( command ) <EOL> def exec_command ( self , command ) : <EOL> os_alias = platform . system ( ) . lower ( ) <EOL> if '<STR_LIT>' in os_alias : <EOL> startupinfo = subprocess . STARTUPINFO ( ) <EOL> startupinfo . dwFlags |= subprocess . STARTF_USESHOWWINDOW <EOL> p = subprocess . Popen ( command , stdout = subprocess . PIPE , stderr = subprocess . PIPE , startupinfo = startupinfo ) <EOL> out , err = p . communicate ( ) <EOL> print ( '<STR_LIT>' ) <EOL> fixed = out . decode ( "<STR_LIT:utf-8>" ) . replace ( '<STR_LIT:\r\n>' , '<STR_LIT:\n>' ) <EOL> return ( fixed , err ) <EOL> else : <EOL> p = subprocess . Popen ( command , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) <EOL> out , err = p . communicate ( ) <EOL> print ( '<STR_LIT>' ) <EOL> fixed = out . decode ( "<STR_LIT:utf-8>" ) <EOL> return ( fixed , err ) <EOL> def edit_window ( self , edit , contents , filename ) : <EOL> view = self . view <EOL> window = sublime . active_window ( ) <EOL> if view != window . transient_view_in_group ( window . active_group ( ) ) : <EOL> view . set_scratch ( True ) <EOL> view . set_syntax_file ( '<STR_LIT>' ) <EOL> view . erase ( edit , sublime . Region ( <NUM_LIT:0> , view . size ( ) ) ) <EOL> view . insert ( edit , <NUM_LIT:0> , contents ) <EOL> view . sel ( ) . clear ( ) <EOL> view . sel ( ) . add ( sublime . Region ( <NUM_LIT:0> ) ) <EOL> def get_new_filename ( self , filename ) : <EOL> return filename . replace ( "<STR_LIT:class>" , "<STR_LIT>" ) <EOL> def get_javap_exec ( self ) : <EOL> os_alias = platform . system ( ) . lower ( ) <EOL> print ( os_alias ) <EOL> if '<STR_LIT>' in os_alias : <EOL> return '<STR_LIT>' <EOL> elif '<STR_LIT>' in os_alias : <EOL> return '<STR_LIT>' <EOL> elif '<STR_LIT>' in os_alias : <EOL> return '<STR_LIT>' <EOL> class OpenClassFileCommand ( sublime_plugin . EventListener ) : <EOL> def on_load ( self , view ) : <EOL> filename = view . file_name ( ) <EOL> extension = os . path . splitext ( filename ) [ <NUM_LIT:1> ] <EOL> if extension == "<STR_LIT>" : <EOL> view . run_command ( "<STR_LIT>" ) <EOL> def on_activated ( self , view ) : <EOL> header = view . substr ( sublime . Region ( <NUM_LIT:0> , <NUM_LIT:9> ) ) <EOL> if header == "<STR_LIT>" : <EOL> self . on_load ( view ) </s>
