-
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
Find All references
doesn't exist for typescript plugin #14856
#7055
Conversation
I can have a look but later this week. If someone else can test and review it would help. That's cool btw :) Tree styling on the screenshot looks bad. |
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.
Looks good in general, but I have a couple of suggestions/questions
packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts
Outdated
Show resolved
Hide resolved
packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts
Outdated
Show resolved
Hide resolved
@@ -108,6 +108,23 @@ export class TreeViewsMainImpl implements TreeViewsMain, Disposable { | |||
} | |||
} | |||
|
|||
async $setMessage(treeViewId: string, message: string): Promise<void> { | |||
this.viewRegistry.getView(treeViewId).then(viewPanel => { |
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.
Do we need some error handling here? What if the tree view does not exist?
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.
Not sure if we can do anything here (with $setMessage
or $setTitle
) in case of tree view doesn't exist. Add an error record to Log?
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.
Yes, this indicates something is wrong, needs to got to the log even if we can't handle 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.
When I try to print an error by console.error(...)
TSLint says: Calls to 'console.error' are not allowed. (no-console)tslint(1)
.
What is the correct way o report an error here?
mappings['goToNextReference'] = ['goToNextReference', MONACO_CONVERSION_IDENTITY]; | ||
mappings['goToPreviousReference'] = ['goToPreviousReference', MONACO_CONVERSION_IDENTITY]; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const VSCODE_CONVERSION_IDENTITY = (args: any[] | undefined) => { |
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.
Also, this is not an identity, it changes stuff. Needs a better name.
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.
Renamed
if (!thing) { | ||
return false; | ||
} | ||
return ('startLineNumber' in thing) && ('startColumn' in thing) && |
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.
Shouldn't we be checking the types are correct?
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.
How? I use these methods (isModelLocation(), isModelRange() and isUriComponents()) in result conversion in order to detect if I can convert an object into a theia.Location, theia.Range etc. Here I have a json-like object with properties. No type nor type name available...
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.
still, doesn't startLineNumber
have to be of type number
?
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.
added checks for property types
@@ -390,7 +411,8 @@ export class Range { | |||
return new Range(start, end); | |||
} | |||
|
|||
static isRange(thing: {}): thing is theia.Range { | |||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |||
static isRange(thing: any): thing is theia.Range { |
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.
Why is this change necessary?
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.
The same reason: to make this class to be defined exactly as it's done in VS Code. Probably it's not necessary change.
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 can rollback the changes in types-impl.ts as they aren't necessary and do not bring any fixes/improvements regarding this issue. Rolledback in fixup
For that specific issue, there is a bug tracking icons which are not rendered in Electron: #7040 |
It is a regression: #7109 |
I've uploaded a new version of PR. Most of requests to change were reworked, but not all. For example, #7055 (comment) - to improve KnownCommands.map()... |
I've pushed a new version of PR:
@tsmaeder Please review. |
|
||
if (widget instanceof TreeViewWidget) { | ||
widget.message = message; | ||
} else { |
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'm not sure about logging errors in else cases, other methods don't do it. It could be that message is resolved by the time when a user already closed the tree, there is nothing bogus to ignore message then.
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.
It was requested by @tsmaeder. I also think the logging is not needed here.
During the run this error appears several times, while not always indicate a real problem with absent widget.
It was discussed here: #7055 (comment)
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.
So what we're trying to guard here is the widget being present, not that it might be there but not a TreeWidget? Then why not do a if (widget)
It has the same effect, but IMO would be better express the meaning.
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.
If we do like here #7055 (comment) then we should log error if only metadata is missing completely (such view is not registered). The same for title.
import { cloneAndChange } from './objects'; | ||
import { Position, Range, Location } from '../plugin/types-impl'; | ||
import { fromPosition, fromRange, fromLocation } from '../plugin/type-converters'; | ||
import { cloneAndChange } from '../common/objects'; |
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.
Could someone elaborate except moving this file and renaming things what was fixes in this file? It is used for all commands triggered by the plugin host process would be bad to break 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.
For vscode.executeReferenceProvider
and vscode.executeImplementationProvider
, as they return location array as result, it is required to convert the result from model.*
objects to theia.*
objects in order to be accepted by VSCode Reference View plugin.
So, optional property is added to the mapping to specify the converter function that is to be used to convert the results. As it is optional, there is no need to add this property to all the other existing mappings. Currently, CONVERT_MONACO_TO_VSCODE
is added to convert the results array into an array of theia.Location
objects. It's used to convert the results of vscode.executeReferenceProvider
and vscode.executeImplementationProvider
command execution.
The only change for the old
mappings is that MONACO_CONVERSION_IDENTITY
function used for arguments conversion is renamed to CONVERT_VSCODE_TO_MONACO
(in order to indicate the fact that it really changes arguments - requested by @tsmaeder )
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.
Unfortunately, the github diff algorithm is being really stupid here: there are loads of single line changes in the command definitions, but GH picks it up as a two entirely changed blocks of code 🤷♂
@@ -159,6 +176,10 @@ class TreeViewExtImpl<T> implements Disposable { | |||
private readonly onDidChangeVisibilityEmitter = new Emitter<TreeViewVisibilityChangeEvent>(); | |||
readonly onDidChangeVisibility = this.onDidChangeVisibilityEmitter.event; | |||
|
|||
protected updateMessage = debounce(() => { |
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.
Why to debounce? Did you observe any performance or usability issues?
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.
At first invocation of Find All References
or Find All Implementations
command, the Reference View widget is not yet created, so I cannot set a message on it. So, when you ask for the references or implementation for the first time the references tree will be shown without that search summary message. Debouncing solves this problem.
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.
No, we cannot just "do it later". The problem here is that the state of the tree view can be changed before the widget in the UI is actually created. This just means that we need to transfer the state at the time the widget is created. But this can be 5 minutes after creation of the tree view, so the debounce() is not reliable.
IMO, we have to pass message and title to TreeViewsMain#reveal(). I think that is the only way a plugin can make a tree view visible, right?
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.
Note sure where to put the message when the widget is not created yet. @akosyakov any suggestions how to do that?
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.
Had a discussion on Friday and will investigate what the behaviour of createTreeView
should be: if it is supposed to open the widget, the set message
should come afterwards and succeed.
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.
The widget creation happens in several steps and is distributed in several events and backend/frontend communications.
During this process $setMessage
and $setTitle
are invoked with default values message=undefined
and title="Results"
in order to indicate that the reference tree is empty during the search for the references (the results are not received yet) - trying to process this initial call is the reason of debounce
appearance.
And it is still possible that $setMessage
with a valuable message will be called before the widget is finally initialized and added to the view on the first request for references/implementations.
After the widget creation these methods are called once again with the real (not empty) values.
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 it should be part of tree view metadata which initially loaded from package.json. When $setMessage
or $setTitle
are called then metadata should be updated and used during creation. If a view already present then we update it as well.
Actually for title
is even stated it in js-doc:
The tree view title is initially taken from the extension package.json
Changes to the title property will be properly reflected in the UI in the title of the view.
We should respect it and make sure that initial title and message from metadata are installed properly. It does not seem to happen in the PR.
When I test it with Electron, in some cases the result items are highlighted, in other cases are not. In case such an item is not highlighted it's enough to mouse click on editor area (so the editor receives focus) - the search item immediately gets highlighted. Exactly the same happens when running Browser version.
Yes, it is. In my case I even didn't have |
Do I get correctly that the reference widget extension already makes use of the call hierarchy API? And we can replace our call hierarchy Theia extension by using it? |
No. The support for |
6cda569
to
a2bc6b3
Compare
The |
I'll fix spacing
Probably we should look into Label Provider: https://github.com/eclipse-theia/theia/blob/master/packages/core/src/browser/label-provider.ts#L203
What do you mean by "description color"? Is it a |
@vrubezhny Could you please do #7153 (comment) it will easy testing of this PR and it would be good to have this extension on master after merging. |
I've updated the PR with:
|
@vrubezhny I can reproduce it reliably for browser. Please make sure to reset the layout before that it is not opened. |
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.
Probably we should look into Label Provider: https://github.com/eclipse-theia/theia/blob/master/packages/core/src/browser/label-provider.ts#L203
I'd like to create a separate issue for this.
Ok, please create.
But I don't understand why some lines in your VSCode have orange foreground and a labeled like 9+ on the right... Is it a something in the UI specially made for MacOS?
We don't support tree item highlights VS Code API: https://github.com/vrubezhny/theia/blob/c9370d3de85b225419d7946938ac6d3ac5624a21/packages/plugin/src/theia-proposed.d.ts#L213 It would be good to file a new issue for this.
It looks good except keybindings don't work for me. |
@vrubezhny Don't care about keybindings. I know there is the issue and it will be fixed in: dae6865#diff-0291e1b92ff01c13c0dc1c98263ac426 Keybindings don't call command handlers properly, so the plugin system gets never notified about executed commands. |
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 it is good, there are some issues but they can be resolved separately. Please take care though about color variable comment before merging.
Fixes: #14856 Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
i believe all comments were addressed
Signed-off-by: Victor Rubezhny vrubezhny@redhat.com
What it does
The fix adds the required API and fixes required to make possible to run VSCode Reference View extension plug-in on Theia.
How to test
Tested manually using references-view-0.0.47 (https://github.com/microsoft/vscode-references-view) downloaded into
plugins/
Theia folder,Review checklist
Find All References
context menu action and revisiting the result tree of the References ViewFind All Implementations
context menu action and revisiting the result tree of the References ViewReminder for reviewers