Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
821024c
Document a log level env variable
apiology Apr 13, 2025
772217c
Fix logger reference
apiology Apr 13, 2025
c15e157
Fix env var name
apiology Apr 13, 2025
ccf3be0
Merge branch 'master' into logging_env_variable
apiology Apr 15, 2025
87c7e4f
Allow log level to be overridden per file
apiology Apr 18, 2025
f2baf01
Various debugging-related log statements
apiology Apr 18, 2025
83e133d
Various debugging-related log statements
apiology Apr 19, 2025
6348b85
Merge branch 'master' into debug_logging
apiology Apr 19, 2025
1074b60
Populate location information from RBS files (#768)
apiology Apr 16, 2025
020a7e9
Consolidate parameter handling into Pin::Callable (#844)
apiology Apr 16, 2025
c008197
Adjust local variable presence to start after assignment, not before …
apiology Apr 19, 2025
9aa5e36
Resolve params from ref tags (#872)
castwide Apr 19, 2025
a94221a
Remove Library#folding_ranges
castwide Apr 19, 2025
cb29ac5
Disable a couple of particularly noisy logs by default
apiology Apr 20, 2025
67dab54
Fix numeric vs symbol logic
apiology Apr 20, 2025
eb49ddb
Avoid marshaling issues
apiology Apr 21, 2025
4eab3f2
Various debugging-related log statements
apiology Apr 24, 2025
d4b7644
Add missing include statement
apiology Apr 24, 2025
4e3496f
Merge branch 'master' into debug_logging
apiology Apr 25, 2025
5379efb
Various debugging-related log statements
apiology Apr 26, 2025
d8a49c6
Merge remote-tracking branch 'castwide/master' into debug_logging
apiology Apr 26, 2025
55a2e26
Various debugging-related log statements
apiology Apr 28, 2025
b84b78f
Merge branch 'master' into debug_logging
apiology Apr 28, 2025
5117e3c
Fix merge issues
apiology Apr 28, 2025
a3081c5
Merge branch 'master' into logging_env_variable
apiology Apr 29, 2025
beacbc1
Fix merge issue
apiology Apr 29, 2025
d2b017c
Add missing bits
apiology Apr 29, 2025
9cde92d
Merge branch 'master' into debug_logging
apiology May 2, 2025
c2fb9f7
Improve Parameter logs
apiology May 3, 2025
153f78e
More debug logging
apiology May 5, 2025
aca89ab
Merge branch 'master' into debug_logging
apiology May 18, 2025
2875d68
Re-enable support for .gem_rbs_collection directories
apiology May 19, 2025
961d2e0
Try harder fetching RBS from gem
apiology May 19, 2025
6472875
GemPins pin merging improvements
apiology May 21, 2025
8142fa0
GemPins pin merging improvements
apiology May 21, 2025
de8506a
GemPins pin merging improvements
apiology May 21, 2025
ded58a6
GemPins pin merging improvements
apiology May 21, 2025
f97cad5
GemPins pin merging improvements
apiology May 21, 2025
70d9106
GemPins pin merging improvements
apiology May 22, 2025
2e1b0eb
Support ActiveSupport::Concern pattern for class methods
apiology May 22, 2025
4e66928
Improve parameter setting
apiology May 22, 2025
56f4699
GemPins pin merging improvements
apiology May 22, 2025
ed054c7
GemPins pin merging improvements
apiology May 22, 2025
44cbbdb
Support class-scoped aliases and attributes from RBS
apiology May 22, 2025
998dc61
Improved handling of YARD macros
apiology May 22, 2025
4bc4b25
Tuple enabler: infer literal types and use them for signature selecti…
apiology May 26, 2025
a60ff66
Merge remote-tracking branch 'castwide/master' into debug_logging
apiology May 26, 2025
72eb43f
Mark asserts pending different PRs
apiology May 26, 2025
6141ede
Tweak README text
apiology May 26, 2025
16ad2c1
Add ::ClassMethods support
apiology Jun 1, 2025
f346892
Avoid bad sources of return_type when possible
apiology Jun 1, 2025
108f2dd
Merge branch 'master' into combine_pins
apiology Jun 1, 2025
9a4a9e3
Merge branch 'master' into reenable_rbs_collection
apiology Jun 1, 2025
e29a28c
Prefer method pins wtih non-undefined signatures
apiology Jun 1, 2025
3c37bc2
Merge branch 'master' into class_scope
apiology Jun 1, 2025
5d4b412
Merge remote-tracking branch 'origin/master' into debug_logging
apiology Jun 1, 2025
b464aea
Fix merge
apiology Jun 1, 2025
cb55bc8
Ensure overrides apply to all pins for a path, since we use all
apiology Jun 2, 2025
5a8e828
Reset method parameters and block if needed in reset_generated!
apiology Jun 2, 2025
620e62c
Block debugging
apiology Jun 2, 2025
2aa6005
Merge branch 'master' into combine_pins
apiology Jun 2, 2025
784eb27
rbs_path -> rbs_collection_path
apiology Jun 7, 2025
b65b2ba
Recreate docmap when rbs_collection_path changes
apiology Jun 7, 2025
e3042f6
Fix doc_map reference
apiology Jun 7, 2025
2e09267
Cache combined pins on disk as well
apiology Jun 11, 2025
8c311a8
Add safety check
apiology Jun 11, 2025
7ec55ba
Add safety check
apiology Jun 11, 2025
4916a38
Better logging / safety checks
apiology Jun 11, 2025
d36ff69
Better logging / safety checks
apiology Jun 11, 2025
6508456
Better logging / safety checks
apiology Jun 11, 2025
4463546
Better logging / safety checks
apiology Jun 11, 2025
a97cd99
Better logging / safety checks
apiology Jun 11, 2025
5b1fc17
Adjust log levels
apiology Jun 11, 2025
a56cf1f
Handle un-installed RBS collection case
apiology Jun 11, 2025
277aa3d
Handle un-installed RBS collection case
apiology Jun 11, 2025
419ae6d
Handle un-installed RBS collection case
apiology Jun 11, 2025
55e2c02
Handle un-installed RBS collection case
apiology Jun 11, 2025
84cee31
Fix type issue
apiology Jun 11, 2025
c2b4138
Drop excess checks
apiology Jun 11, 2025
d633225
Bugfixes
apiology Jun 12, 2025
02c7c4e
Ensure that pin locations are always populated
apiology Jun 12, 2025
0bbed17
Drop ill-conceived backup location info
apiology Jun 12, 2025
9e413fa
Fix CLI cache/uncache issues
apiology Jun 12, 2025
f3553e7
Add more to dodgy_visibility_source?
apiology Jun 12, 2025
f15c23d
Also clear combined pins in uncache command
apiology Jun 12, 2025
8ab3f13
Comply with YARD documentation on Hash tag format
apiology Jun 14, 2025
da3ca5c
Adjust spec
apiology Jun 14, 2025
75ff83d
Restructure ComplexType specs towards YARD doc compliance
apiology Jun 14, 2025
18f3282
Fix bug, add @todo for typechecker
apiology Jun 15, 2025
a6e42f2
Add some type tags
apiology Jun 15, 2025
314d667
Fix issue found in typechecking
apiology Jun 15, 2025
21c18c8
Log during other gem caching operations too
apiology Jun 15, 2025
f2afc3f
Handle a nil case in Pin::Base#assert_same
apiology Jun 17, 2025
28c16bc
Add annotations for strong typechecking on Pin::Base
apiology Jun 17, 2025
891b224
Handle a block combination situation
apiology Jun 17, 2025
5c79657
Use prism
castwide Jun 23, 2025
3c95bf6
Memoize parser
castwide Jun 23, 2025
4dae11f
Merge branch 'master' into class_scope
apiology Jun 23, 2025
861df6e
Merge branch 'master' into combine_pins
apiology Jun 23, 2025
7d8928f
Merge branch 'master' into improve_pin_location_preparation
apiology Jun 23, 2025
999ada7
Fix merge issues
apiology Jun 24, 2025
380e867
Populate locations in additional, uh, spots
apiology Jun 24, 2025
0195d9d
Merge remote-tracking branch 'origin/master' into reenable_rbs_collec…
apiology Jun 24, 2025
96659a2
Allow for simplified usage from specs
apiology Jun 24, 2025
90211b5
Merge branch 'master' into reenable_rbs_collection
apiology Jun 24, 2025
53e1ee1
Nil guards in flow-sensitive typing
castwide Jun 24, 2025
e4ef9f4
Reimplement global conventions
castwide Apr 7, 2025
4f1a0d6
Allow for conventions in map specs
castwide Apr 7, 2025
883025c
Workspace setting
castwide Jun 24, 2025
e9884b6
Environ requires in specs are resolved
castwide Jun 24, 2025
912afe5
Merge branch 'master' into reenable_rbs_collection
apiology Jun 24, 2025
17e01c4
Merge branch 'master' into combine_pins
apiology Jun 24, 2025
614e5a3
Merge branch 'master' into activesupport_concern
apiology Jun 24, 2025
15c1baa
Merge branch 'master' into class_scope
apiology Jun 24, 2025
f37a7c1
Merge branch 'master' into improve_pin_location_preparation
apiology Jun 24, 2025
2477598
Fix merge issue
apiology Jun 24, 2025
3bfad8b
Fix merge issue
apiology Jun 24, 2025
a187671
Merge remote-tracking branch 'origin/master' into debug_logging
apiology Jun 24, 2025
cff157f
Remove debug output
castwide Jun 24, 2025
bb65dbe
Merge branch 'master' into debug_logging
apiology Jun 24, 2025
2fd785d
Bump version
apiology Jun 24, 2025
e010dd5
Merge remote-tracking branch 'castwide/global-conventions' into 2025-…
apiology Jun 24, 2025
8810a59
Merge branch 'logging_env_variable' into 2025-06-24
apiology Jun 24, 2025
6ef7e5e
Merge branch 'master' into per_file_log_overriding
apiology Jun 24, 2025
fbaf35e
Merge branch 'per_file_log_overriding' into 2025-06-24
apiology Jun 24, 2025
0a54195
Merge branch 'reenable_rbs_collection' into 2025-06-24
apiology Jun 24, 2025
11a0cda
Merge branch 'combine_pins' into 2025-06-24
apiology Jun 24, 2025
dea8d36
Fix merge issue
apiology Jun 24, 2025
b2fca46
Handle cases related to future RBS collection pins
apiology Jun 24, 2025
fba73de
Merge branch 'combine_pins' into 2025-06-24
apiology Jun 24, 2025
e87087c
Adjust tests to match code
apiology Jun 24, 2025
ce9f0dd
Merge branch 'combine_pins' into 2025-06-24
apiology Jun 24, 2025
71ec0d8
Drop assert exclusions
apiology Jun 24, 2025
be7b374
Reenable test
apiology Jun 24, 2025
66a6bc3
Efficiency fixes
apiology Jun 24, 2025
2036a7e
Fix broken <=> approach
apiology Jun 24, 2025
d64fc4b
Merge branch 'combine_pins' into 2025-06-24
apiology Jun 24, 2025
c964032
Merge branch 'flow-sensitive-typing-nil-guards' into 2025-06-24
apiology Jun 24, 2025
d0a4b44
Merge remote-tracking branch 'castwide/prism' into 2025-06-24
apiology Jun 24, 2025
61aa22c
Merge branch 'restructure_complex_type_specs' into 2025-06-24
apiology Jun 24, 2025
6b0012d
Merge branch 'hash_fix' into 2025-06-24
apiology Jun 24, 2025
6e4a90e
Merge branch 'improve_pin_location_preparation' into 2025-06-24
apiology Jun 24, 2025
b97cf33
Merge branch 'class_scope' into 2025-06-24
apiology Jun 25, 2025
4396201
Merge remote-tracking branch 'castwide/remove-library-folding-ranges'…
apiology Jun 25, 2025
5b18935
Merge branch 'debug_logging' into 2025-06-24
apiology Jun 25, 2025
16c76dd
Map RBS 'untyped' type (RBS::Types::Bases::Any) to 'undefined'
apiology Jun 25, 2025
3da027f
Fix specs
apiology Jun 25, 2025
db5c332
Reduce logging volume
apiology Jun 25, 2025
93bbb5d
Fix stdlib/core paths
apiology Jun 25, 2025
f36a69b
Undo mistaken refactor
apiology Jun 25, 2025
da750db
Merge branch 'reenable_rbs_collection' into 2025-06-24
apiology Jun 25, 2025
2e135ae
Undo mistaken refactor
apiology Jun 25, 2025
4546b98
Merge branch 'reenable_rbs_collection' into 2025-06-24
apiology Jun 25, 2025
46ad545
Fix merge issue
apiology Jun 25, 2025
10453e3
Fix merge issue
apiology Jun 25, 2025
6687cd3
Merge branch 'reenable_rbs_collection' into 2025-06-24
apiology Jun 25, 2025
9e0ffe0
Merge branch 'untyped_to_undefined' into 2025-06-24
apiology Jun 25, 2025
3aef4ff
Merge branch 'master' into 2025-06-24
apiology Jun 25, 2025
fc65293
Support ActiveSupport::Concern pattern for class methods
apiology Jun 25, 2025
d177453
Add ::ClassMethods support
apiology Jun 1, 2025
6adb558
Differentiate cache based on YARD plugin used
apiology Jun 26, 2025
a974ae9
Merge branch 'activesupport_concern' into 2025-06-24
apiology Jun 26, 2025
9b7a76e
Fix merge
apiology Jun 26, 2025
5505e37
Fix issue with rooting a namespace
apiology Jun 26, 2025
a175153
Merge branch 'activesupport_concern' into 2025-06-24
apiology Jun 26, 2025
339356f
[regression] Gem caching perf and logging fixes
apiology Jun 29, 2025
c665954
Merge branch 'master' into 2025-06-24
apiology Jun 30, 2025
7423648
Merge branch 'gem_caching_fixes' into 2025-06-24
apiology Jun 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
lib/**/*.rb
--plugin yard-solargraph
--plugin activesupport-concern
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ See [https://solargraph.org/guides](https://solargraph.org/guides) for more tips

### Development

To see more logging when typechecking or running specs, set the
`SOLARGRAPH_LOG` environment variable to `debug` or `info`. `warn` is
the default value.

Code contributions are always appreciated. Feel free to fork the repo and submit pull requests. Check for open issues that could use help. Start new issues to discuss changes that have a major impact on the code or require large time commitments.

### Sponsorship and Donation
Expand Down
56 changes: 51 additions & 5 deletions lib/solargraph/api_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,12 @@ def cursor_at filename, position
# @param position [Position, Array(Integer, Integer)]
# @return [SourceMap::Clip]
def clip_at filename, position
logger.debug { "ApiMap#clip_at(filename=#{filename}, position=#{position}) - start" }

position = Position.normalize(position)
clip(cursor_at(filename, position))
out = clip(cursor_at(filename, position))
logger.debug { "ApiMap#clip_at(filename=#{filename}, position=#{position}) => #{out}" }
out
end

# Create an ApiMap with a workspace in the specified directory.
Expand Down Expand Up @@ -254,6 +258,7 @@ def namespace_exists? name, context = ''
# @param contexts [Array<String>] The contexts
# @return [Array<Solargraph::Pin::Base>]
def get_constants namespace, *contexts
logger.debug { "ApiMap#get_constants(namespace=#{namespace.inspect}, contexts=#{contexts.inspect})" }
namespace ||= ''
contexts.push '' if contexts.empty?
cached = cache.get_constants(namespace, contexts)
Expand All @@ -262,11 +267,13 @@ def get_constants namespace, *contexts
result = []
contexts.each do |context|
fqns = qualify(namespace, context)
logger.debug { "ApiMap#get_constants(namespace=#{namespace.inspect}, contexts=#{contexts.inspect}) - fqns=#{fqns}" }
visibility = [:public]
visibility.push :private if fqns == context
result.concat inner_get_constants(fqns, visibility, skip)
end
cache.set_constants(namespace, contexts, result)
logger.debug { "ApiMap#get_constants(namespace=#{namespace.inspect}, contexts=#{contexts.inspect}) => #{result}" }
result
end

Expand Down Expand Up @@ -323,13 +330,15 @@ def qualify tag, context_tag = ''
# @return [String, nil] fully qualified namespace
def qualify_namespace(namespace, context_namespace = '')
cached = cache.get_qualified_namespace(namespace, context_namespace)
logger.debug { "ApiMap#qualify_namespace(namespace=#{namespace.inspect}, context_namespace=#{context_namespace.inspect}) - cached=#{cached.inspect}" }
return cached.clone unless cached.nil?
result = if namespace.start_with?('::')
inner_qualify(namespace[2..-1], '', Set.new)
else
inner_qualify(namespace, context_namespace, Set.new)
end
cache.set_qualified_namespace(namespace, context_namespace, result)
logger.debug { "ApiMap#qualify_namespace(namespace=#{namespace.inspect}, context_namespace=#{context_namespace.inspect}) => #{result.inspect}" }
result
end

Expand Down Expand Up @@ -362,7 +371,9 @@ def visible_pins(*args, **kwargs, &blk)
# @param namespace [String] A fully qualified namespace
# @return [Enumerable<Solargraph::Pin::ClassVariable>]
def get_class_variable_pins(namespace)
prefer_non_nil_variables(store.get_class_variables(namespace))
out = prefer_non_nil_variables(store.get_class_variables(namespace))
logger.debug { "ApiMap#get_class_variable_pins(namespace=#{namespace.inspect}) => #{out}" }
out
end

# @return [Enumerable<Solargraph::Pin::Base>]
Expand Down Expand Up @@ -707,6 +718,8 @@ def inner_get_methods rooted_tag, scope, visibility, deep, skip, no_core = false
# namespaces; resolving the generics in the method pins is this
# class' responsibility
methods = store.get_methods(fqns, scope: scope, visibility: visibility).sort{ |a, b| a.name <=> b.name }
methods = methods.map(&:as_virtual_class_method) if store.get_includes(fqns).include?('ActiveSupport::Concern') && scope == :class
logger.info { "ApiMap#inner_get_methods(rooted_tag=#{rooted_tag.inspect}, scope=#{scope.inspect}, visibility=#{visibility.inspect}, deep=#{deep.inspect}, skip=#{skip.inspect}, fqns=#{fqns}) - added from store: #{methods}" }
result.concat methods
if deep
if scope == :instance
Expand All @@ -719,6 +732,31 @@ def inner_get_methods rooted_tag, scope, visibility, deep, skip, no_core = false
result.concat inner_get_methods_from_reference(rooted_sc_tag, namespace_pin, rooted_type, scope, visibility, true, skip, no_core)
end
else
store.get_includes(fqns).reverse.each do |include_tag|
rooted_include_tag = qualify(include_tag, rooted_tag)
logger.debug { "ApiMap#inner_get_methods(#{fqns}, #{scope}, #{visibility}, #{deep}) - Handling class include include_tag=#{include_tag}" }
module_extends = store.get_extends(rooted_include_tag)
# ActiveSupport::Concern is syntactic sugar for a common
# pattern to include class methods while mixing-in a Module

# See https://api.rubyonrails.org/classes/ActiveSupport/Concern.html
logger.debug { "ApiMap#inner_get_methods(#{fqns}, #{scope}, #{visibility}, #{deep}) - Handling class include include_tag=#{include_tag}" }
if module_extends.include? 'ActiveSupport::Concern'
unless rooted_include_tag.nil?
# yard-activesupport-concern pulls methods inside
# 'class_methods' blocks into main class visible from YARD
included_class_pins = inner_get_methods_from_reference(rooted_include_tag, namespace_pin, rooted_type, :class, visibility, deep, skip, true)
result.concat included_class_pins

# another pattern is to put class methods inside a submodule
classmethods_include_tag = rooted_include_tag + "::ClassMethods"
included_classmethods_pins = inner_get_methods_from_reference(classmethods_include_tag, namespace_pin, rooted_type, :instance, visibility, deep, skip, true)
result.concat included_classmethods_pins
end
end
end

logger.info { "ApiMap#inner_get_methods(#{fqns}, #{scope}, #{visibility}, #{deep}, #{skip}) - looking for get_extends() from #{fqns}" }
store.get_extends(fqns).reverse.each do |em|
fqem = qualify(em, fqns)
result.concat inner_get_methods(fqem, :instance, visibility, deep, skip, true) unless fqem.nil?
Expand Down Expand Up @@ -781,21 +819,28 @@ def inner_get_methods_from_reference(fq_reference_tag, namespace_pin, type, scop
# @param skip [Set<String>]
# @return [Array<Pin::Base>]
def inner_get_constants fqns, visibility, skip
return [] if fqns.nil? || skip.include?(fqns)
logger.debug { "ApiMap#inner_get_constants(fqns=#{fqns.inspect}, visibility=#{visibility.inspect}, skip=#{skip.inspect}) - starting" }
if fqns.nil? || skip.include?(fqns)
logger.debug { "ApiMap#inner_get_constants(fqns=#{fqns.inspect}, visibility=#{visibility.inspect}, skip=#{skip.inspect}) => [] - fqns=#{fqns.inspect}, skip=#{skip}" }
return []
end
skip.add fqns
result = []
store.get_prepends(fqns).each do |is|
result.concat inner_get_constants(qualify(is, fqns), [:public], skip)
end
result.concat store.get_constants(fqns, visibility)
.sort { |a, b| a.name <=> b.name }
constants = store.get_constants(fqns, visibility)
.sort { |a, b| a.name <=> b.name }
logger.debug { "Constants in #{fqns} with visibility #{visibility}, constants=#{constants}" }
result.concat constants
store.get_includes(fqns).each do |is|
result.concat inner_get_constants(qualify(is, fqns), [:public], skip)
end
fqsc = qualify_superclass(fqns)
unless %w[Object BasicObject].include?(fqsc)
result.concat inner_get_constants(fqsc, [:public], skip)
end
logger.debug { "ApiMap#inner_get_constants(fqns=#{fqns.inspect}, visibility=#{visibility.inspect}, skip=#{skip.inspect}) => #{result}" }
result
end

Expand Down Expand Up @@ -831,6 +876,7 @@ def qualify_superclass fq_sub_tag
# @param skip [Set<String>] Contexts already searched
# @return [String, nil] Fully qualified ("rooted") namespace
def inner_qualify name, root, skip
logger.debug { "ApiMap#inner_qualify(name=#{name.inspect}, root=#{root.inspect}, skip=#{skip.inspect}) - starting" }
return name if name == ComplexType::GENERIC_TAG_NAME
return nil if name.nil?
return nil if skip.include?(root)
Expand Down
10 changes: 8 additions & 2 deletions lib/solargraph/api_map/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ def get_symbols
# @param fqns [String]
# @return [Boolean]
def namespace_exists?(fqns)
fqns_pins(fqns).any?
out = fqns_pins(fqns).any?
logger.debug { "Store#namespace_exists?(#{fqns.inspect}) => #{out}" }
out
end

# @return [Set<String>]
Expand Down Expand Up @@ -195,9 +197,13 @@ def fqns_pins fqns
base = ''
name = fqns
end
fqns_pins_map[[base, name]]
out = fqns_pins_map[[base, name]]
logger.debug { "Store#fqns_pins(#{fqns.inspect}) => #{out}" }
out
end

include Logging

private

def index
Expand Down
11 changes: 9 additions & 2 deletions lib/solargraph/complex_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ def initialize types = [UniqueType::UNDEFINED]
# @param context [String]
# @return [ComplexType]
def qualify api_map, context = ''
logger.debug { "ComplexType#qualify(self=#{self.rooted_tags}, context=#{context.inspect}) - starting" }
red = reduce_object
types = red.items.map do |t|
next t if ['nil', 'void', 'undefined'].include?(t.name)
next t if ['::Boolean'].include?(t.rooted_name)
t.qualify api_map, context
end
ComplexType.new(types).reduce_object
out = ComplexType.new(types).reduce_object
logger.debug { "ComplexType#qualify(self=#{self.rooted_tags}, context=#{context.inspect}) => #{out.rooted_tags}" }
out
end

# @param generics_to_resolve [Enumerable<String>]]
Expand Down Expand Up @@ -225,7 +228,9 @@ def force_rooted
# @return [ComplexType]
def resolve_generics definitions, context_type
result = @items.map { |i| i.resolve_generics(definitions, context_type) }
ComplexType.new(result)
out = ComplexType.new(result)
# logger.debug { "ComplexType#resolve_generics(self=#{rooted_tags}, definitions=#{definitions}, context_type=#{context_type.rooted_tags} => #{out.rooted_tags}" }
out
end

def nullable?
Expand Down Expand Up @@ -405,6 +410,8 @@ def try_parse *strings
BOOLEAN = ComplexType.parse('::Boolean')
BOT = ComplexType.parse('bot')

include Logging

private

# @todo This is a quick and dirty hack that forces `self` keywords
Expand Down
9 changes: 6 additions & 3 deletions lib/solargraph/complex_type/unique_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def resolve_param_generics_from_context(generics_to_resolve, context_type, resol
def resolve_generics definitions, context_type
return self if definitions.nil? || definitions.generics.empty?

transform(name) do |t|
out = transform(name) do |t|
if t.name == GENERIC_TAG_NAME
generic_name = t.subtypes.first&.name
idx = definitions.generics.index(generic_name)
Expand All @@ -337,6 +337,8 @@ def resolve_generics definitions, context_type
t
end
end
# logger.debug { "UniqueType#resolve_generics(self=#{self.rooted_tag}, definitions=#{definitions}, context_type=#{context_type.rooted_tags}) => #{out}" }
out
end

# @yieldparam t [self]
Expand Down Expand Up @@ -410,7 +412,7 @@ def transform(new_name = nil, &transform_type)
# @param context [String] The namespace from which to resolve names
# @return [self, ComplexType, UniqueType] The generated ComplexType
def qualify api_map, context = ''
transform do |t|
out = transform do |t|
next t if t.name == GENERIC_TAG_NAME
next t if t.duck_type? || t.void? || t.undefined?
recon = (t.rooted? ? '' : context)
Expand All @@ -421,6 +423,8 @@ def qualify api_map, context = ''
end
t.recreate(new_name: fqns, make_rooted: true)
end
logger.debug { "UniqueType#qualify(self=#{rooted_tags.inspect}, context=#{context}) => #{out.rooted_tags.inspect}" }
out
end

def selfy?
Expand Down Expand Up @@ -468,7 +472,6 @@ def self.can_root_name?(name)
'::NilClass' => UniqueType::NIL
}.freeze


include Logging
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/solargraph/convention/gemspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def local source_map
'Gem::Specification.new',
%(
@yieldparam [self]
)
),
source: :gemspec,
)
]
)
Expand Down
19 changes: 15 additions & 4 deletions lib/solargraph/doc_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,16 @@ def cache_rbs_collection_pins(gemspec, out)

# @param gemspec [Gem::Specification]
def cache(gemspec, rebuild: false, out: nil)
out.puts("Caching pins for gem #{gemspec.name}:#{gemspec.version}") if out
cache_yard_pins(gemspec, out) if uncached_yard_gemspecs.include?(gemspec) || rebuild
cache_rbs_collection_pins(gemspec, out) if uncached_rbs_collection_gemspecs.include?(gemspec) || rebuild
build_yard = uncached_yard_gemspecs.include?(gemspec) || rebuild
build_rbs_collection = uncached_rbs_collection_gemspecs.include?(gemspec) || rebuild
if build_yard || build_rbs_collection
type = []
type << 'YARD' if build_yard
type << 'RBS collection' if build_rbs_collection
out.puts("Caching #{type.join(' and ')} pins for gem #{gemspec.name}:#{gemspec.version}") if out
end
cache_yard_pins(gemspec, out) if build_yard
cache_rbs_collection_pins(gemspec, out) if build_rbs_collection
end

# @return [Array<Gem::Specification>]
Expand Down Expand Up @@ -121,10 +128,14 @@ def rbs_collection_pins_in_memory
self.class.all_rbs_collection_gems_in_memory[rbs_collection_path] ||= {}
end

def combined_pins_in_memory
def self.all_combined_pins_in_memory
@combined_pins_in_memory ||= {}
end

def combined_pins_in_memory
self.class.all_combined_pins_in_memory
end

# @return [Set<Gem::Specification>]
def dependencies
@dependencies ||= (gemspecs.flat_map { |spec| fetch_dependencies(spec) } - gemspecs).to_set
Expand Down
2 changes: 1 addition & 1 deletion lib/solargraph/gem_pins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def self.combine_method_pins(*pins)
end

# @param yard_pins [Array<Pin::Base>]
# @param rbs_map [RbsMap]
# @param rbs_pins [Array<Pin::Base>]
# @return [Array<Pin::Base>]
def self.combine(yard_pins, rbs_pins)
in_yard = Set.new
Expand Down
13 changes: 1 addition & 12 deletions lib/solargraph/library.rb
Original file line number Diff line number Diff line change
Expand Up @@ -436,17 +436,6 @@ def bench
)
end

# Get an array of foldable ranges for the specified file.
#
# @deprecated The library should not need to handle folding ranges. The
# source itself has all the information it needs.
#
# @param filename [String]
# @return [Array<Range>]
def folding_ranges filename
read(filename).folding_ranges
end

# Create a library from a directory.
#
# @param directory [String] The path to be used for the workspace
Expand Down Expand Up @@ -587,7 +576,7 @@ def cache_errors

# @return [void]
def cache_next_gemspec
return if @cache_progres
return if @cache_progress
spec = (api_map.uncached_yard_gemspecs + api_map.uncached_rbs_collection_gemspecs).
find { |spec| !cache_errors.include?(spec) }
return end_cache_progress unless spec
Expand Down
30 changes: 27 additions & 3 deletions lib/solargraph/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,42 @@ module Logging
'info' => Logger::INFO,
'debug' => Logger::DEBUG
}

@@logger = Logger.new(STDERR, level: DEFAULT_LOG_LEVEL)
configured_level = ENV['SOLARGRAPH_LOG']
level = if LOG_LEVELS.keys.include?(configured_level)
LOG_LEVELS.fetch(configured_level)
else
STDERR.puts("Invalid value for SOLARGRAPH_LOG: #{configured_level.inspect} - valid values are #{LOG_LEVELS.keys}") if configured_level
DEFAULT_LOG_LEVEL
end
@@logger = Logger.new(STDERR, level: level)
# @sg-ignore Fix cvar issue
@@logger.formatter = proc do |severity, datetime, progname, msg|
"[#{severity}] #{msg}\n"
end
@@dev_null_logger = Logger.new('/dev/null')


module_function

# override this in your class to temporarily set a custom
# filtering log level for the class (e.g., suppress any debug
# message by setting it to :info even if it is set elsewhere, or
# show existing debug messages by setting to :debug). @return
# [Symbol]
def log_level
:warn
end

# @return [Logger]
def logger
@@logger
if LOG_LEVELS[log_level.to_s] == DEFAULT_LOG_LEVEL
@@logger
else
new_log_level = LOG_LEVELS[log_level.to_s]
logger = Logger.new(STDERR, level: new_log_level)
logger.formatter = @@logger.formatter
logger
end
end
end
end
Loading