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

[plug-in] Implement inspect configuration method of Preferences API #4153

Merged
merged 1 commit into from
Jan 30, 2019

Conversation

akurinnoy
Copy link
Contributor

@akurinnoy akurinnoy commented Jan 23, 2019

This PR adds the implementation of inspect method without the support of multi-root workspaces.

resolves #2289

Signed-off-by: Oleksii Kurinnyi okurinny@redhat.com

@akurinnoy akurinnoy added the plug-in system issues related to the plug-in system label Jan 23, 2019
@akurinnoy akurinnoy self-assigned this Jan 23, 2019
@@ -30,6 +30,7 @@ import './preferences-monaco-contribution';
export function bindPreferences(bind: interfaces.Bind, unbind: interfaces.Unbind): void {
unbind(PreferenceProvider);

bindDefaultPreferenceProvider(bind);
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need an external function
seems like the two following are not using a function so maybe could just write there:

bind(PreferenceProvider).to(PreferenceSchemaProvider).inSingletonScope().whenTargetNamed(PreferenceScope.Default);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this function to avoid further merge conflict with #3247.

}, {});
return result;
}, {});
} catch (e) { }
Copy link
Contributor

@benoitf benoitf Jan 23, 2019

Choose a reason for hiding this comment

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

silent catch ?
in which case does it fail ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It fails if data is undefined or null.
But, in this case
https://github.com/theia-ide/theia/blob/b8d8490740d50a97e32618d2d4d4711e49156ac2/packages/plugin-ext/src/plugin/preference-registry.ts#L213-L215
will fail as well. So, I'm going to refactor it.

@akurinnoy
Copy link
Contributor Author

@benoitf @akosyakov PR is updated

@@ -59,6 +60,10 @@ export function bindPreferenceSchemaProvider(bind: interfaces.Bind): void {
bindContributionProvider(bind, PreferenceContribution);
}

export function bindDefaultPreferenceProvider(bind: interfaces.Bind): void {
bind(PreferenceProvider).to(PreferenceSchemaProvider).inSingletonScope().whenTargetNamed(PreferenceScope.Default);
Copy link
Member

Choose a reason for hiding this comment

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

There is already instance of PreferenceSchemaProvider provided via bindPreferenceSchemaProvider.
bindDefaultPreferenceProvider should not create a completely different instance for PreferenceProvider symbol.

You can just inject PreferenceSchemaProvider in plugin-contribution-handler:

@inject(PreferenceSchemaProvider)
private readonly preferenceSchemaProvider: PreferenceSchemaProvider;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

yes, it should be alright

import cloneDeep = require('lodash.clonedeep');

/* tslint:disable:no-any */

Copy link
Member

Choose a reason for hiding this comment

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

There should be CQ for any copied code. BTW do you change it? I think we already have this code in Monaco, so maybe you delete it and just expose then you don't need CQ and we have less code to maintain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, that code from Monaco cannot be reused in plugin's part of API. In order to avoid opening a CQ, I got rid of copied code and implemented it on my own.

Copy link
Member

Choose a reason for hiding this comment

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

ok

Signed-off-by: Oleksii Kurinnyi <okurinny@redhat.com>
@akurinnoy
Copy link
Contributor Author

@akosyakov PR is updated, please review it again

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

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

Super, verified with debug-auto-attach VS Code extension, toggling works now nicely 👍

screen shot 2019-01-30 at 09 52 52

@akurinnoy akurinnoy merged commit 6b1a35c into eclipse-theia:master Jan 30, 2019
@akurinnoy akurinnoy deleted the inspect-configuration branch July 30, 2019 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plug-in system issues related to the plug-in system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[plug-in] Implement inspect configuration
6 participants