| 3676 | } |
| 3677 | |
| 3678 | void BfAutoComplete::FixitAddMember(BfTypeInstance* typeInst, BfType* fieldType, const StringImpl& fieldName, bool isStatic, BfTypeInstance* referencedFrom) |
| 3679 | { |
| 3680 | if (typeInst == mModule->mContext->mBfObjectType) |
| 3681 | return; |
| 3682 | |
| 3683 | auto parser = typeInst->mTypeDef->GetDefinition()->mSource->ToParser(); |
| 3684 | if (parser == NULL) |
| 3685 | return; |
| 3686 | |
| 3687 | String fullName = typeInst->mTypeDef->mFullName.ToString(); |
| 3688 | String fieldStr; |
| 3689 | |
| 3690 | if (typeInst == referencedFrom) |
| 3691 | { |
| 3692 | // Implicitly private |
| 3693 | } |
| 3694 | else if ((referencedFrom != NULL) && (mModule->TypeIsSubTypeOf(referencedFrom, typeInst))) |
| 3695 | { |
| 3696 | fieldStr += "protected "; |
| 3697 | } |
| 3698 | else |
| 3699 | { |
| 3700 | fieldStr += "public "; |
| 3701 | } |
| 3702 | |
| 3703 | if (isStatic) |
| 3704 | fieldStr += "static "; |
| 3705 | |
| 3706 | if (fieldType != NULL) |
| 3707 | fieldStr += mModule->TypeToString(fieldType, BfTypeNameFlag_ReduceName); |
| 3708 | else |
| 3709 | fieldStr += "Object"; |
| 3710 | |
| 3711 | fieldStr += " " + fieldName + ";"; |
| 3712 | |
| 3713 | int fileLoc = typeInst->mTypeDef->mTypeDeclaration->GetSrcEnd(); |
| 3714 | |
| 3715 | if (auto defineBlock = BfNodeDynCast<BfBlock>(typeInst->mTypeDef->mTypeDeclaration->mDefineNode)) |
| 3716 | fileLoc = BfFixitFinder::FindLineStartAfter(defineBlock->mOpenBrace); |
| 3717 | if (!typeInst->mTypeDef->mFields.empty()) |
| 3718 | { |
| 3719 | auto fieldDecl = typeInst->mTypeDef->mFields.back()->mFieldDeclaration; |
| 3720 | if (fieldDecl != NULL) |
| 3721 | { |
| 3722 | fileLoc = BfFixitFinder::FindLineStartAfter(fieldDecl); |
| 3723 | } |
| 3724 | } |
| 3725 | |
| 3726 | const char* memberName = "field"; |
| 3727 | if (isStatic) |
| 3728 | memberName = "static field"; |
| 3729 | AddEntry(AutoCompleteEntry("fixit", StrFormat("Create %s '%s' in '%s'\taddField|%s||%s", memberName, fieldName.c_str(), fullName.c_str(), |
| 3730 | FixitGetLocation(parser->mParserData, fileLoc).c_str(), fieldStr.c_str()).c_str())); |
| 3731 | } |
| 3732 | |
| 3733 | void BfAutoComplete::FixitAddCase(BfTypeInstance* typeInst, const StringImpl& caseName, const BfTypeVector& fieldTypes) |
| 3734 | { |
nothing calls this directly
no test coverage detected