class Solargraph::SourceMap::Clip

def code_complete

Returns:
  • (Completion) -
def code_complete
  result = []
  result.concat complete_keyword_parameters
  if cursor.chain.constant? || cursor.start_of_constant?
    full = cursor.chain.links.first.word
    type = if cursor.chain.undefined?
      cursor.chain.base.infer(api_map, context_pin, locals)
    else
      if full.include?('::') && cursor.chain.links.length == 1
        ComplexType.try_parse(full.split('::')[0..-2].join('::'))
      elsif cursor.chain.links.length > 1
        ComplexType.try_parse(full)
      else
        ComplexType::UNDEFINED
      end
    end
    if type.undefined?
      if full.include?('::')
        result.concat api_map.get_constants(full, *gates)
      else
        result.concat api_map.get_constants('', cursor.start_of_constant? ? '' : context_pin.full_context.namespace, *gates) #.select { |pin| pin.name.start_with?(full) }

      end
    else
      result.concat api_map.get_constants(type.namespace, cursor.start_of_constant? ? '' : context_pin.full_context.namespace, *gates)
    end
  else
    type = cursor.chain.base.infer(api_map, block, locals)
    result.concat api_map.get_complex_type_methods(type, block.binder.namespace, cursor.chain.links.length == 1)
    if cursor.chain.links.length == 1
      if cursor.word.start_with?('@@')
        return package_completions(api_map.get_class_variable_pins(context_pin.full_context.namespace))
      elsif cursor.word.start_with?('@')
        return package_completions(api_map.get_instance_variable_pins(block.binder.namespace, block.binder.scope))
      elsif cursor.word.start_with?('$')
        return package_completions(api_map.get_global_variable_pins)
      end
      result.concat locals
      result.concat file_global_methods unless block.binder.namespace.empty?
      result.concat api_map.get_constants(context_pin.context.namespace, *gates)
      result.concat api_map.get_methods(block.binder.namespace, scope: block.binder.scope, visibility: [:public, :private, :protected])
      result.concat api_map.get_methods('Kernel')
      result.concat api_map.keyword_pins.to_a
    end
  end
  package_completions(result)
end