lib/steep/project/hover_content.rb in steep-0.14.0 vs lib/steep/project/hover_content.rb in steep-0.15.0

- old
+ new

@@ -40,27 +40,33 @@ when SourceFile::TypeCheckStatus node, *parents = status.source.find_nodes(line: line, column: column) if node case node.type - when :lvar, :lvasgn + when :lvar var_name = node.children[0] - context = status.typing.context_of(node: node) - var_type = context.type_env.get(lvar: var_name.name) + context = status.typing.context_at(line: line, column: column) + var_type = context.lvar_env[var_name.name] || AST::Types::Any.new(location: nil) VariableContent.new(node: node, name: var_name.name, type: var_type, location: node.location.name) + when :lvasgn + var_name, rhs = node.children + context = status.typing.context_at(line: line, column: column) + type = context.lvar_env[var_name.name] || status.typing.type_of(node: rhs) + + VariableContent.new(node: node, name: var_name.name, type: type, location: node.location.name) when :send receiver, method_name, *_ = node.children result_node = if parents[0]&.type == :block parents[0] else node end - context = status.typing.context_of(node: result_node) + context = status.typing.context_at(line: line, column: column) receiver_type = if receiver status.typing.type_of(node: receiver) else context.self_type @@ -96,10 +102,10 @@ type: status.typing.type_of(node: result_node), definition: definition, location: result_node.location.expression ) when :def, :defs - context = status.typing.context_of(node: node) + context = status.typing.context_at(line: line, column: column) method_context = context.method_context if method_context DefinitionContent.new( node: node,