influxdata / flux-lsp

Implementation of Language Server Protocol for the flux language
MIT License
27 stars 5 forks source link

feat: use stateful composition #603

Closed rockstar closed 1 year ago

rockstar commented 1 year ago

This is a big patch, and with reason. Previously, composition wasn't stateful, so the composition statement was re-initialized on every subsequent composition-related command. This meant we had to have some way of finding it all the time. This patch makes the composition part of the lsp server state, so it lives along with the contents of the file. This means that composition can survive unrelated edits to the file, can take manual changes to the composition statement itself, etc.

The tests all had to be re-architected, because composition changed so dramatically. In this case, the tests all live around the Composition struct itself and don't test any more of the internal details. When the changes started coming, and the internal details changed so much, it made it hard to keep them around. It also means we can have behavioral tests for composition that aren't affected by what happens when internal changes are made.

This isn't the last of these patches. There are many things that will be needed to make it more robust. However, this moves the needle significantly enough, and unblocks enough work to warrant a change.

Fixes #583