public void IterateMethodSignatures(string tab, Component jsonFile, Members thisMethod, string optionalFlag, bool useExport, bool isInterface, bool isSingleton)
        {
            string[] tokenizedTypes = GeneretorConfiguration.Settings.UseFullTyping ? TypeManager.getTokenizedReturnTypes(thisMethod.Return) : new string[] { "any" };

            foreach (var tokenizedType in tokenizedTypes)
            {
                MethodParameters methodParameters = new MethodParameters(thisMethod);

                bool isStatic = !isInterface && ((isSingleton && (thisMethod.Static || thisMethod.Autodetected.Static)) ||
                                                 thisMethod.Static ||
                                                 SpecialCases.shouldStatic(jsonFile.Name, thisMethod.Name));

                List <string> usedPermutations = new List <string>();
                bool          methodWritten    = false;

                if (methodParameters.HasOnlyOneSignature())
                {
                    WriteMethod(tab, thisMethod.ShortDoc, thisMethod.Name, optionalFlag, methodParameters, tokenizedType, thisMethod.Return, useExport, isStatic, isInterface);
                }
                else if (ShouldCreateOverrideMethod(methodParameters.requiresOverrides, tokenizedTypes, tokenizedType))
                {
                    List <string>    overrideTypes          = methodParameters.paramNames.Select(a => "any").ToList();
                    MethodParameters overriddenMethodParams = methodParameters.CloneWithNewParamTypes(overrideTypes);
                    WriteMethod(tab, thisMethod.ShortDoc, thisMethod.Name, optionalFlag, overriddenMethodParams, "any", thisMethod.Return, useExport, isStatic, isInterface);
                    usedPermutations = overrideTypes;
                    methodWritten    = true;
                }

                if (GeneretorConfiguration.Settings.UseFullTyping && usedPermutations.Count > 0)
                {
                    ProcessSignaturePermutations(tab, thisMethod, optionalFlag, tokenizedType, methodParameters, usedPermutations, methodWritten, useExport, isStatic);
                }
            }
        }
        public MethodParameters CloneWithNewParamTypes(List <string> newParamTypes)
        {
            MethodParameters methodParameters = new MethodParameters(this.method);

            methodParameters.paramNames        = paramNames;
            methodParameters.paramTypes        = newParamTypes;
            methodParameters.rawParamTypes     = rawParamTypes;
            methodParameters.requiresOverrides = requiresOverrides;
            return(methodParameters);
        }
        public void ProcessSignaturePermutations(string tab, Members thisMethod, string optionalFlag, string thisType, MethodParameters methodParameters, List <string> usedPermutations, bool methodWritten, bool useExport, bool isStatic)
        {
            List <string> paramPermutations = methodParameters.paramTypes;

            if (!methodParameters.requiresOverrides || (methodParameters.requiresOverrides && paramPermutations.Where(a => TypeManager.NormalizeType(a) == "any").Count() < paramPermutations.Count))
            {
                string thisPermutationAsString = string.Join(",", paramPermutations);

                if (!usedPermutations.Contains(thisPermutationAsString))
                {
                    MethodParameters permutationParams = methodParameters.CloneWithNewParamTypes(paramPermutations);

                    WriteMethod(tab, thisMethod.ShortDoc, thisMethod.Name, optionalFlag, permutationParams, thisType, thisMethod.Return, useExport, isStatic, methodWritten);
                    usedPermutations.Add(thisPermutationAsString);
                    methodWritten = true;
                }
            }
        }
        public dynamic AppendMethodParamOutput(string tab, string methodOutput, string paramsDoc, MethodParameters methodParameters)
        {
            for (int i = 0; i < methodParameters.paramNames.Count; i++)
            {
                Param  thisParam     = methodParameters.paramNames[i];
                string thisParamType = TypeManager.ConvertToInterface(methodParameters.paramTypes[i]);
                string thisParamName = thisParam.Name;

                paramsDoc += string.Format("{0} * @param {1} {2} {3}", tab, thisParamName, methodParameters.rawParamTypes[thisParamName], definitionWriter.FormatCommentText(thisParam.Short_Doc));

                if (!string.IsNullOrEmpty(thisParam.Doc) && Regex.IsMatch(thisParam.Doc, @"\boptional\b", RegexOptions.IgnoreCase))
                {
                    thisParam.Optional = true;
                }

                string spread = "";
                if (methodParameters.IsParamWithSpread(thisParam, thisParamType))
                {
                    spread = "...";
                }

                if (thisParamName == "class")
                {
                    thisParamName = "clazz";
                }

                string optionalParamFlag = (thisParam.Optional || !string.IsNullOrEmpty(spread)) ? "?" : "";

                if (string.IsNullOrEmpty(spread) && GeneretorConfiguration.Settings.ForceAllParamsToOptional)
                {
                    optionalParamFlag = "?";
                }
                else if (methodParameters.HasParametersWithSpread())
                {
                    optionalParamFlag = "";
                }

                if (i > 0 && methodParameters.paramNames[i - 1].Optional && string.IsNullOrEmpty(spread))
                {
                    optionalParamFlag = "?";
                }

                methodOutput += string.Format("{0}{1}{2}:{3}", spread, thisParamName, optionalParamFlag, !string.IsNullOrEmpty(spread) ? "any[]" : TypeManager.NormalizeType(thisParamType));

                if (thisParam.Name == methodParameters.paramNames.Last().Name)
                {
                    methodOutput += "";
                }
                else
                {
                    methodOutput += ", ";
                    paramsDoc    += "\n";
                }
            }

            return(new { methodOutput = methodOutput, paramsDoc = paramsDoc });
        }
        public void WriteMethod(string tab, string comment, string methodName, string optionalFlag, MethodParameters methodParameters, string returnType, Return returnMetadata, bool useExport, bool isStatic = false, bool isInterface = false, bool omitComment = false)
        {
            string exportString = useExport ? "export function " : "";
            string staticString = IsStaticMethod(isStatic, useExport, methodName) ? "static " : "";

            comment = string.Format("{0}/** [Method] {1}", tab, definitionWriter.FormatCommentText(comment));

            string paramsDoc = "";

            if (ShouldWriteMethod(isInterface, useExport, isStatic))
            {
                if (GeneretorConfiguration.Settings.InterfaceOnly)
                {
                    returnType = TypeManager.ConvertToInterface(returnType);
                }

                string  methodOutput = string.Format("{0}{1}{2}(", staticString, methodName, optionalFlag);
                dynamic paramResult  = AppendMethodParamOutput(tab, methodOutput, paramsDoc, methodParameters);

                writeMethodComment(tab, comment, paramResult.paramsDoc, returnMetadata, omitComment);
                WriteMethodDefinition(tab, paramResult.methodOutput, exportString, methodName, returnType);
            }
        }