# File lib/ruby_lsp/requests/support/common.rb, line 92defcategorized_markdown_from_index_entries(title, entries, max_entries = nil)
markdown_title = "```ruby\n#{title}\n```"definitions = []
content = +""entries = Array(entries)
entries_to_format = max_entries?entries.take(max_entries) :entriesentries_to_format.eachdo|entry|loc = entry.location# We always handle locations as zero based. However, for file links in Markdown we need them to be one# based, which is why instead of the usual subtraction of 1 to line numbers, we are actually adding 1 to# columns. The format for VS Code file URIs is# `file:///path/to/file.rb#Lstart_line,start_column-end_line,end_column`uri = URI::Generic.from_path(
path:entry.file_path,
fragment:"L#{loc.start_line},#{loc.start_column + 1}-#{loc.end_line},#{loc.end_column + 1}",
)
definitions<<"[#{entry.file_name}](#{uri})"content<<"\n\n#{entry.comments.join("\n")}"unlessentry.comments.empty?endadditional_entries_text = ifmax_entries&&entries.length>max_entriesadditional = entries.length-max_entries" | #{additional} other#{additional > 1 ? "s" : ""}"else""end
{
title:markdown_title,
links:"**Definitions**: #{definitions.join(" | ")}#{additional_entries_text}",
documentation:content,
}
end
constant_name(node)
# File lib/ruby_lsp/requests/support/common.rb, line 156defconstant_name(node)
node.full_namerescuePrism::ConstantPathNode::DynamicPartsInConstantPathErrornilend
# File lib/ruby_lsp/requests/support/common.rb, line 73defnot_in_dependencies?(file_path)
BUNDLE_PATH&&!file_path.start_with?(T.must(BUNDLE_PATH)) &&!file_path.start_with?(RbConfig::CONFIG["rubylibdir"])
end
range_from_location(location)
# File lib/ruby_lsp/requests/support/common.rb, line 30defrange_from_location(location)
Interface::Range.new(
start:Interface::Position.new(
line:location.start_line-1,
character:location.start_column,
),
end:Interface::Position.new(line:location.end_line-1, character:location.end_column),
)
end
range_from_node(node)
# File lib/ruby_lsp/requests/support/common.rb, line 17defrange_from_node(node)
loc = node.locationInterface::Range.new(
start:Interface::Position.new(
line:loc.start_line-1,
character:loc.start_column,
),
end:Interface::Position.new(line:loc.end_line-1, character:loc.end_column),
)
end
self_receiver?(node)
# File lib/ruby_lsp/requests/support/common.rb, line 80defself_receiver?(node)
receiver = node.receiverreceiver.nil?||receiver.is_a?(Prism::SelfNode)
end
visible?(node, range)
# File lib/ruby_lsp/requests/support/common.rb, line 41defvisible?(node, range)
returntrueifrange.nil?returnfalseifnode.nil?loc = node.locationrange.cover?(loc.start_line-1) &&range.cover?(loc.end_line-1)
end