<s> import sublime <EOL> from functools import partial <EOL> from . . import utils , model_index <EOL> from . . inline_documentation import Documentation <EOL> from . . goto_cfml_file import GotoCfmlFile <EOL> from . import metadata <EOL> from . in_file_completions import get_extends <EOL> SYNTAX_EXT = "<STR_LIT>" if int ( sublime . version ( ) ) >= <NUM_LIT> else "<STR_LIT>" <EOL> def get_inline_documentation ( view , position ) : <EOL> doc_name = None <EOL> doc_priority = <NUM_LIT:0> <EOL> extended_meta , function_name , header = get_function_info ( view , position ) <EOL> if extended_meta : <EOL> doc , callback = get_function_documentation ( view , extended_meta , function_name , header ) <EOL> return Documentation ( doc , callback , <NUM_LIT:2> ) <EOL> extended_meta , file_path , header = get_cfc_info ( view , position ) <EOL> if extended_meta : <EOL> doc , callback = get_documentation ( view , extended_meta , file_path , header ) <EOL> return Documentation ( doc , callback , <NUM_LIT:2> ) <EOL> return None <EOL> def get_goto_cfml_file ( view , position ) : <EOL> extended_meta , function_name , header = get_function_info ( view , position ) <EOL> if extended_meta : <EOL> return GotoCfmlFile ( extended_meta [ "<STR_LIT>" ] [ function_name ] , extended_meta [ "<STR_LIT>" ] [ function_name ] . name ) <EOL> extended_meta , file_path , header = get_cfc_info ( view , position ) <EOL> if extended_meta : <EOL> return GotoCfmlFile ( file_path , None ) <EOL> return None <EOL> def get_function_info ( view , position ) : <EOL> if view . match_selector ( position , "<STR_LIT>" ) : <EOL> function_name , function_name_region , function_args_region = utils . get_function_call ( view , position ) <EOL> extended_meta = metadata . get_view_metadata ( view ) <EOL> if function_name in extended_meta [ "<STR_LIT>" ] : <EOL> header = extended_meta [ "<STR_LIT>" ] [ function_name ] . name + "<STR_LIT>" <EOL> return extended_meta , function_name , header <EOL> if view . match_selector ( position , "<STR_LIT>" ) : <EOL> function_name , function_name_region , function_args_region = utils . get_function_call ( view , position ) <EOL> if view . substr ( function_name_region . begin ( ) - <NUM_LIT:1> ) == "<STR_LIT:.>" : <EOL> dot_context = utils . get_dot_context ( view , function_name_region . begin ( ) - <NUM_LIT:1> ) <EOL> if dot_context [ <NUM_LIT:0> ] . name == "<STR_LIT>" : <EOL> extended_meta = metadata . get_view_metadata ( view ) <EOL> if function_name in extended_meta [ "<STR_LIT>" ] : <EOL> header = extended_meta [ "<STR_LIT>" ] [ function_name ] . name + "<STR_LIT>" <EOL> return extended_meta , function_name , header <EOL> if dot_context [ <NUM_LIT:0> ] . name == "<STR_LIT>" : <EOL> project_name = utils . get_project_name ( view ) <EOL> file_path = utils . normalize_path ( view . file_name ( ) ) if view . file_name ( ) else "<STR_LIT>" <EOL> extends = get_extends ( view ) <EOL> extends_file_path = model_index . resolve_path ( project_name , file_path , extends ) <EOL> extended_meta = model_index . get_extended_metadata_by_file_path ( project_name , extends_file_path ) <EOL> if extended_meta and function_name in extended_meta [ "<STR_LIT>" ] : <EOL> header = extended_meta [ "<STR_LIT>" ] [ function_name ] . name + "<STR_LIT>" <EOL> return extended_meta , function_name , header <EOL> return None , None , None <EOL> def get_cfc_info ( view , position ) : <EOL> if view . match_selector ( position , "<STR_LIT>" ) : <EOL> extended_meta = metadata . get_view_metadata ( view ) <EOL> file_path = utils . normalize_path ( view . file_name ( ) ) if view . file_name ( ) else "<STR_LIT>" <EOL> return extended_meta , file_path , "<STR_LIT>" <EOL> if view . match_selector ( position , "<STR_LIT>" ) : <EOL> project_name = utils . get_project_name ( view ) <EOL> file_path = utils . normalize_path ( view . file_name ( ) ) if view . file_name ( ) else "<STR_LIT>" <EOL> extends = get_extends ( view ) <EOL> extends_file_path = model_index . resolve_path ( project_name , file_path , extends ) <EOL> extended_meta = model_index . get_extended_metadata_by_file_path ( project_name , extends_file_path ) <EOL> if extended_meta : <EOL> return extended_meta , extends_file_path , extends <EOL> return None , None , None <EOL> def on_navigate ( view , file_path , function_file_map , href ) : <EOL> if href == "<STR_LIT>" : <EOL> if len ( file_path ) > <NUM_LIT:2> and file_path [ <NUM_LIT:1> ] == "<STR_LIT::>" : <EOL> file_path = "<STR_LIT:/>" + file_path [ <NUM_LIT:0> ] + file_path [ <NUM_LIT:2> : ] <EOL> view . window ( ) . open_file ( file_path ) <EOL> else : <EOL> file_path = function_file_map [ href . lower ( ) ] <EOL> if len ( file_path ) > <NUM_LIT:2> and file_path [ <NUM_LIT:1> ] == "<STR_LIT::>" : <EOL> file_path = "<STR_LIT:/>" + file_path [ <NUM_LIT:0> ] + file_path [ <NUM_LIT:2> : ] <EOL> view . hide_popup ( ) <EOL> view . window ( ) . run_command ( '<STR_LIT>' , { "<STR_LIT>" : file_path , "<STR_LIT>" : href } ) <EOL> def get_documentation ( view , extended_meta , file_path , header ) : <EOL> model_doc = model_index . build_documentation ( extended_meta , file_path , header ) <EOL> callback = partial ( on_navigate , view , file_path , extended_meta [ "<STR_LIT>" ] ) <EOL> return model_doc , callback <EOL> def get_function_documentation ( view , extended_meta , function_name , header ) : <EOL> function_file_path = extended_meta [ "<STR_LIT>" ] [ function_name ] <EOL> view_file_path = utils . normalize_path ( view . file_name ( ) ) if view . file_name ( ) else "<STR_LIT>" <EOL> if len ( function_file_path ) > <NUM_LIT:0> and function_file_path != view_file_path : <EOL> with open ( function_file_path , "<STR_LIT:r>" ) as f : <EOL> file_string = f . read ( ) <EOL> cfml_minihtml_view = view . window ( ) . create_output_panel ( "<STR_LIT>" ) <EOL> cfml_minihtml_view . assign_syntax ( "<STR_LIT>" + utils . get_plugin_name ( ) + "<STR_LIT>" + SYNTAX_EXT ) <EOL> cfml_minihtml_view . run_command ( "<STR_LIT>" , { "<STR_LIT>" : file_string , "<STR_LIT>" : True , "<STR_LIT>" : True } ) <EOL> model_doc = model_index . build_method_documentation ( extended_meta , function_name , header , cfml_minihtml_view ) <EOL> view . window ( ) . destroy_output_panel ( "<STR_LIT>" ) <EOL> else : <EOL> model_doc = model_index . build_method_documentation ( extended_meta , function_name , header , view ) <EOL> callback = partial ( on_navigate , view , extended_meta [ "<STR_LIT>" ] [ function_name ] , extended_meta [ "<STR_LIT>" ] ) <EOL> return model_doc , callback </s>
