Просмотр исходного кода

Fixed outer type search in autocomplete

Brian Fiete 4 лет назад
Родитель
Сommit
13b943855e

+ 14 - 14
IDEHelper/Compiler/BfAutoComplete.cpp

@@ -744,7 +744,7 @@ void BfAutoComplete::AddProp(BfTypeInstance* typeInst, BfPropertyDef* propDef, c
 	}
 	}
 }
 }
 
 
-void BfAutoComplete::AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bool addNonStatic, const StringImpl& filter, BfTypeInstance* startType, bool allowInterfaces, bool allowImplicitThis)
+void BfAutoComplete::AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bool addNonStatic, const StringImpl& filter, BfTypeInstance* startType, bool allowInterfaces, bool allowImplicitThis, bool checkOuterType)
 {
 {
 	bool isInterface = false;
 	bool isInterface = false;
 	
 	
@@ -839,23 +839,23 @@ void BfAutoComplete::AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bo
 	if (allowInterfaces)
 	if (allowInterfaces)
 	{
 	{
 		for (auto iface : typeInst->mInterfaces)
 		for (auto iface : typeInst->mInterfaces)
-			AddTypeMembers(iface.mInterfaceType, addStatic, addNonStatic, filter, startType, false, allowImplicitThis);
+			AddTypeMembers(iface.mInterfaceType, addStatic, addNonStatic, filter, startType, false, allowImplicitThis, false);
 	}
 	}
 
 
 	if (typeInst->mBaseType != NULL)
 	if (typeInst->mBaseType != NULL)
-		AddTypeMembers(typeInst->mBaseType, addStatic, addNonStatic, filter, startType, false, allowImplicitThis);
+		AddTypeMembers(typeInst->mBaseType, addStatic, addNonStatic, filter, startType, false, allowImplicitThis, false);
 	else
 	else
 	{
 	{
 		if (typeInst->IsStruct())
 		if (typeInst->IsStruct())
-			AddTypeMembers(mModule->mContext->mBfObjectType, addStatic, addNonStatic, filter, startType, false, allowImplicitThis);
+			AddTypeMembers(mModule->mContext->mBfObjectType, addStatic, addNonStatic, filter, startType, false, allowImplicitThis, false);
 	}
 	}
 
 
-	if ((addStatic) && (allowImplicitThis))
+	if ((addStatic) && (allowImplicitThis) && (checkOuterType))
 	{
 	{
 		auto outerType = mModule->GetOuterType(typeInst);
 		auto outerType = mModule->GetOuterType(typeInst);
 		if (outerType != NULL)
 		if (outerType != NULL)
 		{
 		{
-			AddTypeMembers(outerType, true, false, filter, startType, false, allowImplicitThis);
+			AddTypeMembers(outerType, true, false, filter, startType, false, allowImplicitThis, false);
 		}
 		}
 	}
 	}
 }
 }
@@ -1419,7 +1419,7 @@ void BfAutoComplete::CheckIdentifier(BfAstNode* identifierNode, bool isInExpress
 		mModule->PopulateGlobalContainersList(globalLookup);
 		mModule->PopulateGlobalContainersList(globalLookup);
 		for (auto& globalContainer : mModule->mContext->mCurTypeState->mGlobalContainers)
 		for (auto& globalContainer : mModule->mContext->mCurTypeState->mGlobalContainers)
 		{
 		{
-			AddTypeMembers(globalContainer.mTypeInst, true, false, filter, globalContainer.mTypeInst, true, true);
+			AddTypeMembers(globalContainer.mTypeInst, true, false, filter, globalContainer.mTypeInst, true, true, false);
 		}
 		}
 	}
 	}
 		
 		
@@ -1428,7 +1428,7 @@ void BfAutoComplete::CheckIdentifier(BfAstNode* identifierNode, bool isInExpress
 	{
 	{
 		for (auto typeInst : staticSearch->mStaticTypes)
 		for (auto typeInst : staticSearch->mStaticTypes)
 		{
 		{
-			AddTypeMembers(typeInst, true, false, filter, typeInst, true, true);
+			AddTypeMembers(typeInst, true, false, filter, typeInst, true, true, false);
 			AddInnerTypes(typeInst, filter, false, false);
 			AddInnerTypes(typeInst, filter, false, false);
 		}
 		}
 	}
 	}
@@ -1446,11 +1446,11 @@ void BfAutoComplete::CheckIdentifier(BfAstNode* identifierNode, bool isInExpress
 				AddEntry(AutoCompleteEntry("object", "this"), filter);
 				AddEntry(AutoCompleteEntry("object", "this"), filter);
 			else
 			else
 				AddEntry(AutoCompleteEntry("pointer", "this"), filter);
 				AddEntry(AutoCompleteEntry("pointer", "this"), filter);
-			AddTypeMembers(mModule->mCurTypeInstance, true, true, filter, mModule->mCurTypeInstance, mModule->mCurTypeInstance->IsInterface(), true);
+			AddTypeMembers(mModule->mCurTypeInstance, true, true, filter, mModule->mCurTypeInstance, mModule->mCurTypeInstance->IsInterface(), true, true);
 		}
 		}
 		else
 		else
 		{
 		{
-			AddTypeMembers(mModule->mCurTypeInstance, true, false, filter, mModule->mCurTypeInstance, mModule->mCurTypeInstance->IsInterface(), true);
+			AddTypeMembers(mModule->mCurTypeInstance, true, false, filter, mModule->mCurTypeInstance, mModule->mCurTypeInstance->IsInterface(), true, true);
 		}
 		}
 
 
 		if (mModule->mCurMethodState != NULL)
 		if (mModule->mCurMethodState != NULL)
@@ -1529,7 +1529,7 @@ void BfAutoComplete::CheckIdentifier(BfAstNode* identifierNode, bool isInExpress
 			staticOnly = false;
 			staticOnly = false;
 
 
 		//BF_ASSERT(mModule->mCurTypeInstance->mResolvingConstField);
 		//BF_ASSERT(mModule->mCurTypeInstance->mResolvingConstField);
-		AddTypeMembers(mModule->mCurTypeInstance, true, !staticOnly, filter, mModule->mCurTypeInstance, false, true);
+		AddTypeMembers(mModule->mCurTypeInstance, true, !staticOnly, filter, mModule->mCurTypeInstance, false, true, true);
 	}
 	}
 
 
 	auto checkMethodState = mModule->mCurMethodState;
 	auto checkMethodState = mModule->mCurMethodState;
@@ -1721,7 +1721,7 @@ bool BfAutoComplete::CheckMemberReference(BfAstNode* target, BfAstNode* dotToken
 					bool showStatics = !targetValue.mValue;
 					bool showStatics = !targetValue.mValue;
 
 
 					for (auto interfaceConstraint : genericParamInstance->mInterfaceConstraints)
 					for (auto interfaceConstraint : genericParamInstance->mInterfaceConstraints)
-						AddTypeMembers(interfaceConstraint, showStatics, !showStatics, filter, interfaceConstraint, true, false);
+						AddTypeMembers(interfaceConstraint, showStatics, !showStatics, filter, interfaceConstraint, true, false, false);
 
 
 					if (genericParamInstance->mTypeConstraint != NULL)
 					if (genericParamInstance->mTypeConstraint != NULL)
 						checkType = genericParamInstance->mTypeConstraint;
 						checkType = genericParamInstance->mTypeConstraint;
@@ -1763,7 +1763,7 @@ bool BfAutoComplete::CheckMemberReference(BfAstNode* target, BfAstNode* dotToken
 
 
 				if (!onlyShowTypes)
 				if (!onlyShowTypes)
 				{
 				{
-					AddTypeMembers(typeInst, isStatic, !isStatic, filter, typeInst, false, false);
+					AddTypeMembers(typeInst, isStatic, !isStatic, filter, typeInst, false, false, false);
 
 
 					if (!isStatic)
 					if (!isStatic)
 					{
 					{
@@ -1796,7 +1796,7 @@ bool BfAutoComplete::CheckMemberReference(BfAstNode* target, BfAstNode* dotToken
 
 
 				if (typeInst->IsInterface())
 				if (typeInst->IsInterface())
 				{
 				{
-					AddTypeMembers(mModule->mContext->mBfObjectType, isStatic, !isStatic, filter, mModule->mContext->mBfObjectType, true, false);
+					AddTypeMembers(mModule->mContext->mBfObjectType, isStatic, !isStatic, filter, mModule->mContext->mBfObjectType, true, false, false);
 				}
 				}
 			}
 			}
 
 

+ 1 - 1
IDEHelper/Compiler/BfAutoComplete.h

@@ -195,7 +195,7 @@ public:
 	void AddTypeDef(BfTypeDef* typeDef, const StringImpl& filter, bool onlyAttribute = false);
 	void AddTypeDef(BfTypeDef* typeDef, const StringImpl& filter, bool onlyAttribute = false);
 	void AddInnerTypes(BfTypeInstance* typeInst, const StringImpl& filter, bool allowProtected, bool allowPrivate);
 	void AddInnerTypes(BfTypeInstance* typeInst, const StringImpl& filter, bool allowProtected, bool allowPrivate);
 	void AddCurrentTypes(BfTypeInstance* typeInst, const StringImpl& filter, bool allowProtected, bool allowPrivate, bool onlyAttribute);
 	void AddCurrentTypes(BfTypeInstance* typeInst, const StringImpl& filter, bool allowProtected, bool allowPrivate, bool onlyAttribute);
-	void AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bool addNonStatic, const StringImpl& filter, BfTypeInstance* startType, bool allowInterfaces, bool allowImplicitThis);
+	void AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bool addNonStatic, const StringImpl& filter, BfTypeInstance* startType, bool allowInterfaces, bool allowImplicitThis, bool checkOuterType);
 	void AddSelfResultTypeMembers(BfTypeInstance* typeInst, BfTypeInstance* selfType, const StringImpl& filter, bool allowPrivate);
 	void AddSelfResultTypeMembers(BfTypeInstance* typeInst, BfTypeInstance* selfType, const StringImpl& filter, bool allowPrivate);
 	bool InitAutocomplete(BfAstNode* dotNode, BfAstNode* nameNode, String& filter);
 	bool InitAutocomplete(BfAstNode* dotNode, BfAstNode* nameNode, String& filter);
 	void AddEnumTypeMembers(BfTypeInstance* typeInst, const StringImpl& filter, bool allowProtected, bool allowPrivate);	
 	void AddEnumTypeMembers(BfTypeInstance* typeInst, const StringImpl& filter, bool allowProtected, bool allowPrivate);	

+ 1 - 1
IDEHelper/Compiler/BfExprEvaluator.cpp

@@ -9767,7 +9767,7 @@ void BfExprEvaluator::Visit(BfInitializerExpression* initExpr)
 					{
 					{
 						String filter;
 						String filter;
 						identiferNode->ToString(filter);
 						identiferNode->ToString(filter);
-						autoComplete->AddTypeMembers(typeInstance, false, true, filter, typeInstance, false, true);
+						autoComplete->AddTypeMembers(typeInstance, false, true, filter, typeInstance, false, true, false);
 					}
 					}
 				}
 				}
 			}
 			}