New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refine cache for typing the buffer #1637
Comments
Let me give a bit more detail on this: Merlin needs the typedtree of the current buffer for most of its queries. The typedtree is produced in two steps (up to details): First, the buffer's source code is parsed into the parsetree. Then, the parsetree is typed, producing the typedtree. Since the typing is very time-intense, that typedtree is cached. So, if the next query is run on the same buffer, Merlin pulls as much as it can from the cached typedtree. If the source code wasn't modified, it can pull the whole typedtree from cache. If it was modified, it can only pull a part of the typedtree, concretely the part before the modification. Everything from the modification on needs to be retyped. This issue is about the granularity with which Merlin splits the tree into "before modification" and "after modification". The current workflow is as follows: The parsetree is a list, concretely a list of structure items for ml-files (aka structure) or a list of signature items for mli-files (aka signature). Merlin goes through the new parsetree and the old parsetree simultaneously and looks for the first item in the list that's different between the two. It does so via a polymorphic compare between the two items. So the splitting is done on top-level structure/signature items. This issue suggests to refine the splitting. Let us only focus on refining it to structures or signatures inside of modules or module types (i.e. the first point above). For that, I suggest the following steps:
|
I've investigated this issue with @voodoos and the problem seems to be let a = 0
module M = struct
let x = 1
let y = 2
let z = 3
end which results in this parsetree:
We can see that module contains a list of However, the biggest challenge is how to type modules partially. We would need to be able to type a module with part of it's items, and then have a way of simply appending it to already typed module. This task seems to require thorough research, as I don't see a clear way how it should be done. I also can't estimate a time cost of this task and even it's doability. |
The buffer cache splits the parsetree into "last typing result can be re-used" and "needs to be typed". That splitting is currently only done on the level of top-level structure/signature items. Let's refine it on two levels:
The text was updated successfully, but these errors were encountered: