Subj : Rhino - Getting a list of functions To : netscape.public.mozilla.jseng From : Jeremy Gillick Date : Wed Sep 28 2005 12:24 pm I have been racking my brain for the last couple of days trying to figure out how to solve this problem: Given a JavaScript source file, I'm trying to get Rhino to output all the functions defined in that file, including nested functions (such as those in JS Classes) with their line number. Using the code below, I am able to get the name of all the top-level functions and their line number, however, class functions only return the line number and the name is blank. What am I doing wrong? The code I'm using is below: ############### ##### JAVA ##### ############### public static void main(String[] args){ // Read JS file into source variable ..... Script script = cx.compileString(source, path, 1, null); findElements(Context.getDebuggableView(script)); } public static void findElements(DebuggableScript debug){ int[] lines; for(int i = 0; i < debug.getFunctionCount(); i++){ // Get linenumber lines = debug.getFunction(i).getLineNumbers(); int line = -1; if(lines.length > 0){ line = lines[0]; for(int l = 0; l < lines.length; l++){ if(lines[l] < line){ line = lines[l]; } } } // Print System.out.print("\n["+ line +"] "); System.out.print(debug.getFunction(i).getFunctionName() +"\n"); // Get Sub-Functions findElements(debug.getFunction(i)); } } ######################### ##### JavaScript Source ##### ######################### function plainFunc(){ } function classFunc(){ this.propOne = false; this.propTwo = "hello"; this.propThree = "world"; this.methodFuncOne = function(){ } this.methodFuncTwo = function(){ } } function helloWorld(){ } ######################### Thanks, Jeremy .