lib/steep/project/completion_provider.rb in steep-0.30.0 vs lib/steep/project/completion_provider.rb in steep-0.31.0
- old
+ new
@@ -27,15 +27,17 @@
@source_text = source_text
@path = path
@subtyping = subtyping
end
- def type_check!(text)
+ def type_check!(text, line:, column:)
@modified_text = text
Steep.measure "parsing" do
- @source = SourceFile.parse(text, path: path, factory: subtyping.factory)
+ @source = SourceFile
+ .parse(text, path: path, factory: subtyping.factory)
+ .without_unrelated_defs(line: line, column: column)
end
Steep.measure "typechecking" do
@typing = SourceFile.type_check(source, subtyping: subtyping)
end
@@ -51,11 +53,11 @@
position = Position.new(line: line, column: column)
begin
Steep.logger.tagged "completion_provider#run(line: #{line}, column: #{column})" do
Steep.measure "type_check!" do
- type_check!(source_text)
+ type_check!(source_text, line: line, column: column)
end
end
Steep.measure "completion item collection" do
items_for_trigger(position: position)
@@ -64,15 +66,15 @@
rescue Parser::SyntaxError => exn
Steep.logger.error "recovering syntax error: #{exn.inspect}"
case possible_trigger
when "."
source_text[index-1] = " "
- type_check!(source_text)
+ type_check!(source_text, line: line, column: column)
items_for_dot(position: position)
when "@"
source_text[index-1] = " "
- type_check!(source_text)
+ type_check!(source_text, line: line, column: column)
items_for_atmark(position: position)
else
[]
end
end
@@ -217,17 +219,17 @@
end
def items_for_atmark(position:)
# @ ←
shift_pos = position-1
- node, *parents = source.find_nodes(line: shift_pos.line, column: shift_pos.column)
+ node, *_ = source.find_nodes(line: shift_pos.line, column: shift_pos.column)
node ||= source.node
return [] unless node
context = typing.context_at(line: position.line, column: position.column)
items = []
- instance_variable_items_for_context(context, prefix: "", position: position, items: items)
+ instance_variable_items_for_context(context, prefix: "@", position: position, items: items)
items
end
def method_items_for_receiver_type(type, include_private:, prefix:, position:, items:)
range = range_for(position, prefix: prefix)