Class: Ruber::FilesRunner::OutputWidget

Inherits:
Ruber::FilteredOutputWidget show all
Defined in:
plugins/ruby_development/ruby_development.rb

Overview

The class used by the Files runner tool widget

It’s a normal Ruber::FilteredOutputWidget which overrides the #find_filename_in_index method

Constant Summary

Constants inherited from OutputWidget

IsTitleRole, OutputTypeRole

Instance Attribute Summary

Attributes inherited from Ruber::FilteredOutputWidget

filter_model

Attributes inherited from OutputWidget

action_list, actions, auto_scroll, ignore_word_wrap_option, model, skip_first_file_in_title, view, working_dir

Instance Method Summary (collapse)

Methods inherited from Ruber::FilteredOutputWidget

#clear_filter, #copy, #copy_selected, #create_filter_from_editor, #create_standard_actions, #ignore_filter, #initialize, keyReleaseEvent, #maybe_open_file, #scroll_to, #show_editor

Methods inherited from OutputWidget

#clear_output, #copy, #copy_selected, #create_standard_actions, #create_widgets, #do_auto_scroll, #fill_menu, #find_filename_in_string, #has_title?, #hints, #initialize, #load_settings, #maybe_open_file, #pinned_down?, #rows_changed, #scroll_to, #selection_changed, #set_color_for, #set_output_type, #setup_model, #show_menu, #text_for_clipboard, #title=, #update_index_color, #with_auto_scrolling

Methods included from GuiStatesHandler

#change_state, included, #initialize_states_handler, #register_action_handler, #remove_action_handler_for, #state

Constructor Details

This class inherits a constructor from Ruber::FilteredOutputWidget

Instance Method Details

- (<String,Integer>, ...) find_filename_in_index(idx) (private)

Override of #find_filename_in_index

It differs from the original implementation in that it attempts to work around the situation where there’s a syntax error in a file loaded using require. In this case, the error message takes the form:

requiring_file:line: in `require': file_with_syntax_error:line: syntax error...

Most often, the user will want to open the file with the syntax error, not the one requiring it, so this method attempts to remove the first part of the string before passing it to super. It also works with rubygems in ruby 1.8, when require is replaced by gem_original_require

Parameters:

  • idx (Qt::ModelIndex)

    the index to search for a filename

Returns:



500
501
502
503
504
505
506
# File 'plugins/ruby_development/ruby_development.rb', line 500

def find_filename_in_index idx
  str = idx.data.to_string
  if idx.row == 0 then super
  else 
    super str.sub( %r<^[^\s:]+:\d+:in\s+`(?:gem_original_require|require):\s+'>, '')
  end
end