Skip to content

Allows plugin to register commands - #44291

Merged
Nathan Shively-Sanders (sandersn) merged 8 commits into
microsoft:mainfrom
Kingwl:allow_typescript_plugin_to_register_commands
Jun 18, 2021
Merged

Nathan Shively-Sanders (sandersn) merged 8 commits into
microsoft:mainfrom
Kingwl:allow_typescript_plugin_to_register_commands

Conversation

@Kingwl

Copy link
Copy Markdown
Contributor

@Kingwl
Wenlu Wang (Kingwl) marked this pull request as draft May 27, 2021 08:26
@typescript-bot TypeScript Bot (typescript-bot) added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label May 27, 2021
@typescript-bot

Copy link
Copy Markdown
Contributor

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@RyanCavanaugh

Copy link
Copy Markdown
Member

Sheetal Nandi (@sheetalkamat) this seems about right to me. Thoughts?

@sheetalkamat Sheetal Nandi (sheetalkamat) left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would rather prefer if enablePlugins passes session (along with project which is already passed in) to the plugin rather than having these extra methods and we having to deal with the additions etc

@Kingwl
Wenlu Wang (Kingwl) force-pushed the allow_typescript_plugin_to_register_commands branch from b411c08 to fad1c05 Compare May 28, 2021 10:14
@Kingwl

Copy link
Copy Markdown
Contributor Author

I'm not pretty sure what's different about these kind of projects.

Comment thread src/server/editorServices.ts Resolved
Comment thread src/server/editorServices.ts Resolved
Comment thread src/server/editorServices.ts Resolved

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also add test for plugin where session is passed through and you call addProtocolHandler and test that functionality
Tests are in src/testRunner/unittests/tsserver/plugins.ts

private packageJsonFilesMap: ESMap<Path, FileWatcher> | undefined;

/*@internal*/
readonly session: Session<unknown> | undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you should wire TMessage thing here and PluginCreateInfo too,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought the unknown is better:

If we add type parameter TMessage into editorService, We should also add the type parameter into Project and etc. Too many changes.

And we are not really care about the type of message in editorService. We just forward session into pluin.

And the handlers or addProtocolHandler does not have TMessage too. Thay are raw string.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If that’s the case we shouldn’t add it to project service options either

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

need to update tsserverlibrary.d.ts baseline but otherwise change looks good. Thank you for your patience and sorry for going back and forth on this one as it was little unclear if TypeParameter was needed or not until you made those changes.

@Kingwl

Copy link
Copy Markdown
Contributor Author

Never mind.

@RyanCavanaugh

Copy link
Copy Markdown
Member

Wenlu Wang (@Kingwl) are you OK if I un-draft and merge this?

@Kingwl

Wenlu Wang (Kingwl) commented Jun 16, 2021 •

Copy link
Copy Markdown
Contributor Author

Wenlu Wang (@Kingwl) are you OK if I un-draft and merge this?

Sure. Please feel free to merge.
Sorry. I havn't noticed that this is a draft.

@RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh) marked this pull request as ready for review June 16, 2021 20:33
@sandersn

Copy link
Copy Markdown
Member

Just noticed this in the PR backlog. I'm going to merge it since it looks ready to go.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants