repl_type_completor 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8bc2a3dc75c556f643d844c58fc4e414f4452319d38a55ba198adaef5833a51
4
- data.tar.gz: 3c2c38eeb3345e95a551312e8c395cce4f05031114141b91db2683a17c600caa
3
+ metadata.gz: 8060250e5e4f5251ad0e55bbe62123e7990c77b390f60b20b8ededd06baadeba
4
+ data.tar.gz: afb502380d8e26217a95e7a8e273bf3a93242ce8f2f88acadfffe4f462a10a3d
5
5
  SHA512:
6
- metadata.gz: 15f55aa4f8f9da9e0ad8fdac3b1905a07237d18d5ea7ffe59ccd1ee4125c1b79cb4baff6db62f8abfcf8cbcac958cc5280d4495d90176532de052a8074e6ab07
7
- data.tar.gz: ee0d6bb8ba290779a4f47b1b164db71158a1f1f7baa9f42f2672eb53a81bb624ba0924cfc733e841df77cb6921a1eb591e9fbe912f22a4aa17dbf808d325388f
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.4"
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.4
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-08 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
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.19.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: 0.26.0
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +24,6 @@ dependencies:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.19.0
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: 0.26.0
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: rbs
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -92,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
86
  - !ruby/object:Gem::Version
93
87
  version: '0'
94
88
  requirements: []
95
- rubygems_version: 3.5.3
89
+ rubygems_version: 3.5.9
96
90
  signing_key:
97
91
  specification_version: 4
98
92
  summary: Type based completion for REPL.