protected void readAndAddMethod(ref ExtClass extClass, ExtObjectMember extObjectMember, ref FuncParamsSyntaxCollections funcParamsSyntaxCollections, string currentClassName, string methodName, bool ownedByCurrent, bool isStatic) { string[] docs = this.readJsDocs(extObjectMember.Doc, JsDocsType.METHOD, currentClassName, methodName); Method item = new Method( methodName, funcParamsSyntaxCollections.StandardParamsSyntax, docs, extObjectMember.Owner, ownedByCurrent ); item.Deprecated = this.readJsDocsDeprecated( extObjectMember.Deprecated, currentClassName, methodName ); item.AccessModJs = this.readItemAccessModifier(extObjectMember); item.AccessModTs = item.AccessModJs; item.ExistenceReason = ExistenceReasonType.NATURAL; item.IsStatic = isStatic; item.IsChainable = (extObjectMember.Chainable.HasValue && extObjectMember.Chainable.Value == true); item.IsTemplate = (extObjectMember.Template.HasValue && extObjectMember.Template.Value == true); item.Renderable = extClass.Extends == null || extObjectMember.Name == "statics"; // force render if it is class without any parent if (item.IsChainable) { item.Renderable = true; // always render chanable method with it's return type item.ReturnTypes.Add(extClass.Name.FullName); } else { if (extObjectMember.Return != null) { item.ReturnTypes = this.readAndAddMethodReturn( ref extClass, extObjectMember, currentClassName, isStatic ); } else { item.ReturnTypes.Add("void"); } } if (extObjectMember.Return != null && extObjectMember.Return.Doc != null) { item.ReturnDocs = this.readJsDocs( extObjectMember.Return.Doc, JsDocsType.METHOD_RETURN, currentClassName, "return" ); } extClass.AddMemberMethod(item); if (funcParamsSyntaxCollections.SpreadParamsSyntax.Count > 0) { // There is necessary to add second method form, // because there was last param with standard param // syntax mixed with spread param syntax: Method itemClone = item.Clone(); itemClone.OwnedByCurrent = item.OwnedByCurrent; itemClone.Params = funcParamsSyntaxCollections.SpreadParamsSyntax; extClass.AddMemberMethod(itemClone); } }
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); } } }