code: expose workspaces to other extensions; remove addProject command#15830
Conversation
|
cc: @Wilfred @P1n3appl3. |
2269c36 to
497c019
Compare
|
@lnicola don't land this yet, sorry! I'm working on a (quick) change that modifies (I should've commented sooner!) |
|
Yeah, no worries. Veykril might also want to take a look when he's back. |
| log.info(`running command: ${command}`); | ||
| const project: JsonProject = await vscode.commands.executeCommand(command); | ||
| this.addToDiscoveredWorkspaces([project]); | ||
| this.setWorkspaces([project]); |
There was a problem hiding this comment.
Maybe I'm not reading this correctly (it's quite possible I am) - but is the implication of this that if I am currently working in project1/foo.rs and then open a new .rs file in project2/bar.rs, I will lose r-a support in project1?
There was a problem hiding this comment.
You will not lose IDE functionality when switching targets.
The relationship between the rust-analyzer extension and the companion extension is a little weird. At startup, the rust-analyzer extension will pull data from the companion extension, but in the steady state, the companion extension will push changes to the rust-analyzer extension. The code you're commenting on is responsible for pulling changes at startup.
I need to cherry-pick changes I made on a branch that would make the companion extension fully control rust-analyzer's view of linkedProjects, which is what I was referring to when I asked Laurențiu not to land this PR.
Relatedly, rust-project will managed each workspace (the generated rust-project.json) based on the target label or the contents of _workspace (as set by with_rust_workspace).
|
@lnicola depending on your interest level, i've updated this PR to include the changes I wanted to. (let me know if I shouldn't @ you!) |
|
@bors delegate+ |
|
✌️ @davidbarsky, you can now approve this pull request! If @Veykril told you to " |
2625495 to
0cd68bf
Compare
|
@bors r+ |
|
☀️ Test successful - checks-actions |
…, r=Veykril feature: Create `UnindexedProject` notification to be sent to the client (Note that this branch contains commits from #15830, which I'll rebase atop of as needed.) Based on the discussion in #15837, I've added a notification and off-by-default toggle to send that notification from `handle_did_open_text_document`. I'm happy to rename/tweak this as needed. I've been using this for a little bit, and it does seem to cause a little bit more indexing/work in rust-analyzer, but it's something that I'll profile as needed, I think.
This (mostly red) PR does three things:
setWorkspacesandnotifyRustAnalyzer).setWorkspacesis needed to updatelinkedProjectswithout writing workspace/global configuration.notifyRustAnalyzerto get the server to pull the new configuration.CtximplementRustAnalyzerExtensionApito prevent accidental regressions.rust-analyzer.addProject, as that will live in a buck2 companion extension. No need for that to be in rust-analyzer!I can see the utility of combining
notifyRustAnalyzerandsetWorkspacesinto a single method (updateWorkspacesAndNotify()?), but I don't feel strongly about this. My feeling is that this API could be easily changed in the future.