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
# File 'lib/solargraph/api_map/cache.rb', line 6

def initialize
  # @type [Hash{Array => Array<Pin::Method>}]
  @methods = {}
  @constants = {}
  @qualified_namespaces = {}
  @receiver_definitions = {}
end

Instance Method Details

#clearvoid

This method returns an undefined value.



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

def clear
  @methods.clear
  @constants.clear
  @qualified_namespaces.clear
  @receiver_definitions.clear
end

#empty?Boolean

Returns:

  • (Boolean)


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

def empty?
  @methods.empty? &&
    @constants.empty? &&
    @qualified_namespaces.empty? &&
    @receiver_definitions.empty?
end

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

Returns:



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

def get_constants namespace, context
  @constants[[namespace, context]]
end

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

Returns:



15
16
17
# File 'lib/solargraph/api_map/cache.rb', line 15

def get_methods fqns, scope, visibility, deep
  @methods[[fqns, scope, visibility.sort, deep]]
end

#get_qualified_namespace(name, context) ⇒ String

Returns:

  • (String)


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

def get_qualified_namespace name, context
  @qualified_namespaces[[name, context]]
end

#get_receiver_definition(path) ⇒ Pin::Method

Returns:



47
48
49
# File 'lib/solargraph/api_map/cache.rb', line 47

def get_receiver_definition path
  @receiver_definitions[path]
end

#receiver_defined?(path) ⇒ Boolean

Returns:

  • (Boolean)


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

def receiver_defined? path
  @receiver_definitions.key? path
end

#set_constants(namespace, context, value) ⇒ Object



29
30
31
# File 'lib/solargraph/api_map/cache.rb', line 29

def set_constants namespace, context, value
  @constants[[namespace, context]] = value
end

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

Returns:



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

def set_methods fqns, scope, visibility, deep, value
  @methods[[fqns, scope, visibility.sort, deep]] = value
end

#set_qualified_namespace(name, context, value) ⇒ Object



38
39
40
# File 'lib/solargraph/api_map/cache.rb', line 38

def set_qualified_namespace name, context, value
  @qualified_namespaces[[name, context]] = value
end

#set_receiver_definition(path, pin) ⇒ Object



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

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