class RDoc::RI::Driver

def complete_method(name, klass, selector, completions) # :nodoc:

:nodoc:
def complete_method(name, klass, selector, completions) # :nodoc:
  if completions.include? klass and name =~ /#|\.|::/ then
    methods = list_methods_matching name
    if not methods.empty? then
      # remove Foo if given Foo:: and a method was found
      completions.delete klass
    elsif selector then
      # replace Foo with Foo:: as given
      completions.delete klass
      completions << "#{klass}#{selector}"
    end
    methods.each do |klass_sel_method|
      match = klass_sel_method.match(/^(.+)(#|\.|::)([^#.:]+)$/)
      # match[2] is `::` for class method and `#` for instance method.
      # To be consistent with old completion that completes `['Foo#i', 'Foo::c']` for `Foo.`,
      # `.` should be a wildcard for both `#` and `::` here.
      if match && match[2] == selector || selector == '.'
        completions << match[1] + selector + match[3]
      end
    end
  end
end