One of Ruby’s most powerful features is the ability to extend the language itself through meta-programming. We can create rich and elegant DSLs that allow developers to solve problems with flexible and concise code.
The drawback of DSLs is that they are difficult to analyze statically, reducing the usefulness of developer tooling like editor integrations. Since each gem can define their own DSL, we cannot account for all possible DSLs that may exist in a given application. So what can we do?
Let’s do a deep dive into the Ruby LSP’s add-on API, which allows any other gem to enhance the static analysis understanding of the language server for a more accurate editor experience. We’ll explore the techniques behind it and which class of problems it can solve.