class Prism::ParseResult
这是针对 `parse` 和 `parse_file` 方法的特定结果。
属性
从源代码解析的语法树。
公共类方法
源码
# File lib/prism/parse_result.rb, line 735 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::new
公共实例方法
源码
# File lib/prism/parse_result.rb, line 746 def attach_comments! Comments.new(self).attach! # steep:ignore end
将注释列表附加到树中各自的位置。
源码
# File lib/prism/parse_result.rb, line 741 def deconstruct_keys(keys) super.merge!(value: value) end
为 ParseResult
实现哈希模式匹配接口。
源码
# File lib/prism/parse_result.rb, line 758 def errors_format Errors.new(self).format end
返回语法树的字符串表示形式,其中错误以行内方式显示。
源码
# File lib/prism/parse_result.rb, line 752 def mark_newlines! value.accept(Newlines.new(source.offsets.size)) # steep:ignore end
遍历树并标记位于新行上的节点,大致模拟 CRuby 的 `:line` tracepoint 事件的行为。