Class: Solargraph::Pin::Reference
- Defined in:
- lib/solargraph/pin/reference.rb,
lib/solargraph/pin/reference/extend.rb,
lib/solargraph/pin/reference/include.rb,
lib/solargraph/pin/reference/prepend.rb,
lib/solargraph/pin/reference/require.rb,
lib/solargraph/pin/reference/override.rb,
lib/solargraph/pin/reference/superclass.rb,
lib/solargraph/pin/reference/type_alias.rb
Defined Under Namespace
Classes: Extend, Include, Override, Prepend, Require, Superclass, TypeAlias
Constant Summary
Constants included from Logging
Logging::DEFAULT_LOG_LEVEL, Logging::LOG_LEVELS
Instance Attribute Summary collapse
-
#generic_values ⇒ Object
readonly
Returns the value of attribute generic_values.
Attributes inherited from Base
#code_object, #combine_priority, #directives, #docstring, #location, #name, #path, #return_type, #source, #type_location
Attributes included from Common
Instance Method Summary collapse
-
#initialize(generic_values: [], **splat) ⇒ Reference
constructor
A Reference is a pin that associates a type with another type.
-
#reference_gates ⇒ Array<String>
@sg-ignore Need to add nil check here.
- #type ⇒ ComplexType
Methods inherited from Base
#==, #all_location_text, #all_rooted?, #assert_location_provided, #assert_same, #assert_same_array_content, #assert_same_count, #assert_same_macros, #assert_source_provided, #best_location, #choose, #choose_longer, #choose_node, #choose_pin_attr, #choose_pin_attr_with_same_name, #choose_priority, #closure, #combine_closure, #combine_directives, #combine_name, #combine_return_type, #combine_with, #comments, #completion_item_kind, #deprecated?, #desc, #dodgy_return_type_source?, #erase_generics, #filename, #gates, #identity, #infer, #inner_desc, #inspect, #macros, #maybe_directives?, #nearly?, #needs_consistent_name?, #prefer_rbs_location, #presence_certain?, #probe, #probed?, #proxied?, #proxy, #rbs_location?, #realize, #reset_generated!, #resolve_generics, #resolve_generics_from_context, #symbol_kind, #to_rbs, #to_s, #transform_types, #type_desc, #typify, #variable?
Methods included from Logging
Methods included from Documenting
#documentation, normalize_indentation, strip_html_comments
Methods included from Conversions
#completion_item, #completion_item_kind, #deprecated?, #detail, #link_documentation, #probed?, #proxied?, #reset_conversions, #resolve_completion_item, #signature_help, #text_documentation
Methods included from Common
#binder, #closure, #closure=, #comments, #name, #namespace, #path, #reset_generated!, #return_type, #source
Constructor Details
#initialize(generic_values: [], **splat) ⇒ Reference
can the above be represented in a less subtle way?
consider refactoring so that we can replicate more
A Reference is a pin that associates a type with another type. The existing type is marked as the closure. The name of the type we’re associating with it is the ‘name’ field, and subtypes are in the ‘generic_values’ field.
These pins are a little different - the name is a rooted name, which may be relative or absolute, preceded with ::, not a fully qualified namespace, which is implicitly in the root namespace and is never preceded by ::.
complex types like Hash=> Integer and has both key types and subtypes.
34 35 36 37 |
# File 'lib/solargraph/pin/reference.rb', line 34 def initialize generic_values: [], **splat super(**splat) @generic_values = generic_values end |
Instance Attribute Details
#generic_values ⇒ Object (readonly)
Returns the value of attribute generic_values.
14 15 16 |
# File 'lib/solargraph/pin/reference.rb', line 14 def generic_values @generic_values end |
Instance Method Details
#reference_gates ⇒ Array<String>
@sg-ignore Need to add nil check here
53 54 55 56 |
# File 'lib/solargraph/pin/reference.rb', line 53 def reference_gates # @sg-ignore Need to add nil check here closure.gates end |
#type ⇒ ComplexType
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/solargraph/pin/reference.rb', line 40 def type @type ||= ComplexType.try_parse( name + if generic_values&.length&.> 0 "<#{generic_values.join(', ')}>" else '' end ) end |