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 Go to Super Implementation to context menu and command palette #1395

Merged
merged 1 commit into from
Jul 21, 2020

Conversation

jdneo
Copy link
Collaborator

@jdneo jdneo commented Apr 16, 2020

demo

Note: so far, if the selected element has no super implementation, we are not able to show the editor message. This need VS Code to support such API. See: microsoft/vscode#95308

Signed-off-by: Sheng Chen sheche@microsoft.com

@fbricon
Copy link
Collaborator

fbricon commented Apr 22, 2020

The fact the menu item shows up everywhere is very distracting, given than there's no feedback when you call it

@jdneo
Copy link
Collaborator Author

jdneo commented Apr 23, 2020

@akaroml Let's sync with VS Code team about this issue. We need the API to show the editor message. Otherwise the no-feedback behavior would make user confused.

@jdneo
Copy link
Collaborator Author

jdneo commented Jun 29, 2020

Update: VS Code team has exposed a new API to show the editor message. I will update this PR after the next VS Code stable version released.

@jdneo
Copy link
Collaborator Author

jdneo commented Jul 10, 2020

@fbricon @testforstephen PR updated

Comment on lines 252 to 259
return commands.executeCommand(
'editor.action.goToLocations',
window.activeTextEditor.document.uri,
window.activeTextEditor.selection.active,
[],
'goto',
'No super implementation found'
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

CommandsRegistry.registerCommand({
	id: 'editor.action.goToLocations',
	description: {
		description: 'Go to locations from a position in a file',
		args: [
			{ name: 'uri', description: 'The text document in which to start', constraint: URI },
			{ name: 'position', description: 'The position at which to start', constraint: corePosition.Position.isIPosition },
			{ name: 'locations', description: 'An array of locations.', constraint: Array },
			{ name: 'multiple', description: 'Define what to do when having multiple results, either `peek`, `gotoAndPeek`, or `goto' },
			{ name: 'noResultsMessage', description: 'Human readable message that shows when locations is empty.' },
		]
	},

Can you also use this function to jump to target location when there is result?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tried but seems not working. I'm asking in VS Code repo...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Finally it turns out that all the types should be generated by their constructors in API. Simply making the structure won't work.

@jdneo jdneo changed the title Add Go to Super Implementation to context menu Add Go to Super Implementation to context menu and command palette Jul 14, 2020
@fbricon
Copy link
Collaborator

fbricon commented Jul 16, 2020

@snjeza can you check this PR on Theia/Che?

@snjeza
Copy link
Contributor

snjeza commented Jul 16, 2020

can you check this PR on Theia/Che?

The Go to Super Implementation command doesn't work on Theia.
I am getting:

root ERROR Fail to open 'command:java.action.navigateToSuperImplementation?%5B%7B%22uri%22%3A%22ZmlsZTovLy9ob21lL3NucGUvdGVzdGxzcC9zcHJpbmctcGV0Y2xpbmljL3NyYy9tYWluL2phdmEvb3JnL3NwcmluZ2ZyYW1ld29yay9zYW1wbGVzL3BldGNsaW5pYy9tb2RlbC9CYXNlRW50aXR5LmphdmE%3D%22%2C%22range%22%3A%7B%22start%22%3A%7B%22line%22%3A41%2C%22character%22%3A19%7D%2C%22end%22%3A%7B%22line%22%3A41%2C%22character%22%3A24%7D%7D%7D%5D': validateConstraint@http://localhost:3000/vs/editor/editor.main.js:16167:19
validateConstraints@http://localhost:3000/vs/editor/editor.main.js:16142:31
exports.CommandsRegistry</class_1.prototype.registerCommand/idOrCommand.handler@http://localhost:3000/vs/editor/editor.main.js:81296:29
InstantiationService</InstantiationService.prototype.invokeFunction@http://localhost:3000/vs/editor/editor.main.js:83001:27
execute@http://localhost:3000/66.bundle.js:690:64

@jdneo
Copy link
Collaborator Author

jdneo commented Jul 17, 2020

Is it caused by the new command introduced in VS Code 1.47.0: editor.action.goToLocations?

},
{
"command": "java.action.navigateToSuperImplementation",
"when": "javaLSReady && editorTextFocus && editorLangId == java",
Copy link
Collaborator

@fbricon fbricon Jul 17, 2020

Choose a reason for hiding this comment

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

can we add a supportsGoToSuperImplementation flag, computed dynamically, similar to javaLSReady?

@@ -735,6 +745,10 @@
"command": "java.project.import",
"when": "javaLSReady"
},
{
"command": "java.action.navigateToSuperImplementation",
"when": "javaLSReady && editorLangId == java"
Copy link
Collaborator

Choose a reason for hiding this comment

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

also check if supportsGoToSuperImplementation

preserveFocus: true,
selection: range,
});
context.subscriptions.push(commands.registerCommand(Commands.NAVIGATE_TO_SUPER_IMPLEMENTATION_COMMAND, async (location: LinkLocation | Uri) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

only register if supportsGoToSuperImplementation === true

@jdneo
Copy link
Collaborator Author

jdneo commented Jul 20, 2020

@fbricon @snjeza Is Theia/Che support the goto super implementation in the hover? I mean, should the flag supportsGoToSuperImplementation used to control the entire goto super implementation feature, or just some scenarios of it. (for example, only for the context menu and command palette)

@snjeza
Copy link
Contributor

snjeza commented Jul 20, 2020

Is Theia/Che support the goto super implementation in the hover?

It works in Theia without this PR.

@fbricon
Copy link
Collaborator

fbricon commented Jul 20, 2020

Is Theia/Che support the goto super implementation in the hover?

It works in Theia without this PR.

you mean a supportsGoToSuperImplementation flag is not required?

@snjeza
Copy link
Contributor

snjeza commented Jul 20, 2020

you mean a supportsGoToSuperImplementation flag is not required?

I mean it is required.

@snjeza
Copy link
Contributor

snjeza commented Jul 20, 2020

@jdneo could you resolve conflicts?

Signed-off-by: Sheng Chen <sheche@microsoft.com>
@jdneo
Copy link
Collaborator Author

jdneo commented Jul 21, 2020

PR updated. Now it's using window.showTextDocument() to do the navigation. And the go-to-location command will only be used to show the editor message (no super implementation found).

In Che/Theia, since that command so far does not support to show such message, so nothing will happen when no result found.

An issue has been created in the theia repo: eclipse-theia/theia#8212

@jdneo
Copy link
Collaborator Author

jdneo commented Jul 21, 2020

I also observed that in my machine, sometimes it will take ~10+s to get the result of super implementation. @fbricon @snjeza @testforstephen @Eskibear Have you met that case?

@fbricon
Copy link
Collaborator

fbricon commented Jul 21, 2020

works fine for me

@fbricon fbricon merged commit d6b090f into redhat-developer:master Jul 21, 2020
@fbricon fbricon added this to the End July 2020 milestone Jul 21, 2020
@fbricon
Copy link
Collaborator

fbricon commented Jul 21, 2020

@jdneo thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants