| 614 | } |
| 615 | |
| 616 | void BfAutoComplete::AddTypeDef(BfTypeDef* typeDef, const StringImpl& filter, bool onlyAttribute) |
| 617 | { |
| 618 | BF_ASSERT(typeDef->mDefState != BfTypeDef::DefState_Emitted); |
| 619 | |
| 620 | if (typeDef->mTypeDeclaration == NULL) |
| 621 | return; |
| 622 | |
| 623 | StringT<64> name(typeDef->mName->ToString()); |
| 624 | if (name == "@") |
| 625 | return; |
| 626 | int gravePos = (int)name.IndexOf('`'); |
| 627 | if (gravePos != -1) |
| 628 | name = name.Substring(0, gravePos) + "<>"; |
| 629 | |
| 630 | if (onlyAttribute) |
| 631 | { |
| 632 | if ((mIsGetDefinition) && (name == filter + "Attribute")) |
| 633 | { |
| 634 | SetDefinitionLocation(typeDef->mTypeDeclaration->mNameNode); |
| 635 | return; |
| 636 | } |
| 637 | |
| 638 | int score; |
| 639 | uint8 matches[256]; |
| 640 | if (!DoesFilterMatch(name.c_str(), filter.c_str(), score, matches, sizeof(matches))) |
| 641 | return; |
| 642 | |
| 643 | auto type = mModule->ResolveTypeDef(typeDef, BfPopulateType_Declaration); |
| 644 | if (type != NULL) |
| 645 | { |
| 646 | auto typeInst = type->ToTypeInstance(); |
| 647 | if (!IsAttribute(typeInst)) |
| 648 | return; |
| 649 | } |
| 650 | |
| 651 | const char* attrStr = "Attribute"; |
| 652 | const int attrStrLen = (int)strlen(attrStr); |
| 653 | if (((int)name.length() > attrStrLen) && ((int)name.length() - (int)attrStrLen >= filter.length()) && (strcmp(name.c_str() + (int)name.length() - attrStrLen, attrStr) == 0)) |
| 654 | { |
| 655 | // Shorter name - remove "Attribute" |
| 656 | name = name.Substring(0, name.length() - attrStrLen); |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | AutoCompleteEntry* entryAdded = NULL; |
| 661 | if (typeDef->mTypeCode == BfTypeCode_Object) |
| 662 | entryAdded = AddEntry(AutoCompleteEntry("class", name), filter); |
| 663 | else if (typeDef->mTypeCode == BfTypeCode_Interface) |
| 664 | entryAdded = AddEntry(AutoCompleteEntry("interface", name), filter); |
| 665 | else |
| 666 | entryAdded = AddEntry(AutoCompleteEntry("valuetype", name), filter); |
| 667 | |
| 668 | if (entryAdded != NULL) |
| 669 | { |
| 670 | if ((CheckDocumentation(entryAdded, NULL)) && (entryAdded->mDocumentation == NULL)) |
| 671 | { |
| 672 | auto type = mModule->ResolveTypeDef(typeDef, BfPopulateType_IdentityNoRemapAlias); |
| 673 | StringT<1024> str; |
nothing calls this directly
no test coverage detected