Sha256: 41b7800ce0e6bb857233e6c702b344cc67796b3e90a5b7166825f3b97f8e8de9

Contents?: true

Size: 1.16 KB

Versions: 53

Compression:

Stored size: 1.16 KB

Contents

module Redcar
  class Declarations
    class SelectTagDialog < FilterListDialog

      def initialize(matches)
        super()
        @matches = matches
      end

      def close
        super
      end

      def update_list(filter)
        @last_list    = @matches
        filtered_list = @matches
        if filter.length >= 1
          filtered_list = filter_and_rank_by(filtered_list, filter, filtered_list.length) do |match|
            match[:file].split(::File::SEPARATOR).last
          end
          @last_list = filtered_list
        end
        align_matches_for_display(filtered_list)
      end

      def selected(text, ix, closing=false)
        if @last_list
          close
          Redcar::Declarations.go_to_definition(@last_list[ix])
        end
      end

      private

      def align_matches_for_display(filtered_list)
        filtered_list.collect do |match|
          file_path     = match[:file]
          file          = file_path.split(::File::SEPARATOR).last
          relative_path = file_path.gsub(Regexp.compile(Project::Manager.focussed_project.path + '/'), '')
          "%s (%s)" % [file, relative_path]
        end
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 2 rubygems

Version Path
redcar-0.9.0 plugins/declarations/lib/declarations/select_tag_dialog.rb
redcar-0.8.1 plugins/declarations/lib/declarations/select_tag_dialog.rb
redcar-0.8 plugins/declarations/lib/declarations/select_tag_dialog.rb
redcar-0.7 plugins/declarations/lib/declarations/select_tag_dialog.rb
redcar-0.6.1 plugins/declarations/lib/declarations/select_tag_dialog.rb
redcar-0.6 plugins/declarations/lib/declarations/select_tag_dialog.rb
redcar-0.6.1dev plugins/declarations/lib/declarations/select_tag_dialog.rb
redcar-0.5.1 plugins/declarations/lib/declarations/select_tag_dialog.rb
redcar-0.5 plugins/declarations/lib/declarations/select_tag_dialog.rb
redcar-0.5.6dev plugins/declarations/lib/declarations/select_tag_dialog.rb
redcar-0.5.5dev plugins/declarations/lib/declarations/select_tag_dialog.rb
redcar-0.5.4dev plugins/declarations/lib/declarations/select_tag_dialog.rb
redcar-0.5.3dev plugins/declarations/lib/declarations/select_tag_dialog.rb