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

Method AddField

IDEHelper/Compiler/BfAutoComplete.cpp:783–841  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

781}
782
783void BfAutoComplete::AddField(BfTypeInstance* typeInst, BfFieldDef* fieldDef, BfFieldInstance* fieldInstance, const StringImpl& filter)
784{
785 if (fieldDef->mName.IsEmpty())
786 return;
787 int wantPrefixCount = 0;
788 const char* filterStr = filter.c_str();
789 while (filterStr[0] == '@')
790 {
791 filterStr++;
792 wantPrefixCount++;
793 }
794 AutoCompleteEntry entry(GetTypeName(fieldInstance->mResolvedType), fieldDef->mName, fieldDef->mNamePrefixCount - wantPrefixCount);
795 if (auto entryAdded = AddEntry(entry, filterStr))
796 {
797 auto fieldDecl = fieldDef->GetFieldDeclaration();
798 auto documentation = (fieldDecl != NULL) ? fieldDecl->mDocumentation : NULL;
799 if (CheckDocumentation(entryAdded, documentation))
800 {
801 mModule->PopulateType(typeInst);
802
803 bool isTag = typeInst->IsEnum() && typeInst->IsOnDemand();
804
805 String str;
806 if (!isTag)
807 {
808 if (!fieldInstance->GetFieldDef()->IsEnumCaseEntry())
809 {
810 str += mModule->TypeToString(fieldInstance->mResolvedType);
811 str += " ";
812 }
813 str += mModule->TypeToString(typeInst);
814 str += ".";
815 str += fieldDef->mName;
816 }
817
818 if (entryAdded->mDocumentation != NULL)
819 {
820 str += "\x04";
821 str.Append(entryAdded->mDocumentation);
822 }
823 else if (documentation != NULL)
824 {
825 str += "\x05";
826 documentation->GetDocString(str);
827 }
828
829 if (!str.IsEmpty())
830 entryAdded->mDocumentation = mAlloc.AllocString(str);
831 }
832
833 if ((mIsGetDefinition) && (mDefType == NULL))
834 {
835 mDefType = typeInst->mTypeDef;
836 mDefField = fieldDef;
837 if (auto nameNode = fieldDef->GetNameNode())
838 SetDefinitionLocation(nameNode);
839 }
840 }

Callers

nothing calls this directly

Calls 13

GetFieldDeclarationMethod · 0.80
IsEnumCaseEntryMethod · 0.80
GetFieldDefMethod · 0.80
AppendMethod · 0.80
GetDocStringMethod · 0.80
AllocStringMethod · 0.80
GetNameNodeMethod · 0.80
IsEmptyMethod · 0.45
c_strMethod · 0.45
PopulateTypeMethod · 0.45
IsEnumMethod · 0.45
IsOnDemandMethod · 0.45

Tested by

no test coverage detected