Class: Hind::LSIF::Vertex

Inherits:
Object
  • Object
show all
Defined in:
lib/hind/lsif/vertex.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, label, data = nil) ⇒ Vertex

Returns a new instance of Vertex.



8
9
10
11
12
# File 'lib/hind/lsif/vertex.rb', line 8

def initialize(id, label, data = nil)
  @id = id
  @label = label
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



6
7
8
# File 'lib/hind/lsif/vertex.rb', line 6

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/hind/lsif/vertex.rb', line 6

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label.



6
7
8
# File 'lib/hind/lsif/vertex.rb', line 6

def label
  @label
end

Instance Method Details

#to_json(*_args) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/hind/lsif/vertex.rb', line 14

def to_json(*_args)
  json = {
    id: @id,
    type: 'vertex',
    label: @label
  }

  if @data
    if %w[hoverResult definitionResult referenceResult].include?(@label)
      json[:result] = @data
    else
      json.merge!(@data)
    end
  end

  json
end