JetBrains / ForTea

Apache License 2.0
56 stars 10 forks source link

Store T4 include graph in cache #11

Closed kirillgla closed 4 years ago

kirillgla commented 4 years ago

Prior to this, there was a weird construction by @MrJul which manually tracked file changes and stored them in a cache-like structure. It didn't work very well in some edge cases; particularly so - during startup. This PR is dedicated to rewriting that structure based on SimpleICache. The main goals of keeping the graph are:

  1. finding a file that includes the current file but is not included anywhere else, and
  2. marking all the files psi of which depends on the contents of the current file as dirty.

The first part is exposed as FindRoot method; the second one is handled directly in the Merge method

kirillgla commented 4 years ago

Right, in projects with hundreds of thousands of T4 files my implementation might create significant memory traffic on every typing in T4 file. For small real-world projects though, memory profiling did not reveal any noticeable issues. I know it is possible to avoid allocating that memory by manually maintaining a dictionary from files to files including them and manually invalidating it, but that does not seem to me to be worth the effort