Skip to content
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

[Discussion] [Live Share] Restricting language services on file scheme #492

Merged
merged 4 commits into from
Apr 5, 2018

Conversation

lostintangent
Copy link
Contributor

@lostintangent lostintangent commented Apr 4, 2018

In preparation for Visual Studio Live Share adding support for "guests" to receive remote language services for Java, this PR simply updates the current DocumentSelector to be limited to file and untitled (unsaved) files. This way, when someone has this extension installed, and joins a Live Share session (where files use the vsls: scheme), their language services will be entirely derived from the remote/host side, which provides a more accurate and project-wide experience (guests in Live Share don't have local file access to the project they're collaborating with).

If someone joins a Java project using Live Share, and doesn't have this extension installed, then they will automatically receive language services from the host (which is awesome! 🎉), so this PR is simply an optimization for the case where collaborating developers both have the Java extension installed. Additionally, this wouldn't impact the "local" Java development experience.

Note: As an example, the TypeScript/JavaScript language services that come in-box with VS Code already have this scheme restriction, and so this PR replicates that behavior.

Signed-off-by: Jonathan Carter <joncart@outlook.com>
src/extension.ts Outdated
documentSelector: ['java'],
documentSelector: [
{ scheme: 'file', language: 'java' },
{ scheme: 'untitled', language: 'java' }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need

{ scheme: 'jdt', language: 'java' },

else we lose all the java support (hover, navigation...) when opening sources (try ctrl+click on String)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Just fixed this.

@fbricon
Copy link
Collaborator

fbricon commented Apr 5, 2018

@lostintangent your "Visual Studio Live Share" link is dead, do you have a better one?

Signed-off-by: Jonathan Carter <joncart@outlook.com>
@lostintangent
Copy link
Contributor Author

@fbricon Apologies! I forgot to add the http:// prefix to the link in my PR description (that's fixed now). https://code.visualstudio.com/visual-studio-live-share

src/extension.ts Outdated
@@ -82,6 +85,7 @@ export function activate(context: ExtensionContext) {
let languageClient = new LanguageClient('java', 'Language Support for Java', serverOptions, clientOptions);
languageClient.registerProposedFeatures();
languageClient.onReady().then(() => {
toggleItem(window.activeTextEditor, item);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too comfortable moving the toggleItem call here. It's currently displayed as soon as the extension starts, regardless of the server state. Now, if there's an error, it won't be displayed, so you won't be able to open the server output log from there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I'll revert this change, as it isn't critical to the main intent of this PR.

Signed-off-by: Jonathan Carter <joncart@outlook.com>
Signed-off-by: Jonathan Carter <joncart@outlook.com>
@fbricon fbricon merged commit daa4dc6 into redhat-developer:master Apr 5, 2018
@fbricon
Copy link
Collaborator

fbricon commented Apr 5, 2018

@lostintangent thanks for the patch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants