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

def initialize
  @methods = {}
  @constants = {}
  @qualified_namespaces = {}
  @receiver_definitions = {}
end

Instance Method Details

#clearvoid

This method returns an undefined value.



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

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

#empty?Boolean

Returns:

  • (Boolean)


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

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

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

Returns:



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

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

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

Returns:



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

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

#get_qualified_namespace(name, context) ⇒ String

Returns:

  • (String)


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

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

#get_receiver_definition(path) ⇒ Pin::Method

Returns:



45
46
47
# File 'lib/solargraph/api_map/cache.rb', line 45

def get_receiver_definition path
  @receiver_definitions[path]
end

#receiver_defined?(path) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/solargraph/api_map/cache.rb', line 40

def receiver_defined? path
  @receiver_definitions.key? path
end

#set_constants(namespace, context, value) ⇒ Object



27
28
29
# File 'lib/solargraph/api_map/cache.rb', line 27

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

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



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

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

#set_qualified_namespace(name, context, value) ⇒ Object



36
37
38
# File 'lib/solargraph/api_map/cache.rb', line 36

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

#set_receiver_definition(path, pin) ⇒ Object



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

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