crystal-lang / crystal

The Crystal Programming Language
https://crystal-lang.org
Apache License 2.0
19.21k stars 1.61k forks source link

Cache compiler results for tools #14705

Open nobodywasishere opened 3 weeks ago

nobodywasishere commented 3 weeks ago

Feature Request

When doing repeated calls to the crystal tools (unreachable, implementations, etc) it has to call compile_no_codegen each time, resulting in longer times to get information. I think there should be some mechanism / flag allowing for the AST to be cached once (based on a basic hash of the file contents or a top-level compile) and re-used over and over for the different tools. This shouldn't break backwards compatibility.

$ crystal tool unreachable file.cr            # takes a few seconds, but AST is cached
$ crystal tool implementations -c file.cr:1:3 # instantly returns as using cached AST