Class: Rbs::Merge::Backends::RbsBackend::Tree Private

Inherits:
TreeHaver::Base::Tree
  • Object
show all
Defined in:
lib/rbs/merge/backends/rbs_backend.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

RBS tree wrapper

Wraps RBS parse results behind the current TreeHaver tree API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(declarations, source: nil, directives: [], errors: []) ⇒ Tree

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Tree.



219
220
221
222
223
224
# File 'lib/rbs/merge/backends/rbs_backend.rb', line 219

def initialize(declarations, source: nil, directives: [], errors: [])
  super(declarations, source: source)
  @declarations = declarations
  @directives = directives
  @errors = errors
end

Instance Attribute Details

#declarationsArray<::RBS::AST::Declarations::Base> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the declarations.

Returns:

  • (Array<::RBS::AST::Declarations::Base>)

    the declarations



211
212
213
# File 'lib/rbs/merge/backends/rbs_backend.rb', line 211

def declarations
  @declarations
end

#directivesArray<::RBS::AST::Directives::Base> (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the directives.

Returns:

  • (Array<::RBS::AST::Directives::Base>)

    the directives



214
215
216
# File 'lib/rbs/merge/backends/rbs_backend.rb', line 214

def directives
  @directives
end

#errorsArray (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns parse errors.

Returns:

  • (Array)

    parse errors



217
218
219
# File 'lib/rbs/merge/backends/rbs_backend.rb', line 217

def errors
  @errors
end

Instance Method Details

#has_errors?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Check if the parse had errors

Returns:

  • (Boolean)


238
239
240
# File 'lib/rbs/merge/backends/rbs_backend.rb', line 238

def has_errors?
  @errors.any?
end

#inner_treeArray<::RBS::AST::Declarations::Base>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Access the underlying declarations (passthrough)
Overrides inner_tree to return declarations

Returns:

  • (Array<::RBS::AST::Declarations::Base>)


246
247
248
# File 'lib/rbs/merge/backends/rbs_backend.rb', line 246

def inner_tree
  @declarations
end

#root_nodeNode

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get the root node of the parse tree

Returns a synthetic “program” node that contains all declarations.

Returns:

  • (Node)

    wrapped root node



231
232
233
# File 'lib/rbs/merge/backends/rbs_backend.rb', line 231

def root_node
  Node.new_root(@declarations, source: source, lines: lines)
end