This is an archive of the discontinued LLVM Phabricator instance.

[mlir-vscode] Add better support for multiple workspace folders
ClosedPublic

Authored by rriddle on Mar 31 2022, 2:26 AM.

Details

Summary

We currently only launch one set of language clients when starting the extension,
but this has the unfortunate effect of applying the same settings to all workspace
folders. This commit adds support for multiple workspace folders by launching
a server for each folder in the workspace. This allows for having different servers
for different workspace folders, e.g. when there are multiple MLIR projects in
the same workspace.

Diff Detail

Event Timeline

rriddle created this revision.Mar 31 2022, 2:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 31 2022, 2:26 AM
rriddle requested review of this revision.Mar 31 2022, 2:26 AM
jpienaar accepted this revision.Mar 31 2022, 7:16 AM

LG, I'm just not sure how much the optionality/null is getting you here vs extra paths created.

mlir/utils/vscode/src/mlirContext.ts
44

Is it inefficient to specify workspace folder rather than null in the singleton case?

This revision is now accepted and ready to land.Mar 31 2022, 7:16 AM
rriddle updated this revision to Diff 420611.Apr 5 2022, 1:06 PM
rriddle edited the summary of this revision. (Show Details)
rriddle marked an inline comment as done.

LG, I'm just not sure how much the optionality/null is getting you here vs extra paths created.

The problem is that a workspace folder isn't actually available in all cases, so to avoid the null checks we'd have to make the extension fail in certain cases (though to be fair, I'm not sure how important those specific cases are).

mlir/utils/vscode/src/mlirContext.ts
44

In this case (the one where the comment is pointing) there is no workspace folder, such as when you just open a .mlir file. In the case where we only have one folder in the workspace, passing in the folder shouldn't be inefficient given that it helps gate various things (such as finding the server). Providing the workspace folder when possible also properly handles when the folder itself overrides the extension configuration (e.g. to specify a specific server).