lib/steep/services/hover_content.rb in steep-0.42.0 vs lib/steep/services/hover_content.rb in steep-0.43.0
- old
+ new
@@ -41,10 +41,11 @@
end
def typecheck(target, path:, content:, line:, column:)
subtyping = service.signature_services[target.name].current_subtyping or return
source = Source.parse(content, path: path, factory: subtyping.factory)
+ source = source.without_unrelated_defs(line: line, column: column)
Services::TypeCheckService.type_check(source: source, subtyping: subtyping)
rescue
nil
end
@@ -60,18 +61,18 @@
if node
case node.type
when :lvar
var_name = node.children[0]
context = typing.context_at(line: line, column: column)
- var_type = context.lvar_env[var_name.name] || AST::Types::Any.new(location: nil)
+ var_type = context.lvar_env[var_name] || AST::Types::Any.new(location: nil)
- VariableContent.new(node: node, name: var_name.name, type: var_type, location: node.location.name)
+ VariableContent.new(node: node, name: var_name, type: var_type, location: node.location.name)
when :lvasgn
var_name, rhs = node.children
context = typing.context_at(line: line, column: column)
- type = context.lvar_env[var_name.name] || typing.type_of(node: rhs)
+ type = context.lvar_env[var_name] || typing.type_of(node: rhs)
- VariableContent.new(node: node, name: var_name.name, type: type, location: node.location.name)
+ VariableContent.new(node: node, name: var_name, type: type, location: node.location.name)
when :send
receiver, method_name, *_ = node.children
result_node = if parents[0]&.type == :block