class SyntaxSuggest::RipperErrors
Prism
返回带有消息的错误,但 Ripper
不会。为了获取它们,我们必须创建一个自定义子类。
示例
puts RipperErrors.new(" def foo").call.errors # => ["syntax error, unexpected end-of-input, expecting ';' or '\\n'"]
属性
公共实例方法
源代码
# File lib/syntax_suggest/ripper_errors.rb, line 30 def call @run_once ||= begin @errors = [] parse true end self end
源代码
# File lib/syntax_suggest/ripper_errors.rb, line 19 def on_parse_error(msg) @errors ||= [] @errors << msg end
来自 ripper,在每次解析错误时调用,msg 是一个字符串