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) => 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.



94
95
96
# File 'lib/solargraph/api_map/cache.rb', line 94

def clear
  all_caches.each(&:clear)
end

#empty?Boolean

Returns:

  • (Boolean)


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

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

#get_clip(cursor) ⇒ SourceMap::Clip?

Parameters:

Returns:



83
84
85
# File 'lib/solargraph/api_map/cache.rb', line 83

def get_clip(cursor)
  @clips["#{cursor.filename}|#{cursor.range.inspect}|#{cursor.node&.to_sexp}"]
end

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

Parameters:

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

Returns:



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

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:



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

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)


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

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

#get_receiver_definition(path) ⇒ Pin::Method

Parameters:

  • path (String)

Returns:



70
71
72
# File 'lib/solargraph/api_map/cache.rb', line 70

def get_receiver_definition path
  @receiver_definitions[path]
end

#set_clip(cursor, clip) ⇒ Object

Parameters:



89
90
91
# File 'lib/solargraph/api_map/cache.rb', line 89

def set_clip(cursor, clip)
  @clips["#{cursor.filename}|#{cursor.range.inspect}|#{cursor.node&.to_sexp}"] = clip
end

#set_constants(namespace, contexts, value) ⇒ void

This method returns an undefined value.

Parameters:

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


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

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>)


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

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)


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

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:



77
78
79
# File 'lib/solargraph/api_map/cache.rb', line 77

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