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

Method AddProp

IDEHelper/Compiler/BfAutoComplete.cpp:843–916  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

841}
842
843void BfAutoComplete::AddProp(BfTypeInstance* typeInst, BfPropertyDef* propDef, const StringImpl& filter)
844{
845 int wantPrefixCount = 0;
846 const char* filterStr = filter.c_str();
847 while (filterStr[0] == '@')
848 {
849 filterStr++;
850 wantPrefixCount++;
851 }
852 BfCommentNode* documentation = NULL;
853 auto fieldDecl = propDef->GetFieldDeclaration();
854 if (fieldDecl != NULL)
855 documentation = fieldDecl->mDocumentation;
856 AutoCompleteEntry entry("property", propDef->mName, propDef->mNamePrefixCount - wantPrefixCount);
857 if (auto entryAdded = AddEntry(entry, filterStr))
858 {
859 if (CheckDocumentation(entryAdded, documentation))
860 {
861 BfType* propType = NULL;
862 bool hasGetter = false;
863 bool hasSetter = false;
864
865 for (auto methodDef : propDef->mMethods)
866 {
867 auto methodInstance = mModule->GetRawMethodInstance(typeInst, methodDef);
868 if (methodInstance == NULL)
869 continue;
870 if (methodDef->mMethodType == BfMethodType_PropertyGetter)
871 {
872 hasGetter = true;
873 propType = methodInstance->mReturnType;
874 }
875 if (methodDef->mMethodType == BfMethodType_PropertySetter)
876 {
877 hasSetter = true;
878 if (methodInstance->GetParamCount() > 0)
879 propType = methodInstance->GetParamType(0);
880 }
881 }
882
883 String str;
884 if (propType != NULL)
885 {
886 str += mModule->TypeToString(propType);
887 str += " ";
888 }
889
890 str += mModule->TypeToString(typeInst);
891 str += ".";
892 str += propDef->mName;
893
894 str += " { ";
895 if (hasGetter)
896 str += "get; ";
897 if (hasSetter)
898 str += "set; ";
899 str += "}";
900

Callers

nothing calls this directly

Calls 9

GetFieldDeclarationMethod · 0.80
GetRawMethodInstanceMethod · 0.80
AppendMethod · 0.80
GetDocStringMethod · 0.80
AllocStringMethod · 0.80
c_strMethod · 0.45
GetParamCountMethod · 0.45
GetParamTypeMethod · 0.45
TypeToStringMethod · 0.45

Tested by

no test coverage detected