Why do we need semantic information?
Every tool that is working with any language needs to understand it. Not only its syntax but also its type system and symbol resolution. To understand the language means to be able to obtain and process semantic information from the code. Reimplementing a parser and big parts of the compiler itself would be a huge effort. Moreover, that reimplementation would have not supported compilers plugins which are present in Kotlin ecosystem (eg. `kotlinx.serialization`).
How to get semantic information?
To mitigate these difficulties in our tools, VirtusLab’s team uses deep integration with Kotlin compiler itself – it stands out as an extensively modular piece of software. This allows us to pick services and components from the compiler and mix them into our own codebase. Thanks to that we get exactly the same representation of syntax, types, and references as the one that compiler is using to produce its output without the overhead of bytecode generation and other steps irrelevant for our tools. Moreover, we are able to integrate with the compiler plugins and provide scripting capabilities.
What we did – 3 Successful integrations
We are using compiler internals to extract documentation from code, to resolve links, and to analyze code samples.
.kts Eclipse Plugin (under development)
We leveraged the services of the compiler to provide simple IDE functions for Kotlin scripts in the Eclipse environment.
Kotlin Eclipse plugin
IDE requires a lot of features that duplicate ones from a compiler or are built on top of it. IDE should be also easy to maintain and supports the older version of the language. Our integration with Kotlin compiler and ecosystem fits there perfectly and allowed the team to focus on new features rather than doing mundane maintenance work or reinvent the wheel by duplicating features provided by the compiler.
Read more about Kotlin Eclipse plugin here.
100+ hours of development saved
With us setting up a tool that is based on semantic information takes hours rather than weeks. This means that the initial investment cost of creating a solution is much lower, PoC or working solution can be delivered within a single sprint. It allows creating tools that solve current problems quickly and adapt to changing devs’ environments (like unexpected lockdown).
Cutting down the maintenance costs
Our solution enables keeping plugins & tools up-to-date easily with the latest version of Kotlin. This means that our clients can reap all the benefits of a new version without much effort or risk involved. These solutions are also backward compatible with all stable versions of Kotlin which reduce maintenance cost further down.
Take the chance
Our solution can be the backbone of various tools that will improve team performance and code quality. Some examples may be:
- Static code analysis that will enforce that code applies to company rules or properly utilize the environment
- Tools to boost code review quality and reduce time spend on it
- Custom code completion and refactorings to speed up development
- … or any other solution that we are happy to discuss!