protected SpecialParamTypes matchSpecStructParamInParamTypes(ref ParsedTypes paramTypes) { SpecialParamTypes result = new SpecialParamTypes() { Matches = SpecialParamMatch.NONE, MethodOrEventParamTypes = new List <string>(), MethodOrEventSpreadParamTypes = new List <string>(), MethodOrEventAllParamTypes = new List <string>(), }; SpecialParamTypes collectionResult = new SpecialParamTypes() { Matches = SpecialParamMatch.NONE, MethodOrEventAllParamTypes = new List <string>(), }; if (paramTypes.MethodOrEventParam.Count > 0) { collectionResult = this.matchSpecStructParamInParamTypesCollection( paramTypes.MethodOrEventParam, true ); result.Matches |= collectionResult.Matches; if (collectionResult.MethodOrEventAllParamTypes.Count > 0) { result.MethodOrEventParamTypes = new List <string>(collectionResult.MethodOrEventAllParamTypes); result.MethodOrEventAllParamTypes = new List <string>(collectionResult.MethodOrEventAllParamTypes); } } if (paramTypes.MethodOrEventSpreadParam.Count > 0) { collectionResult = this.matchSpecStructParamInParamTypesCollection( paramTypes.MethodOrEventSpreadParam, false ); result.Matches |= collectionResult.Matches; if (collectionResult.MethodOrEventAllParamTypes.Count > 0) { result.MethodOrEventSpreadParamTypes = new List <string>(collectionResult.MethodOrEventAllParamTypes); foreach (string paramType in collectionResult.MethodOrEventAllParamTypes) { if (!result.MethodOrEventAllParamTypes.Contains(paramType)) { result.MethodOrEventAllParamTypes.Add(paramType); } } } } return(result); }
protected SpecialParamTypes matchSpecStructParamInParamTypesCollection( List <string> paramAllTypesCollection, bool standardParamsCollection ) { // Process params collection - clone and remove all primitive types, then decide: SpecialParamTypes result = new SpecialParamTypes() { Matches = SpecialParamMatch.NONE, MethodOrEventAllParamTypes = new List <string>(), }; List <string> nonPrimitiveTypes = new List <string>(); foreach (string paramType in paramAllTypesCollection) { if (!JavascriptInternals.IsJsPrimitive(paramType.ToLower())) { nonPrimitiveTypes.Add(paramType); } } if (nonPrimitiveTypes.Count > 0) { // Callback function: if (nonPrimitiveTypes.Contains("Function")) { result.Matches |= standardParamsCollection ? SpecialParamMatch.STANDARD_COLLECTION_FUNC : SpecialParamMatch.SPREAD_COLLECTION_FUNC; nonPrimitiveTypes.Remove("Function"); } if (standardParamsCollection && nonPrimitiveTypes.Contains("Function[]")) { result.Matches |= SpecialParamMatch.STANDARD_COLLECTION_FUNC_ARR; nonPrimitiveTypes.Remove("Function[]"); } // Configuration object: if (nonPrimitiveTypes.Contains("Object")) { result.Matches |= standardParamsCollection ? SpecialParamMatch.STANDARD_COLLECTION_OBJECT : SpecialParamMatch.SPREAD_COLLECTION_OBJECT; nonPrimitiveTypes.Remove("Object"); } if (nonPrimitiveTypes.Contains("object")) { result.Matches |= standardParamsCollection ? SpecialParamMatch.STANDARD_COLLECTION_OBJECT : SpecialParamMatch.SPREAD_COLLECTION_OBJECT; nonPrimitiveTypes.Remove("object"); } if (standardParamsCollection && nonPrimitiveTypes.Contains("Object[]")) { result.Matches |= SpecialParamMatch.STANDARD_COLLECTION_OBJECT_ARR; nonPrimitiveTypes.Remove("Object[]"); } if (standardParamsCollection && nonPrimitiveTypes.Contains("object[]")) { result.Matches |= SpecialParamMatch.STANDARD_COLLECTION_OBJECT_ARR; nonPrimitiveTypes.Remove("object[]"); } // Any other like: Ext.event.Event: if (nonPrimitiveTypes.Count > 0) { bool arrayMatch = false; bool nonArrayMatch = false; foreach (string nonPrimitiveType in nonPrimitiveTypes) { if (nonPrimitiveType.EndsWith("[]")) { arrayMatch = true; } else { nonArrayMatch = true; } result.MethodOrEventAllParamTypes.Add(nonPrimitiveType); } if (standardParamsCollection && arrayMatch) { result.Matches |= SpecialParamMatch.STANDARD_COLLECTION_INTERFACE_ARR; } if (nonArrayMatch) { result.Matches |= standardParamsCollection ? SpecialParamMatch.STANDARD_COLLECTION_INTERFACE : SpecialParamMatch.SPREAD_COLLECTION_INTERFACE; } } } return(result); }
protected void readFunctionParamSpecials( MemberParam param, ref ParsedTypes paramTypes, bool eventCompleting, string currentClassName, string eventOrMethodName, bool isStatic, bool eventsCompleting ) { string extParamsPseudoCallbackName; string extParamsPseudoClassName; SpecialParamTypes specialTypes = this.matchSpecStructParamInParamTypes(ref paramTypes); if ((specialTypes.Matches & SpecialParamMatch.ANY_FUNC) != 0) { // Described function callback as special class, not rendered later as type but directly: extParamsPseudoCallbackName = this.extClassMethodConfigObjectPresudoClassName( currentClassName, eventOrMethodName, isStatic, eventsCompleting, param.Name, false ); // `extParamsPseudoCallbackName = 'Ext.AbstractManager.methodsCallbackParams.each.Fn';` // `extParamsPseudoCallbackName = 'Ext.Class.staticMethodsCallbackParams.registerPreprocessor.Fn';` this.readFunctionParamCallbackProperties( extParamsPseudoCallbackName, eventOrMethodName, param.Doc, param.Properties, eventCompleting ); // Add described virtual callback type: if ((specialTypes.Matches & SpecialParamMatch.STANDARD_COLLECTION_FUNC) != 0) { paramTypes.MethodOrEventParam.Add(extParamsPseudoCallbackName); } if ((specialTypes.Matches & SpecialParamMatch.STANDARD_COLLECTION_FUNC_ARR) != 0) { paramTypes.MethodOrEventParam.Add(extParamsPseudoCallbackName + "[]"); } if ((specialTypes.Matches & SpecialParamMatch.SPREAD_COLLECTION_FUNC) != 0) { paramTypes.MethodOrEventSpreadParam.Add(extParamsPseudoCallbackName); } } if ((specialTypes.Matches & SpecialParamMatch.ANY_OBJECT) != 0) { // Described config object as special class, rendered later as type, // extended from `Object` TypeScript interface: extParamsPseudoClassName = this.extClassMethodConfigObjectPresudoClassName( currentClassName, eventOrMethodName, isStatic, eventsCompleting, param.Name, true ); // `extParamsPseudoClassName = 'Ext.Ajax.methodsParams.addListener.Options';` // `extParamsPseudoClassName = 'Ext.data.Model.staticMethodsParams.load.Options';` this.readFunctionParamConfObjectProperties( currentClassName, extParamsPseudoClassName, eventOrMethodName, "Object", param.Doc, param.Properties, eventCompleting, isStatic ); if ((specialTypes.Matches & SpecialParamMatch.STANDARD_COLLECTION_OBJECT) != 0) { paramTypes.MethodOrEventParam.Add(extParamsPseudoClassName); } if ((specialTypes.Matches & SpecialParamMatch.STANDARD_COLLECTION_OBJECT_ARR) != 0) { paramTypes.MethodOrEventParam.Add(extParamsPseudoClassName + "[]"); } if ((specialTypes.Matches & SpecialParamMatch.SPREAD_COLLECTION_OBJECT) != 0) { paramTypes.MethodOrEventSpreadParam.Add(extParamsPseudoClassName); } } if ((specialTypes.Matches & SpecialParamMatch.ANY_INTERFACE) != 0) { // Described config object as special class, rendered later as type, // extended from given interface(s): bool numberTypes = specialTypes.MethodOrEventAllParamTypes.Count > 1; int index = 1; bool specTypeIsArr; bool typeIsForStandardCollection; bool typeIsforSpreadCollection; foreach (string specialTypeParent in specialTypes.MethodOrEventAllParamTypes) { specTypeIsArr = specialTypeParent.EndsWith("[]"); extParamsPseudoClassName = this.extClassMethodConfigObjectPresudoClassName( currentClassName, eventOrMethodName, isStatic, eventsCompleting, param.Name, true ); // `extParamsPseudoClassName = 'Ext.button.Segmented.methodsParams.onFocusLeave.E';` if (numberTypes) { extParamsPseudoClassName += index.ToString(); } this.readFunctionParamConfObjectProperties( currentClassName, extParamsPseudoClassName, eventOrMethodName, specTypeIsArr ? specialTypeParent.Substring(0, specialTypeParent.Length - 2) : specialTypeParent, param.Doc, param.Properties, eventCompleting, isStatic ); typeIsForStandardCollection = specialTypes.MethodOrEventParamTypes.Contains(specialTypeParent); typeIsforSpreadCollection = specialTypes.MethodOrEventSpreadParamTypes.Contains(specialTypeParent); if ( typeIsForStandardCollection && (specialTypes.Matches & SpecialParamMatch.STANDARD_COLLECTION_INTERFACE) != 0 ) { paramTypes.MethodOrEventParam.Add(extParamsPseudoClassName); } if ( typeIsForStandardCollection && specTypeIsArr && (specialTypes.Matches & SpecialParamMatch.STANDARD_COLLECTION_INTERFACE_ARR) != 0 ) { paramTypes.MethodOrEventParam.Add(extParamsPseudoClassName + "[]"); } if ( typeIsforSpreadCollection && (specialTypes.Matches & SpecialParamMatch.SPREAD_COLLECTION_INTERFACE) != 0 ) { paramTypes.MethodOrEventSpreadParam.Add(extParamsPseudoClassName); } index += 1; } } }