Module: Solargraph::Pin::Conversions

Included in:
Base
Defined in:
lib/solargraph/pin/conversions.rb

Overview

TODO:

Move this stuff. It should be the responsibility of the language server.

Instance Method Summary collapse

Instance Method Details

#completion_itemHash

Returns:



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/solargraph/pin/conversions.rb', line 10

def completion_item
  @completion_item ||= {
    label: name,
    kind: completion_item_kind,
    detail: detail,
    data: {
      path: path,
      return_type: return_type.tag,
      location: (location ? location.to_hash : nil),
      deprecated: deprecated?
    }
  }
end

#detailString

Returns:

  • (String)


46
47
48
49
50
51
52
53
54
55
# File 'lib/solargraph/pin/conversions.rb', line 46

def detail
  # This property is not cached in an instance variable because it can
  # change when pins get proxied.
  detail = String.new
  detail += "(#{parameters.map(&:full).join(', ')}) " unless !is_a?(Pin::Method) || parameters.empty?
  detail += "=#{probed? ? '~' : (proxied? ? '^' : '>')} #{return_type.to_s}" unless return_type.undefined?
  detail.strip!
  return nil if detail.empty?
  detail
end

Get a markdown-flavored link to a documentation page.

Returns:

  • (String)


60
61
62
# File 'lib/solargraph/pin/conversions.rb', line 60

def link_documentation
  @link_documentation ||= generate_link
end

#reset_conversionsObject



70
71
72
73
74
75
76
# File 'lib/solargraph/pin/conversions.rb', line 70

def reset_conversions
  @completion_item = nil
  @resolve_completion_item = nil
  @signature_help = nil
  @detail = nil
  @link_documentation = nil
end

#resolve_completion_itemHash

Returns:



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/solargraph/pin/conversions.rb', line 25

def resolve_completion_item
  @resolve_completion_item ||= begin
    extra = {}
    alldoc = ''
    # alldoc += link_documentation unless link_documentation.nil?
    # alldoc += "\n\n" unless alldoc.empty?
    alldoc += documentation unless documentation.nil?
    extra[:documentation] = alldoc unless alldoc.empty?
    completion_item.merge(extra)
  end
end

#signature_helpHash

Returns:



38
39
40
41
42
43
# File 'lib/solargraph/pin/conversions.rb', line 38

def signature_help
  @signature_help ||= {
    label: name + '(' + parameters.map(&:full).join(', ') + ')',
    documentation: documentation
  }
end

#text_documentationObject



64
65
66
67
68
# File 'lib/solargraph/pin/conversions.rb', line 64

def text_documentation
  this_path = path || return_type.tag
  return nil if this_path == 'undefined'
  escape_brackets this_path
end