<s> import re <EOL> import sublime <EOL> import sublime_plugin <EOL> from Dart . _init_ import editor_context <EOL> from Dart . lib . notifications import show_analysis_tooltip <EOL> from Dart . lib . notifications import show_status_tooltip <EOL> class DartGoToDeclaration ( sublime_plugin . WindowCommand ) : <EOL> def run ( self ) : <EOL> try : <EOL> view = self . window . active_view ( ) <EOL> if not view : <EOL> return <EOL> except Exception as e : <EOL> return <EOL> sel = view . sel ( ) [ <NUM_LIT:0> ] <EOL> self . get_navigation ( view , sel ) <EOL> def get_navigation ( self , view , r ) : <EOL> navigation = editor_context . navigation <EOL> if not navigation : <EOL> sublime . status_message ( '<STR_LIT>' ) <EOL> return <EOL> sources = navigation . regions <EOL> targets = [ source for source in sources <EOL> if source . offset <= r . begin ( ) <= ( source . offset + source . length ) ] <EOL> if not targets : <EOL> show_status_tooltip ( "<STR_LIT>" , timeout = <NUM_LIT> ) <EOL> sublime . status_message ( '<STR_LIT>' ) <EOL> return <EOL> first_target = targets [ <NUM_LIT:0> ] . targets [ <NUM_LIT:0> ] <EOL> first_target = navigation . targets [ first_target ] <EOL> fname = navigation . files [ first_target . fileIndex ] <EOL> row = first_target . startLine <EOL> col = first_target . startColumn <EOL> self . window . open_file ( "<STR_LIT>" . format ( fname , row , col ) , sublime . ENCODED_POSITION ) <EOL> class ErrorNavigator ( object ) : <EOL> '''<STR_LIT>''' <EOL> ERROR_LINE_RX = re . compile ( r'<STR_LIT>' ) <EOL> def __init__ ( self , editor_context ) : <EOL> self . editor_context = editor_context <EOL> def next ( self ) : <EOL> self . editor_context . increment_error_index ( ) <EOL> match = self . ERROR_LINE_RX . match ( editor_context . get_current_error ( ) ) <EOL> return match . groupdict ( ) <EOL> def previous ( self ) : <EOL> self . editor_context . decrement_error_index ( ) <EOL> match = self . ERROR_LINE_RX . match ( editor_context . get_current_error ( ) ) <EOL> return match . groupdict ( ) <EOL> class DartGoToNextResult ( sublime_plugin . WindowCommand ) : <EOL> def run ( self ) : <EOL> self . window . run_command ( '<STR_LIT>' ) <EOL> if editor_context . errors : <EOL> navi = ErrorNavigator ( editor_context ) <EOL> try : <EOL> data = navi . next ( ) <EOL> except IndexError : <EOL> return <EOL> else : <EOL> show_analysis_tooltip ( data ) <EOL> class DartGoToPrevResult ( sublime_plugin . WindowCommand ) : <EOL> def run ( self ) : <EOL> self . window . run_command ( '<STR_LIT>' ) <EOL> if editor_context . errors : <EOL> navi = ErrorNavigator ( editor_context ) <EOL> try : <EOL> data = navi . previous ( ) <EOL> except IndexError : <EOL> return <EOL> else : <EOL> show_analysis_tooltip ( data ) </s>
