if (editor != null)
{
Position cursorPosition =
editor.getSession().getSelection().getCursor();
CodeModel codeModel = editor.getSession().getMode().getCodeModel();
// Try to see if we can find a function name
TokenCursor cursor = codeModel.getTokenCursor();
// NOTE: This can fail if the document is empty
if (!cursor.moveToPosition(cursorPosition))
return;
if (cursor.currentValue() == "(" || cursor.findOpeningBracket("(", false))
{
if (cursor.moveToPreviousToken())
{
// Check to see if this really is the name of a function
JsArray<ScopeFunction> functionsInScope =
codeModel.getAllFunctionScopes();
String tokenName = cursor.currentValue();
for (int i = 0; i < functionsInScope.length(); i++)
{
ScopeFunction rFunction = functionsInScope.get(i);