Class: Solargraph::Pin::Closure

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

Direct Known Subclasses

BaseMethod, Block, Namespace, Singleton

Instance Attribute Summary collapse

Attributes inherited from Base

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

Attributes included from Common

#closure, #location

Instance Method Summary collapse

Methods inherited from Base

#==, #comments, #completion_item_kind, #deprecated?, #directives, #docstring, #filename, #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

Methods included from Common

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

Constructor Details

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


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

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

Instance Attribute Details

#scope::Symbol (readonly)


5
6
7
# File 'lib/solargraph/pin/closure.rb', line 5

def scope
  @scope
end

Instance Method Details

#binderObject


23
24
25
# File 'lib/solargraph/pin/closure.rb', line 23

def binder
  @binder || context
end

#contextObject


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

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