From 8868d3216e5f3736356812ed713e232643e326ee Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Sun, 23 Aug 2020 06:45:14 -0700 Subject: [PATCH] Properly colorize type declarations --- IDEHelper/Compiler/BfCompiler.cpp | 9 ++++++++- IDEHelper/Compiler/BfModuleTypeUtils.cpp | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/IDEHelper/Compiler/BfCompiler.cpp b/IDEHelper/Compiler/BfCompiler.cpp index 1887ab1b..f72980bd 100644 --- a/IDEHelper/Compiler/BfCompiler.cpp +++ b/IDEHelper/Compiler/BfCompiler.cpp @@ -3946,7 +3946,14 @@ void BfCompiler::ProcessAutocompleteTempType() if ((typeInst->mModule != NULL) && (!typeInst->mModule->mIsScratchModule)) mLastAutocompleteModule = typeInst->mModule; #endif - + + BfSourceElementType elemType = BfSourceElementType_Type; + if (typeInst->IsInterface()) + elemType = BfSourceElementType_Interface; + else if (typeInst->IsObject()) + elemType = BfSourceElementType_RefType; + mResolvePassData->mSourceClassifier->SetElementType(tempTypeDef->mTypeDeclaration->mNameNode, elemType); + SetAndRestoreValue prevType(module->mCurTypeInstance, typeInst); typeState.mTypeInstance = typeInst; diff --git a/IDEHelper/Compiler/BfModuleTypeUtils.cpp b/IDEHelper/Compiler/BfModuleTypeUtils.cpp index a4140d7e..35f663fe 100644 --- a/IDEHelper/Compiler/BfModuleTypeUtils.cpp +++ b/IDEHelper/Compiler/BfModuleTypeUtils.cpp @@ -3739,6 +3739,27 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy if (typeInstance == mContext->mBfObjectType) typeInstance->mHasBeenInstantiated = true; + auto _HandleTypeDeclaration = [&](BfTypeDeclaration* typeDeclaration) + { + if ((typeDeclaration != NULL) && (typeDeclaration->mNameNode != NULL)) + { + auto typeRefSource = typeDeclaration->mNameNode->GetParserData(); + if ((mCompiler->mResolvePassData != NULL) && (mCompiler->mResolvePassData->mSourceClassifier != NULL) && (typeRefSource != NULL) && (typeRefSource == mCompiler->mResolvePassData->mParser->mSourceData)) + { + BfSourceElementType elemType = BfSourceElementType_Type; + if (typeInstance->IsInterface()) + elemType = BfSourceElementType_Interface; + else if (typeInstance->IsObject()) + elemType = BfSourceElementType_RefType; + mCompiler->mResolvePassData->mSourceClassifier->SetElementType(typeDeclaration->mNameNode, elemType); + } + } + }; + + _HandleTypeDeclaration(typeDef->mTypeDeclaration); + for (auto partial : typeDef->mPartials) + _HandleTypeDeclaration(partial->mTypeDeclaration); + if (populateType == BfPopulateType_Data) return;