class Prism::ParseResult
这是 parse 和 parse_file 方法特有的结果。
属性
从源代码解析出的语法树。
Public Class Methods
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
使用给定值创建一个新的解析结果对象。
调用超类方法
Prism::Result::newPublic Instance Methods
Source
# File lib/prism/parse_result.rb, line 751 def attach_comments! Comments.new(self).attach! # steep:ignore end
将注释列表附加到树中各自的位置。
Source
# File lib/prism/parse_result.rb, line 746 def deconstruct_keys(keys) super.merge!(value: value) end
为 ParseResult 实现哈希模式匹配接口。
Source
# File lib/prism/parse_result.rb, line 763 def errors_format Errors.new(self).format end
返回语法树的字符串表示形式,并将错误内联显示。
Source
# File lib/prism/parse_result.rb, line 757 def mark_newlines! value.accept(Newlines.new(source.offsets.size)) # steep:ignore end
遍历树并标记在新行上的节点,大致模仿 CRuby 的 :line 跟踪点事件的行为。