Exemplo n.º 1
0
        protected void readAndAddProp(ref ExtClass extClass, ExtObjectMember member, ParsedTypes types, bool ownedByCurrent, bool required)
        {
            string name = this.sanitizeName(member.Name);

            string[] docs = this.readJsDocs(member.Doc, JsDocsType.PROPERTY, extClass.Name.FullName, name);
            //if (extClass.Name.FullName == "Ext.Base")
            //	Debugger.Break();
            Property newPropItem = new Property(
                name, types.CfgOrProp, docs, member.Owner, ownedByCurrent
                );

            //newPropItem.DefaultValue = String.IsNullOrEmpty(member.Default) ? "" : member.Default;
            newPropItem.DefaultValue = member.Default == "" ? "''" : member.Default;
            newPropItem.Deprecated   = this.readJsDocsDeprecated(
                member.Deprecated, extClass.Name.FullName, name
                );
            newPropItem.AccessModJs = this.readItemAccessModifier(member);
            newPropItem.AccessModTs = newPropItem.AccessModJs;
            newPropItem.IsStatic    = (member.Static.HasValue && member.Static.Value == true);
            newPropItem.IsReadOnly  = (member.Readonly.HasValue && member.Readonly.Value == true);
            if (!newPropItem.IsReadOnly)
            {
                string nameUpper = name.ToUpper();
                if (name == nameUpper && types.CfgOrProp.Count == 1)
                {
                    newPropItem.IsReadOnly = true;                     // it's looking like some contant:
                }
            }
            newPropItem.Renderable = extClass.Extends == null || name == "self";             // force render if it is class without any parent
            extClass.AddMemberProperty(newPropItem);
        }
Exemplo n.º 2
0
        protected void readFunctionParamConfObjectProperties(string currentClassName, string extParamsPseudoClassName, string eventOrMethodName, string baseClassOrInterfaceFullName, string pseudoClassDoc, IList <MemberParamProperty> funcParamConfObjectProps, bool eventsCompleting, bool isStatic)
        {
            ConfigProperty funcParamConfObjectPropOther;
            ExtClass       extParamConfObject = new ExtClass(
                extParamsPseudoClassName,
                (baseClassOrInterfaceFullName == "Object"
                                        ? SpecialsGenerator.BASE_PARAMS_INTERFACE_NAME
                                        : baseClassOrInterfaceFullName),
                this.readJsDocs(
                    pseudoClassDoc,
                    eventsCompleting
                                                ? JsDocsType.EVENT_PARAM_CONF_OBJ
                                                : JsDocsType.METHOD_PARAM_CONF_OBJ,
                    extParamsPseudoClassName
                    )
                );

            extParamConfObject.Package = this.currentPackage.Type;
            //extParamConfObject.SrcJson = this.srcJson;
            extParamConfObject.Name.PackagedNamespace = this.GetPackagedNamespaceFromFullClassName(
                currentClassName
                );
            if (eventsCompleting)
            {
                extParamConfObject.Link = new string[] {
                    currentClassName + "." + eventOrMethodName,
                    this.GetLinkHrefForClassEvent(
                        currentClassName, eventOrMethodName
                        )
                };
            }
            else
            {
                extParamConfObject.Link = new string[] {
                    currentClassName + "." + eventOrMethodName,
                    this.GetLinkHrefForClassMethod(
                        currentClassName, isStatic, eventOrMethodName
                        )
                };
            }
            extParamConfObject.ClassType = ClassType.CLASS_METHOD_PARAM_CONF_OBJ;
            foreach (MemberParamProperty funcParamConfObjectProp in funcParamConfObjectProps)
            {
                funcParamConfObjectPropOther = this.readFunctionParamConfObjectProperty(
                    extParamsPseudoClassName,
                    pseudoClassDoc,
                    funcParamConfObjectProp,
                    eventOrMethodName,
                    eventsCompleting,
                    isStatic
                    );
                extParamConfObject.AddMemberProperty(funcParamConfObjectPropOther);
            }
            this.processor.Store.AddExtClass(extParamConfObject);
        }
Exemplo n.º 3
0
        protected List <string> readAndAddMethodReturn(ref ExtClass extClass, ExtObjectMember extObjectMember, string currentClassName, bool isStatic)
        {
            List <string> returnTypes    = new List <string>();
            List <string> rawReturnTypes = this.typesParser.Parse(
                TypeDefinitionPlace.METHOD_RETURN,
                currentClassName,
                extObjectMember.Name,
                extObjectMember.Return.Type
                ).MethodOrEventReturn;
            // check if there is any directly written object:
            string        rawReturnType;
            List <string> rawMembers;
            string        rawMember;

            string[]      rawMemberNameAndType;
            string        rawMemberName;
            List <string> rawMemberTypes;

            string[] returnDocs = null;
            Property prop;

            if (extObjectMember.Return != null && extObjectMember.Return.Doc != null)
            {
                returnDocs = this.readJsDocs(
                    extObjectMember.Return.Doc,
                    JsDocsType.METHOD_RETURN,
                    currentClassName,
                    "return"
                    );
            }
            for (int i = 0; i < rawReturnTypes.Count; i++)
            {
                rawReturnType = rawReturnTypes[i];
                if (rawReturnType.Length > 2 && rawReturnType.StartsWith("{") && rawReturnType.EndsWith("}"))
                {
                    // Ext.draw.engine.Canvas.getBBox(): {x: Number, y: Number, width: number, height: number}
                    ExtClass returnClass = new ExtClass(
                        this.extClassMethodReturnObjectPresudoClassName(
                            currentClassName, extObjectMember.Name, isStatic
                            ),
                        SpecialsGenerator.BASE_RETURNS_INTERFACE_NAME,
                        returnDocs
                        );
                    returnClass.Package = extClass.Package;
                    //returnClass.SrcJson = this.srcJson;
                    returnClass.Name.PackagedNamespace = this.GetPackagedNamespaceFromFullClassName(
                        extClass.Name.FullName
                        );
                    returnClass.ClassType = ClassType.CLASS_METHOD_RETURN_OBJECT;
                    returnClass.Link      = new string[] {
                        currentClassName + "." + extObjectMember.Name,
                        this.GetLinkHrefForClassMethod(
                            currentClassName, isStatic, extObjectMember.Name
                            )
                    };
                    //returnClass.AddMemberProperty()
                    rawReturnType = rawReturnType.TrimStart('{').TrimEnd('}');
                    rawMembers    = rawReturnType.Split(',').ToList <string>();
                    for (int j = 0; j < rawMembers.Count; j++)
                    {
                        rawMember            = rawMembers[j].Trim();
                        rawMemberNameAndType = rawMember.Split(':').ToArray <string>();
                        if (rawMemberNameAndType.Length == 1)
                        {
                            rawMemberName  = rawMemberNameAndType[0];
                            rawMemberTypes = this.typesParser.Parse(
                                TypeDefinitionPlace.METHOD_RETURN,
                                currentClassName,
                                extObjectMember.Name,
                                extObjectMember.Return.Type
                                ).MethodOrEventReturn;
                            // rawMemberNameAndType[1]
                        }
                        else if (rawMemberNameAndType.Length > 1)
                        {
                            rawMemberName  = rawMemberNameAndType[0];
                            rawMemberTypes = new List <string>()
                            {
                                "any"
                            };
                        }
                        else
                        {
                            continue;
                        }
                        prop = new Property(
                            rawMemberName, rawMemberTypes, null, returnClass.Name.FullName, true
                            );
                        prop.IsStatic    = false;
                        prop.IsReadOnly  = false;
                        prop.Inherited   = false;
                        prop.AccessModJs = AccessModifier.PUBLIC;
                        prop.AccessModTs = AccessModifier.PUBLIC;
                        returnClass.AddMemberProperty(prop);
                    }
                    this.processor.Store.AddExtClass(returnClass);
                    returnTypes.Add(returnClass.Name.FullName);
                }
                else
                {
                    returnTypes.Add(rawReturnType);
                }
            }
            return(returnTypes);
        }
Exemplo n.º 4
0
        protected internal bool CheckAllSingletonClasses(typesCheckerProgressHandler progressHandler)
        {
            int extClassesIndex = 0;
            // check all class parents definitions existence:
            bool     namespaceClassRenderedAsClass;
            ExtClass namespaceClass;
            ExtClass namespaceClassParent;
            ExtClass namespaceAliasClass;
            Property singletonAliasProp;

            foreach (ExtClass extClass in this.processor.Store.ExtStandardSingletonClasses)
            {
                if (extClass.Name.FullName == "Ext")
                {
                    continue;
                }
                // Try to find the same class name as singleton namespace is:
                if (this.processor.Store.ExtClassesMap.ContainsKey(extClass.Name.NamespaceName))
                {
                    namespaceClass = this.processor.Store.GetByFullName(extClass.Name.NamespaceName);
                    // Check if class is standard, non singleton, or singleton but non "Ext" or it could be alias without such parent:
                    namespaceClassRenderedAsClass = false;
                    if (namespaceClass.ClassType == ExtTypes.Enums.ClassType.CLASS_STANDARD)
                    {
                        namespaceClassRenderedAsClass = (
                            namespaceClass.Singleton == false || (
                                namespaceClass.Singleton &&
                                namespaceClass.Name.FullName == "Ext"
                                )
                            );
                    }
                    else if (
                        namespaceClass.ClassType == ExtTypes.Enums.ClassType.CLASS_ALIAS &&
                        namespaceClass.Extends == null
                        )
                    {
                        namespaceClassRenderedAsClass = true;
                    }
                    else if (
                        namespaceClass.ClassType == ExtTypes.Enums.ClassType.CLASS_ALIAS &&
                        namespaceClass.Extends != null
                        )
                    {
                        namespaceClassParent = this.processor.Store.GetParentClassByCurrentClassFullName(
                            namespaceClass.Extends.FullName
                            );
                        namespaceClassRenderedAsClass = (
                            namespaceClassParent.Singleton == false || (
                                namespaceClassParent.Singleton &&
                                namespaceClassParent.Name.FullName == "Ext"
                                )
                            );
                    }
                    singletonAliasProp = new Property(
                        extClass.Name.ClassName,
                        new List <string>()
                    {
                        extClass.Name.FullName
                    },
                        null,
                        extClass.Name.FullName,
                        false
                        );
                    singletonAliasProp.Renderable        = true;
                    singletonAliasProp.SingletonInstance = extClass;
                    if (namespaceClassRenderedAsClass)
                    {
                        // Add public static readonly property:
                        singletonAliasProp.AccessModJs = ExtTypes.Enums.AccessModifier.PUBLIC;
                        singletonAliasProp.AccessModTs = ExtTypes.Enums.AccessModifier.PUBLIC;
                        singletonAliasProp.IsStatic    = true;
                        singletonAliasProp.IsReadOnly  = true;
                    }                    /* else {
                                          *     // Add property only (rendered in interface):
                                          * }*/
                    namespaceClass.AddMemberProperty(singletonAliasProp);
                }
                else
                {
                    // create alias class like "declare namespace Ext { class dom { public static readonly Helper; } }":
                    namespaceAliasClass = new ExtClass(
                        extClass.Name.NamespaceName, "", null
                        );
                    namespaceAliasClass.Package = extClass.Package;
                    //namespaceAliasClass.SrcJson = extClass.SrcJson;
                    namespaceAliasClass.Name.PackagedNamespace = this.processor.Reader.GetPackagedNamespaceFromFullClassName(
                        extClass.Name.FullName
                        );
                    namespaceAliasClass.ClassType = ExtTypes.Enums.ClassType.CLASS_ALIAS;
                    singletonAliasProp            = new Property(
                        extClass.Name.ClassName,
                        new List <string>()
                    {
                        extClass.Name.FullName
                    },
                        null,
                        extClass.Name.FullName,
                        false
                        );
                    singletonAliasProp.Renderable        = true;
                    singletonAliasProp.AccessModJs       = ExtTypes.Enums.AccessModifier.PUBLIC;
                    singletonAliasProp.AccessModTs       = ExtTypes.Enums.AccessModifier.PUBLIC;
                    singletonAliasProp.IsStatic          = true;
                    singletonAliasProp.IsReadOnly        = true;
                    singletonAliasProp.SingletonInstance = extClass;
                    namespaceAliasClass.AddMemberProperty(singletonAliasProp);
                    this.processor.Store.AddExtClass(namespaceAliasClass);
                }
                //
                extClassesIndex += 1;
                progressHandler.Invoke(
                    extClassesIndex,
                    extClass.Name.FullName
                    );
            }
            // check all class members types existence:
            string[] allDefinedTypes = this.processor.Store.TypesPlaces.Keys.ToArray <string>();
            string   typeFullName;
            List <TypeDefinitionSource> definedPlaces;
            List <string> definedPlacesStr;

            for (int i = 0; i < allDefinedTypes.Length; i++)
            {
                typeFullName = allDefinedTypes[i];
                if (!this.processor.Store.ExtClassesMap.ContainsKey(typeFullName))
                {
                    if (!this.tryToGetTypeExistenceAsClassStaticProperty(typeFullName))
                    {
                        definedPlaces    = this.processor.Store.TypesPlaces[typeFullName];
                        definedPlacesStr = new List <string>();
                        foreach (TypeDefinitionSource definedPlace in definedPlaces)
                        {
                            definedPlacesStr.Add(definedPlace.DefinitionFullPath);
                        }
                        // add parent class name definition into unknown types:
                        this.processor.Store.AddUnknownType(
                            typeFullName, String.Join(", ", definedPlacesStr)
                            );
                    }
                }
            }
            return(true);
        }
Exemplo n.º 5
0
        protected void generateDefinitionsClassesAddDefsClassConfigItems(List <Configuration> extClassConfigs, ExtClass standardClass, ref ExtClass definitionsClass)
        {
            Dictionary <string, Member>         standardClassProps   = standardClass.Members.Properties;
            Dictionary <string, List <Member> > standardClassMethods = standardClass.Members.Methods;
            Property      newProp;
            List <string> newPropTypes;
            bool          standardClassHasConfigsInterface = (
                standardClass.Members.Configations.Count > 0
                );
            bool standardClassHasStaticsInterface = (
                standardClass.Members.MethodsStatic.Count > 0 ||
                standardClass.Members.PropertiesStatic.Count > 0
                );
            Property      mixedStandardClassOrParentProperty;
            ExtClass      mixedStandardClassOrParentMethodsClass;
            List <Member> mixedStandardClassOrParentMethods;
            Method        mixedStandardClassOrParentMethod;
            Method        mixedStandardClassOrParentMethodClone;

            foreach (Configuration extClassConfig in extClassConfigs)
            {
                mixedStandardClassOrParentProperty = null;
                mixedStandardClassOrParentMethods  = null;
                if (standardClassHasConfigsInterface && extClassConfig.Name == "config")
                {
                    newPropTypes = new List <string>()
                    {
                        standardClass.Name.FullName + SpecialsGenerator.CONFIGS_NAME_ADDITION
                    };
                }
                else if (standardClassHasStaticsInterface && extClassConfig.Name == "statics")
                {
                    newPropTypes = new List <string>()
                    {
                        standardClass.Name.FullName + SpecialsGenerator.STATICS_NAME_ADDITION
                    };
                }
                else
                {
                    newPropTypes = new List <string>(extClassConfig.Types);
                }
                newProp = new Property(
                    extClassConfig.Name,
                    newPropTypes,
                    extClassConfig.Doc,
                    extClassConfig.Owner.FullName,
                    true
                    );
                newProp.AccessModJs  = AccessModifier.PROTECTED;
                newProp.AccessModTs  = AccessModifier.PROTECTED;
                newProp.DefaultValue = extClassConfig.DefaultValue;
                newProp.Deprecated   = extClassConfig.Deprecated;
                newProp.Inherited    = true;
                newProp.IsReadOnly   = false;
                newProp.IsStatic     = false;
                newProp.Renderable   = true;
                mixedStandardClassOrParentProperty = this.generateDefinitionsClassesTryToFindTheSameProp(
                    standardClass, extClassConfig.Name
                    );
                mixedStandardClassOrParentMethodsClass = this.generateDefinitionsClassesTryToFindTheSameMethodClass(
                    standardClass, extClassConfig.Name
                    );
                if (mixedStandardClassOrParentProperty != null)
                {
                    // mix with already defined property - merge new property types and make parent property renderable
                    this.generateDefinitionsClassesMergeProperties(
                        ref mixedStandardClassOrParentProperty, ref newProp
                        );
                }
                else if (mixedStandardClassOrParentMethodsClass != null)
                {
                    // mix with already defined methods
                    mixedStandardClassOrParentMethods = mixedStandardClassOrParentMethodsClass.Members.Methods[extClassConfig.Name];
                    if (mixedStandardClassOrParentMethodsClass.Name.FullName == standardClass.Name.FullName)
                    {
                        // mexid method is in the same class - mixed method + property will be rendered at the end,
                        // so only make method renderable for sure
                        for (int i = 0; i < mixedStandardClassOrParentMethods.Count; i++)
                        {
                            mixedStandardClassOrParentMethod                      = mixedStandardClassOrParentMethods[i] as Method;
                            mixedStandardClassOrParentMethod.Renderable           = true;
                            mixedStandardClassOrParentMethods[i]                  = mixedStandardClassOrParentMethod;
                            mixedStandardClassOrParentMethodClone                 = mixedStandardClassOrParentMethod.Clone();
                            mixedStandardClassOrParentMethodClone.ExistenceReason = ExistenceReasonType.NATURAL;
                            mixedStandardClassOrParentMethodClone.OwnedByCurrent  = true;                            // always render js docs for @mixed
                            definitionsClass.AddMemberMethod(mixedStandardClassOrParentMethodClone);
                        }
                        definitionsClass.AddMemberProperty(newProp);
                    }
                    else
                    {
                        // mexid method is in some parent class - add this method to current class, make it renderable
                        // and mixed prop andmethod will be rendered at the end
                        for (int i = 0; i < mixedStandardClassOrParentMethods.Count; i++)
                        {
                            mixedStandardClassOrParentMethod                      = mixedStandardClassOrParentMethods[i] as Method;
                            mixedStandardClassOrParentMethod.Renderable           = true;
                            mixedStandardClassOrParentMethods[i]                  = mixedStandardClassOrParentMethod;
                            mixedStandardClassOrParentMethodClone                 = mixedStandardClassOrParentMethod.Clone();
                            mixedStandardClassOrParentMethodClone.ExistenceReason = ExistenceReasonType.NATURAL;
                            mixedStandardClassOrParentMethodClone.OwnedByCurrent  = true;                            // always render js docs for @mixed
                            definitionsClass.AddMemberMethod(mixedStandardClassOrParentMethodClone);
                        }
                        definitionsClass.AddMemberProperty(newProp);
                    }
                }
                else
                {
                    definitionsClass.AddMemberProperty(newProp);
                }
            }
        }