Control a running instance of intellij/phpstorm for example to open file

Hello Community

I noticed that a running instance of my PHPStorm has many ports opens (4 tcp and 2 udp). I know some are used for example for the jstestdriver, but I was wondering if one could be used to control the instance? My goal is to make the IDE open a file at a given line (and maybe more, who knows?)

TIA

greg

9 comments

Hello,

Why would you need that?

Denis

0

Our PHP opensource framework has a error page which is displayed when an exception is thrown. This page show a debug backtrace. I'd like to "link" that page to my running instance of PHPStorm to have the page displayed directly. Of course I can do that manually, but a simple click would be awesome :) Note that it's not debugging (the site is likely to be on a remote, non xdebug server).

greg

0

AFAIK our teamcity plugin achieves that by listening incoming http requests at IJ process and performing navigation when a specific request arrives (a user clicks a code link at browser).

Will ask teamcity guys to comment here on if it's possible to re-use that functionality.

Denis

0

So, both youtrack and teamcity plugins perform browser->ide navigation via teamcity plugin. Hence, there are at least three ways to go

  • you can create you own plugin which listens incoming http connections and performs navigation;
  • require teamcity plugin to be installed and use their protocol;
  • do not provide browser->ide navigation feature;


Denis

0

Option 3 sounds easier ;)

However the Teamcity option may be good for my own use. I don't need a Teamcity server for that purpose, do I? do you know where I can find documentation on the "control protocol"?

TIA

greg

0

I'm afraid there is no such documentation but the idea is pretty simple - web page triggers an http request when a user clicks particular file link (target file name/localtion is delivered as one of parameters); an ide plugin listens http requests at particular port, parses them and performs navigation to the target location

Denis

0

That's exactly what I need :)
I've installed the Teamcity plugin in my PHPStorm, and it seems it opens port 6776. However, I don't know what  to send at this port to make it open a file (I've tried sending a file path with no result).
Is the plugin source available? I could study it if it is.

greg

0

Asked teamcity guys to comment.

Btw, you can always use sniffer to check the communication format. I assume it must be very simple and contain just target file name/path and line number.

Denis

0

Hi,

I am part of TeamCity team and can provide you the necessary guidance.

Unfortunately, currently TeamCity plugin should be both installed and logged into some TeamCity server for this "open file in IDE" functionality to work. See http://youtrack.jetbrains.com/issue/TW-18546
(BTW TeamCity has free professional edition if you would want to try it.)

Once the plugin installed and logged in to TeamCity server, the browser can use JS functions which can be found in http://teamcity.jetbrains.com/js/bs/activation.js (it makes sense to copy the .js file or re-host it, it's Apache license due to TW-4854)
You can see an example of the functionality usage in YouTrack, for example links in the stacktrace of: http://youtrack.jetbrains.com/issue/TW-29694

Hope this helps.

0

Please sign in to leave a comment.