zeroc-ice / vscode-slice

Slice syntax highlighter for Visual Studio Code
BSD 3-Clause "New" or "Revised" License
5 stars 4 forks source link

No Longer Store Diagnostics in `CompilationState` #35

Closed InsertCreativityHere closed 9 months ago

InsertCreativityHere commented 9 months ago

Currently, the extension directly uses CompilationState (ast, files, diagnostics) from slicec. This PR adds a new type to replace it: CompilationData. This type only holds (ast, files). It does this to simplify how we get, and publish diagnostics.

Currently:

I also think it's a little strange that just making a Configuration triggers a compilation. That's pretty heavy for a constructor, and I'd expect it to be a different function you call on it.


CompilationData solves these problems:

So, now we create the CompilationData, then, when we're actually ready to compile and report diagnostics, we call trigger_compilation. No more mem::take, no more hackily storing the diagnostics temporarily.

It also has the side-benefit of centralizing where we compile. Before this PR, we call slicec::compile_from... in 3 places. Now it's only called from trigger_compilation.