class Solargraph::Pin::Namespace

Attributes

parameters[R]
type[R]

@return [::Symbol] :class or :module

visibility[R]

@return [::Symbol] :public or :private

Public Class Methods

new(type: :class, visibility: :public, gates: [''], parameters: [], **splat) click to toggle source

@param type [::Symbol] :class or :module @param visibility [::Symbol] :public or :private @param gates [Array<String>]

Calls superclass method Solargraph::Pin::Closure::new
# File lib/solargraph/pin/namespace.rb, line 17
def initialize type: :class, visibility: :public, gates: [''], parameters: [], **splat
  # super(location, namespace, name, comments)
  super(**splat)
  @type = type
  @visibility = visibility
  if name.start_with?('::')
    @name = name[2..-1]
    @closure = Solargraph::Pin::ROOT_PIN
  end
  @open_gates = gates
  if @name.include?('::')
    # In this case, a chained namespace was opened (e.g., Foo::Bar)
    # but Foo does not exist.
    parts = @name.split('::')
    @name = parts.pop
    closure_name = if [Solargraph::Pin::ROOT_PIN, nil].include?(closure)
      ''
    else
      closure.full_context.namespace + '::'
    end
    closure_name += parts.join('::')
    @closure = Pin::Namespace.new(name: closure_name, gates: [parts.join('::')])
    @context = nil
  end
  @parameters = parameters
end

Public Instance Methods

binder() click to toggle source
# File lib/solargraph/pin/namespace.rb, line 52
def binder
  full_context
end
completion_item_kind() click to toggle source
# File lib/solargraph/pin/namespace.rb, line 60
def completion_item_kind
  (type == :class ? LanguageServer::CompletionItemKinds::CLASS : LanguageServer::CompletionItemKinds::MODULE)
end
domains() click to toggle source
# File lib/solargraph/pin/namespace.rb, line 77
def domains
  @domains ||= []
end
full_context() click to toggle source
# File lib/solargraph/pin/namespace.rb, line 48
def full_context
  @full_context ||= ComplexType.try_parse("#{type.to_s.capitalize}<#{path}>")
end
gates() click to toggle source
# File lib/solargraph/pin/namespace.rb, line 85
def gates
  @gates ||= if path.empty?
    @open_gates
  else
    [path] + @open_gates
  end
end
namespace() click to toggle source
# File lib/solargraph/pin/namespace.rb, line 44
def namespace
  context.namespace
end
path() click to toggle source
# File lib/solargraph/pin/namespace.rb, line 69
def path
  @path ||= (namespace.empty? ? '' : "#{namespace}::") + name
end
return_type() click to toggle source
# File lib/solargraph/pin/namespace.rb, line 73
def return_type
  @return_type ||= ComplexType.try_parse( (type == :class ? 'Class' : 'Module') + "<#{path}>" )
end
scope() click to toggle source
# File lib/solargraph/pin/namespace.rb, line 56
def scope
  context.scope
end
symbol_kind() click to toggle source

@return [Integer]

# File lib/solargraph/pin/namespace.rb, line 65
def symbol_kind
  (type == :class ? LanguageServer::SymbolKinds::CLASS : LanguageServer::SymbolKinds::MODULE)
end
typify(api_map) click to toggle source
# File lib/solargraph/pin/namespace.rb, line 81
def typify api_map
  return_type
end