Class: Solargraph::Pin::Closure

Inherits:
Base
  • Object
show all
Defined in:
lib/solargraph/pin/closure.rb

Direct Known Subclasses

Block, Method, Namespace, Singleton

Instance Attribute Summary collapse

Attributes inherited from Base

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

Attributes included from Common

#closure, #location

Instance Method Summary collapse

Methods inherited from Base

#==, #comments, #completion_item_kind, #deprecated?, #directives, #docstring, #filename, #identity, #infer, #inspect, #macros, #maybe_directives?, #nearly?, #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, #text_documentation

Methods included from Common

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

Constructor Details

#initialize(scope: :class, **splat) ⇒ Closure

Returns a new instance of Closure.



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

def initialize scope: :class, **splat
  super(**splat)
  @scope = scope
end

Instance Attribute Details

#scope::Symbol (readonly)

Returns :class or :instance.

Returns:

  • (::Symbol)

    :class or :instance



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

def scope
  @scope
end

Instance Method Details

#binderObject



25
26
27
# File 'lib/solargraph/pin/closure.rb', line 25

def binder
  @binder || context
end

#contextObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/solargraph/pin/closure.rb', line 14

def context
  @context ||= begin
    result = super
    if scope == :instance
      Solargraph::ComplexType.parse(result.namespace)
    else
      result
    end
  end
end

#gatesArray<String>

Returns:

  • (Array<String>)


30
31
32
33
34
# File 'lib/solargraph/pin/closure.rb', line 30

def gates
  # @todo This check might not be necessary. There should always be a
  #   root pin
  closure ? closure.gates : ['']
end