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 void HandleReturnTypeSpecialCases(Members thisMethod, Component fileJson)
        {
            string propertyOverride = SpecialCases.getReturnTypeOverride(thisMethod.Return != null ? thisMethod.Return.Type : "");

            if (!string.IsNullOrEmpty(propertyOverride))
            {
                thisMethod.Return.Type = propertyOverride;
            }

            propertyOverride = SpecialCases.getReturnTypeOverride(fileJson.Name, thisMethod.Name);
            if ((thisMethod.Return != null || thisMethod.Return == null) && !string.IsNullOrEmpty(propertyOverride))
            {
                if (thisMethod.Return == null)
                {
                    var retorno = new Return()
                    {
                        Type = propertyOverride
                    };
                    thisMethod.Return = retorno;
                }
                else
                {
                    thisMethod.Return.Type = propertyOverride;
                }
            }
        }
        public bool WriteMethods(Component jsonFile, List <string> processedNames, bool isInterface, bool useExport, bool staticOnly, bool isDeclare)
        {
            List <string> processedMethodNames = new List <string>();

            string optionalFlag = "";

            bool hasStaticMethods = false;
            bool isSingleton      = !isInterface && (jsonFile.Singleton || staticOnly);

            var tab = isDeclare ? "\t" : "\t\t";

            var classMethods = jsonFile.Members.Where(m => m.Tagname == "method");

            foreach (var classMethod in classMethods)
            {
                var thisMethod = classMethod;

                if (ShouldIncludeMethod(jsonFile, thisMethod, isSingleton, isInterface, staticOnly, processedNames))
                {
                    if (SpecialCases.shouldRewriteMethod(jsonFile.Name, classMethod.Name))
                    {
                        thisMethod = SpecialCases.getRewriteMethod(jsonFile.Name, classMethod.Name, classMethod);
                    }

                    processedMethodNames.Add(thisMethod.Name);
                    NormalizeMethodDoc(thisMethod);
                    HandleReturnTypeSpecialCases(thisMethod, jsonFile);

                    optionalFlag = isInterface ? "?" : "";

                    if (SpecialCases.shouldConvertToProperty(jsonFile.Name, thisMethod.Name))
                    {
                        WriteMethodAsProperty(thisMethod, tab, optionalFlag);
                    }
                    else
                    {
                        IterateMethodSignatures(tab, jsonFile, thisMethod, optionalFlag, useExport, isInterface, isSingleton);
                    }
                }

                if (classMethod.Static && !hasStaticMethods && ShouldIncludeMethod(jsonFile, classMethod, isInterface, isSingleton, true, processedNames))
                {
                    hasStaticMethods = true;
                }
            }

            return(hasStaticMethods);
        }
        public bool ShouldIncludeMethod(Component fileJson, Members thisMethod, bool isSingleton, bool isInterface, bool staticOnly, List <string> processedNames)
        {
            bool result = false;

            if (TypeManager.IsOwner(fileJson, thisMethod.Owner) || (fileJson.Mixins != null && fileJson.Mixins.Contains(thisMethod.Owner)) || isSingleton)
            {
                if ((!isInterface && (!isSingleton || (isSingleton && thisMethod.Name != "constructor"))) || (isInterface && thisMethod.Name != "constructor"))
                {
                    if ((GeneretorConfiguration.Settings.IncludePrivate == thisMethod.Private || GeneretorConfiguration.Settings.IncludePrivate) || thisMethod.Protected || thisMethod.Template)
                    {
                        //Novo
                        if (!staticOnly || (staticOnly && (thisMethod.Static || fileJson.Singleton || SpecialCases.shouldStatic(fileJson.Name, thisMethod.Name) || thisMethod.Name == "constructor")))
                        {
                            if (!processedNames.Contains(thisMethod.Name) && thisMethod.Deprecated == null && !SpecialCases.shouldRemoveMethod(fileJson.Name, thisMethod.Name))
                            {
                                if (!string.IsNullOrEmpty(thisMethod.Doc) || (!thisMethod.Doc.ToLower().Contains("overridden and disabled")))
                                {
                                    result = true;
                                }
                            }
                        }
                    }
                }

                if (isInterface && thisMethod.Static)
                {
                    result = false;
                }
            }
            return(result);
        }
        public List <string> WriteProperties(Component jsonFile, bool isInterface, bool useExport, bool isDeclare)
        {
            List <string> processedConfigNames = new List <string>();

            var configs    = jsonFile.Members.Where(m => m.Tagname == "cfg");
            var properties = jsonFile.Members.Where(m => m.Tagname == "property");

            string tab = isDeclare ? "\t" : "\t\t";

            string optionalFlag = isInterface ? "?" : "";
            string exportString = useExport ? "export var " : "";

            if (!useExport && !isInterface && jsonFile.Singleton)
            {
                exportString = "static ";
            }

            foreach (var classConfig in configs)
            {
                if (classConfig.Owner == jsonFile.Name && classConfig.Name != "")
                {
                    if (GeneretorConfiguration.Settings.IncludePrivate == classConfig.Private || GeneretorConfiguration.Settings.IncludePrivate)
                    {
                        if (classConfig.Static && !isInterface)
                        {
                            exportString = "static ";
                        }

                        if (!SpecialCases.shouldRemoveProperty(jsonFile.Name, classConfig.Name))
                        {
                            string thisType     = classConfig.Type;
                            string overrideType = SpecialCases.getPropertyTypeOverride(jsonFile.Name, classConfig.Name);

                            if (!string.IsNullOrEmpty(overrideType))
                            {
                                thisType = overrideType;
                            }

                            // Property type conversions
                            if (thisType.Contains("/") || thisType.Contains("|"))
                            {
                                string[] types = thisType.Split(new char[] { '/', '|' }, StringSplitOptions.RemoveEmptyEntries);

                                for (int i = 0; i < types.Count(); i++)
                                {
                                    types[i] = TypeManager.NormalizeType(TypeManager.ConvertToInterface(types[i]));
                                }

                                thisType = string.Join(" | ", types);

                                if (types.Contains("any") || types.Contains("any[]"))
                                {
                                    thisType = "any";
                                }
                            }
                            else
                            {
                                thisType = TypeManager.NormalizeType(TypeManager.ConvertToInterface(thisType));
                            }

                            definitionWriter.WriteToDefinition("{0}/** [Config Option] ({1}) {2} */", tab, classConfig.Type, definitionWriter.FormatCommentText(classConfig.ShortDoc));
                            definitionWriter.WriteToDefinition("{0}{1}{2}{3}: {4}", tab, exportString, classConfig.Name.Replace("-", ""), optionalFlag, thisType);
                        }

                        processedConfigNames.Add(classConfig.Name);
                    }
                }
            }

            foreach (var classProperty in properties)
            {
                if ((!isInterface && jsonFile.Singleton) || (classProperty.Owner == jsonFile.Name && classProperty.Name != ""))
                {
                    if (GeneretorConfiguration.Settings.IncludePrivate == classProperty.Private || GeneretorConfiguration.Settings.IncludePrivate)
                    {
                        if (classProperty.Static && !isInterface)
                        {
                            exportString = "static ";
                        }

                        if (!processedConfigNames.Contains(classProperty.Name) && !SpecialCases.shouldRemoveProperty(jsonFile.Name, classProperty.Name))
                        {
                            string thisType     = classProperty.Type;
                            string overrideType = SpecialCases.getPropertyTypeOverride(jsonFile.Name, classProperty.Name);

                            if (!string.IsNullOrEmpty(overrideType))
                            {
                                thisType = overrideType;
                            }

                            // Property type conversions
                            if (thisType.Contains("/") || thisType.Contains("|"))
                            {
                                string[] types = thisType.Split(new char[] { '/', '|' }, StringSplitOptions.RemoveEmptyEntries);
                                for (int i = 0; i < types.Count(); i++)
                                {
                                    types[i] = TypeManager.NormalizeType(TypeManager.ConvertToInterface(types[i]));
                                }

                                if (!types.Contains("any"))
                                {
                                    thisType = string.Join(" | ", types);
                                }
                                else
                                {
                                    thisType = "any";
                                }
                            }
                            else
                            {
                                thisType = TypeManager.NormalizeType(TypeManager.ConvertToInterface(thisType));
                            }

                            definitionWriter.WriteToDefinition("{0}/** [Property] ({1}) {2} */", tab, classProperty.Type, definitionWriter.FormatCommentText(classProperty.ShortDoc));
                            definitionWriter.WriteToDefinition("{0}{1}{2}{3}: {4}", tab, exportString, classProperty.Name.Replace('-', ' '), optionalFlag, thisType);
                        }

                        processedConfigNames.Add(classProperty.Name);
                    }
                }
            }

            return(processedConfigNames);
        }