Invoking IntellIJ from the browser?

In TeamCity you can click on a file or line number and IntelliJ opens
that file right away. How is this exactly done? Is there some URL
handler installed? It would be very useful for a project of mine if I
could click stack traces in a browser and then IntelliJ opens the
respective file. Is there any documentation on this?

Kind regards,
Jan

21 comments
Comment actions Permalink

I would be interested in knowing this as well.

I know if you run idea.exe with the filename it will open that file in the current running instance (just like any text editor), but is there an additional argument to indicate the line number as well? This could be very handy for connecting IDEA with other applications.

Or if there if there is a HTTP command as Jan suggests that does the same thing that would be great also.

Thanks,
dave

0
Comment actions Permalink

TeamCity communicates with IDEA using XmlRpc Server integrated in TeamCity plugin. IDEA also have its own XmlRpc Server listening on port 63342 (see
http://git.jetbrains.org/?p=idea/community.git;a=blob;f=platform/platform-impl/src/com/intellij/ide/XmlRpcServerImpl.java). If you want to open a file
in IDEA you can call fileOpener.open method with path-to-file parameter (see
http://git.jetbrains.org/?p=idea/community.git;a=blob;f=java/idea-ui/src/com/intellij/ide/OpenFileXmlRpcHandler.java).

In TeamCity you can click on a file or line number and IntelliJ opens that file right away. How is this exactly done? Is there some URL handler
installed? It would be very useful for a project of mine if I could click stack traces in a browser and then IntelliJ opens the respective file. Is
there any documentation on this?

>

Kind regards,
Jan



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink
Nikolay wrote:


TeamCity communicates with IDEA using XmlRpc Server integrated in TeamCity plugin. IDEA also have its own XmlRpc Server listening on port 63342 (see
http://git.jetbrains.org/?p=idea/community.git;a=blob;f=platform/platform-impl/src/com/intellij/ide/XmlRpcServerImpl.java). If you want to open a file
in IDEA you can call fileOpener.open method with path-to-file parameter (see
http://git.jetbrains.org/?p=idea/community.git;a=blob;f=java/idea-ui/src/com/intellij/ide/OpenFileXmlRpcHandler.java).



Thank you for the excellent tip. How can we find out about the XML/RPC protocol? I tried starting from the source you gave above, but every thing I tried searching for in the source repository wasn't found. I'm guessing there is a class that is mapped to a bean that is exposed as XML/RPC. Would you or someone else know the name of that bean that has the XML/RPC functions on it?

Thanks,
dave

0
Comment actions Permalink

Also, is there a command line argument for indicating line number? That would be much easier for some integration situations.

d

0
Comment actions Permalink

I've added method 'openAndNavigate' with parameters file-path, line and column numbers.

Also, is there a command line argument for indicating line number? That would be much easier for some integration situations.

>

d

>

---
Original message URL: http://devnet.jetbrains.net/message/5276520#5276520



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

You need to send XML RPC request via HTTP protocol using POST method (see http://www.tutorialspoint.com/xml-rpc/xml_rpc_request.htm, for example).
Xml Rpc request for opening file will look like



On 10/29/2010 12:57 AM, David Rees wrote:

Thank you for the excellent tip. How can we find out about the XML/RPC protocol? I tried starting from the source you gave above, but every thing I tried searching for in the source repository wasn't found. I'm guessing there is a class that is mapped to a bean that is exposed as XML/RPC. Would you or someone else know the name of that bean that has the XML/RPC functions on it?

>

Thanks,
dave

>

---
Original message URL: http://devnet.jetbrains.net/message/5276142#5276142



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Nikolay wrote:

...
I've added method 'openAndNavigate' with parameters file-path, line and column numbers.
...
You need to send XML RPC request via HTTP protocol using POST method (see http://www.tutorialspoint.com/xml-rpc/xml_rpc_request.htm, for example).
Xml Rpc request for opening file will look like



On 10/29/2010 12:57 AM, David Rees wrote:

Thank you for the excellent tip. How can we find out about the XML/RPC protocol? I tried starting from the source you gave above, but every thing I tried searching for in the source repository wasn't found. I'm guessing there is a class that is mapped to a bean that is exposed as XML/RPC. Would you or someone else know the name of that bean that has the XML/RPC functions on it?


Thank you for your quick replies. I actually am pretty familiar with XML/RPC. What i am looking for is what methods are supported by IntelliJ's XML-RPC server. Is there a class that has all the exposed methods? Or in other words, where did you put openAndNavigate?

And what version of IDEA should I download to get access to the openAndNavigate function? The next IDEA 9 EAP or IDEA X EAP?

Also, it looked like you were going to paste an example openAndNavigate XML request. That would be a bonus to see also.

Thank you for all your help,
dave

0
Comment actions Permalink

'openAndNavigate' method will be available in next IDEA X EAP.
Currently all available methods are located in OpenFileXmlRpcHandler class. Names of these methods should be prefixed with "fileOpener." in XML RPC request:

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<methodCall>
  <methodName>fileOpener.open</methodName>
  <params>
    <param><value>/path/to/file</value></param>
  </params>
</methodCall>

0
Comment actions Permalink

nik wrote:

'openAndNavigate' method will be available in next IDEA X EAP.
Currently all available methods are located in OpenFileXmlRpcHandler class. Names of these methods should be prefixed with "fileOpener." in XML RPC request:

...


Thank you very much both for the change and the usage example. I'm looking forward to trying it out in the next EAP.

d

0
Comment actions Permalink

Digging though the Firefox 3.6.* source code I have discovered tht its supports line number as an arg (%LINE%) for an external source editor. That would allow IDEA/WebStorm to open to exact right line when clicking on an entry in the error console. Just another +1 for IDEA supporting an -line command line argument.

d

0
Comment actions Permalink

FYI, Adding line number to the command line is (already) in youtrack at http://youtrack.jetbrains.net/issue/WI-3604 (thanks Andriy Bazanov).

0
Comment actions Permalink

Hi Nikolay,

I'm trying (again) to open a file/line using XML-RPC and not getting a lot of success. The port is open, but its not allowing me to connect. Is there is a setting somewhere to turn the listener on? I'll add I have I installled the TeamCity plugin just in case that matters. Below is what I am seeing in cygwin inside Windows XP.

PS, I would rather do this using command line, but that seems to have been pushed to the "Post 2.x pool" (http://youtrack.jetbrains.net/issue/WI-3604).

Thanks,
dave


reesd2@dgrbcwin /cygdrive/z/dgr/dev/js/tweakingJetbrainsConnector
$ netstat -a | grep 63342
  TCP    dgrbcwin:63342         dgrbcwin:0             LISTENING


reesd2@dgrbcwin /cygdrive/z/dgr/dev/js/tweakingJetbrainsConnector
$ telnet localhost 63342
Connecting To localhost...Could not open connection to the host, on port 63342: Connect failed

0
Comment actions Permalink

Hello,

the listener is turned on automatically. However we changed Xml Rpc server behaviour in IDEA 10 so it accepts only connections from localhost. Maybe
it is cause of problems in your case. Did you try to connect to IDEA from java code?

Hi Nikolay,

>

I'm trying (again) to open a file/line using XML-RPC and not getting a lot of success. The port is open, but its not allowing me to connect. Is there is a setting somewhere to turn the listener on? I'll add I have I installled the TeamCity plugin just in case that matters. Below is what I am seeing in cygwin inside Windows XP.

>

PS, I would rather do this using command line, but that seems to have been pushed to the "Post 2.x pool" (http://youtrack.jetbrains.net/issue/WI-3604).

>

Thanks,
dave

>
>

reesd2@dgrbcwin /cygdrive/z/dgr/dev/js/tweakingJetbrainsConnector
$ netstat -a | grep 63342
   TCP    dgrbcwin:63342         dgrbcwin:0             LISTENING

>

reesd2@dgrbcwin /cygdrive/z/dgr/dev/js/tweakingJetbrainsConnector
$ telnet localhost 63342
Connecting To localhost...Could not open connection to the host, on port 63342: Connect failed

>

---
Original message URL: http://devnet.jetbrains.net/message/5282958#5282958



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Nikolay wrote:

the listener is turned on automatically. However we changed Xml Rpc server behaviour in IDEA 10 so it accepts only connections from localhost. Maybe
it is cause of problems in your case. Did you try to connect to IDEA from java code?


Thanks for the ideas, but I am trying to connect from localhost, so that isn't the issue. And  I can't even open the port (telnet fails), so I don't know about trying it from Java.

$ netstat -a | grep 63342
TCP    dgrbcwin:63342         dgrbcwin:0             LISTENING
$ telnet localhost 63342
Connecting To localhost...Could not open connection to the host, on port 63342: Connect failed




Still, for completeness here is what I see from Java. I am using the following simple chunk of code and getting the error that follows, which is consistent with what I am seeing from the command line that its listening but rejecting connections.

import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import java.net.MalformedURLException; import java.net.URL; public class XmlRpcTestIdea {     public static void main(String[] args) throws MalformedURLException, XmlRpcException {         XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();         config.setServerURL(new URL("http://localhost:63342"));         XmlRpcClient client = new XmlRpcClient();         client.setConfig(config);         Object[] params = new Object[]{"Z:\\dgr\\dev\\java\\ideaXmlRpcClient\\src\\XmlRpcTestIdea.java"};         Object result = client.execute("fileOpener.open", params);         System.err.println(result);     } }



Exception in thread "main" org.apache.xmlrpc.XmlRpcException: Failed to read server's response: Connection refused: connect      at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:161)      at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:115)      at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)      at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)      at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)      at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:137)      at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:126)      at XmlRpcTestIdea.main(XmlRpcTestIdea.java:15)      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)      at java.lang.reflect.Method.invoke(Method.java:597)      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115) Caused by: java.net.ConnectException: Connection refused: connect      at java.net.PlainSocketImpl.socketConnect(Native Method)      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)      at java.net.Socket.connect(Socket.java:529)      at java.net.Socket.connect(Socket.java:478)      at sun.net.NetworkClient.doConnect(NetworkClient.java:163)      at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)      at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)      at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)      at sun.net.www.http.HttpClient.New(HttpClient.java:306)      at sun.net.www.http.HttpClient.New(HttpClient.java:323)      at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:860)      at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:801)      at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:726)      at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:904)      at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.writeRequest(XmlRpcSunHttpTransport.java:104)      at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:151)      ... 12 more Caused by: java.net.ConnectException: Connection refused: connect      at java.net.PlainSocketImpl.socketConnect(Native Method)      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)      at java.net.Socket.connect(Socket.java:529)      at java.net.Socket.connect(Socket.java:478)      at sun.net.NetworkClient.doConnect(NetworkClient.java:163)      at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)      at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)      at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)      at sun.net.www.http.HttpClient.New(HttpClient.java:306)      at sun.net.www.http.HttpClient.New(HttpClient.java:323)      at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:860)      at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:801)      at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:726)      at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:904)      at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.writeRequest(XmlRpcSunHttpTransport.java:104)      at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:151)      at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:115)      at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)      at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)      at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)      at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:137)      at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:126)      at XmlRpcTestIdea.main(XmlRpcTestIdea.java:15)      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)      at java.lang.reflect.Method.invoke(Method.java:597)      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)



Thanks,
dave

0
Comment actions Permalink

Please wait for IDEA 10.0.2 EAP build which will be released soon. It will contain some changes related to XmlRpc server so the problem may go away.

On 01/12/2011 08:13 PM, David Rees wrote:
>
>

Thanks for the ideas, but I am trying to connect from localhost, so that isn't the issue. And  I can't even open the port (telnet fails), so I don't know about trying it from Java.

>

Thanks,
dave

>

---
Original message URL: http://devnet.jetbrains.net/message/5283259#5283259



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Nikolay wrote:

Please wait for IDEA 10.0.2 EAP build which will be released soon. It will contain some changes related to XmlRpc server so the problem may go away.


Which WebStorm release will that be? Is there a mapping between release versions I can use to tell?

Thanks,
dave

0
Comment actions Permalink

reesd wrote:

Nikolay wrote:

the listener is turned on automatically. However we changed Xml Rpc server behaviour in IDEA 10 so it accepts only connections from localhost. Maybe
it is cause of problems in your case. Did you try to connect to IDEA from java code?


Thanks for the ideas, but I am trying to connect from localhost, so that isn't the issue. And  I can't even open the port (telnet fails), so I don't know about trying it from Java.

$ netstat -a | grep 63342
TCP    dgrbcwin:63342         dgrbcwin:0             LISTENING
$ telnet localhost 63342
Connecting To localhost...Could not open connection to the host, on port 63342: Connect failed 

dave


The netstat output "

dgrbcwin:63342" says 
port 63342 is being listened in the
dgrbcwin address not localhost. Connecting to localhost will obviously give a connect failed in this case.


On linux I always like "netstat -ltp" (or "netstat -ltpn") to see active tcp ports.
0
Comment actions Permalink

Ok, I’m assuming that WebStorm WS-102.114 has the changes you mentioned, because I am now able to connect to the socket and send a XMPRPC request!

However, using the Java example I listed above I am now getting the following error back so I think I must have the wrong method name or I am missing how to properly use it with Apache XMLRPC. I am using the same Java code I listed above.

Exception in thread "main" org.apache.xmlrpc.XmlRpcException: java.lang.Exception: RPC handler object "fileOpener" not found and no default handler registered.



I also decided to try connecting using just cURL from the command line and passing the following file (copied from your example). But I am getting a blank response and WebStorm doesn’t open the file. Here is the file and results of passing it.

jbFileOpen.xml

<?xml version="1.0" encoding="UTF-8"?>
<methodCall>
  <methodName>fileOpener.open</methodName>
  <params>
   <param><value>Z:\dgr\dev\js\crowdmashUber\dojoObjectsWork\src\Entity.js</value></param>
  </params>
</methodCall>

$ curl -X POST -H 'Content-type: text/xml' --verbose --data jbFileOpen.xml http://localhost:63342
* About to connect() to localhost port 63342 (#0)
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 63342 (#0)
> POST / HTTP/1.1
> User-Agent: curl/7.20.1 (i686-pc-cygwin) libcurl/7.20.1 OpenSSL/0.9.8q zlib/1.2.5 libidn/1.18 libssh2/1.2.5
> Host: localhost:63342
> Accept: */*
> Content-type: text/xml
> Content-Length: 14
>
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
* Closing connection #0


Thanks,
dave

0
Comment actions Permalink

carloscs wrote:

The netstat output "

dgrbcwin:63342" says 
port 63342 is being listened in the
dgrbcwin address not localhost. Connecting to localhost will obviously give a connect failed in this case.


On linux I always like "netstat -ltp" (or "netstat -ltpn") to see active tcp ports.


Hi Carlos,

This is windows (using cygwin), so the netstat results may not look the same as on Linux. But dgrbcwin is hostname of the localhost, and it was listening but wasn't accepting.

With the new update of WebSphere I still see the exact same line in windows netstat, but I can now telnet to it.

Thanks,
dave

0
Comment actions Permalink

It appears that fileOpener handler wasn't included in WebStorm. It will be fixed in next WebStorm EAP build.
However your code should work in IDEA 10.0.2 EAP build.

Ok, I’m assuming that WebStorm WS-102.114 has the changes you mentioned, because I am now able to connect to the socket and send a XMPRPC request!

>

However, using the Java example I listed above I am now getting the following error back so I think I must have the wrong method name or I am missing how to properly use it with Apache XMLRPC. I am using the same Java code I listed above.

>

>
>

I also decided to try connecting using just cURL from the command line and passing the following file (copied from your example). But I am getting a blank response and WebStorm doesn’t open the file. Here is the file and results of passing it.

>

jbFileOpen.xml

> 
>    fileOpener.open
>    
>     Z:\dgr\dev\js\crowdmashUber\dojoObjectsWork\src\Entity.js
>    
> 
> ]]>

>

 * About to connect() to localhost port 63342 (#0)
> *   Trying 127.0.0.1... connected
> * Connected to localhost (127.0.0.1) port 63342 (#0)
>> POST / HTTP/1.1
>> User-Agent: curl/7.20.1 (i686-pc-cygwin) libcurl/7.20.1 OpenSSL/0.9.8q zlib/1.2.5 libidn/1.18 libssh2/1.2.5
>> Host: localhost:63342
>> Accept: */*
>> Content-type: text/xml
>> Content-Length: 14
>>
> * Empty reply from server
> * Connection #0 to host localhost left intact
> curl: (52) Empty reply from server
> * Closing connection #0]]>

>

Thanks,
dave

>

---
Original message URL: http://devnet.jetbrains.net/message/5283447#5283447



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Nikolay wrote:

It appears that fileOpener handler wasn't included in WebStorm. It will be fixed in next WebStorm EAP build.
However your code should work in IDEA 10.0.2 EAP build.


Success!!! I have fileOpener.open(path) and fileOpener.openAndNavigate(path, line, column) both working with 10.0.2 (IU-02.149)!

For others reading this thread I'll mention that line and column are 0 based (first character is 0,0).

Thanks Nikolay!

dave

0

Please sign in to leave a comment.