Code Monkey home page Code Monkey logo

scry's People

Contributors

bew avatar bmulvihill avatar br1ght0ne avatar coderbydesign avatar dnamsons avatar faustinoaq avatar gitter-badger avatar kachick avatar keplersj avatar kimburgess avatar kofno avatar laginha87 avatar matthewmcgarvey avatar matthiaswinkelmann avatar peterhoeg avatar simaoneves avatar spencerwi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scry's Issues

error trying to build

sh darwin_build.sh
Error in ./src/scry.cr:1: while requiring "./scry/*"

require "./scry/*"
^

in ./src/scry/analyzer.cr:4: while requiring "compiler/crystal/**"

require "compiler/crystal/**"
^

in /usr/local/Cellar/crystal-lang/0.19.4_1/src/compiler/crystal/program.cr:1: while requiring "llvm"

require "llvm"
^

in /usr/local/Cellar/crystal-lang/0.19.4_1/src/llvm.cr:1: while requiring "./llvm/**"

require "./llvm/**"
^

in /usr/local/Cellar/crystal-lang/0.19.4_1/src/llvm/di_builder.cr:1: while requiring "./lib_llvm"

require "./lib_llvm"
^

in /usr/local/Cellar/crystal-lang/0.19.4_1/src/llvm/lib_llvm.cr:3: expanding macro

{% begin %}
^

in /usr/local/Cellar/crystal-lang/0.19.4_1/src/llvm/lib_llvm.cr:6: error executing command: [ -n "$LLVM_CONFIG" ] && command -v "$LLVM_CONFIG" || command -v llvm-config-3.9 || command -v llvm-config39 || (command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 3.9*) command -v llvm-config;; *) false;; esac)) || command -v llvm-config-3.8 || command -v llvm-config38 || (command -v llvm-config > /dev/null && (case "$(llvm-config --version)" in 3.8*) command -v llvm-config;; *) false;; esac)) || command -v llvm-config-3.6 || command -v llvm-config36 || command -v llvm-config-3.5 || command -v llvm-config35 || command -v llvm-config
                  , got exit status 1

                  `[ -n "$LLVM_CONFIG" ] && command -v "$LLVM_CONFIG" || \
                  ^

Refactoring: embedded "compiler/crystal" by crystal commandline

Currently Scry uses a huge amout of memory because the crystal compiler is embedded on it.
Scry analyze files every time a file is saved without checking if the file have been truly changed increasing even more the footprint (aprox. over 300 MB RAM on Linux)

Also maybe we can use external crystal processes instead of using require "compiler/crystal/**" ('cause, compiler is very heavy) I think using processes will free memory easier and improve Scry performance.

Also new features as types on hover and refactoring could be easier to implement.

failed to deploy

Currently the master branch shows build error.

screenshot_20170809_140802

TravisCI ouputs:

/home/travis/.rvm/gems/ruby-2.2.7/gems/octokit-4.6.2/lib/octokit/client/releases.rb:86:in `initialize': No such file or directory @ rb_sysopen - bin/linux/scry (Errno::ENOENT)
	from /home/travis/.rvm/gems/ruby-2.2.7/gems/octokit-4.6.2/lib/octokit/client/releases.rb:86:in `new'
	from /home/travis/.rvm/gems/ruby-2.2.7/gems/octokit-4.6.2/lib/octokit/client/releases.rb:86:in `upload_asset'
	from /home/travis/.rvm/gems/ruby-2.2.7/gems/dpl-1.8.40/lib/dpl/provider/releases.rb:135:in `upload_file'
	from /home/travis/.rvm/gems/ruby-2.2.7/gems/dpl-1.8.40/lib/dpl/provider/releases.rb:116:in `block in push_app'
	from /home/travis/.rvm/gems/ruby-2.2.7/gems/dpl-1.8.40/lib/dpl/provider/releases.rb:107:in `each'
	from /home/travis/.rvm/gems/ruby-2.2.7/gems/dpl-1.8.40/lib/dpl/provider/releases.rb:107:in `push_app'
	from /home/travis/.rvm/gems/ruby-2.2.7/gems/dpl-1.8.40/lib/dpl/provider.rb:154:in `block in deploy'
	from /home/travis/.rvm/gems/ruby-2.2.7/gems/dpl-1.8.40/lib/dpl/cli.rb:41:in `fold'
	from /home/travis/.rvm/gems/ruby-2.2.7/gems/dpl-1.8.40/lib/dpl/provider.rb:154:in `deploy'
	from /home/travis/.rvm/gems/ruby-2.2.7/gems/dpl-1.8.40/lib/dpl/cli.rb:32:in `run'
	from /home/travis/.rvm/gems/ruby-2.2.7/gems/dpl-1.8.40/lib/dpl/cli.rb:7:in `run'
	from /home/travis/.rvm/gems/ruby-2.2.7/gems/dpl-1.8.40/bin/dpl:5:in `<top (required)>'
	from /home/travis/.rvm/gems/ruby-2.2.7/bin/dpl:22:in `load'
	from /home/travis/.rvm/gems/ruby-2.2.7/bin/dpl:22:in `<main>'
failed to deploy

/cc @keplersj

Handle inmemory files better

VSCode will send an inmemory:// file for new files are files that are opened as part of a git diff.

Two problems arise:

  1. Crystal doesn't handle require's from these files, since it can't recognize the in memory path, so error checking them will report false positives.
  2. We aren't cleaning up the reported errors when the inmemory file is closed.

To solve #1, we may want to only run the parser analyzer over inmemory files (and offer them completion services, when those are available).

To solve #2, we should send a clean diagnostic report whenever we close an inmemory file.

Scry diagnostics bug

On ST3 to reproduce this issue try scry diagnostics using LSP plugin and disabling auto_format on crystal package

bug02

As you can see ST3 is showing just the first error found and this error keep stuck in editor

Ref: #34

Add support to find classes and modules implementation

Add support to find classes and modules implementation

This is not supported by crystal tool implementations yet

I guess we can use something like symbol search to get class and modules location,

@crystal-lang-tools/scry WDYT?

Related to #109

Missing hash key "<name_of_file>"

So I've got Scry working sometime in Neovim!!

Sometime I have a weird bug, where restarting the editor and scry doesn't resolve.
The log is: (I've just removed the huuuuge dependency graph line)

I, [2018-03-10 02:15:44 -08:00 #3622]  INFO -- : Scry is looking into your code...
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : Content-Length: 413
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"completion":{"completionItem":{"commitCharactersSupport":null,"documentationFormat":null,"snippetSupport":false},"dynamicRegistration":null}}},"initializationOptions":null,"processId":3611,"rootPath":"/home/lesell_b/tests/crystal/dbus/pure_dbus","rootUri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus","trace":"off"},"id":8}
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : initialize
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : Starting to build dependancy graph for these paths: /home/lesell_b/tests/crystal/dbus/pure_dbus/lib
lib
/usr/lib/crystal
/home/lesell_b/tests/crystal/dbus/pure_dbus
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 244

{"jsonrpc":"2.0","id":8,"result":{"capabilities":{"textDocumentSync":1,"documentFormattingProvider":true,"definitionProvider":true,"documentSymbolProvider":true,"completionProvider":{"resolveProvider":true,"triggerCharacters":[".","\"","/"]}}}}
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : Content-Length: 327
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"crystal","text":"class Foo\n  def self.bar(io : IO)\n  end\nend\n\nclass Bar\n  def self.bla\n    3\n  end\n\n  def ljkh\n    2\n  end\nend\n\nBar.new.","uri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr","version":0}}}
D, [2018-03-10 02:15:44 -08:00 #3622] DEBUG -- : textDocument/didOpen
D, [2018-03-10 02:15:45 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 3013

{"jsonrpc":"2.0","error":{"code":-32001,"message":"expecting any of these tokens: IDENT, CONST, +, -, *, /, %, |, &, ^, **, <<, <, <=, ==, !=, =~, !~, >>, >, >=, <=>, ===, [], []=, []?, [ (not 'EOF')","data":["/usr/lib/crystal/compiler/crystal/syntax/lexer.cr:2751:9 in 'raise'","/usr/lib/crystal/compiler/crystal/syntax/lexer.cr:2750:5 in 'raise'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:183:11 in 'check'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:606:11 in 'parse_atomic_method_suffix'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:558:7 in 'parse_atomic_with_method'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:549:9 in 'parse_prefix'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:533:5 in 'parse_pow'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:532:5 in 'parse_mul_or_div'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:498:7 in 'parse_add_or_sub'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:493:5 in 'parse_shift'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:492:5 in 'parse_logical_and'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:491:5 in 'parse_logical_or'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:490:5 in 'parse_cmp'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:489:5 in 'parse_equality'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:488:5 in 'parse_and'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:487:5 in 'parse_or'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:440:7 in 'parse_range'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:413:7 in 'parse_question_colon'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:304:7 in 'parse_op_assign'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:300:5 in 'parse_op_assign'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:236:7 in 'parse_expression'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:113:7 in 'parse_multi_assign'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:102:9 in 'parse_expressions_internal'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:3784:7 in 'parse_expressions'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:73:21 in 'parse'","/usr/lib/crystal/compiler/crystal/syntax/parser.cr:16:7 in 'parse'","/home/lesell_b/Projects/opensource/scry/src/scry/completion/method_db.cr:27:11 in 'generate'","/home/lesell_b/Projects/opensource/scry/src/scry/workspace.cr:27:7 in 'put_file'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:128:7 in 'dispatchNotification'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:39:7 in 'dispatch'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:23:19 in 'start'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}
D, [2018-03-10 02:15:45 -08:00 #3622] DEBUG -- : Content-Length: 196
D, [2018-03-10 02:15:45 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:45 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":8,"line":15},"textDocument":{"uri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr"}},"id":13}
D, [2018-03-10 02:15:45 -08:00 #3622] DEBUG -- : textDocument/completion
D, [2018-03-10 02:15:45 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 882

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Missing hash key: \"/home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr\"","data":["/usr/lib/crystal/hash.cr:0:9 in 'fetch'","/usr/lib/crystal/hash.cr:62:5 in '[]'","/home/lesell_b/Projects/opensource/scry/src/scry/workspace.cr:44:7 in 'get_file'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:58:36 in 'dispatchRequest'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:33:9 in 'dispatch'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:23:19 in 'start'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content-Length: 358
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":null,"rangeLength":null,"text":"class Foo\n  def self.bar(io : IO)\n  end\nend\n\nclass Bar\n  def self.bla\n    3\n  end\n\n  def ljkh\n    2\n  end\nend\n\nBar.new"}],"textDocument":{"uri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr","version":1}}}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : textDocument/didChange
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 891

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Missing hash key: \"/home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr\"","data":["/usr/lib/crystal/hash.cr:0:9 in 'fetch'","/usr/lib/crystal/hash.cr:62:5 in '[]'","/home/lesell_b/Projects/opensource/scry/src/scry/workspace.cr:33:17 in 'update_file'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:138:7 in 'dispatchNotification'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:39:7 in 'dispatch'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:23:19 in 'start'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content-Length: 196
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":7,"line":15},"textDocument":{"uri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr"}},"id":14}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : textDocument/completion
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 882

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Missing hash key: \"/home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr\"","data":["/usr/lib/crystal/hash.cr:0:9 in 'fetch'","/usr/lib/crystal/hash.cr:62:5 in '[]'","/home/lesell_b/Projects/opensource/scry/src/scry/workspace.cr:44:7 in 'get_file'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:58:36 in 'dispatchRequest'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:33:9 in 'dispatch'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:23:19 in 'start'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content-Length: 359
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":null,"rangeLength":null,"text":"class Foo\n  def self.bar(io : IO)\n  end\nend\n\nclass Bar\n  def self.bla\n    3\n  end\n\n  def ljkh\n    2\n  end\nend\n\nBar.new."}],"textDocument":{"uri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr","version":2}}}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : textDocument/didChange
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 891

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Missing hash key: \"/home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr\"","data":["/usr/lib/crystal/hash.cr:0:9 in 'fetch'","/usr/lib/crystal/hash.cr:62:5 in '[]'","/home/lesell_b/Projects/opensource/scry/src/scry/workspace.cr:33:17 in 'update_file'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:138:7 in 'dispatchNotification'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:39:7 in 'dispatch'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:23:19 in 'start'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content-Length: 196
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":8,"line":15},"textDocument":{"uri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr"}},"id":15}
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : textDocument/completion
D, [2018-03-10 02:15:46 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 882

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Missing hash key: \"/home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr\"","data":["/usr/lib/crystal/hash.cr:0:9 in 'fetch'","/usr/lib/crystal/hash.cr:62:5 in '[]'","/home/lesell_b/Projects/opensource/scry/src/scry/workspace.cr:44:7 in 'get_file'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:58:36 in 'dispatchRequest'","/home/lesell_b/Projects/opensource/scry/src/scry/context.cr:33:9 in 'dispatch'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:23:19 in 'start'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}
D, [2018-03-10 02:15:47 -08:00 #3622] DEBUG -- : Content-Length: 148
D, [2018-03-10 02:15:47 -08:00 #3622] DEBUG -- : 
D, [2018-03-10 02:15:47 -08:00 #3622] DEBUG -- : {"jsonrpc":"2.0","method":"textDocument/didSave","params":{"textDocument":{"uri":"file:///home/lesell_b/tests/crystal/dbus/pure_dbus/src/test.cr"}}}
D, [2018-03-10 02:15:47 -08:00 #3622] DEBUG -- : textDocument/didSave
D, [2018-03-10 02:15:48 -08:00 #3622] DEBUG -- : 
W, [2018-03-10 02:15:48 -08:00 #3622]  WARN -- : Connection with client lost
D, [2018-03-10 02:15:48 -08:00 #3622] DEBUG -- : Content SEND: Content-Length: 872

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Content-Length header is required. Ex: Content-Length: 132\\r\\n","data":["/home/lesell_b/Projects/opensource/scry/src/scry/headers.cr:25:17 in 'content_length'","/home/lesell_b/Projects/opensource/scry/src/scry/request.cr:45:7 in 'content_length'","/home/lesell_b/Projects/opensource/scry/src/scry/request.cr:39:18 in 'read_content'","/home/lesell_b/Projects/opensource/scry/src/scry/request.cr:14:7 in 'read'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:21:19 in 'start'","/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}
E, [2018-03-10 02:15:48 -08:00 #3622] ERROR -- : Error writing file: Broken pipe
/usr/lib/crystal/io/file_descriptor.cr:72:11 in 'unbuffered_write'
/usr/lib/crystal/io/buffered.cr:120:9 in 'write'
/usr/lib/crystal/io.cr:487:7 in 'write_utf8'
/usr/lib/crystal/string.cr:4139:5 in 'to_s'
/usr/lib/crystal/io.cr:192:5 in '<<'
/home/lesell_b/Projects/opensource/scry/src/scry/response.cr:24:7 in 'log_and_write'
/home/lesell_b/Projects/opensource/scry/src/scry/response.cr:17:9 in 'write'
/home/lesell_b/Projects/opensource/scry/src/scry.cr:28:9 in 'start'
/home/lesell_b/Projects/opensource/scry/src/scry.cr:40:1 in '__crystal_main'
/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'
/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'
/usr/lib/crystal/crystal/main.cr:101:7 in 'main'
/usr/lib/crystal/crystal/main.cr:135:3 in 'main'
__libc_start_main
_start
???

This seems to happen when the opened file is not valid on first load. So when Scry receives the textDocument/didOpen request, it tries to build the MethodDB. At this point, as the file is not valid, the method failes, and doesn't add the file in the list of opened file in the workspace, and subsequent operations on this file (even if it fixes the syntax (or other) error, the file will not be added to the workspace again.

Maybe we should add a default empty MethodDB if the initial generation fails?

Scry formatting bug

On ST3 to reproduce this issue try scry formatting disabling crystal auto_format on crystal package setting:

{
  "auto_format": false,
  "crystal_cmd": "crystal"
}

bug01

As you can see scry formatting is almost deleting all file text.

Ref: #34

Add test for the compiled binary itself

After working on #48 I realize our specs don't test the working binary, just the isolated code of scry modules and features.

My proposal is to create a spec for testing the compiled binary, simulating a client to writing the input, checking output and to get the right response.

Review editor specific code inside scry

Initially scry was created to work with VSCode, times have changed and now scry aims to support many other editors and IDEs.

This issue is to discuss what we should keep inside scry, by example: The inmemory: and git: parts are needed to avoid errors in diff views inside VSCode, should we remove them?

Perhaps, we can include specific fixes for other editors as well, WDYT?

Ref #84 (comment)

Use static linked binaries

Many people have problems to compile Scry even to execute the releases binaries.

Maybe we can link it statically using docker image.

I was able to compile Scry staticaly using official Crystal docker image and the binary runs without dependencies in almost every distro: ArchLnux, Ubuntu, Centos. (not Alpine)

To compile statically we can use crystal build src/scry.cr --link-flags="-static" on Linux.

What do you think guys?

Recommend better alternatives for a piece of code?

For example, in RubyMine, there's a feature where something such as:

for a in [*0...10]

RubyMine will automatically recommend you to change the for statement to a each do statement. This also applies to something like when you use if with a negative statement (in which case unless is recommended), etcetera.

This requires a centralised style guide or linter, however.

Fix build on Travis

Beg, borrow or steal a travis config/ docker file installs crystal w/ llvm so our build can run.

No space left on device - reduce logger level

I usually work with large files (300-400 lines), and the logging file can become very big and take all the space available in /tmp (which is a tmpfs on my system, so it lives in the ram).

A sample list of scry's log files:

-rw-------  1 lesell_b users  3.1G Mar 21 20:25 scry.out.27K0Q6
-rw-------  1 lesell_b users  1.1M Mar 21 17:24 scry.out.DJW0Dc
-rw-------  1 lesell_b users 1014K Mar 21 17:22 scry.out.KqqV1g
-rw-------  1 lesell_b users  6.8M Mar 21 23:31 scry.out.lyxMHz
-rw-------  1 lesell_b users 1014K Mar 21 17:23 scry.out.M8PRUt
-rw-------  1 lesell_b users 1013K Mar 21 17:22 scry.out.TShzqU
-rw-------  1 lesell_b users 1014K Mar 21 17:21 scry.out.VkHbyS
-rw-------  1 lesell_b users  845M Mar 21 23:27 scry.out.XTtliD
-rw-------  1 lesell_b users 1020K Mar 21 17:21 scry.out.ZtJysi

I suggest to at least disable the logging of every request/response unless the --debug flag is given to scry, this will reduce the size of log files significantly I think.

Lack of documentation on the scry setup

Hi @crystal-lang-tools/scry community!

This project is getting better everyday. I think is cool but some newcomers are getting confused on how to use scry. This is mainly because the lack of documentation on LSP clients configuration:

I propose to write some wiki articles about configuring scry to run on:

โš ๏ธ Work In Progress, see the wiki: https://github.com/crystal-lang-tools/scry/wiki/Clients

Missing `id` in ResponseError

When an error happens during a RPC call, a ResponseMessage is returned, without the message id it's currently in processing.

struct ResponseError
JSON.mapping({
code: Int32,
message: String,
data: Array(String)?,
}, true)
def initialize(@message, @data)
@code = ErrorCodes::UnknownErrorCode.value
end
end

This makes the Language Client for Neovim crash for the request.

I looked at the code, the important bit is

scry/src/scry.cr

Lines 20 to 29 in a2ac15c

begin
content = Request.new(STDIN).read
request = Message.new(content).parse
results = context.dispatch(request)
rescue ex
results = [ResponseMessage.new(ex)]
ensure
response = Response.new([results].flatten)
response.write(STDOUT)
end

At line 25, the ResponseMessage object will create a ReponseError with the given exception.
But the current request's ID we are processing is lost.

Completion doesn't work on current file content

Hi @laginha87 I just found another little issue with completion:

When I was testing #92 I realize the completion follows requires but doesn't includes content for the file itself.

By example:

This works:

image

This doesn't work:

image

I guess there is some issue with requires parsing somewhere here:

def process_requires(file, graph)
requires = parse_requires(file)
current_file_path = File.expand_path(file)

Are we missing the current file content on completion?

Issues with completion on some files

@laginha87 I knew I had some issues with auto-completion feature and I have found them, sometimes the completion is broken in projects with sub directories. And keep working only in the main project file.

In the example below, I tried scry master and tested completion on all files, (baz.cr, bar.cr and foo.cr) and no one works but only console.cr. No matter where I put them, completion just work on one file, the main file console.cr for the project console

vokoscreen-2018-04-09_15-39-07

Full logs here: https://gist.github.com/faustinoaq/65b39e810dc1e4a6a3456bb0286d48e6

Intellij-Idea LSP protocol mismatch

OS: Linux 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64 GNU/Linux
IDE: RubyMine 2017.3.3
Plugin: https://plugins.jetbrains.com/plugin/10209-lsp-support

image

image

scry.out.tHN1QZ

I, [2018-03-30 20:08:56 -04:00 #16188]  INFO -- : Scry is looking into your code...
D, [2018-03-30 20:08:56 -04:00 #16188] DEBUG -- : Content-Length: 586
D, [2018-03-30 20:08:56 -04:00 #16188] DEBUG -- : 
D, [2018-03-30 20:08:56 -04:00 #16188] DEBUG -- : {"jsonrpc":"2.0","id":"1","method":"initialize","params":{"rootUri":"file:///api_v2/","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true},"didChangeWatchedFiles":{},"symbol":{},"executeCommand":{}},"textDocument":{"synchronization":{"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"completionItem":{"snippetSupport":false}},"hover":{},"signatureHelp":{},"references":{},"documentHighlight":{},"formatting":{},"rangeFormatting":{},"onTypeFormatting":{},"definition":{},"codeAction":{},"rename":{}}}}}
D, [2018-03-30 20:08:56 -04:00 #16188] DEBUG -- : Content SEND: Content-Length: 839

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Couldn't parse (Scry::NotificationMessage | Scry::RequestMessage) from {\"jsonrpc\":\"2.0\",\"id\":\"1\",\"method\":\"initialize\",\"params\":{\"rootUri\":\"file:///api_v2/\",\"capabilities\":{\"workspace\":{\"applyEdit\":true,\"workspaceEdit\":{\"documentChanges\":true},\"didChangeWatchedFiles\":{},\"symbol\":{},\"executeCommand\":{}},\"textDocument\":{\"synchronization\":{\"willSave\":true,\"willSaveWaitUntil\":true,\"didSave\":true},\"completion\":{\"completionItem\":{\"snippetSupport\":false}},\"hover\":{},\"signatureHelp\":{},\"references\":{},\"documentHighlight\":{},\"formatting\":{},\"rangeFormatting\":{},\"onTypeFormatting\":{},\"definition\":{},\"codeAction\":{},\"rename\":{}}}}} at 1:1","data":["???","???","???","???","???","???","???"]}}

Error reading file: Is a directory

Hi, seems completion feature is including directories in some wrong places ๐Ÿ˜…

I found this strange error when I was working on other unrelated features:

D, [2018-04-08 23:55:59 -05:00 #5457] DEBUG -- : Content-Length: 281
D, [2018-04-08 23:55:59 -05:00 #5457] DEBUG -- : 
D, [2018-04-08 23:55:59 -05:00 #5457] DEBUG -- : {"jsonrpc":"2.0","id":23,"method":"completionItem/resolve","params":{"label":"bar/","detail":"bar/","filterText":"bar/","insertTextFormat":1,"insertText":"bar/","kind":9,"sortText":"bar/","data":{"require_module_context":true,"path":"/home/main/Projects/console/src/console/bar"}}}
D, [2018-04-08 23:55:59 -05:00 #5457] DEBUG -- : completionItem/resolve
D, [2018-04-08 23:55:59 -05:00 #5457] DEBUG -- : Content SEND: Content-Length: 1215

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Error reading file: Is a directory","data":["/usr/lib/crystal/io/file_descriptor.cr:53:9 in 'unbuffered_read'","/usr/lib/crystal/io/buffered.cr:206:5 in 'fill_buffer'","/usr/lib/crystal/io/buffered.cr:82:7 in 'peek'","/usr/lib/crystal/io.cr:638:37 in 'gets'","/usr/lib/crystal/io.cr:611:5 in 'gets'","/usr/lib/crystal/io.cr:581:5 in 'gets'","/usr/lib/crystal/io.cr:580:3 in 'gets'","/usr/lib/crystal/io.cr:1167:7 in 'next'","/usr/lib/crystal/iterator.cr:913:9 in 'next'","/usr/lib/crystal/enumerable.cr:390:15 in 'join'","/usr/lib/crystal/enumerable.cr:620:7 in 'join'","/home/main/Projects/scry/src/scry/completion_resolver.cr:11:9 in 'run'","/home/main/Projects/scry/src/scry/context.cr:103:19 in 'dispatch_request'","/home/main/Projects/scry/src/scry/context.cr:31:7 in 'dispatch'","/home/main/Projects/scry/src/scry.cr:25:19 in 'start'","/home/main/Projects/scry/src/scry.cr:42:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}

/cc @laginha87

Expected Hash for #[]?(key : String), not Array(JSON::Type)

I found this ๐Ÿ‘‡ error today when I was working in my projects:

D, [2018-04-13 13:38:10 -05:00 #28884] DEBUG -- : workspace/didChangeConfiguration
E, [2018-04-13 13:39:46 -05:00 #28884] ERROR -- : A error was found while searching definitions
Expected Hash for #[]?(key : String), not Array(JSON::Type)
E, [2018-04-13 13:51:12 -05:00 #28884] ERROR -- : A error was found while searching definitions
Expected Hash for #[]?(key : String), not Array(JSON::Type)
E, [2018-04-13 13:51:40 -05:00 #28884] ERROR -- : A error was found while searching definitions
Expected Hash for #[]?(key : String), not Array(JSON::Type)
E, [2018-04-13 13:53:34 -05:00 #28884] ERROR -- : A error was found while searching definitions
Expected Hash for #[]?(key : String), not Array(JSON::Type)
E, [2018-04-13 13:56:44 -05:00 #28884] ERROR -- : A error was found while searching definitions
Expected Hash for #[]?(key : String), not Array(JSON::Type)
E, [2018-04-13 14:00:33 -05:00 #28884] ERROR -- : A error was found while searching definitions
Expected Hash for #[]?(key : String), not Array(JSON::Type)
E, [2018-04-13 14:00:33 -05:00 #28884] ERROR -- : A error was found while searching definitions
Expected Hash for #[]?(key : String), not Array(JSON::Type)
E, [2018-04-13 14:00:35 -05:00 #28884] ERROR -- : A error was found while searching definitions
Expected Hash for #[]?(key : String), not Array(JSON::Type)
E, [2018-04-13 14:03:10 -05:00 #28884] ERROR -- : A error was found while searching definitions
Expected Hash for #[]?(key : String), not Array(JSON::Type)
E, [2018-04-13 14:59:37 -05:00 #28884] ERROR -- : A error was found while searching definitions
Unexpected char 'E' at 1:1

I haven't seen this error before, I guess we need to review ๐Ÿ‘‡ implementations feature again ๐Ÿ˜…

Log.logger.error("A error was found while searching definitions\n#{ex}")
implementation_response

Support find references

Hi community!

Find references is a feature I have no idea or clue on how to implement,

This is the only missing feature to complete basic LSP support see: https://langserver.org/

screenshot_20180504_205743
screenshot_20180504_205839

So, WDYT about this scry capability?

Crystal URL Scheme

It's not like it's a big issue or anything, but it kind of bugs me. The Crystal URL in the "topic"/"description" of the repository uses HTTP, while the site uses HTTPS. Granted it redirects, it looks kind of bad to me and anyone alike me.

Remove specific editor settings

I think scry should be editor/IDE agnostic

So, I guess We need to remove these lines from the protocol:

struct SettingsCrystalIDE
JSON.mapping({
crystal_config: {type: CustomizationsCrystalIDE, key: "crystal-ide"},
})
end
# :ditto:
struct CustomizationsCrystalIDE
JSON.mapping({
max_number_of_problems: {type: Int32, key: "maxNumberOfProblems"},
backend: String,
custom_command: {type: String, key: "customCommand"},
custom_command_args: {type: Array(String), key: "customCommandArgs"},
log_level: {type: String, key: "logLevel"},
})
end
# Configuration for vscode-crystal-lang
# https://github.com/faustinoaq/vscode-crystal-lang
struct SettingsCrystalLang
JSON.mapping({
crystal_config: {type: CustomizationsCrystalLang, key: "crystal-lang"},
})
end
# :ditto:
struct CustomizationsCrystalLang
JSON.mapping({
max_number_of_problems: {type: Int32, key: "maxNumberOfProblems"},
log_level: {type: String, key: "logLevel"},
})
end
# Configuration for atom-crystal
# https://github.com/atom-crystal/scry
# struct SettingsAtomCrystal
# JSON.mapping({
# crystal_config: {type: CustomizationsAtomCrystal, key: "atom-crystal"},
# })
# end
# :ditto:
# struct CustomizationsAtomCrystal
# JSON.mapping({
# max_number_of_problems: {type: Int32, key: "maxNumberOfProblems"},
# log_level: {type: String, key: "logLevel"},
# })
# end

@crystal-lang-tools/scry WDYT?

Support Scry on Windows using WSL

Scry doesn't run on Windows. Because Crystal doesn't run on windows. But Windows 10 can run scry in bash. However, I'm not certain that we can mix STDIN and STDOUT in a useful way.

First step, test if we can connect to a Scry running bash from windows. If that works, there's nothing to change.

If that doesn't work, add support for optionally connecting to scry of TCP.

Missing hash key on completion for external files

Hi, completion works per project, although, If I open an external crystal file in my current workspace I get this:

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Missing hash key: \"/home/main/Projects/interactive-
crystal/mandel.cr\"","data":["/usr/lib/crystal/hash.cr:0:9 in 'fetch'","/usr/lib/crystal/hash.cr:62:5 in 
'[]'","/home/main/Projects/scry/src/scry/completion/dependency_graph.cr:32:7 in 
'[]'","/home/main/Projects/scry/src/scry/workspace.cr:29:29 in 
'put_file'","/home/main/Projects/scry/src/scry/context.cr:138:7 in 
'dispatch_notification'","/home/main/Projects/scry/src/scry/context.cr:36:7 in 
'dispatch'","/home/main/Projects/scry/src/scry.cr:23:19 in 
'start'","/home/main/Projects/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 
in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 
'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 
'main'","__libc_start_main","_start","???"]}}

I think we can check an existing file here:

if file.untitled?
@open_files[file.filename] = {file, Completion::MethodDB.new}
else
file_dependencies = @dependency_graph[file.filename].descendants.map &.value
method_db = Completion::MethodDB.generate(file_dependencies)
@open_files[file.filename] = {file, method_db}
end

something like:

if @dependency_graph[file.filename]?
  file_dependencies = @dependency_graph[file.filename].descendants.map &.value
  method_db = Completion::MethodDB.generate(file_dependencies)
  @open_files[file.filename] = {file, method_db}
else
  @open_files[file.filename] = {file, Completion::MethodDB.new}
end

[RFC] Better distribution story for scry

VSCode packages can't be larger then 20MB. So I can't distribute Cystal-IDE w/ bundled binaries for all platform/arch combos we'll want to support (probably a bad idea anyway).

So how should we distribute scry?

  1. Maintain brew taps and apt-get repos. Brew taps don't seem that hard to maintain, but I'm uncertain of the cost in effort for keeping an apt distribution. And that excludes arch and redhat linux users.

  2. Build logic into Crystal-IDE to fetch proper version of scry (and detect updates). There's a lot of hidden effort here; like prompting users that an update is available, etc.

  3. See if it's possible to make scry distributable as a development dependency. This is how, for example, rake is distributed most often to ruby projects. This would actually make the most sense, since you may need a different scry on different projects. However, I'm not certain that shards supports distributing binary dependencies in this way.

Support workspace symbols

Hi community!

@bmulvihill already implemented listing symbols per file via #39 and #43

Would be nice to use the new "main file" .scry.cr to get workspace symbols, WDYT?

.scry.cr file is optional, implemented on #95

Enable server capabilities depending on client capabilities support

Hi After testing scry on sublime text and intellij-idea I just realize, scry is bypassing initialize capabilities supported by client.

def initialize
@textDocumentSync = TextDocumentSyncKind::Full
@documentFormattingProvider = true
@definitionProvider = true
@documentSymbolProvider = true
@completionProvider = CompletionOptions.new
end

@capabilities = ServerCapabilities.new

capabilities: JSON::Any,

We're not using capabilities: JSON::Any at all

I think we should enable features only if the client has/want support for specified capability.

So we can create a JSON.mapping for capabilities and check them before creating ServerCapabilities.new

External files diagnostic are not cleared

After working on amberframework source code for a few days I notice the diagnostic for external files is not clean, so, I always see these errors, until the editor is reloaded.

External file Untitled-4.cr located in home directory, and opened from a Project folder

screenshot_20180414_105558

I think this code is causing the issue:

# Reset all diagnostics in the current project
def clean_diagnostic
Dir.glob("#{@workspace.root_uri}/**/*.cr").map do |file|
@diagnostic.clean("file://#{file}")
end
end

So, we need to send clean diagnostics to all files in @text_document.text.map and not only to files inside src/ folder.

IMPORTANT: We're sending clean diagnostics to all files because some errors are not located in the same file, and because we support implicit requires now, the files scope is a bit bigger and needs to be clean.

Error compiling scry in mac os x El capitan

Hello:

I'm receiving this error when trying to compile the source code.

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: execution of command failed with code: 1: `cc -o "/Users/.../.cache/crystal/crystal-run-scry.tmp" "${@}"  -rdynamic  -lz `pkg-config --libs libssl || printf %s '-lssl -lcrypto'` `pkg-config --libs libcrypto || printf %s '-lcrypto'` /usr/local/Cellar/crystal-lang/0.18.7/src/llvm/ext/llvm_ext.o `$(command -v llvm-config-3.6 || command -v llvm-config36 || command -v llvm-config-3.5 || command -v llvm-config35 || command -v llvm-config) --libs --system-libs --ldflags 2> /dev/null` -lstdc++ -lpcre -lgc -lpthread /usr/local/Cellar/crystal-lang/0.18.7/src/ext/libcrystal.a -levent -liconv -ldl -L/usr/lib -L/usr/local/lib`

Completion RoadMap

Hi all, this issue is a compilation of features I think we can add to the completion part of scry.
Open to suggestions.

Overview

  • Load classes from libs
  • Add module function completion

Literal object declarations

  • Add string literal completion

  • Add array literal method completion

  • Add hash literal method completion

  • Support generic method completion

  • Add chain method completion

  • Add inherited instance methods completion

  • Add inherited class methods completion

  • Add json mappings completion

Requires identifying context:

  • Add symbol completion
  • Add overloading auto complete
  • Add overriding autocompletion when definining a new method
  • Add module function completion in module context
  • Add classname completion with module namespace
  • Add top level classname completion.
  • Add top level module completion

Descriptions

Load classes from libs

Any class defined under libs/ isn't used, this is because the requires aren't looked up properly when loading the requires

Add Module function completion

Right now we identify class methods but don't identify module functions. For example: Kemal.r should complete with run.

Literal object declarations

This section is for when we have situations like a = [] of String it should identify a as Array(String).

Add string literal completion

 a = ""

should identify a as String.

Add array literal method completion

 a = [1,2,3]
 a = [] of String

Should identify as Array(String, String).

Add hash literal method completion

a = {
    "" => ""
}

a = {} of String => String

Should identify as Hash(String, String)

Support generic method completion

a = [] of String; a.map(&.) should complete with string methods.

Add chain method completion

a.method_a.method_b. should be able to give some completion hints (This needs methods to define the return type or we need to find away to guess tha too.)

Add inherited instance methods completion

When suggesting completion on an object it should also include instance methods from the classes it inherits from.

Add inherited class methods completion

When suggesting completion on a class it should also include class methods from the classes it inherits from.

Add included methods completion

When suggesting completion on an object it should also include methods inherited from included modules.

Add json mappings completion

I have no idea how to handle completion on methods defined by macros, so we could add special cases for json mappings.

Requires identifying context:

This set of features needs the completion code to identify which class or module the cursor is on.

TODO Fill out this section.

Formatting untitled files is broken

Hi, I tried latest scry release (v0.7.1) and seems formatting untitled files (implemented on #54 ) is broken now:

I'm getting this message (relevant message):

D, [2018-03-11 08:57:22 -05:00 #2962] DEBUG -- : Content-Length: 276
D, [2018-03-11 08:57:22 -05:00 #2962] DEBUG -- : 
D, [2018-03-11 08:57:22 -05:00 #2962] DEBUG -- : {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"untitled:Untitled-1","version":3},"contentChanges":[{"text":"module Console\n    class ClassName\n      def initialize\n      end\n  \n      def method_name\n      end\n    end\n  end\n  "}]}}
D, [2018-03-11 08:57:22 -05:00 #2962] DEBUG -- : textDocument/didChange
D, [2018-03-11 08:57:22 -05:00 #2962] DEBUG -- : Content SEND: Content-Length: 780

{"jsonrpc":"2.0","error":{"code":-32001,"message":"Missing hash key: \"untitled:Untitled-1\"","data":["/usr/lib/crystal/hash.cr:0:9 in 'fetch'","/usr/lib/crystal/hash.cr:62:5 in '[]'","/home/main/Projects/scry/src/scry/workspace.cr:33:17 in 'update_file'","/home/main/Projects/scry/src/scry/context.cr:138:7 in 'dispatchNotification'","/home/main/Projects/scry/src/scry/context.cr:39:7 in 'dispatch'","/home/main/Projects/scry/src/scry.cr:23:19 in 'start'","/home/main/Projects/scry/src/scry.cr:40:1 in '__crystal_main'","/usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'","/usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'","/usr/lib/crystal/crystal/main.cr:101:7 in 'main'","/usr/lib/crystal/crystal/main.cr:135:3 in 'main'","__libc_start_main","_start","???"]}}

I tried to format this code:

screenshot_20180311_085902

I think the problem is somewhere here:

https://github.com/crystal-lang-tools/scry/blob/master/src/scry/workspace.cr#L26

or

https://github.com/crystal-lang-tools/scry/blob/master/src/scry/context.cr#L58

because Untitled files doesn't use a valid path.

/cc @laginha87

Multiples issues on Sublime Text 3 LSP

Hi community!

Requirements to reproduce this issue:

Currently Sublime Text 3 has full LSP support

screenshot_20171022_054522

I tried LSP on ST3 using https://github.com/tomv564/LSP with this settings:

// Settings in here override those in "LSP/LSP.sublime-settings",

{
  "clients":
  {
    // Each new client must have the following structure.
    "crystal":
    {
  
      // The command line required to run the server.
      "command": ["/home/main/Projects/scry/bin/linux/scry"],
  
      // Use: "Show Scope Name" from Sublime's Developer menu
      "scopes": ["source.crystal"],
  
      // Run: view.settings().get("syntax") in console
      "syntaxes": ["Packages/Crystal/Crystal.sublime-syntax"],
  
      // See: https://github.com/Microsoft/language-server-protocol/issues/213
      "languageId": "crystal",
  
      // Sent to server once using workspace/didConfigurationChange notification
      "settings": { },
  
      // Sent once to server in initialize request
      "initializationOptions": { },
  
      // Extra variables to override/add to language server's environment.
      "env": { },
    }
  },
  "auto_show_diagnostics_panel": false,
  "show_diagnostics_phantoms": true
}

However I found some issues trying scry:

1. Formatting doesn't work:

See issue #35

2. Diagnostics doesn't work well.

See issue #36

3. GoTo Definition works!

The only feature that currently works well!, To try Scry GoTo Definition first disable default GoTo Definition on ST3 settings:

{
	"index_files": false
}

bug03

As you can see GoToDef works almost perfectly :)

Conclusion

I think these issues related to formatting and diagnostics would be configuration errors, maybe on initialize protocol. Latest contributions by @bmulvihill could be trying to fix some of these issues.

Next features to support will be Hover information (using crystal tool context) and Completion using Cracker (maybe embedded on Scry WDYT @TechMagister ?).

Also I'm thinking on use crystal commandline tools instead of require "compiler/crystal/**" this would reduce Scry size a ton and should allow us to implement features easily. However I still think require "compiler/crystal/syntax" will be useful to implement features like List & Rename Symbols.

/cc @keplersj @kofno @bcardiff

Support auto completion

Currently @TechMagister have a really good tool for autocompletion [0]

I think we can implement auto completion on Scry using cracker [0]

[0] - https://github.com/TechMagister/cracker

Update

Adding a TODO list by @laginha87

  • Add dependency graph, simple method db and method completion with the basic scenarios.
  • Add method resolve for documentation
  • Add the class graph generation and add super method calls. Should handle namespaced classes better.
  • Improve autocompletion by adding more scenarios
  • Add support for module inclusion

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.