Here you can find the source of getFunctionArgsString(FunctionNode fn)
Parameter | Description |
---|---|
fn | The function node. |
public static final String getFunctionArgsString(FunctionNode fn)
//package com.java2s; /*/*w w w .j av a 2s.c o m*/ * 06/05/2014 * * Copyright (C) 2014 Robert Futrell * robert_futrell at users.sourceforge.net * http://fifesoft.com/rsyntaxtextarea * * This library is distributed under a modified BSD license. See the included * RSTALanguageSupport.License.txt file for details. */ import java.util.List; import org.mozilla.javascript.Token; import org.mozilla.javascript.ast.AstNode; import org.mozilla.javascript.ast.FunctionNode; import org.mozilla.javascript.ast.Name; public class Main { /** * Iterates through a function's parameters and returns a string * representation of them, suitable for presentation as part of the * method's signature. * * @param fn The function node. * @return The string representation of the function's arguments. */ public static final String getFunctionArgsString(FunctionNode fn) { StringBuilder sb = new StringBuilder("("); int paramCount = fn.getParamCount(); if (paramCount > 0) { List<AstNode> fnParams = fn.getParams(); for (int i = 0; i < paramCount; i++) { String paramName = null; AstNode paramNode = fnParams.get(i); switch (paramNode.getType()) { case Token.NAME: paramName = ((Name) paramNode).getIdentifier(); break; default: System.out.println("Unhandled class for param: " + paramNode.getClass()); paramName = "?"; break; } sb.append(paramName); if (i < paramCount - 1) { sb.append(", "); } } } sb.append(')'); return sb.toString(); } }