repl_type_completor 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9fd32939443428590da667d339d7bb234b7831f259d4d5fc6f9aa4c89e30265
4
- data.tar.gz: 60893ba2d927272dce119ee977d6c8d3c472af808c80b482f3ee8e420532749a
3
+ metadata.gz: 8060250e5e4f5251ad0e55bbe62123e7990c77b390f60b20b8ededd06baadeba
4
+ data.tar.gz: afb502380d8e26217a95e7a8e273bf3a93242ce8f2f88acadfffe4f462a10a3d
5
5
  SHA512:
6
- metadata.gz: 1012c8e5c03bf2f76d267454c17f95e816d986a82bfc91a8f1ea37a2a562bc28d5c9df69e2ab143ada813a8231ec309520d86a168680a31f13be0caf96cf452b
7
- data.tar.gz: b008d3bf44a71071d3cacd4ee163abb31ccadced36020733dbf562fa603e914855ef215a1820b3d07afbb1ac89fdd107f2aadc20c5a474722cfa3b439dc9038a
6
+ metadata.gz: 99efc8d227d5a8a9003b79f3d397fb223a9c330484beee358b96d6963c03d07ac6b3d651fb0e2403d0b82dd1acaeb58834166e5a29350d0f400f3dd1071b53b7
7
+ data.tar.gz: 04a0c4d76215a73a41714f216a742c4dc620d042e5b34bcc6b8ccfabab006f9cf1417841be6d7a9afb0d7125388a27b9de06025ed1587193a2cf91d93a1c186c
@@ -419,7 +419,8 @@ module ReplTypeCompletor
419
419
  def evaluate_constant_path_write_node(node, scope)
420
420
  receiver = evaluate node.target.parent, scope if node.target.parent
421
421
  value = evaluate node.value, scope
422
- const_path_write receiver, node.target.child.name.to_s, value, scope
422
+ name = const_path_name(node.target)
423
+ const_path_write receiver, name, value, scope
423
424
  value
424
425
  end
425
426
 
@@ -578,12 +579,7 @@ module ReplTypeCompletor
578
579
  end
579
580
  error_types << Types::InstanceType.new(StandardError) if error_types.empty?
580
581
  error_type = Types::UnionType[*error_types]
581
- case node.reference
582
- when Prism::LocalVariableTargetNode, Prism::InstanceVariableTargetNode, Prism::ClassVariableTargetNode, Prism::GlobalVariableTargetNode, Prism::ConstantTargetNode
583
- s[node.reference.name.to_s] = error_type
584
- when Prism::CallTargetNode, Prism::IndexTargetNode
585
- evaluate_multi_write_receiver node.reference, s, nil
586
- end
582
+ evaluate_write node.reference, error_type, s, nil
587
583
  end
588
584
  node.statements ? evaluate(node.statements, s) : Types::NIL
589
585
  end
@@ -843,6 +839,16 @@ module ReplTypeCompletor
843
839
  [args_types, kwargs_types, block_sym_node, !!block_arg]
844
840
  end
845
841
 
842
+ def const_path_name(node)
843
+ if node.respond_to?(:name)
844
+ # ConstantPathNode#name ConstantPathTargetNode#name is added in Prism 0.28.0
845
+ node.name.to_s
846
+ else
847
+ # ConstantPathNode#child ConstantPathTargetNode#child is deprecated in Prism 0.28.0
848
+ node.child.name.to_s
849
+ end
850
+ end
851
+
846
852
  def const_path_write(receiver, name, value, scope)
847
853
  if receiver # receiver::A = value
848
854
  singleton_type = receiver.types.find { _1.is_a? Types::SingletonType }
@@ -871,7 +877,7 @@ module ReplTypeCompletor
871
877
  def evaluate_constant_node_info(node, scope)
872
878
  case node
873
879
  when Prism::ConstantPathNode
874
- name = node.child.name.to_s
880
+ name = const_path_name(node)
875
881
  if node.parent
876
882
  receiver = evaluate node.parent, scope
877
883
  if receiver.is_a? Types::SingletonType
@@ -1042,7 +1048,8 @@ module ReplTypeCompletor
1042
1048
  scope[node.name.to_s] = value
1043
1049
  when Prism::ConstantPathTargetNode
1044
1050
  receiver = evaluated_receivers&.[](node.parent) || evaluate(node.parent, scope) if node.parent
1045
- const_path_write receiver, node.child.name.to_s, value, scope
1051
+ name = const_path_name(node)
1052
+ const_path_write receiver, name, value, scope
1046
1053
  end
1047
1054
  end
1048
1055
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReplTypeCompletor
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.6"
5
5
  end
@@ -101,6 +101,15 @@ module ReplTypeCompletor
101
101
  [op == '::' ? :call_or_const : :call, name, receiver_type, self_call]
102
102
  when Prism::LocalVariableReadNode, Prism::LocalVariableTargetNode
103
103
  [:lvar_or_method, target_node.name.to_s, calculate_scope.call]
104
+ when Prism::ConstantPathNode, Prism::ConstantPathTargetNode
105
+ name = target_node.name.to_s
106
+ if target_node.parent # A::B
107
+ receiver, scope = calculate_type_scope.call(target_node.parent)
108
+ [:const, name, receiver, scope]
109
+ else # ::A
110
+ scope = calculate_scope.call
111
+ [:const, name, Types::SingletonType.new(Object), scope]
112
+ end
104
113
  when Prism::ConstantReadNode, Prism::ConstantTargetNode
105
114
  name = target_node.name.to_s
106
115
  if parents.last.is_a? Prism::ConstantPathNode
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repl_type_completor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - tompng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-29 00:00:00.000000000 Z
11
+ date: 2024-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prism