code: private String findCommaSeparatedArgument(String functionBody, int index)
      {
          int start = 0;
          int found = -1;
          int brackets = 0;
          int pos = 0;
          int length = functionBody.length();
  
          while (found < index && pos < length)
          {
              char ch = functionBody.charAt(pos);
              switch (ch)
              {
              case ',':
                  if (brackets == 0)
                  {
                      found++;
  
                      if (found < index)
                      {
                          start = pos + 1;
                      }
                  }
                  break;
              case '(':
              case '[':
              case '{':
                  brackets++;
                  break;
              case ')':
              case ']':
              case '}':
                  brackets--;
                  break;
              }
  
              pos++;
          }
  
          if (found == index)
          {
              return functionBody.substring(start, pos - 1);
          }
          else if (pos == length)
          {
              return functionBody.substring(start);
          }
          else
          {
              return "";
          }
      }
docs: Find comma separated argument.
  
  @param functionBody
  the function body
  @param index
  the index
  @return the string