Class: RBS::Source::Ruby
- Inherits:
-
Object
- Object
- RBS::Source::Ruby
- Defined in:
- lib/rbs/source.rb,
sig/source.rbs
Instance Attribute Summary collapse
-
#buffer ⇒ Buffer
readonly
Returns the value of attribute buffer.
-
#declarations ⇒ Array[AST::Ruby::Declarations::t]
readonly
Returns the value of attribute declarations.
-
#diagnostics ⇒ Array[InlineParser::Diagnostic::t]
readonly
Returns the value of attribute diagnostics.
-
#prism_result ⇒ Prism::ParseResult
readonly
Returns the value of attribute prism_result.
Instance Method Summary collapse
-
#== ⇒ Boolean
Compares the type declaration between
selfandother. - #each_declaration_type_name(names, decl, &block) ⇒ Object
- #each_type_name {|arg0| ... } ⇒ Object
-
#initialize(buffer, prism, declarations, diagnostics) ⇒ Ruby
constructor
A new instance of Ruby.
Constructor Details
#initialize(buffer, prism, declarations, diagnostics) ⇒ Ruby
Returns a new instance of Ruby.
58 59 60 61 62 63 |
# File 'lib/rbs/source.rb', line 58 def initialize(buffer, prism, declarations, diagnostics) @buffer = buffer @prism_result = prism @declarations = declarations @diagnostics = diagnostics end |
Instance Attribute Details
#buffer ⇒ Buffer (readonly)
Returns the value of attribute buffer.
53 54 55 |
# File 'lib/rbs/source.rb', line 53 def buffer @buffer end |
#declarations ⇒ Array[AST::Ruby::Declarations::t] (readonly)
Returns the value of attribute declarations.
55 56 57 |
# File 'lib/rbs/source.rb', line 55 def declarations @declarations end |
#diagnostics ⇒ Array[InlineParser::Diagnostic::t] (readonly)
Returns the value of attribute diagnostics.
56 57 58 |
# File 'lib/rbs/source.rb', line 56 def diagnostics @diagnostics end |
#prism_result ⇒ Prism::ParseResult (readonly)
Returns the value of attribute prism_result.
54 55 56 |
# File 'lib/rbs/source.rb', line 54 def prism_result @prism_result end |
Instance Method Details
#== ⇒ Boolean
Compares the type declaration between self and other
The comparison is based on the AST structure. Differences on Ruby code implementation may be ignored.
45 |
# File 'sig/source.rbs', line 45
def ==: (other: Ruby) -> bool
|
#each_declaration_type_name(names, decl, &block) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/rbs/source.rb', line 76 def each_declaration_type_name(names, decl, &block) case decl when AST::Ruby::Declarations::ClassDecl decl.each_decl do |d| each_declaration_type_name(names, d, &block) end type_name = decl.class_name when AST::Ruby::Declarations::ModuleDecl decl.each_decl do |d| each_declaration_type_name(names, d, &block) end type_name = decl.module_name end if type_name unless names.include?(type_name) yield type_name names << type_name end end end |
#each_type_name ⇒ void #each_type_name ⇒ Enumerator[TypeName]
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rbs/source.rb', line 65 def each_type_name(&block) if block names = Set[] #: Set[TypeName] declarations.each do |decl| each_declaration_type_name(names, decl, &block) end else enum_for :each_type_name end end |