views:

38

answers:

2

I'm attempting to debug some issues in some (rather bletcherous) Grails code that I inherited. I'm a relative noob in Groovy and Grails although an old Java guy.

Here's the problem: I have this thing running with jconsole and jdb hooks in, but it's tough to use the debugger because so much of the code is in closures. So, for example,

def niftyMethod = {
    // do something nifty
    anObject.doSomethingThatBreaks()
}

as the implementation of a single method on a controller.

Being a closure, the name (by the time the debugger sees it) is TheController.closure527 (or something like that), and notably hard to find.

So, how can one find the map from the block name to the closure?

More generally, are there any good tutorials on doing this sort of thing?

Ideally the answer won't involve changing over to IntelliJ, as if God had meant us to use IDEs like that She wouldn't have given us EMACS.

+1  A: 

This isn't what you want to hear, but debugging is the only reason that I use intellij for my grails programming. If it were easy to do what you're asking, I'd leave it for a better editor. The weak, non-standard key bindings drive me crazy, but sometimes debugging is the best way to find the problem.

The best thing that I can think of is to compile the code and open up the Class.closure123 then pipe them through javap and grep through them to identify the right closure. Painful, but I'm not sure there's a better way.

Alternatively, you could throw an exception from the code, look at the stack trace and then find the right underlying class from there.

I know, gross.

Ted Naleid
You can change the IntelliJ keybindings to whatever suits your taste
Don
yes and no, you can change your keybindings but only to the functionality that intellij will actually support. There are a number of things in the default emacs keybindings that intellij doesn't support (the things I miss are mostly around the paredit/region marking stuff).
Ted Naleid
A: 

Use Intellij, set the Eclipse or Emacs Keymap (or make your own perfect keymap), and enjoy the 21st century.

lacroix1547
You young kids get off my lawn.
Charlie Martin