Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 8 additions & 4 deletions lib/ruby_lsp/requests/support/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,25 @@ def each_constant_path_part(node, &block)
end
end

#: (RubyIndexer::Entry entry) -> Integer?
#: (RubyIndexer::Entry entry) -> Integer
def kind_for_entry(entry)
case entry
when RubyIndexer::Entry::Class
Constant::SymbolKind::CLASS
when RubyIndexer::Entry::Module
Constant::SymbolKind::NAMESPACE
when RubyIndexer::Entry::Constant
when RubyIndexer::Entry::Constant, RubyIndexer::Entry::UnresolvedConstantAlias, RubyIndexer::Entry::ConstantAlias
Constant::SymbolKind::CONSTANT
when RubyIndexer::Entry::Method
when RubyIndexer::Entry::Method, RubyIndexer::Entry::UnresolvedMethodAlias, RubyIndexer::Entry::MethodAlias
entry.name == "initialize" ? Constant::SymbolKind::CONSTRUCTOR : Constant::SymbolKind::METHOD
when RubyIndexer::Entry::Accessor
Constant::SymbolKind::PROPERTY
when RubyIndexer::Entry::InstanceVariable
when RubyIndexer::Entry::InstanceVariable, RubyIndexer::Entry::ClassVariable
Constant::SymbolKind::FIELD
when RubyIndexer::Entry::GlobalVariable
Constant::SymbolKind::VARIABLE
else
Constant::SymbolKind::NULL
end
end
end
Expand Down
21 changes: 21 additions & 0 deletions test/requests/support/common_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# typed: true
# frozen_string_literal: true

require "test_helper"

module RubyLsp
class CommonTest < Minitest::Test
include Requests::Support::Common

def test_kinds_are_defined_for_every_entry
index = RubyIndexer::Index.new
index.index_all

entries = index.instance_variable_get(:@entries).values.flatten
entries.each do |entry|
kind = kind_for_entry(entry)
refute_equal(kind, Constant::SymbolKind::NULL, "Kind not defined for entry: #{entry.inspect}")
end
end
end
end