Skip to content

Support consuming document changes incrementally #330

@vinistock

Description

@vinistock

We're getting close to the design of the resolution phase working properly and now a new problem arises: we are only able to take all of the information we indexed and transform it in one go, but we have no way of accounting for incremental changes.

To support usage in LSP mode (and in the future, incremental mode through the database), we need to be able to consume changes incrementally.

As part of this issue, let's understand how we can implement this.

Notes

The unit of indexing or consuming changes is always the same: a document. The incremental aspect comes from understanding what kind of change happened and matching that to what needs to happen in the subsequent parts of the analysis.

Some examples:

  • If someone just adds a bunch of blank lines in a file, we need to index it again (to update the offsets), but there's no need to discard declaration level information or run resolution again
  • If someone adds new declarations that don't impact constant and ancestor resolution (like a new method), maybe we can skip most of the resolution phase
  • If someone deletes a constant or changes inheritance, we need to try to compute the minimum amount of work that has to happen to account for it

My understanding is that most type checkers use hashed values for this. For example, if we hash all definitions that we got in a local graph from indexing a single document and that doesn't match the previous state, then there are new/modified definitions (maybe we need to remember the definition hashes in Document?). Maybe we need an ancestors hash?

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions