mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48: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
|
@ -312,6 +312,9 @@ namespace IDE
|
|||
public Color mComment = 0xFF75715E;
|
||||
public Color mMethod = 0xFFA6E22A;
|
||||
public Color mType = 0xFF66D9EF;
|
||||
public Color mPrimitiveType = 0xFF66D9EF;
|
||||
public Color mStruct = 0xFF66D9EF;
|
||||
public Color mGenericParam = 0xFF66D9EF;
|
||||
public Color mRefType = 0xFF66A0EF;
|
||||
public Color mInterface = 0xFF9A9EEB;
|
||||
public Color mNamespace = 0xFF7BEEB7;
|
||||
|
@ -355,13 +358,22 @@ namespace IDE
|
|||
if (sd.Contains("Type"))
|
||||
{
|
||||
GetColor("Type", ref mType);
|
||||
if (!sd.Contains("PrimitiveType"))
|
||||
mPrimitiveType = mType;
|
||||
if (!sd.Contains("Struct"))
|
||||
mStruct = mType;
|
||||
if (!sd.Contains("RefType"))
|
||||
mRefType = mType;
|
||||
if (!sd.Contains("Interface"))
|
||||
mInterface = mType;
|
||||
if (!sd.Contains("GenericParam"))
|
||||
mGenericParam = mType;
|
||||
}
|
||||
GetColor("PrimitiveType", ref mPrimitiveType);
|
||||
GetColor("Struct", ref mStruct);
|
||||
GetColor("RefType", ref mRefType);
|
||||
GetColor("Interface", ref mInterface);
|
||||
GetColor("GenericParam", ref mGenericParam);
|
||||
GetColor("Namespace", ref mNamespace);
|
||||
GetColor("DisassemblyText", ref mDisassemblyText);
|
||||
GetColor("DisassemblyFileName", ref mDisassemblyFileName);
|
||||
|
@ -380,6 +392,9 @@ namespace IDE
|
|||
SourceEditWidgetContent.sTextColors[(.)SourceElementType.Comment] = mComment;
|
||||
SourceEditWidgetContent.sTextColors[(.)SourceElementType.Method] = mMethod;
|
||||
SourceEditWidgetContent.sTextColors[(.)SourceElementType.Type] = mType;
|
||||
SourceEditWidgetContent.sTextColors[(.)SourceElementType.PrimitiveType] = mPrimitiveType;
|
||||
SourceEditWidgetContent.sTextColors[(.)SourceElementType.Struct] = mStruct;
|
||||
SourceEditWidgetContent.sTextColors[(.)SourceElementType.GenericParam] = mGenericParam;
|
||||
SourceEditWidgetContent.sTextColors[(.)SourceElementType.RefType] = mRefType;
|
||||
SourceEditWidgetContent.sTextColors[(.)SourceElementType.Interface] = mInterface;
|
||||
SourceEditWidgetContent.sTextColors[(.)SourceElementType.Namespace] = mNamespace;
|
||||
|
|
|
@ -208,6 +208,9 @@ namespace IDE.ui
|
|||
0xFF75715E, // Comment
|
||||
0xFFA6E22A, // Method
|
||||
0xFF66D9EF, // Type
|
||||
0xFF66D9EF, // PrimitiveType
|
||||
0xFF66D9EF, // Struct
|
||||
0xFF66D9EF, // GenericParam
|
||||
0xFF66A0EF, // RefType
|
||||
0xFF9A9EEB, // Interface
|
||||
0xFF7BEEB7, // Namespace
|
||||
|
|
|
@ -30,6 +30,9 @@ namespace IDE.ui
|
|||
Comment,
|
||||
Method,
|
||||
Type,
|
||||
PrimitiveType,
|
||||
Struct,
|
||||
GenericParam,
|
||||
RefType,
|
||||
Interface,
|
||||
Namespace,
|
||||
|
|
|
@ -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