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

Add correct extension mode to plugin context #10977

Merged
merged 3 commits into from
May 25, 2022

Conversation

eneufeld
Copy link
Contributor

@eneufeld eneufeld commented Apr 1, 2022

Fix #10201

Contributed on behalf of STMicroelectronics
Signed-off-by: Eugen Neufeld [email protected]

What it does

The plugin context was hardcoded to have the production extensionMode.
Now a flag is passed to mark a plugin as under development when
deploying it. This flag is stored in the plugin metadata and later set in
the plugin. When creating the context this flag is then converted to the
correct extensionMode.

How to test

Download this plugin project: theia-hello-world-plugin.zip .
It contains a built version of the plugin which you should add to your plugins folder. This add a new command which opens a message with Hello World! Mode: ${mode} where the mode is the extensionMode. For the deployed plugin the mode should be '1' (Production).
Also add the project to your workspace so that you can start the plugin in a hosted version, by calling Hosted mode: start instance. When you trigger the command now in the hosted mode, the message should be Hello World! Mode: 2 (Development).

Review checklist

Reminder for reviewers

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

@eneufeld thank you for the contribution, please be sure to properly fill out the pull-request template including steps on how to test for reviewers (ideally with an example plugin).

@vince-fugnitto vince-fugnitto added the vscode issues related to VSCode compatibility label Apr 1, 2022
@eneufeld
Copy link
Contributor Author

eneufeld commented Apr 4, 2022

@vince-fugnitto sorry, I was to fast creating the PR. I updated the description now.

@@ -131,6 +131,7 @@ export class HostedPluginDeployerHandler implements PluginDeployerHandler {
}

const metadata = this.reader.readMetadata(manifest);
metadata.isUnderDevelopment = isUnderDevelopment;
Copy link
Contributor

@colin-grant-work colin-grant-work May 10, 2022

Choose a reason for hiding this comment

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

I think that this line suggests that the approach taken here is a little bit against the grain of how the plugin system should work: ideally the plugin reader system should set the metadata, but here isUnderDelevopment is grafted onto the metadata after the readers have had their say. Given that, I think the correct approach would be to ensure that whichever HostedPluginReader is responsible for setting the metadata of the plugin under development correctly sets this field, rather than passing it through the deployer system.

There's some terminological confusion here, unfortunately. HostedPluginReader is the name of the class implemented in hosted-plugin-reader.ts which passes the plugin under development into the plugin deployer system, but it's also the name of the class implemented in plugin-reader.ts. The latter is responsible for setting the metadata by delegating to MetadataScanners, and it's there that the plugin should be marked as 'under development'. It looks like the originID = 'Hosted Plugin' of the PluginDeployerEntry created in hosted-plugin-reader.ts should be a good marker for the metadata scanners to use to identify the plugin that is under development and set the isUnderDevelopment field by.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the review and the hints to clean up the code.
Unfortunately the scanner never has access to the PluginDeployerEntry.
I now set a marker inside the PluginDeployerEntryImpl based on the originId and instead of passing the isUnderDelevopment through the deployment system, the value is read from the PluginDeployerEntry.
What do you think, is this a viable approach?

Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately the scanner never has access to the PluginDeployerEntry.

Quite right.

I now set a marker inside the PluginDeployerEntryImpl based on the originId and instead of passing the isUnderDelevopment through the deployment system, the value is read from the PluginDeployerEntry.
What do you think, is this a viable approach?

I think that's fine. It still cuts a little against the grain, but the metadata system as it is currently implemented isn't worth working around that much. The alternative, which I don't really think is desirable in this case, since there will only ever be one plugin to which isUnderDevelopment applies, is to implement a separate service to track which plugin is underDevelopment and then access that service from the metadata reader. I've done something similar to that here for uninstalled plugins, but I don't think that much machinery is required for this use case.

@colin-grant-work colin-grant-work self-requested a review May 14, 2022 17:31
@@ -47,6 +47,7 @@ export class PluginDeployerEntryImpl implements PluginDeployerEntry {
} else {
this.resolved = false;
}
this.storeValue('isUnderDevelopment', originId === 'Hosted Plugin');
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this needs to be done in the PluginDeployerEntryImpl. The HostedPluginReader(packages/plugin-dev/src/node/hosted-plugin-reader.ts) can call storeValue on the plugin deployer entry that it creates.

CHANGELOG.md Outdated
@@ -3,6 +3,11 @@
## History

- [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/)
## v1.25.0 - 4/28/2022
Copy link
Contributor

Choose a reason for hiding this comment

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

This will need to be moved to the section for 1.26

eneufeld added 2 commits May 20, 2022 11:18
The plugin context was hardcoded to have the production extensionMode.
Now a flag is passed to mark a plugin as under development when
deploying it. This flag is stored in the plugin metadata and later set in
the plugin. When creating the context this flag is then converted to the
correct extensionMode.

Fix eclipse-theia#10201

Contributed on behalf of STMicroelectronics
Signed-off-by: Eugen Neufeld <[email protected]>
As indicated in a review, remove the passing `isUnderDevelopment`
through the deployment system.
@eneufeld eneufeld force-pushed the 10201-extensionmode branch from 4baf4c0 to af88af0 Compare May 20, 2022 09:25
@eneufeld eneufeld force-pushed the 10201-extensionmode branch from af88af0 to 85a0bc9 Compare May 20, 2022 09:25
@colin-grant-work colin-grant-work self-requested a review May 20, 2022 14:21
Copy link
Contributor

@colin-grant-work colin-grant-work left a comment

Choose a reason for hiding this comment

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

The changes are sound and correctly set the plugin mode 👍

@JonasHelming JonasHelming merged commit 1732179 into eclipse-theia:master May 25, 2022
@JonasHelming JonasHelming added this to the 1.26.0 milestone May 25, 2022
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.

Implement ExtensionMode
4 participants