mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Add colorization options for primitives, structs, generic params and make typealias match aliased type color.
This commit is contained in:
parent
10e2a56530
commit
7a7cc716c6
8 changed files with 66 additions and 11 deletions
|
@ -4069,6 +4069,8 @@ void BfCompiler::ProcessAutocompleteTempType()
|
|||
elemType = BfSourceElementType_Interface;
|
||||
else if (checkTempType->mTypeCode == BfTypeCode_Object)
|
||||
elemType = BfSourceElementType_RefType;
|
||||
else if (checkTempType->mTypeCode == BfTypeCode_Struct)
|
||||
elemType = BfSourceElementType_Struct;
|
||||
mResolvePassData->mSourceClassifier->SetElementType(checkTempType->mTypeDeclaration->mNameNode, elemType);
|
||||
}
|
||||
|
||||
|
|
|
@ -8492,7 +8492,7 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp
|
|||
}
|
||||
|
||||
if (auto identifier = BfNodeDynCastExact<BfIdentifierNode>(targetSrc))
|
||||
mModule->SetElementType(identifier, BfSourceElementType_Type);
|
||||
mModule->SetElementType(identifier, resolvedTypeInstance->IsEnum() ? BfSourceElementType_Type : BfSourceElementType_Struct);
|
||||
if (mModule->mCompiler->mResolvePassData != NULL)
|
||||
mModule->mCompiler->mResolvePassData->HandleTypeReference(targetSrc, resolvedTypeInstance->mTypeDef);
|
||||
|
||||
|
|
|
@ -4772,6 +4772,8 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
elemType = BfSourceElementType_Interface;
|
||||
else if (typeInstance->IsObject())
|
||||
elemType = BfSourceElementType_RefType;
|
||||
else if (typeInstance->IsStruct() || (typeInstance->IsTypedPrimitive() && !typeInstance->IsEnum()))
|
||||
elemType = BfSourceElementType_Struct;
|
||||
mCompiler->mResolvePassData->mSourceClassifier->SetElementType(typeDeclaration->mNameNode, elemType);
|
||||
}
|
||||
}
|
||||
|
@ -8072,10 +8074,35 @@ BfType* BfModule::ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTy
|
|||
}
|
||||
}
|
||||
|
||||
BfSourceElementType elemType = BfSourceElementType_Type;
|
||||
{
|
||||
auto typeRef = resolvedTypeRef;
|
||||
while (typeRef->IsTypeAlias())
|
||||
{
|
||||
typeRef = typeRef->GetUnderlyingType();
|
||||
if (typeRef == NULL)
|
||||
{
|
||||
typeRef = resolvedTypeRef;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeRef->IsInterface())
|
||||
elemType = BfSourceElementType_Interface;
|
||||
else if (typeRef->IsObject())
|
||||
elemType = BfSourceElementType_RefType;
|
||||
else if (typeRef->IsGenericParam())
|
||||
elemType = BfSourceElementType_GenericParam;
|
||||
else if (typeRef->IsPrimitiveType())
|
||||
elemType = BfSourceElementType_PrimitiveType;
|
||||
else if (typeRef->IsStruct() || (typeRef->IsTypedPrimitive() && !typeRef->IsEnum()))
|
||||
elemType = BfSourceElementType_Struct;
|
||||
}
|
||||
|
||||
while (auto qualifiedTypeRef = BfNodeDynCast<BfQualifiedTypeReference>(checkTypeRef))
|
||||
{
|
||||
if ((mCompiler->mResolvePassData->mSourceClassifier != NULL) && (checkTypeRef == headTypeRef) && (resolvedTypeRef->IsObjectOrInterface()))
|
||||
mCompiler->mResolvePassData->mSourceClassifier->SetElementType(qualifiedTypeRef->mRight, resolvedTypeRef->IsInterface() ? BfSourceElementType_Interface : BfSourceElementType_RefType);
|
||||
if ((mCompiler->mResolvePassData->mSourceClassifier != NULL) && (checkTypeRef == headTypeRef) && (elemType != BfSourceElementType_Type))
|
||||
mCompiler->mResolvePassData->mSourceClassifier->SetElementType(qualifiedTypeRef->mRight, elemType);
|
||||
|
||||
StringView leftString = qualifiedTypeRef->mLeft->ToStringView();
|
||||
BfSizedAtomComposite leftComposite;
|
||||
|
@ -8107,16 +8134,16 @@ BfType* BfModule::ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTy
|
|||
auto checkNameNode = namedTypeRef->mNameNode;
|
||||
bool setType = false;
|
||||
|
||||
if ((mCompiler->mResolvePassData->mSourceClassifier != NULL) && (checkTypeRef == headTypeRef) && (resolvedTypeRef->IsObjectOrInterface()))
|
||||
if ((mCompiler->mResolvePassData->mSourceClassifier != NULL) && (checkTypeRef == headTypeRef) && (elemType != BfSourceElementType_Type))
|
||||
{
|
||||
if (auto qualifiedNameNode = BfNodeDynCast<BfQualifiedNameNode>(checkNameNode))
|
||||
{
|
||||
mCompiler->mResolvePassData->mSourceClassifier->SetElementType(qualifiedNameNode->mRight, resolvedTypeRef->IsInterface() ? BfSourceElementType_Interface : BfSourceElementType_RefType);
|
||||
mCompiler->mResolvePassData->mSourceClassifier->SetElementType(qualifiedNameNode->mRight, elemType);
|
||||
}
|
||||
else
|
||||
{
|
||||
setType = true;
|
||||
mCompiler->mResolvePassData->mSourceClassifier->SetElementType(checkNameNode, resolvedTypeRef->IsInterface() ? BfSourceElementType_Interface : BfSourceElementType_RefType);
|
||||
mCompiler->mResolvePassData->mSourceClassifier->SetElementType(checkNameNode, elemType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8921,7 +8948,7 @@ BfTypedValue BfModule::TryLookupGenericConstVaue(BfIdentifierNode* identifierNod
|
|||
{
|
||||
auto typeRefSource = identifierNode->GetSourceData();
|
||||
if ((mCompiler->mResolvePassData != NULL) && (mCompiler->mResolvePassData->mSourceClassifier != NULL) && (typeRefSource != NULL) && (typeRefSource == mCompiler->mResolvePassData->mParser->mSourceData))
|
||||
mCompiler->mResolvePassData->mSourceClassifier->SetElementType(identifierNode, BfSourceElementType_Type);
|
||||
mCompiler->mResolvePassData->mSourceClassifier->SetElementType(identifierNode, BfSourceElementType_GenericParam);
|
||||
|
||||
if (genericParamResult->IsConstExprValue())
|
||||
{
|
||||
|
|
|
@ -55,6 +55,8 @@ void BfSourceClassifier::SetElementType(BfAstNode * node, BfTypeCode typeCode)
|
|||
elemType = BfSourceElementType_Interface;
|
||||
else if (typeCode == BfTypeCode_Object)
|
||||
elemType = BfSourceElementType_RefType;
|
||||
else if (typeCode == BfTypeCode_Struct)
|
||||
elemType = BfSourceElementType_Struct;
|
||||
SetElementType(node, elemType);
|
||||
}
|
||||
|
||||
|
@ -558,7 +560,7 @@ void BfSourceClassifier::Visit(BfMethodDeclaration* methodDeclaration)
|
|||
for (auto& genericParam : methodDeclaration->mGenericParams->mGenericParams)
|
||||
{
|
||||
BfIdentifierNode* typeRef = genericParam;
|
||||
SetElementType(typeRef, BfSourceElementType_Type);
|
||||
SetElementType(typeRef, BfSourceElementType_GenericParam);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -570,7 +572,7 @@ void BfSourceClassifier::Visit(BfMethodDeclaration* methodDeclaration)
|
|||
{
|
||||
BfTypeReference* typeRef = genericConstraint->mTypeRef;
|
||||
if (typeRef != NULL)
|
||||
SetElementType(typeRef, BfSourceElementType_Type);
|
||||
SetElementType(typeRef, BfSourceElementType_GenericParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -642,7 +644,7 @@ void BfSourceClassifier::Handle(BfTypeDeclaration* typeDeclaration)
|
|||
for (auto& genericParam : typeDeclaration->mGenericParams->mGenericParams)
|
||||
{
|
||||
BfIdentifierNode* typeRef = genericParam;
|
||||
SetElementType(typeRef, BfSourceElementType_Type);
|
||||
SetElementType(typeRef, BfSourceElementType_GenericParam);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -654,7 +656,7 @@ void BfSourceClassifier::Handle(BfTypeDeclaration* typeDeclaration)
|
|||
|
||||
BfTypeReference* typeRef = genericConstraint->mTypeRef;
|
||||
if (typeRef != NULL)
|
||||
SetElementType(typeRef, BfSourceElementType_Type);
|
||||
SetElementType(typeRef, BfSourceElementType_GenericParam);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,9 @@ enum BfSourceElementType
|
|||
BfSourceElementType_Comment,
|
||||
BfSourceElementType_Method,
|
||||
BfSourceElementType_Type,
|
||||
BfSourceElementType_PrimitiveType,
|
||||
BfSourceElementType_Struct,
|
||||
BfSourceElementType_GenericParam,
|
||||
BfSourceElementType_RefType,
|
||||
BfSourceElementType_Interface,
|
||||
BfSourceElementType_Namespace
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue