Determines the index of the parameter in a call list using
        string manipulation and context information.

def call_arg_index(self):
        """Determines the index of the parameter in a call list using
        string manipulation and context information."""
        #The function name we are calling should be in el_name by now
        if self._call_index is None:
            if (self.el_section == "body" and
                self.el_call in [ "sub", "fun" ]):
                #Get hold of the element instance of the function being called so
                #we can examine its parameters.
                fncall = self.el_name
                if fncall in self.current_line[:self.pos[1]]:
                    args = self.current_line[:self.pos[1]].split(fncall)[1]
                else:
                    args = ""

                #This handles the case of the bracket-complete.
                if args == "":
                    return 0
                #The nester requires each start bracket to have an end bracket
                if args[-1] != ")":
                    args += ")"

                #Pyparsing handles calls where functions are being called as
                #the values for parameters like function(a, fun(c,d), r).
                try:
                    nl = cache.nester.parseString(args).asList()[0]
                    clean = [n for n in nl if not isinstance(n, list) and n != ","]
                    #We need to specially handle the case where they have started typing the
                    #name of the first parameter but haven't put a ',' in yet. In that case, 
                    #we are still on the first argument.
                    if clean[-1][-1] != ',':
                        self._call_index = len(clean) - 1
                    else:
                        self._call_index = len(clean)
                except:
                    msg.warn("ARG INDEX: lookup failed on bracket parsing.")
            
        return self._call_index