<s> """<STR_LIT>""" <EOL> import re <EOL> import sublime <EOL> import sublime_plugin <EOL> import subprocess <EOL> from . import util <EOL> class LookupSymbolCommand ( sublime_plugin . TextCommand ) : <EOL> """<STR_LIT>""" <EOL> DOC_URLS = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> MUTABLE_CLASSES = ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ) <EOL> def __init__ ( self , view ) : <EOL> """<STR_LIT>""" <EOL> super ( ) . __init__ ( view ) <EOL> self . search_handlers = { <EOL> '<STR_LIT>' : self . dash_lookup , <EOL> '<STR_LIT>' : self . web_lookup <EOL> } <EOL> def is_enabled ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( <EOL> sublime . platform ( ) == '<STR_LIT>' and <EOL> self . view . settings ( ) . get ( '<STR_LIT>' ) . endswith ( '<STR_LIT>' ) <EOL> ) <EOL> def run ( self , edit ) : <EOL> """<STR_LIT>""" <EOL> target = '<STR_LIT>' <EOL> msg = self . lookup ( target ) <EOL> if msg : <EOL> sublime . error_message ( msg ) <EOL> def lookup ( self , target ) : <EOL> """<STR_LIT>""" <EOL> region = self . view . sel ( ) [ <NUM_LIT:0> ] <EOL> region = sublime . Region ( region . begin ( ) , region . end ( ) ) <EOL> word_region = self . view . word ( region ) <EOL> word = self . view . substr ( word_region ) <EOL> if region . empty ( ) and word and region . begin ( ) == word_region . end ( ) : <EOL> region = sublime . Region ( region . begin ( ) - <NUM_LIT:1> , region . begin ( ) - <NUM_LIT:1> ) <EOL> pt = region . begin ( ) <EOL> scopes = self . view . scope_name ( pt ) . split ( ) <EOL> scopes . reverse ( ) <EOL> klass = None <EOL> protocol = None <EOL> method = None <EOL> search = None <EOL> error = None <EOL> if ( <EOL> word . startswith ( '<STR_LIT>' ) and <EOL> '<STR_LIT>' not in scopes and <EOL> '<STR_LIT>' not in scopes <EOL> ) : <EOL> search = word <EOL> elif '<STR_LIT>' in scopes : <EOL> klass , method , error = util . get_container_and_method ( self . view , '<STR_LIT>' , pt ) <EOL> elif '<STR_LIT>' in scopes : <EOL> protocol , method , error = util . get_container_and_method ( self . view , '<STR_LIT>' , pt ) <EOL> elif '<STR_LIT>' in scopes : <EOL> search = self . view . substr ( self . view . word ( region ) ) <EOL> else : <EOL> error = '<STR_LIT>' <EOL> if error is not None : <EOL> return error <EOL> elif search is not None and target == '<STR_LIT>' : <EOL> return '<STR_LIT>' <EOL> return self . search_handlers [ target ] ( klass = klass , protocol = protocol , method = method , search = search ) <EOL> def dash_lookup ( self , klass = None , protocol = None , method = None , search = None ) : <EOL> """<STR_LIT>""" <EOL> if search : <EOL> query = search <EOL> else : <EOL> if klass or protocol : <EOL> query = klass or protocol <EOL> if query in self . MUTABLE_CLASSES : <EOL> query = '<STR_LIT>' + query [ <NUM_LIT:2> : ] <EOL> if method : <EOL> query += '<STR_LIT:U+0020>' + method <EOL> query = re . sub ( r'<STR_LIT>' , r'<STR_LIT>' , query , count = <NUM_LIT:1> ) <EOL> subprocess . call ( [ '<STR_LIT>' , self . DOC_URLS [ '<STR_LIT>' ] . format ( query ) ] ) <EOL> def web_lookup ( self , klass = None , protocol = None , method = None , search = None ) : <EOL> """<STR_LIT>""" <EOL> pass </s>
