kisstkondoros / codemetrics

VSCode extension which shows the complexity information for TypeScript class members
Other
402 stars 20 forks source link

Adding support from Visual Studio Live Share #52

Closed lostintangent closed 6 years ago

lostintangent commented 6 years ago

This PR adds support for Visual Studio Live Share, which allows developers who have this extension installed, to continue seeing code complexity metrics while collaborating on someone else's project. On the guest's side, files use the vsls scheme, which prevents this extension from displaying metrics, despite the fact that it would otherwise work. Note that the green/yellow/red decorator already displays in all scheme types, so this change simply allows the CodeLens to show as well. For example, this is what the experience looks like for a Live Share guest before this PR:

screen shot 2018-02-24 at 8 05 38 pm

And this is what the experience looks like after the PR. Notice that both the guest and the host of the collaboration session are able to view metrics, which is awesome, since the "guest" might want to see this metadata and recommend some refactoring to the developer he/she is helping:

screen shot 2018-02-24 at 8 07 10 pm

As a side effect of removing the scheme in general, the complexity metrics would also begin showing up in "untitled" files (e.g. unsaved/in-memory documents), which seems reasonable to me, since the red/green/yellow decorator would already show up, and the CodeLens is already filtered by supported languages.

// CC @kisstkondoros

kisstkondoros commented 6 years ago

Thank you!

kisstkondoros commented 6 years ago

Version 1.12.0 was just published, thanks again!

lostintangent commented 6 years ago

@kisstkondoros Awesome!

kisstkondoros commented 6 years ago

Hi @lostintangent,

could you please check the change in https://github.com/kisstkondoros/codemetrics/commit/fd1212f3ce0358d68a952b596f1c451eaaf89dcd wether it is still suitable for vsls? I couldn't find any hint for what kind of scheme should I specify in order to avoid the warning log at runtime but still be compatible with vsls.

Extension 'kisstkondoros.vscode-codemetrics' uses a document selector without scheme. Learn more about this: https://go.microsoft.com/fwlink/?linkid=872305

Thanks in advance!

lostintangent commented 6 years ago

@kisstkondoros The downside of that change is that if a Live Share guest has CodeMetrics installed, then they wouldn't see the CodeMetrics code lenses anymore. That's because documents on their end use the vsls file scheme as opposed to file. If you'd like, you could simply add vsls to that scheme array and that would fix it.

That said, we're about to do the work to share code lenses from the Live Share host->guest, at which point, guests would see CodeMetrics as long as the host had that extension installed (even if they didn't have it installed!). So, I'd recommend just leaving things for now, and we'll resolve this by "remoting" the code lenses all-up.

kisstkondoros commented 6 years ago

Thanks @lostintangent for taking time answering this. I'll leave it as it is for now then.