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

Method AddEnumTypeMembers

IDEHelper/Compiler/BfAutoComplete.cpp:1272–1318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1270}
1271
1272void BfAutoComplete::AddEnumTypeMembers(BfTypeInstance* typeInst, const StringImpl& filter, bool allowProtected, bool allowPrivate)
1273{
1274 mModule->PopulateType(typeInst, BfPopulateType_Data);
1275
1276 auto activeTypeDef = mModule->GetActiveTypeDef();
1277
1278 for (auto& fieldInst : typeInst->mFieldInstances)
1279 {
1280 auto fieldDef = fieldInst.GetFieldDef();
1281 if ((fieldDef != NULL) && (fieldDef->mIsConst) &&
1282 ((fieldInst.mResolvedType == typeInst) || (fieldInst.mIsEnumPayloadCase)) &&
1283 (CheckProtection(fieldDef->mProtection, fieldDef->mDeclaringType, allowProtected, allowPrivate)))
1284 {
1285 if ((!typeInst->IsTypeMemberIncluded(fieldDef->mDeclaringType, activeTypeDef, mModule)) ||
1286 (!typeInst->IsTypeMemberAccessible(fieldDef->mDeclaringType, activeTypeDef)))
1287 continue;
1288
1289 bool hasPayload = false;
1290 if ((fieldInst.mIsEnumPayloadCase) && (fieldInst.mResolvedType->IsTuple()))
1291 {
1292 auto payloadType = (BfTypeInstance*)fieldInst.mResolvedType;
1293 if (!payloadType->mFieldInstances.empty())
1294 hasPayload = true;
1295 }
1296
1297 AutoCompleteEntry entry(hasPayload ? "payloadEnum" : "value", fieldDef->mName);
1298 if (auto entryAdded = AddEntry(entry, filter))
1299 {
1300 auto fieldDecl = fieldDef->GetFieldDeclaration();
1301 if (fieldDecl == NULL)
1302 continue;
1303
1304 if (CheckDocumentation(entryAdded, fieldDecl->mDocumentation))
1305 {
1306 }
1307
1308 if (mIsGetDefinition)
1309 {
1310 mDefType = typeInst->mTypeDef;
1311 mDefField = fieldDef;
1312 if (fieldDecl != NULL)
1313 SetDefinitionLocation(fieldDecl->mNameNode);
1314 }
1315 }
1316 }
1317 }
1318}
1319
1320void BfAutoComplete::AddExtensionMethods(BfTypeInstance* targetType, BfTypeInstance* extensionContainer, const StringImpl & filter, bool allowProtected, bool allowPrivate)
1321{

Callers 4

TryCaseEnumMatchMethod · 0.80
HandleCaseBindMethod · 0.80
DoInvocationMethod · 0.80
DoMemberReferenceMethod · 0.80

Calls 9

CheckProtectionFunction · 0.85
GetActiveTypeDefMethod · 0.80
GetFieldDefMethod · 0.80
GetFieldDeclarationMethod · 0.80
PopulateTypeMethod · 0.45
IsTypeMemberIncludedMethod · 0.45
IsTupleMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected