elbywan / crystalline

A Language Server Protocol implementation for Crystal. 🔮
MIT License
436 stars 23 forks source link

LSP server crashes if there is a syntax error #5

Closed grkek closed 4 years ago

grkek commented 4 years ago
[Info  - 9:27:32 AM] Crystalline LSP server is ready.
[Error - 9:28:34 AM] syntax error in :2
Error: expecting any of these tokens: IDENT, CONST, +, -, *, /, //, %, |, &, ^, ~, !, **, <<, <, <=, ==, !=, =~, !~, >>, >, >=, <=>, ===, [], []=, []?, [, &+, &-, &*, &** (not 'EOF')
[Error - 9:28:34 AM] Request textDocument/formatting failed.
  Message: expecting any of these tokens: IDENT, CONST, +, -, *, /, //, %, |, &, ^, ~, !, **, <<, <, <=, ==, !=, =~, !~, >>, >, >=, <=>, ===, [], []=, []?, [, &+, &-, &*, &** (not 'EOF')
  Code: -32001 
raise<Crystal::SyntaxException>:NoReturn,Crystal::Parser@Crystal::Lexer#raise<String, Crystal::Token, Nil>:NoReturn,Crystal::Parser@Crystal::Lexer#raise<String, Crystal::Token>:NoReturn,Crystal::Parser#parse_atomic_method_suffix<Crystal::ASTNode+, Crystal::Location>:Crystal::ASTNode+,Crystal::Parser#parse_pow:Crystal::ASTNode+,Crystal::Parser#parse_mul_or_div:Crystal::ASTNode+,Crystal::Parser#parse_add_or_sub:Crystal::ASTNode+,Crystal::Parser#parse_shift:Crystal::ASTNode+,Crystal::Parser#parse_logical_and:Crystal::ASTNode+,Crystal::Parser#parse_logical_or:Crystal::ASTNode+,Crystal::Parser#parse_cmp:Crystal::ASTNode+,Crystal::Parser#parse_equality:Crystal::ASTNode+,Crystal::Parser#parse_and:Crystal::ASTNode+,Crystal::Parser#parse_or:Crystal::ASTNode+,Crystal::Parser#parse_question_colon:Crystal::ASTNode+,Crystal::Parser#parse_op_assign<Bool, Bool>:Crystal::ASTNode+,Crystal::Parser#parse_multi_assign:Crystal::ASTNode+,Crystal::Parser#parse_expressions_internal:Crystal::ASTNode+,Crystal::Formatter::format<String, Nil>:String,Crystalline::Controller#on_request<(LSP::CompletionRequest | LSP::DefinitionRequest | LSP::HoverRequest | LSP::InitializeRequest | LSP::RequestMessage(Array(LSP::TextEdit) | Nil)+ | LSP::RequestMessage(Nil)+ | LSP::ShowMessageRequest | LSP::SignatureHelpRequest)>:(Array(LSP::Location | LSP::LocationLink) | Array(LSP::TextEdit) | LSP::CompletionList | LSP::Hover | Nil),~procProc(Nil)@lib/crystalline/src/crystalline/lsp/server.cr:148,Fiber#run:(IO::FileDescriptor | Nil)

If you put a dot after anything literally and save it, the server will crash and won't restart until you restart VS Code.

grkek commented 4 years ago

Keep in mind this happens because I have the formatOnSave setting on.

elbywan commented 4 years ago

Hi @grkek, thanks for reporting the issue!

A new version is out including a fix, could you please check with the latest binaries to confirm that it is working fine now?