-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 the ability to open classes from the DevUI in the IDE #15296
Conversation
@stuartwdouglas @mkouba @maxandersen WDYT? If you think this makes sense, I can proceed further |
// TODO: determine whether IntelliJ or other IDE is being used determine the proper link | ||
|
||
// for this to work, users need to check 'Allow unsigned requests' in the Debugger Settings | ||
String link = "http://localhost:63342/api/file/" + srcMainJavaPath + '/' |
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 localhost:63342
is something IntelliJ-specific?
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, IntelliJ starts a web server that handles a few API requests
I like the idea. Do you think we'd be able to support all the popular IDEs? |
I sure hope so 😃 |
// TODO: determine whether IntelliJ or other IDE is being used determine the proper link | ||
|
||
// for this to work, users need to check 'Allow unsigned requests' in the Debugger Settings | ||
String link = "http://localhost:63342/api/file/" + srcMainJavaPath + '/' |
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.
This is cool. You can also use Desktop.getDesktop().open(file)
to invoke the preferred editor in the host machine
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 didn't know that, thanks!
That is probably going to be a good fallback if we can't determine what IDE is being used (which I hope we can)
Good idea. It's only intellij that had this server thing atm. Fyi: started https://github.com/starfixdev/starfix to handle this and other usecases more generically. Still poc though :) But vscode has a URL we can use. Eclipse can too - but not uniform across platfotms. I'll take a look and see if can make it work. |
Thanks for the info Max! I had seen vscode has its own protocol for the URL so I wasn't worried about it. I'll take a look at the code you linked soon and see what can be done |
If we get this working can we also add it to the error page so we can open the class directly from the stack track? |
That's a superb idea |
okey, so looking in more detail I'm grokking this better. This approach is dependent on generating a link that gets generated into the webpage thus it will only work with IDE's that has url or link support. Thus the only two IDE's I know that supports this well is intellij and vscode with its vscode:// url form. The good thing is that this is also what starfix enables - it will register: ide:// and then relay to users IDE. Thus we probably want a setting like:
and then generate the appropriate url - possibly also allow "custom" and have a Another alternative could be we don't generate a link to a url but just a GET which then local devmode will use to execute code locally...but that has security implications if you share a url then remote users could be opening IDE's on your local machine ;) |
Another aspect is to open at certain line number - that will also be different per IDE/URL. |
Line numbers would take a lot more work to get - we'd need to actually get them from debugging info in the |
It doesn't have to be like this - I just did it to get some quick off the ground. |
Looking at how Eclipse doesn't seem to have a way to do this, I am thinking that we will likely need to open the IDE from the "server-side", meaning that the link in the DevUI will be handled by a Vert.x Handler that will then do whatever is necessary to open the link in the IDE. |
@geoand my thought exactly 👍🏻 |
i would not be too excited having this be something that we open server side for two reasons:
something like starfix would fix it for eclipse btw. |
@maxandersen that makes sense, remote dev is a clear use case that invalidates a server side approach. It would be great if we could use Starfix here. |
If we can get this to work from a browser URL, then sure, that makes the most sense. But startix is something a user would need to install, right? As for the other cases, do we really think that dev Mode running on another machine is a thing? The way I see it, both options have pros and cons. |
Also to be clear, relying on starfix would make this PR relatively easy - it would just create starfix URLs |
Yeah, jokes aside, maybe the best UX would be to enable links ONLY if Starfix is installed (as a chrome extension). AFAIK there is a Jetbrains chrome extension that does that already: https://chrome.google.com/webstore/detail/jetbrains-toolbox-extensi/offnedcbhjldheanlbojaefbfbllddna |
Yeah, we really need to decide what we want the user experience to be. The technical work should be simple (as demonstrated in this PR) |
no, and i havent spend much time since gsoc last year.
to start, i dont want to suggest to target starfix only. what im suggesting is that we make it url based to get resolved client side rather than handling it server side, at least by default. we can do a detection in path to make a best guess for what will work, but have a property guiding it, like:
and then generate accordingly. ultimately, we probably want to enable passing in not just physical location and line number but things like git url and classname as the location on disk might not match. |
then you would do something like
for starfix, where as for vscode it would just refer to location and line. |
IIUC, there is no URL that could be used for Eclipse, correct?
…On Sun, Feb 28, 2021, 09:41 Max Rydahl Andersen ***@***.***> wrote:
then you would do something like
quarkus.ide.openurl=ide://openClass?git=$git&class=$class&line=$line&location=$location
for starfix, where as for vscode it would just refer to location and line.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15296 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABBMDP26MQ6OU3OFNXWZBTTTBHXUJANCNFSM4YEHNPKQ>
.
|
Not at this stage no. I've opened eclipse issues for it but not been picked up yet. Maybe we could add a endpoint that Will launch Process locally given request comes from localhost to guard against at.least a direct exploit ? |
Yeah, that sounds reasonable
…On Sun, Feb 28, 2021, 11:40 Max Rydahl Andersen ***@***.***> wrote:
Not at this stage no.
I've opened eclipse issues for it but not been picked up yet.
Maybe we could add a endpoint that Will launch Process locally given
request comes from localhost to guard against at.least a direct exploit ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15296 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABBMDP6SIFTJ7AQ3N22SQWLTBIFRLANCNFSM4YEHNPKQ>
.
|
I would prefer writing docs after this PR is in as I have already had to rebase 3 times since yesterday alone. |
The failures are totally unrelated |
I'll see if I can try it - where should I see the links be added ? In exceptions or just on arc bean Dev list? |
Only in the Arc beans page. But the plumbing is there to later on add it wherever we like |
Unless there are objections, I'd like to merge this and not have to deal with any more conflicts (which are certain to arise) |
is there a reason why the links aren't copyable ? |
// the idea here is to auto-detect the special files that IDEs create | ||
// and also the running IDE process if need be | ||
|
||
if (ideFile.getDetectedIDEs().size() == 1) { |
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.
A nice approach to know which of potential many ide files that should win is to sort them by last modification time. Right now it seems old idea filled would win over more recent code artifacts. For example.
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.
Good point, but it still doesn't help us determine Eclipse vs VSCode - which is why this whole dance is 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.
This detects runtime IDEs, but doesn't even copy their path, so it also doesn't look at executable modification date, which was my issue, because my IDE was not in my path. I figured this could be a further improvement.
Even then, if you decide to do this, watch out that often executables are links and I'm not sure their modification dates can be trusted without resolving the link.
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 am absolutely sure there will be improvements to be done in this area
@ConfigItem(defaultValue = "auto") | ||
public Target target; | ||
|
||
enum Target { |
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.
any way for us to allow user to specify a custom command ?
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 yet
} else { | ||
List<Ide> matches = new ArrayList<>(); | ||
for (Ide file : ideFile.getDetectedIDEs()) { | ||
for (Ide process : runningIdes) { |
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.
oh wow - just realized you detecting running ides ....thats awesome :)
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.
one caveat - this requires the IDE to be running when we start quarkus:dev, right?
also - while testing this having no IDE running i stopped getting links highlighted since no changes made and thus we never relooked for running processes ?
feels a bit weird.
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.
and changing code to try trigger recalculation of running ides does not seem to be enough.
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.
People close their IDE?
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 do constantly :)
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 IDE detection is necessary because there from the project files we can't really diferentiate if VSCode is Eclipse is being used.
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 there is another way to differentiate an Eclise project from a VSCode project, then I'll gladly use 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.
rigger recalculation of runni
When the changes result in a Quarkus dev restart, the processes are re-detected.
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.
Weird - it stopped showing links for me :/
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
@ConfigRoot | ||
public class IdeConfig { |
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 whre the bug is but using dev config editor it makesthis "quarkus.ide.target=code' which gives an error.
also i believe the current property is "quarkus.ide" which i think is limiting our options.
i would suggest "quarkus.ide.command" or similar allowing us to do i.e
quarkus.ide.command=custom
quarukus.ide.custom.command=open -a /Applications/Eclipse.app {filename}"
or similar in the future.
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 really like where this is going but for some reason it stops working for me eventually. no linking happens.worked fine the first time.
but that is probably something we can fix in future update.
the only thing i would say to reconsider is to not use toplevel quarkus.ide
property name space as the single value to set.
@maxandersen I don't see what the problem with the ide config is. Currently you set |
The aren't actual links in the HTML sense. They are just spans that are clickable and what happens when you click on them is done in Javascript (in order to make it trivial for extensions to be able to use those functions and not have to worry about any of the internals of opening in the IDE) |
Hmm Okey then I misread the code - what I got was that when I set .target I got an exception. |
Let me try it and see. |
I just tried it and when I set |
@maxandersen and I discussed and agreed to get this in now and start using it. Any shortcomings or alternatives approaches can certainly be taken up as we get more hands on experience with DevUI entries using this feature. @phillip-kruger would you be willing to integrate this with the Log output to allow users to open classes from exception stacktraces? |
@geoand - yes, happy to help. As a separate PR though right ? |
Thanks! Definitely a separate PR. I'll merge this once CI completes |
TODO: