From 687dde063f2e73329cd11d1c6fbddf8ea72d8f31 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 4 Dec 2020 05:22:49 -0800 Subject: [PATCH] Include inner-overload method in classview --- IDE/src/ui/ClassViewPanel.bf | 10 +++++--- IDEHelper/Compiler/BfCompiler.cpp | 7 ++++-- IDEHelper/Compiler/BfModule.cpp | 39 ++++++++++++++++++++++++------- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/IDE/src/ui/ClassViewPanel.bf b/IDE/src/ui/ClassViewPanel.bf index dc02dc02..8a96b19f 100644 --- a/IDE/src/ui/ClassViewPanel.bf +++ b/IDE/src/ui/ClassViewPanel.bf @@ -62,7 +62,8 @@ namespace IDE.ui case .Field, .Property: IDEUtils.ColorizeCodeString(mLabel, .Field); - case .Method: + case .Method, + .MethodOverride: IDEUtils.ColorizeCodeString(mLabel, .Method); default: } @@ -109,7 +110,8 @@ namespace IDE.ui icon = DarkTheme.sDarkTheme.GetImage(.Field); case .Property: icon = DarkTheme.sDarkTheme.GetImage(.Property); - case .Method: + case .Method, + .MethodOverride: icon = DarkTheme.sDarkTheme.GetImage(.Method); default: } @@ -319,7 +321,8 @@ namespace IDE.ui Field, Property, - Method + Method, + MethodOverride, } class PendingInfo @@ -764,6 +767,7 @@ namespace IDE.ui case 'F': kind = .Field; case 'P': kind = .Property; case 'M': kind = .Method; + case 'o': kind = .MethodOverride; } var itr = param.Split('\t'); let entry = mPendingInfo.mPendingRoot.AddChild(kind, scope String()..Reference(itr.GetNext().Get())); diff --git a/IDEHelper/Compiler/BfCompiler.cpp b/IDEHelper/Compiler/BfCompiler.cpp index 9819a23d..46c79f4e 100644 --- a/IDEHelper/Compiler/BfCompiler.cpp +++ b/IDEHelper/Compiler/BfCompiler.cpp @@ -8237,11 +8237,14 @@ String BfCompiler::GetTypeDefMatches(const StringImpl& searchStr) if (methodDef->mMethodDeclaration == NULL) continue; - + matchHelper.ClearResults(); if (matchHelper.CheckMemberMatch(typeDef, methodDef->mName)) { - result += "M"; + if (methodDef->mIsOverride) + result += "o"; + else + result += "M"; if (BfTypeUtils::TypeToString(result, typeDef, (BfTypeNameFlags)(BfTypeNameFlag_HideGlobalName | BfTypeNameFlag_InternalName))) result += "."; matchHelper.AddMethodDef(methodDef); diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index dd56e79f..982937ee 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -20669,15 +20669,15 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool genericParam->mExternType = ResolveTypeRef(externConstraintDef->mTypeRef); auto autoComplete = mCompiler->GetAutoComplete(); - if (autoComplete != NULL) - autoComplete->CheckTypeRef(externConstraintDef->mTypeRef, false); +if (autoComplete != NULL) +autoComplete->CheckTypeRef(externConstraintDef->mTypeRef, false); - if (genericParam->mExternType != NULL) - { - // - } - else - genericParam->mExternType = GetPrimitiveType(BfTypeCode_Var); +if (genericParam->mExternType != NULL) +{ + // +} +else +genericParam->mExternType = GetPrimitiveType(BfTypeCode_Var); } ResolveGenericParamConstraints(genericParam, methodInstance->mIsUnspecialized); @@ -20724,6 +20724,8 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool if (methodDef->mIsOverride) { + bool found = false; + for (int virtIdx = 0; virtIdx < (int)typeInstance->mVirtualMethodTable.size(); virtIdx++) { auto& ventry = typeInstance->mVirtualMethodTable[virtIdx]; @@ -20742,6 +20744,7 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool auto baseType = typeInstance->mBaseType; if (baseType != NULL) { + found = true; while ((baseType->mBaseType != NULL) && (virtIdx < baseType->mBaseType->mVirtualMethodTableSize)) baseType = baseType->mBaseType; BfMethodInstance* baseVirtMethod = baseType->mVirtualMethodTable[virtIdx].mImplementingMethod; @@ -20755,7 +20758,25 @@ void BfModule::DoMethodDeclaration(BfMethodDeclaration* methodDeclaration, bool } } } - } + + if ((!found) && (autoComplete->mIsGetDefinition) && (methodDef->mDeclaringType->IsExtension())) + { + for (auto& methodGroup : typeInstance->mMethodInstanceGroups) + { + auto defaultMethod = methodGroup.mDefault; + if (defaultMethod == NULL) + continue; + if (!defaultMethod->mMethodDef->mIsExtern) + continue; + if (!CompareMethodSignatures(defaultMethod, methodInstance)) + continue; + + autoComplete->SetDefinitionLocation(defaultMethod->mMethodDef->GetRefNode(), true); + autoComplete->mDefType = typeInstance->mTypeDef; + autoComplete->mDefMethod = defaultMethod->mMethodDef; + } + } + } } }