Module: Solargraph::Pin::Conversions

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

Instance Method Summary collapse

Instance Method Details

#completion_itemHash


6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/solargraph/pin/conversions.rb', line 6

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


43
44
45
46
47
48
49
50
51
52
# 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 = ''
  detail += "(#{parameters.join(', ')}) " unless kind != Pin::METHOD or parameters.empty?
  detail += "=#{probed? ? '~' : (proxied? ? '^' : '>')} #{return_type}" unless return_type.undefined?
  detail.strip!
  return nil if detail.empty?
  detail
end

Get a markdown-flavored link to a documentation page.


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

def link_documentation
  @link_documentation ||= generate_link
end

#reset_conversionsObject


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

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

#resolve_completion_itemHash


21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/solargraph/pin/conversions.rb', line 21

def resolve_completion_item
  if @resolve_completion_item.nil?
    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?
    @resolve_completion_item = completion_item.merge(extra)
  end
  @resolve_completion_item
end

#signature_helpHash


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

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