class Prism::ParseResult - Documentation for Ruby 4.0
Description: class Prism::ParseResult: This is a result specific to the `parse` and `parse_file` methods.
Keywords: ruby,class,Prism::ParseResult

🔍

No recent searches

# class Prism::ParseResult

This is a result specific to the `parse` and `parse_file` methods.

### Attributes

value [R]

The syntax tree that was parsed from the source code.

### Public Class Methods

new (value, comments, magic_comments, data_loc, errors, warnings, source)
Source

    # File lib/prism/parse_result.rb, line 740
    def initialize(value, comments, magic_comments, data_loc, errors, warnings, source)
      @value = value
      super(comments, magic_comments, data_loc, errors, warnings, source)
    end

Create a new parse result object with the given values.

Calls superclass method `Prism::Result::new`

### Public Instance Methods

attach_comments! ()
Source

    # File lib/prism/parse_result.rb, line 751
    def attach_comments!
      Comments.new(self).attach! # steep:ignore
    end

Attach the list of comments to their respective locations in the tree.

deconstruct_keys (keys)
Source

    # File lib/prism/parse_result.rb, line 746
    def deconstruct_keys(keys)
      super.merge!(value: value)
    end

Implement the hash pattern matching interface for `ParseResult`.

Calls superclass method `Prism::Result#deconstruct_keys`
errors_format ()
Source

    # File lib/prism/parse_result.rb, line 763
    def errors_format
      Errors.new(self).format
    end

Returns a string representation of the syntax tree with the errors displayed inline.

mark_newlines! ()
Source

    # File lib/prism/parse_result.rb, line 757
    def mark_newlines!
      value.accept(Newlines.new(source.offsets.size)) # steep:ignore
    end

Walk the tree and mark nodes that are on a new line, loosely emulating the behavior of CRuby’s `:line` tracepoint event.