MCPcopy Create free account
hub / github.com/beefytech/Beef / FixitAddConstructor

Method FixitAddConstructor

IDEHelper/Compiler/BfAutoComplete.cpp:4071–4165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4069}
4070
4071void BfAutoComplete::FixitAddConstructor(BfTypeInstance *typeInstance)
4072{
4073 auto baseType = typeInstance->mBaseType;
4074 auto parser = typeInstance->mTypeDef->GetDefinition()->mSource->ToParser();
4075 if (parser != NULL)
4076 {
4077 for (auto methodDef : baseType->mTypeDef->mMethods)
4078 {
4079 if (methodDef->mMethodType != BfMethodType_Ctor)
4080 continue;
4081 if (methodDef->mIsStatic)
4082 continue;
4083 if (methodDef->mProtection <= BfProtection_Private)
4084 continue;
4085
4086 auto methodInstance = mModule->GetRawMethodInstanceAtIdx(baseType, methodDef->mIdx);
4087
4088 String ctorShowName;
4089
4090 int insertPos = FixitGetMemberInsertPos(mModule->mCurTypeInstance->mTypeDef);
4091 String methodStr = "\f\a";
4092 if (methodInstance->mMethodDef->HasAppend())
4093 methodStr += "[AllowAppend]\r";
4094 methodStr += "public this(";
4095 int useParamIdx = 0;
4096 for (int paramIdx = 0; paramIdx < methodInstance->GetParamCount(); paramIdx++)
4097 {
4098 if (useParamIdx > 0)
4099 methodStr += ", ";
4100
4101 auto paramKind = methodInstance->GetParamKind(paramIdx);
4102 if (paramKind == BfParamKind_AppendIdx)
4103 continue;
4104
4105 switch (paramKind)
4106 {
4107 case BfParamKind_Params:
4108 methodStr += "params ";
4109 break;
4110 default:
4111 break;
4112 }
4113 methodStr += mModule->TypeToString(methodInstance->GetParamType(paramIdx), BfTypeNameFlag_ReduceName);
4114 methodStr += " ";
4115 methodStr += methodInstance->GetParamName(paramIdx);
4116 useParamIdx++;
4117 }
4118 methodStr += ") : base(";
4119
4120 ctorShowName += "this(";
4121 useParamIdx = 0;
4122 for (int paramIdx = 0; paramIdx < methodInstance->GetParamCount(); paramIdx++)
4123 {
4124 if (useParamIdx > 0)
4125 {
4126 ctorShowName += ", ";
4127 methodStr += ", ";
4128 }

Callers 1

CreateCallMethod · 0.80

Calls 12

AutoCompleteEntryClass · 0.85
GetDefinitionMethod · 0.80
HasAppendMethod · 0.80
GetParamKindMethod · 0.80
ToParserMethod · 0.45
GetParamCountMethod · 0.45
TypeToStringMethod · 0.45
GetParamTypeMethod · 0.45
GetParamNameMethod · 0.45
IsRefMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected