Example of controlling the debugger with a custom language?
I have a company created templating language that I've created a custom language plugin for. Now I'd like to add the functionality to my plugin similar to JSP so that my users can debug templates. Any ideas where I begin? I've found the com.intellij.debugger package in the Open API but I haven't found and good documentation. Based on the javadoc for that package I realize I need to implement PositionManager which I get. But where do I 'register' an instance of my PositionManager with IDEA or my plugin? Also, how do I get the editor to allow me to set breakpoints?
Please sign in to leave a comment.
Alright so I answered some of my questions on my own using the Tomcat plugin as an example. I'm still unsure how to properly register my PositionManager though. I created a ProjectComponent that on projectOpened will do this:
But I'm not sure where to get an instance of ProcessHandler from? My guess is I need to be doing th+is logic somewhere else but I'm having trouble finding where. Any ideas?
Alright I think I'm past this. I got IDEA to call my PositionManager. Here's the code I used in my projectOpened:
Actually that code only attaches the PositionManager for the first debug execution. Subsequent executions don't have my PositionManager associated with them.
As for the first run though, it was very successful. I can set a breakpoint in my custom language and the jvm will break on it as well I can step over and even step into calls out to my Java code from our templating language. Very cool stuff. My other big issue, the debug pane claims that "Debug info unavailable". What do I need to do to implement the Debug pane so I can explore the frame context?
So I found the answer that works:
Also in regards to my second question about the "Debug info unavailable" I found that our compiler wasn't writing the LocalVariableTableAttr to the class files for our templates. Once I changed the compiler to write out this information then the Debug info is available. So that turned out to be nothing wrong with my IDEA plugin.
This topic covers exactly what I am interested in but it appears the APIs have changed enough that I am having difficulty figuring out what to do. Moreover, I have been unable to locate the Tomcat plugin example. A full working example would go a LONG way towards helping me.
Here's my situation: I have a template parser which translates into a tree structure (of java objects). The nodes in the tree may be containers, static text, or bound to a value in a java file. Some of the nodes support control flow (eg if and loop). My parser records the line number info into each node. I would like to be able to allow the developers using my templating engine to step through their templates and see each line highlighted as they step. My code that walks this tree is a well-contained loop that does an iterative tree walk so this should be fairly straight forward, but in the absence of examples, I am not having much luck.
Is the Tomcat plugin example really gone these days?
Hello Charles,
The Tomcat plugin example is currently included in the main IntelliJ IDEA
distribution, as lib\src\src_tomcat.zip
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
I could not find what you were referring to. I downloaded the tarball from the link below and didn't see it:
http://download.jetbrains.com/idea/ideaIC-9.0.2-src.tar.bz2
Then I went to the git repository and poked around with no luck (the following link is one of many places I looked in the git tree):
http://git.jetbrains.org/?p=idea/community.git;a=tree;f=lib/src;h=e2ec969a7f9788f88c496d9d3199313f964ef598;hb=HEAD
However, I don't necessarily need the Tomcat example. If there is a different example available that shows how to work with the PositionManager and DebuggerManager I would be happy. A really simple example would be wonderful!
Thanks!
Charles.
Hello Charles,
The Tomcat plugin is only included in IntelliJ IDEA Ultimate, so it's no
wonder you couldn't find it in the Community Edition sources. You'll need
to download a distribution of IntelliJ IDEA Ultimate, for example:
http://download.jetbrains.com/idea/ideaIU-9.0.3.zip
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"