Skip to content

Commit

Permalink
merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnyboyC committed Jan 19, 2020
1 parent bbab342 commit 3b66285
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/solargraph/api_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def catalog bundle
reqs.merge bundle.workspace.config.required
local_path_hash.clear
unless bundle.workspace.require_paths.empty?
reqs = @require_diff.unresolved_requires(bundle, reqs.clone, new_map_hash)
local_path_hash = @require_diff.unresolved_requires(bundle, reqs.clone, new_map_hash)
end
reqs.merge implicit.requires
pins.concat implicit.overrides
Expand Down
38 changes: 25 additions & 13 deletions lib/solargraph/api_map/req_diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ def initialize
# @return [Array<String>]
def unresolved_requires bundle, reqs, new_map_hash
if @native
diff_native bundle, reqs, new_map_hash
diff_native(bundle, reqs, new_map_hash)
else
diff_pure bundle, reqs, new_map_hash
diff_pure(bundle, reqs, new_map_hash)
end
end

Expand All @@ -33,6 +33,8 @@ def unresolved_requires bundle, reqs, new_map_hash
# @param new_map_hash [Hash<String, String>]
# @return [Array<String>]
def diff_native bundle, reqs, new_map_hash
local_path_hash = {}

# convert new map hash to a trie
source_trie = Trie.new
new_map_hash.keys.each do |key|
Expand Down Expand Up @@ -78,11 +80,16 @@ def diff_native bundle, reqs, new_map_hash
break if req_node.nil?
end

!req_node.nil?
if req_node.nil?
true
else
local_path_hash[req] = req_node.full_state
false
end
end
end

reqs
local_path_hash
end

# Determine requires that still need processing using trie_fast
Expand All @@ -92,17 +99,22 @@ def diff_native bundle, reqs, new_map_hash
# @param new_map_hash [Hash<String, String>]
# @return [Array<String>]
def diff_pure bundle, reqs, new_map_hash
reqs.reject do |r|
result = false
bundle.workspace.require_paths.each do |l|
pn = Pathname.new(bundle.workspace.directory).join(l, "#{r}.rb")
next unless new_map_hash.keys.include?(pn.to_s)
local_path_hash[r] = pn.to_s
result = true
break
local_path_hash = {}
file_keys = new_map_hash.keys
workspace_path = Pathname.new(bundle.workspace.directory)
reqs.delete_if do |r|
bundle.workspace.require_paths.any? do |base|
pn = workspace_path.join(base, "#{r}.rb").to_s
if file_keys.include? pn
local_path_hash[r] = pn
true
else
false
end
end
result
end

local_path_hash
end

# Find the longest prefix in an array of strings
Expand Down

0 comments on commit 3b66285

Please sign in to comment.