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

[vscode] basic support of activation events #5622

Merged
merged 3 commits into from
Jul 4, 2019

Conversation

akosyakov
Copy link
Member

@akosyakov akosyakov commented Jul 2, 2019

What it does

  • [vscode] support activation events #4199 - provides basic mechanism for activation events:
    • compatibility: if an activation event is not supported yet then an extension will be activated eagerly with *
    • support of onLanguage activation event
    • support of onCommand activation event

How to test

See how to deploy vscode extension here: https://github.com/theia-ide/theia/wiki/Testing-VS-Code-Extensions

Review Checklist

  • as an author I have carefully reviewed and thoroughly tested my changes.
  • commits are signed-off: https://github.com/theia-ide/theia/blob/master/CONTRIBUTING.md#sign-your-work
  • commit history is rebased on master and contains only meaningful commits and changes (less are usually better)
    • for example use git pull -r or git fetch && git rebase to pick up changes from the master
  • changelog is updated
  • breaking changes are justified and recorded in the changelog
  • each new file has a proper copyright with the current year and the name of contributing entity (individual or company)
  • new dependendencies are justified and verified
  • copied code is justified and approved via a CQ
  • new code is aligned with project organization and coding conventions
  • each review approve is provided with a comment regarding whether functionallity is tested, design or code are aligned with project organization and conventions
    • an approve without comment should be dismissed
    • a reviewer should focus on requirements and design validation first, testing second and checking code alignment as the last

@akosyakov
Copy link
Member Author

@evidolob Could you assign someone to help with the review?

private frontendExtManagerProxy: PluginManagerExt;
private backendExtManagerProxy: PluginManagerExt;

protected readonly managers: PluginManagerExt[] = [];
Copy link
Member Author

Choose a reason for hiding this comment

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

@evidolob @benoitf I've refactored this code to support multiple managers properly. Before one backend manager will receive events from the frontend. Are you fine with such breaking changes? I will update the changelog.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think refactoring and new feature should be separate commits or separate PR
moving from constructor injection to property injection is not directly linked to that PR so it makes a lot of extra changes for nothing.
I think this is kind of PR that I dislike the more when there is one change that is important but it's flooded by tons of cleanup/style/user preferences that should be just for that.
It's like something can't be added without changing all the code which usually is not so true.

BTW 'properly' is not meaningful. You should describe why it was limited and how you've removed that limitation so that people using that class are able to see what was the goal. This is more meaningful for me that a checklist of 100 items which are not describing the why, how and what.

besides that it's a great feature and I'm ok with the refactoring. But breaking change doesn't mean to mix enhancement/bugfixes with code cleanup/rewrite for its own style preference, etc the class in one step. It's so inconvenient to review.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think refactoring and new feature should be separate commits or separate PR
moving from constructor injection to property injection is not directly linked to that PR so it makes a lot of extra changes for nothing.
I think this is kind of PR that I dislike the more when there is one change that is important but it's flooded by tons of cleanup/style/user preferences that should be just for that.
It's like something can't be added without changing all the code which usually is not so true.

Generally agree that PRs should be to the point. Not sure about refactoring PRs itself. It is fine if there is good set of regression tests, but if there are not it is an extra effort to test again. I would try to make additional explicit commits for refactoring next time or better to look in the test infrastructure next weeks.

BTW 'properly' is not meaningful. You should describe why it was limited and how you've removed that limitation so that people using that class are able to see what was the goal. This is more meaningful for me that a checklist of 100 items which are not describing the why, how and what.

To be fair I've tried to describe it with: Before one backend manager will receive events from the frontend.. Maybe it was not clear: now all remote plugin host processes get notified about updated storage path and activation events. Agree that i had to put it in the description.

@AlexTugarev
Copy link
Contributor

Great preparation for a review @akosyakov! 🥇

Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
@akosyakov
Copy link
Member Author

I've pushed support of onCommand activation event. We need to check that there is no regressions for theia plugins which don't use package metadata but register command programatically. @benoitf @evidolob Could you recommend theia plugin for it? @azatsarynnyy maybe you can help to verify it

@kittaakos
Copy link
Contributor

@akosyakov, your last commit seems to broke the build: https://github.com/theia-ide/theia/pull/5622/files#diff-ab6e2d4c57658cf60e550cfe9ba87eacR291

@akosyakov
Copy link
Member Author

@kittaakos pushed again, should be good now

@azatsarynnyy
Copy link
Member

@akosyakov I've modified your extension here https://github.com/akosyakov/command-activation-event/blob/master/src/extension.ts#L20 to call another command

vscode.commands.executeCommand('extension.helloWorld2');

instead of showing a message.

Then I've forked your extension and slightly modified it
akosyakov/command-activation-event@master...azatsarynnyy:master

So, calling Hello World command from the 1'st extension via Cmd Palette should call extension.helloWorld2 command from the 2'nd extension which is the activation event for the 2'nd extension.
But calling Hello World command throws

root ERROR [hosted-plugin: 25339] (node:25339) UnhandledPromiseRejectionWarning: Error: The command 'extension.helloWorld2' cannot be executed. There are no active handlers available for the command.
    at CommandRegistry.<anonymous> (http://localhost:3000/bundle.js:107193:31)
    at step (http://localhost:3000/bundle.js:106971:23)
    at Object.next (http://localhost:3000/bundle.js:106952:53)
    at fulfilled (http://localhost:3000/bundle.js:106943:58)

@kittaakos
Copy link
Contributor

kittaakos commented Jul 3, 2019

Fixed

I got this after installing the go extension as suggested in the description and I clicked on:

Screen Shot 2019-07-03 at 14 54 19

Uncaught (in promise) Error: The command 'go.promptforinstall' cannot be executed. There are no active handlers available for the command.
    at CommandRegistry.<anonymous> (command.ts:285)
    at step (command.ts:15)
    at Object.next (command.ts:15)
    at fulfilled (command.ts:15)

@kittaakos
Copy link
Contributor

[out-of-scope?]: I do not know if this is a bug or the desired behavior, but I put all three above-mentioned plug-ins into the plugins folder and I can see:

root INFO [hosted-plugin: 55804] PLUGIN_HOST(55804): initializing(/Users/akos.kitta/git/theia/packages/plugin-ext-vscode/lib/node/plugin-vscode-init.js)

root INFO [hosted-plugin: 55804] PLUGIN_HOST(55804): initializing(/Users/akos.kitta/git/theia/packages/plugin-ext-vscode/lib/node/plugin-vscode-init.js)

root INFO [hosted-plugin: 55804] PLUGIN_HOST(55804): initializing(/Users/akos.kitta/git/theia/packages/plugin-ext-vscode/lib/node/plugin-vscode-init.js)

I wonder why do we log the same things three times.

Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

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

I read through the code, added a few remarks here and there. I also tried it with the command, language, and the "wildcard" activation. They've worked. 🎉 Let's improve the documentation for the new command API.

packages/core/src/common/command.ts Show resolved Hide resolved
packages/core/src/common/command.ts Show resolved Hide resolved
/**
* An event is emmited when a command is about to be executed.
*
* It can be used to install or active a command handler.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: or activate

Copy link
Member Author

Choose a reason for hiding this comment

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

done

packages/plugin-ext/src/plugin/plugin-manager.ts Outdated Show resolved Hide resolved
packages/plugin-ext/src/api/plugin-api.ts Show resolved Hide resolved
packages/core/src/common/command.ts Show resolved Hide resolved
@akosyakov
Copy link
Member Author

@kittaakos could you file an issue for #5622 (comment)? I don't know either.

@akosyakov
Copy link
Member Author

@azatsarynnyy it cannot work, since command declaration is missing, It is mandatory in VS Code. I will verify it. registerCommand works differently for theia and vscode namespaces. For theia it registers a command, for vscode it registers a handler.

@akosyakov
Copy link
Member Author

@azatsarynnyy oh, actually it does work in VS Code 😄

@akosyakov
Copy link
Member Author

@azatsarynnyy could you try again? I've adjusted logic how we register commands for vscode namespace, now only if a command is presented in the metadata it will be registered as a handler, otherwise like a command and handler. See https://github.com/theia-ide/theia/pull/5622/files#diff-66cd2825aa616ad9a26b1f62e1b21e5b

Super simple and good test btw. It verified theia plugins and found new and existing bugs :)

@akosyakov
Copy link
Member Author

akosyakov commented Jul 3, 2019

@kittaakos Can you try again #5622 (comment)? I cannot reproduce it in Gitpod, will try locally. But probably it is fixed by #5622 (comment) as well

I was not able to reproduce it locally as well:
Screen Shot 2019-07-03 at 17 56 39
Screen Shot 2019-07-03 at 17 56 35

Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
@akosyakov akosyakov added the vscode issues related to VSCode compatibility label Jul 4, 2019
@kittaakos
Copy link
Contributor

Can you try again #5622 (comment)?

No errors this time 👍

@kittaakos kittaakos self-requested a review July 4, 2019 07:27
Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

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

I have verified it once more locally. I have checked the followings:

  • go extension,
  • activation by language, and
  • activation by command.

It worked. I did not see any errors in the logs. Very nice 👍

PS: Thank you for adding the empty lines 😊

Copy link
Member

@azatsarynnyy azatsarynnyy left a comment

Choose a reason for hiding this comment

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

@akosyakov I've tested it again with two plugins and plugin activation works well

Copy link
Contributor

@benoitf benoitf left a comment

Choose a reason for hiding this comment

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

tested with one che-theia example

@akosyakov akosyakov mentioned this pull request Jul 4, 2019
1 task
@akosyakov akosyakov merged commit b39a852 into master Jul 4, 2019
@akosyakov akosyakov deleted the ak/basic_activation_event branch July 4, 2019 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants