1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Fixed autocomplete doc crash for generic methods

This commit is contained in:
Brian Fiete 2020-10-10 06:12:29 -07:00
parent 0f9ae6ab8c
commit 42a361a8c0
2 changed files with 36 additions and 27 deletions

View file

@ -483,7 +483,11 @@ void BfAutoComplete::AddMethod(BfTypeInstance* typeInstance, BfMethodDef* method
if ((methodInstance == NULL) && (methodDef != NULL))
methodInstance = mModule->GetRawMethodInstance(typeInstance, methodDef);
if (methodInstance != NULL)
str = mModule->MethodToString(methodInstance, BfMethodNameFlag_IncludeReturnType);
{
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mModule->mCurTypeInstance, typeInstance);
SetAndRestoreValue<BfMethodInstance*> prevCurMethodInstance(mModule->mCurMethodInstance, methodInstance);
str = mModule->MethodToString(methodInstance, (BfMethodNameFlags)(BfMethodNameFlag_IncludeReturnType | BfMethodNameFlag_ResolveGenericParamNames));
}
if (entryAdded->mDocumentation != NULL)
{

View file

@ -9872,9 +9872,19 @@ StringT<128> BfModule::MethodToString(BfMethodInstance* methodInst, BfMethodName
StringT<128> methodName;
auto _AddTypeName = [&](BfType* type)
{
auto typeNameFlags = BfTypeNameFlags_None;
if (allowResolveGenericParamNames)
typeNameFlags = BfTypeNameFlag_ResolveGenericParamNames;
if ((methodGenericArgs != NULL) && (type->IsUnspecializedType()))
type = ResolveGenericType(type, NULL, methodGenericArgs);
methodName += TypeToString(type, typeNameFlags);
};
if ((methodNameFlags & BfMethodNameFlag_IncludeReturnType) != 0)
{
methodName += TypeToString(methodInst->mReturnType);
_AddTypeName(methodInst->mReturnType);
methodName += " ";
}
@ -10001,7 +10011,7 @@ StringT<128> BfModule::MethodToString(BfMethodInstance* methodInst, BfMethodName
if ((methodInst->mMethodInfoEx != NULL) && (methodInst->mMethodInfoEx->mMethodGenericArguments.size() != 0))
{
methodName += "<";
for (int i = 0; i < (int) methodInst->mMethodInfoEx->mMethodGenericArguments.size(); i++)
for (int i = 0; i < (int)methodInst->mMethodInfoEx->mMethodGenericArguments.size(); i++)
{
if (i > 0)
methodName += ", ";
@ -10057,7 +10067,7 @@ StringT<128> BfModule::MethodToString(BfMethodInstance* methodInst, BfMethodName
{
int dispParamIdx = 0;
methodName += "(";
for (int paramIdx = 0; paramIdx < (int) methodInst->GetParamCount(); paramIdx++)
for (int paramIdx = 0; paramIdx < (int)methodInst->GetParamCount(); paramIdx++)
{
int paramKind = methodInst->GetParamKind(paramIdx);
if (paramKind == BfParamKind_ImplicitCapture)
@ -10069,13 +10079,8 @@ StringT<128> BfModule::MethodToString(BfMethodInstance* methodInst, BfMethodName
if (paramKind == BfParamKind_Params)
methodName += "params ";
typeNameFlags = BfTypeNameFlags_None;
if (allowResolveGenericParamNames)
typeNameFlags = BfTypeNameFlag_ResolveGenericParamNames;
BfType* type = methodInst->GetParamType(paramIdx);
if ((methodGenericArgs != NULL) && (type->IsUnspecializedType()))
type = ResolveGenericType(type, NULL, methodGenericArgs);
methodName += TypeToString(type, typeNameFlags);
_AddTypeName(type);
methodName += " ";
methodName += methodInst->GetParamName(paramIdx);