Class: Solargraph::Pin::Block

Inherits:
Closure show all
Defined in:
lib/solargraph/pin/block.rb

Instance Attribute Summary collapse

Attributes inherited from Closure

#scope

Attributes inherited from Base

#code_object, #location, #name, #path, #return_type

Attributes included from Common

#closure, #location

Instance Method Summary collapse

Methods inherited from Closure

#context

Methods inherited from Base

#==, #comments, #completion_item_kind, #deprecated?, #directives, #docstring, #filename, #infer, #inspect, #macros, #maybe_directives?, #probe, #probed?, #proxied?, #proxy, #realize, #symbol_kind, #to_s, #try_merge!, #typify, #variable?

Methods included from Documenting

#documentation

Methods included from Conversions

#completion_item, #detail, #link_documentation, #reset_conversions, #resolve_completion_item, #signature_help

Methods included from Common

#comments, #context, #name, #namespace, #path, #return_type

Constructor Details

#initialize(receiver: nil, args: [], **splat) ⇒ Block


9
10
11
12
13
# File 'lib/solargraph/pin/block.rb', line 9

def initialize receiver: nil, args: [], **splat
  super(splat)
  @receiver = receiver
  @parameters = args
end

Instance Attribute Details

#receiverParser::AST::Node (readonly)

The signature of the method that receives this block.


7
8
9
# File 'lib/solargraph/pin/block.rb', line 7

def receiver
  @receiver
end

Instance Method Details

#binderObject


24
25
26
# File 'lib/solargraph/pin/block.rb', line 24

def binder
  @binder || context
end

#kindObject


28
29
30
# File 'lib/solargraph/pin/block.rb', line 28

def kind
  Pin::BLOCK
end

#nearly?(other) ⇒ Boolean


42
43
44
45
46
47
# File 'lib/solargraph/pin/block.rb', line 42

def nearly? other
  return false unless super
  # @todo Trying to not to block merges too much
  # receiver == other.receiver and parameters == other.parameters
  true
end

#parameter_namesArray<String>


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

def parameter_names
  @parameter_names ||= parameters.map{|p| p.split(/[ =:]/).first.gsub(/^(\*{1,2}|&)/, '')}
end

#parametersArray<String>


33
34
35
# File 'lib/solargraph/pin/block.rb', line 33

def parameters
  @parameters ||= []
end

#rebind(context) ⇒ Object


15
16
17
18
# File 'lib/solargraph/pin/block.rb', line 15

def rebind context
  @rebound = true
  @binder = context unless context.undefined?
end

#rebound?Boolean


20
21
22
# File 'lib/solargraph/pin/block.rb', line 20

def rebound?
  @rebound ||= false
end