starkware-libs / cairo

Cairo is the first Turing-complete language for creating provable programs for general computation.
Apache License 2.0
1.6k stars 495 forks source link

Get rid of needless `scarb metadata` calls #6689

Open piotmag769 opened 22 hours ago

piotmag769 commented 22 hours ago

This PR improves UX regarding project loading for Scarb projects (so assume the rest of the description concerns only these). Logic regarding cairo_project.toml-based projects remains unchanged as there is no such an UX issue associated with them.

Before this PR scarb metadata was called on every didOpen notification. Moreover it was called once for each currently open file when:

This PR changes it so we keep paths to Scarb.tomls that correspond to members of Scarb's workspaces we already analysed/loaded.

When a didOpen notification is received, we check if the path to Scarb.toml for the opened file is in paths. If it is, we skip the scarb metadata execution, else we do as before, but we add paths of all workspace members' manifests to paths.

Keep in mind it also improves UX for the two remaining cases: we clear paths and load projects for all currently open files, but loading a project for one file from workspace A will prevent redundant scarb metadata calls for all the other open files from workspace A (via mechanism described above).

reviewable-StarkWare commented 22 hours ago

This change is Reviewable