Welcome, guest | Sign In | My Account | Store | Cart

Here's a snippet for Komodo JavaScript macros that gives the name of the current method

JavaScript, 15 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
function getCurrentMethodName() {
    var view = ko.views.manager.currentView;
    var scimoz = view.scimoz;
    var ciBuf = view.koDoc.ciBuf;
    var x = ciBuf.curr_section_from_line(view.currentLine);
    return x.title;
}

var s;
try {
    s = getCurrentMethodName();
} catch(ex) {
    s = "Failed getCurrentMethodName: " + ex;
}
alert(s);

This isn't perfect. If the cursor falls after the last method, it returns the name of that method.

ciBuf.curr_section_from_line(view.currentLine) returns a koICodeIntelSection object. You can explore the IDL for that class to determine other methods available on it.

Created by Eric Promislow on Mon, 3 Jan 2011 (MIT)
JavaScript recipes (69)
Eric Promislow's recipes (11)

Required Modules

  • (none specified)

Other Information and Tasks