Class: Solargraph::ApiMap::Cache

Inherits:
Object
  • Object
show all
Defined in:
lib/solargraph/api_map/cache.rb

Instance Method Summary collapse

Constructor Details

#initializeCache

Returns a new instance of Cache.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/solargraph/api_map/cache.rb', line 6

def initialize
  # @type [Hash{Array => Array<Pin::Method>}]
  @methods = {}
  # @type [Hash{(String, Array<String>) => Array<Pin::Base>}]
  @constants = {}
  # @type [Hash{String => String}]
  @qualified_namespaces = {}
  # @type [Hash{String => Pin::Method}]
  @receiver_definitions = {}
  # @type [Hash{String => SourceMap::Clip}]
  @clips = {}
end

Instance Method Details

#clearvoid

This method returns an undefined value.



91
92
93
94
95
# File 'lib/solargraph/api_map/cache.rb', line 91

def clear
  return if empty?

  all_caches.each(&:clear)
end

#empty?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/solargraph/api_map/cache.rb', line 98

def empty?
  all_caches.all?(&:empty?)
end

#get_constants(namespace, contexts) ⇒ Array<Pin::Base>

Parameters:

  • namespace (String)
  • contexts (Array<String>)

Returns:



50
51
52
# File 'lib/solargraph/api_map/cache.rb', line 50

def get_constants namespace, contexts
  @constants["#{namespace}|#{contexts}"]
end

#get_methods(fqns, scope, visibility, deep) ⇒ Array<Pin::Method>

Parameters:

  • fqns (String)
  • scope (Symbol)
  • visibility (Array<Symbol>)
  • deep (Boolean)

Returns:



33
34
35
# File 'lib/solargraph/api_map/cache.rb', line 33

def get_methods fqns, scope, visibility, deep
  @methods["#{fqns}|#{scope}|#{visibility}|#{deep}"]
end

#get_qualified_namespace(name, context) ⇒ String

Parameters:

  • name (String)
  • context (String)

Returns:

  • (String)


65
66
67
# File 'lib/solargraph/api_map/cache.rb', line 65

def get_qualified_namespace name, context
  @qualified_namespaces["#{name}|#{context}"]
end

#get_receiver_definition(path) ⇒ Pin::Method

Parameters:

  • path (String)

Returns:



79
80
81
# File 'lib/solargraph/api_map/cache.rb', line 79

def get_receiver_definition path
  @receiver_definitions[path]
end

#inspectObject

avoid enormous dump



24
25
26
# File 'lib/solargraph/api_map/cache.rb', line 24

def inspect
  to_s
end

#set_constants(namespace, contexts, value) ⇒ void

This method returns an undefined value.

Parameters:

  • namespace (String)
  • contexts (Array<String>)
  • value (Array<Pin::Base>)


58
59
60
# File 'lib/solargraph/api_map/cache.rb', line 58

def set_constants namespace, contexts, value
  @constants["#{namespace}|#{contexts}"] = value
end

#set_methods(fqns, scope, visibility, deep, value) ⇒ void

This method returns an undefined value.

Parameters:

  • fqns (String)
  • scope (Symbol)
  • visibility (Array<Symbol>)
  • deep (Boolean)
  • value (Array<Pin::Method>)


43
44
45
# File 'lib/solargraph/api_map/cache.rb', line 43

def set_methods fqns, scope, visibility, deep, value
  @methods["#{fqns}|#{scope}|#{visibility}|#{deep}"] = value
end

#set_qualified_namespace(name, context, value) ⇒ void

This method returns an undefined value.

Parameters:

  • name (String)
  • context (String)
  • value (String)


73
74
75
# File 'lib/solargraph/api_map/cache.rb', line 73

def set_qualified_namespace name, context, value
  @qualified_namespaces["#{name}|#{context}"] = value
end

#set_receiver_definition(path, pin) ⇒ void

This method returns an undefined value.

Parameters:



86
87
88
# File 'lib/solargraph/api_map/cache.rb', line 86

def set_receiver_definition path, pin
  @receiver_definitions[path] = pin
end

#to_sObject



19
20
21
# File 'lib/solargraph/api_map/cache.rb', line 19

def to_s
  self.class.to_s
end