Class: RubyLsp::TypeInferrer
- Inherits:
-
Object
- Object
- RubyLsp::TypeInferrer
- Extended by:
- T::Sig
- Defined in:
- lib/ruby_lsp/type_inferrer.rb
Overview
A minimalistic type checker to try to resolve types that can be inferred without requiring a type system or annotations
Defined Under Namespace
Classes: GuessedType, Type
Instance Attribute Summary collapse
-
#experimental_features ⇒ Object
writeonly
Sets the attribute experimental_features.
Instance Method Summary collapse
- #infer_receiver_type(node_context) ⇒ Object
-
#initialize(index, experimental_features = true) ⇒ TypeInferrer
constructor
A new instance of TypeInferrer.
Constructor Details
#initialize(index, experimental_features = true) ⇒ TypeInferrer
Returns a new instance of TypeInferrer.
14 15 16 17 |
# File 'lib/ruby_lsp/type_inferrer.rb', line 14 def initialize(index, experimental_features = true) @index = index @experimental_features = experimental_features end |
Instance Attribute Details
#experimental_features=(value) ⇒ Object (writeonly)
Sets the attribute experimental_features
11 12 13 |
# File 'lib/ruby_lsp/type_inferrer.rb', line 11 def experimental_features=(value) @experimental_features = value end |
Instance Method Details
#infer_receiver_type(node_context) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ruby_lsp/type_inferrer.rb', line 20 def infer_receiver_type(node_context) node = node_context.node case node when Prism::CallNode infer_receiver_for_call_node(node, node_context) when Prism::InstanceVariableReadNode, Prism::InstanceVariableAndWriteNode, Prism::InstanceVariableWriteNode, Prism::InstanceVariableOperatorWriteNode, Prism::InstanceVariableOrWriteNode, Prism::InstanceVariableTargetNode, Prism::SuperNode, Prism::ForwardingSuperNode self_receiver_handling(node_context) end end |