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:

  • (Hash)


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)


43
44
45
46
47
48
49
50
51
# File 'lib/solargraph/pin/conversions.rb', line 43

def detail
  # This property is not cached in an instance variable because it can
  # change when pins get proxied.
  detail = String.new
  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)


56
57
58
# File 'lib/solargraph/pin/conversions.rb', line 56

def link_documentation
  @link_documentation ||= generate_link
end

#reset_conversionsObject



66
67
68
69
70
71
72
# File 'lib/solargraph/pin/conversions.rb', line 66

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

#resolve_completion_itemHash

Returns:

  • (Hash)


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_helpArray<Hash>

Returns:

  • (Array<Hash>)


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

def signature_help
  []
end

#text_documentationObject



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

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