Class: YARD::Handlers::RBS::AttributeHandler

Inherits:
Base
  • Object
show all
Defined in:
lib/yard/handlers/rbs/attribute_handler.rb

Overview

Handles RBS attr_reader, attr_writer, and attr_accessor declarations.

Registers one or two CodeObjects::MethodObject instances (reader and/or writer) with @return / @param tags derived from the RBS type.

Constant Summary

Constants included from CodeObjects

CodeObjects::BUILTIN_ALL, CodeObjects::BUILTIN_CLASSES, CodeObjects::BUILTIN_EXCEPTIONS, CodeObjects::BUILTIN_EXCEPTIONS_HASH, CodeObjects::BUILTIN_MODULES, CodeObjects::CONSTANTMATCH, CodeObjects::CONSTANTSTART, CodeObjects::CSEP, CodeObjects::CSEPQ, CodeObjects::ISEP, CodeObjects::ISEPQ, CodeObjects::METHODMATCH, CodeObjects::METHODNAMEMATCH, CodeObjects::NAMESPACEMATCH, CodeObjects::NSEP, CodeObjects::NSEPQ

Instance Method Summary collapse

Methods included from CodeObjects::NamespaceMapper

#clear_separators, #default_separator, on_invalidate, #register_separator, #separators, #separators_for_type, #separators_match, #types_for_separator, #unregister_separator_by_type

Constructor Details

This class inherits a constructor from YARD::Handlers::Base

Instance Method Details

#processvoid

This method returns an undefined value.

Main processing callback



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/yard/handlers/rbs/attribute_handler.rb', line 9

process do
  attr_name  = statement.name
  rbs_type   = statement.attr_rbs_type
  yard_types = rbs_type ? YARD::Handlers::RBS::MethodHandler.rbs_type_to_yard_types(rbs_type) : nil
  mscope     = statement.visibility == :class ? :class : :instance

  case statement.type
  when :attr_reader
    register_reader(attr_name, yard_types, mscope)
  when :attr_writer
    register_writer(attr_name, yard_types, mscope)
  when :attr_accessor
    register_reader(attr_name, yard_types, mscope)
    register_writer(attr_name, yard_types, mscope)
  end
end