dist/parser/server.rb in prettier-2.0.0 vs dist/parser/server.rb in prettier-2.1.0

- old
+ new

@@ -4,10 +4,14 @@ require 'socket' require 'json' require 'fileutils' require 'open3' +# Ensure the parent module is defined before requiring the parsers. +module Prettier +end + require_relative '../ruby/parser' require_relative '../rbs/parser' require_relative '../haml/parser' # Make sure we trap these signals to be sure we get the quit command coming from @@ -70,11 +74,11 @@ response = case parser when 'ping' 'pong' when 'ruby' - Prettier::Parser.parse(source) + SyntaxTree.parse(source) when 'rbs' Prettier::RBSParser.parse(source) when 'haml' Prettier::HAMLParser.parse(source) end @@ -82,10 +86,10 @@ if response socket.write(JSON.fast_generate(response)) else socket.write('{ "error": true }') end - rescue Prettier::Parser::ParserError => error + rescue SyntaxTree::ParseError => error loc = { start: { line: error.lineno, column: error.column } } socket.write(JSON.fast_generate(error: error.message, loc: loc)) rescue StandardError => error begin socket.write(JSON.fast_generate(error: error.message))