Class: Solargraph::Pin::Attribute
- Inherits:
-
BaseMethod
- Object
- Base
- Closure
- BaseMethod
- Solargraph::Pin::Attribute
- Defined in:
- lib/solargraph/pin/attribute.rb
Instance Attribute Summary collapse
-
#access ⇒ ::Symbol
readonly
:reader or :writer.
Attributes inherited from BaseMethod
Attributes inherited from Closure
Attributes inherited from Base
#code_object, #location, #name, #return_type
Attributes included from Common
Instance Method Summary collapse
- #completion_item_kind ⇒ Object
-
#initialize(access: :reader, **splat) ⇒ Attribute
constructor
A new instance of Attribute.
- #path ⇒ Object
- #probe(api_map) ⇒ Object
- #symbol_kind ⇒ Object
Methods inherited from BaseMethod
#documentation, #explicit?, #parameter_names, #parameters, #return_type, #typify
Methods inherited from Closure
Methods inherited from Base
#==, #comments, #deprecated?, #directives, #docstring, #filename, #identity, #infer, #inspect, #macros, #maybe_directives?, #nearly?, #probed?, #proxied?, #proxy, #realize, #to_s, #try_merge!, #typify, #variable?
Methods included from Documenting
Methods included from Conversions
#completion_item, #detail, #link_documentation, #reset_conversions, #resolve_completion_item, #signature_help, #text_documentation
Methods included from Common
#binder, #comments, #context, #name, #namespace, #return_type
Constructor Details
#initialize(access: :reader, **splat) ⇒ Attribute
Returns a new instance of Attribute.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/solargraph/pin/attribute.rb', line 10 def initialize access: :reader, **splat super(**splat) @access = access if access == :writer parameters.push( Pin::Parameter.new(name: 'value', decl: :arg, closure: self) ) if return_type.defined? docstring.add_tag YARD::Tags::Tag.new(:param, '', return_type.to_s.split(', '), 'value') end end end |
Instance Attribute Details
#access ⇒ ::Symbol (readonly)
Returns :reader or :writer.
7 8 9 |
# File 'lib/solargraph/pin/attribute.rb', line 7 def access @access end |
Instance Method Details
#completion_item_kind ⇒ Object
23 24 25 |
# File 'lib/solargraph/pin/attribute.rb', line 23 def completion_item_kind Solargraph::LanguageServer::CompletionItemKinds::PROPERTY end |
#path ⇒ Object
31 32 33 |
# File 'lib/solargraph/pin/attribute.rb', line 31 def path @path ||= namespace + (scope == :instance ? '#' : '.') + name end |
#probe(api_map) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/solargraph/pin/attribute.rb', line 35 def probe api_map types = [] varname = "@#{name.gsub(/=$/, '')}" pins = api_map.get_instance_variable_pins(binder.namespace, binder.scope).select { |iv| iv.name == varname } pins.each do |pin| type = pin.typify(api_map) type = pin.probe(api_map) if type.undefined? types.push type if type.defined? end return ComplexType::UNDEFINED if types.empty? ComplexType.try_parse(*types.map(&:tag).uniq) end |
#symbol_kind ⇒ Object
27 28 29 |
# File 'lib/solargraph/pin/attribute.rb', line 27 def symbol_kind Solargraph::LanguageServer::SymbolKinds::PROPERTY end |