-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
code: expose workspaces to other extensions; remove addProject
command
#15830
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. |
editors/code/src/ctx.ts
Outdated
@@ -190,7 +191,7 @@ export class Ctx { | |||
const command = `${this.config.discoverProjectRunner}.discoverWorkspaceCommand`; | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm with a the comment nit
@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:
setWorkspaces
andnotifyRustAnalyzer
).setWorkspaces
is needed to updatelinkedProjects
without writing workspace/global configuration.notifyRustAnalyzer
to get the server to pull the new configuration.Ctx
implementRustAnalyzerExtensionApi
to 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
notifyRustAnalyzer
andsetWorkspaces
into 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.