Remote / External Control Interface? Open Files From a Shell?

Hi,

As I divide my development activities between an interactive command shell and the IDE, I often find it convenient to issue a command that tell the IDE editor to open a file whose name is specified to that command.

In jEdit there is a networking-based command interface that enables this. (The editor opens a port and listens there, if I understand it correctly--the editor's own launcher itself handles the details when invoked with file name arguments and there is already a local instance of jEdit running.)

Is there any way to accomplish this in IDEA?

Thanks.

Randall Schulz

10 comments
Comment actions Permalink

Not that I'm aware of (correct me if I'm wrong), but it should be fairly
easy to write a plugin that does exactly that.

Hi,

As I divide my development activities between an interactive command
shell and the IDE, I often find it convenient to issue a command that
tell the IDE editor to open a file whose name is specified to that
command.

In jEdit there is a networking-based command interface that enables
this. (The editor opens a port and listens there, if I understand it
correctly--the editor's own launcher itself handles the details when
invoked with file name arguments and there is already a local instance
of jEdit running.)

Is there any way to accomplish this in IDEA?

Thanks.

Randall Schulz



0
Comment actions Permalink

I think there is an embedded XML-RPC server in Idea - if you can figure
out how to talk to it (and get past any firewalls) you can tell it to
open files, go to specific lines, etc. This is how TeamCity provides
clickable links in its HTML report that, when clicked, open the relevant
file in Idea.

I don't know where (if anywhere) the documentation for this feature lives.
R

0
Comment actions Permalink

That sounds like it has the elementary capabilities one would require. Firewalls are not an issue since I'm strictly interested in intra-machine operation.

Or course, without documentation, it's pretty much moot.

A quick check with "lsof" shows that IDEA is holding two Unix-domain sockets and one unspecified network socket. I suppose one or more of them might be related to the XML-RPC capability.

Does anyone know more about this? Has anyone reverse-engineered the protocol used by TeamCity?

RRS

0
Comment actions Permalink

Hello Robert,

RG> I think there is an embedded XML-RPC server in Idea - if you can
RG> figure out how to talk to it (and get past any firewalls) you can
RG> tell it to open files, go to specific lines, etc. This is how
RG> TeamCity provides clickable links in its HTML report that, when
RG> clicked, open the relevant file in Idea.

This is currently not quite true. There is indeed an XML-RPC server, but
it doesn't expose any functions by default - it's useful only if plugins
plug into it. And the TeamCity integration doesn't use it - it has its own
HTTP server requests to which are sent from the TeamCity Web UI pages.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

So is there a pre-existing mechanism I can use to command IDEA to open files from an external process? If not, is it possible to create a plug-in to do so? And if that is possible, what is the pertinent documentation for the elementary capabilities?

Randall Schulz

0
Comment actions Permalink

Hello Randall,

RS> So is there a pre-existing mechanism I can use to command IDEA to
RS> open files from an external process?

No.

RS> If not, is it possible to
RS> create a plug-in to do so?

Yes. I think you can find some existing plugins that provide such functionality
in the plugin manager.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Ah! Here we go: System Tools appears to do this, though the explanatory text is miniscule:

"System tools for IntelliJ IDEA. This plugin include: File Loader: to load files into IDEA from OS shell by command line."

I tracked down the plug-in's page on the IntelliJ TWiki, SystemToolsPlugin, I found how to invoke it from its external interface.

Unfortunately, it appears not to be compatible with IDEA 6, since activating the external tool leads to an internal error in IDEA, specifically a NoSuchMethodError:

Error during dispatching of java.awt.event.InvocationEvent[INVOCATION_DEFAULT,runnable=org.intellij.systemTools.fileServer.AbstractFileServer$1@1f3792,notifier=null,catchExceptions=false,when=1164214593451] on sun.awt.X11.XToolkit@1e9029b: com.intellij.openapi.fileEditor.OpenFileDescriptor.(Lcom/intellij/openapi/vfs/VirtualFile;II)V java.lang.NoSuchMethodError:
com.intellij.openapi.fileEditor.OpenFileDescriptor.(Lcom/intellij/openapi/vfs/VirtualFile;II)V
at org.intellij.systemTools.fileServer.DefaultFileServerListener.handleEvent(DefaultFileServerListener.java:83)
at org.intellij.systemTools.fileServer.AbstractFileServer$1.run(AbstractFileServer.java:24)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
...

]]>

Randall Schulz

0
Comment actions Permalink

rrschulz wrote:

Ah! Here we go: Randall Schulz

Hi Randall,

I know it's been a while, but if you are still on can you tell me what you discovered? I am trying to make the same thing work as well.

For those interested in this also see this thread - http://devnet.jetbrains.net/thread/291600.

d

0
Comment actions Permalink

Did I really write that???

Anyway, yes, there's a plug-in, OpenInIDEA, that, when installed, opens a port to listen for requests from an external agent requesting that it open files whose names are passed in the request. The plug-in includes a JAR file has a main() entry point that can be used as the client submitting those open requests from outside. I wrote a simple shell script to facilitate the interaction. (Among other things, each request can specify only one file, so if you want to be able to open more than one on a single command, you have to repeatedly invoke the client library.)

I attached my BASH script. At a quick glance, you'll have to change at least two thing: 1) The OII_JAR variable must point to the installed OpenInIDEA.jar file that gets installed with the plug-in (in the plug-in's ../lib/ directory); 2) The "j6" command should probably just be "java" (That's a left-over of a time when both Java 5 and 6 were concurrently relevent for me.)


Randall Schulz



Attachment(s):
oii.zip
0
Comment actions Permalink

Thanks Randall!

FYI, Standing on your shoulders they baked it into the core product :). See - http://devnet.jetbrains.net/thread/291600.

0

Please sign in to leave a comment.