-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
CodeAction
and CodeActionProviderMetaData
fields added
#10073
Conversation
bfae798
to
f06fff2
Compare
@tsmaeder Do you have an example extension at hand with which one can test these changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Archie27376 using the test plugin vscode-code-action I was able to confirm at least for the CodeAction
changes that there is still work to do.
bug-code-action.mp4
The cat
result in the quick-fix should not be displayed (similarly to vscode) as it is explicitly disabled.
The fix is quite simple however.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed that the behavior works correctly with the test plugin 👍
The cat
result is explicitly disabled and not visible similarly to vscode:
code-action-test.mp4
* | ||
* At most one documentation entry will be shown per provider. | ||
*/ | ||
documentation?: ReadonlyArray<{ command: Command, kind: CodeActionKind }> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how the documentation field is transferred to the main side and ultimately the monaco editor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can omit support for documentation
for now, it is used when registering registerCodeActionsProvider
but our implementation differs from vscode in many ways:
theia/packages/plugin-ext/src/plugin/languages.ts
Lines 441 to 456 in 0f7dec1
registerCodeActionsProvider( | |
selector: theia.DocumentSelector, | |
provider: theia.CodeActionProvider, | |
pluginModel: PluginModel, | |
pluginInfo: PluginInfo, | |
metadata?: theia.CodeActionProviderMetadata | |
): theia.Disposable { | |
const callId = this.addNewAdapter(new CodeActionAdapter(provider, this.documents, this.diagnostics, pluginModel ? pluginModel.id : '', this.commands)); | |
this.proxy.$registerQuickFixProvider( | |
callId, | |
pluginInfo, | |
this.transformDocumentSelector(selector), | |
metadata && metadata.providedCodeActionKinds ? metadata.providedCodeActionKinds.map(kind => kind.value!) : undefined | |
); | |
return this.createDisposable(callId); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But ultimately, we're registering the code action provider to the editor, which does have a documentation field. We should pass this info to the editor in Theia, as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tsmaeder Would you know how to properly pass the documentation
field? I myself am not sure how to go about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our definition of modes.CodeActionProvider is way out of date. We need to update our definition in monaco.d.ts and pass the necessary information to the front end through "registerQuickFixProvider". The current definition in monaco actually looks like this: https://github.com/microsoft/vscode/blob/2586299c42490a8ed6dff96ed731d44fcbe5b20e/src/vs/editor/common/languages.ts#L777
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looks like in the branch we currently use (0.23) of vs code, the definition lives here: (https://github.com/microsoft/vscode/blob/b882940dc6d5b2acb096969b9e43385248719df7/src/vs/editor/common/modes.ts#L740).
I believe it would work to extend the definition of CodeActionProvider in monaco.d.ts
with the needed bits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Archie27376 : Please have a look at the hints that Thomas provided and let us know if you need further information!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JonasHelming Dante's (@Archie27376) internship has terminated, someone else would need to pick up the pull-request.
What it does
Fixes #9989
disabled
andisPreferred
fields to theCodeAction
interfacedocumentation
field toCodeActionProviderMetaData
interfaceHow to test
:)
in the fileReview checklist
Reminder for reviewers