mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +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 mComment = 0xFF75715E;
|
||||||
public Color mMethod = 0xFFA6E22A;
|
public Color mMethod = 0xFFA6E22A;
|
||||||
public Color mType = 0xFF66D9EF;
|
public Color mType = 0xFF66D9EF;
|
||||||
|
public Color mPrimitiveType = 0xFF66D9EF;
|
||||||
|
public Color mStruct = 0xFF66D9EF;
|
||||||
|
public Color mGenericParam = 0xFF66D9EF;
|
||||||
public Color mRefType = 0xFF66A0EF;
|
public Color mRefType = 0xFF66A0EF;
|
||||||
public Color mInterface = 0xFF9A9EEB;
|
public Color mInterface = 0xFF9A9EEB;
|
||||||
public Color mNamespace = 0xFF7BEEB7;
|
public Color mNamespace = 0xFF7BEEB7;
|
||||||
|
@ -355,13 +358,22 @@ namespace IDE
|
||||||
if (sd.Contains("Type"))
|
if (sd.Contains("Type"))
|
||||||
{
|
{
|
||||||
GetColor("Type", ref mType);
|
GetColor("Type", ref mType);
|
||||||
|
if (!sd.Contains("PrimitiveType"))
|
||||||
|
mPrimitiveType = mType;
|
||||||
|
if (!sd.Contains("Struct"))
|
||||||
|
mStruct = mType;
|
||||||
if (!sd.Contains("RefType"))
|
if (!sd.Contains("RefType"))
|
||||||
mRefType = mType;
|
mRefType = mType;
|
||||||
if (!sd.Contains("Interface"))
|
if (!sd.Contains("Interface"))
|
||||||
mInterface = mType;
|
mInterface = mType;
|
||||||
|
if (!sd.Contains("GenericParam"))
|
||||||
|
mGenericParam = mType;
|
||||||
}
|
}
|
||||||
|
GetColor("PrimitiveType", ref mPrimitiveType);
|
||||||
|
GetColor("Struct", ref mStruct);
|
||||||
GetColor("RefType", ref mRefType);
|
GetColor("RefType", ref mRefType);
|
||||||
GetColor("Interface", ref mInterface);
|
GetColor("Interface", ref mInterface);
|
||||||
|
GetColor("GenericParam", ref mGenericParam);
|
||||||
GetColor("Namespace", ref mNamespace);
|
GetColor("Namespace", ref mNamespace);
|
||||||
GetColor("DisassemblyText", ref mDisassemblyText);
|
GetColor("DisassemblyText", ref mDisassemblyText);
|
||||||
GetColor("DisassemblyFileName", ref mDisassemblyFileName);
|
GetColor("DisassemblyFileName", ref mDisassemblyFileName);
|
||||||
|
@ -380,6 +392,9 @@ namespace IDE
|
||||||
SourceEditWidgetContent.sTextColors[(.)SourceElementType.Comment] = mComment;
|
SourceEditWidgetContent.sTextColors[(.)SourceElementType.Comment] = mComment;
|
||||||
SourceEditWidgetContent.sTextColors[(.)SourceElementType.Method] = mMethod;
|
SourceEditWidgetContent.sTextColors[(.)SourceElementType.Method] = mMethod;
|
||||||
SourceEditWidgetContent.sTextColors[(.)SourceElementType.Type] = mType;
|
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.RefType] = mRefType;
|
||||||
SourceEditWidgetContent.sTextColors[(.)SourceElementType.Interface] = mInterface;
|
SourceEditWidgetContent.sTextColors[(.)SourceElementType.Interface] = mInterface;
|
||||||
SourceEditWidgetContent.sTextColors[(.)SourceElementType.Namespace] = mNamespace;
|
SourceEditWidgetContent.sTextColors[(.)SourceElementType.Namespace] = mNamespace;
|
||||||
|
|
|
@ -208,6 +208,9 @@ namespace IDE.ui
|
||||||
0xFF75715E, // Comment
|
0xFF75715E, // Comment
|
||||||
0xFFA6E22A, // Method
|
0xFFA6E22A, // Method
|
||||||
0xFF66D9EF, // Type
|
0xFF66D9EF, // Type
|
||||||
|
0xFF66D9EF, // PrimitiveType
|
||||||
|
0xFF66D9EF, // Struct
|
||||||
|
0xFF66D9EF, // GenericParam
|
||||||
0xFF66A0EF, // RefType
|
0xFF66A0EF, // RefType
|
||||||
0xFF9A9EEB, // Interface
|
0xFF9A9EEB, // Interface
|
||||||
0xFF7BEEB7, // Namespace
|
0xFF7BEEB7, // Namespace
|
||||||
|
|
|
@ -30,6 +30,9 @@ namespace IDE.ui
|
||||||
Comment,
|
Comment,
|
||||||
Method,
|
Method,
|
||||||
Type,
|
Type,
|
||||||
|
PrimitiveType,
|
||||||
|
Struct,
|
||||||
|
GenericParam,
|
||||||
RefType,
|
RefType,
|
||||||
Interface,
|
Interface,
|
||||||
Namespace,
|
Namespace,
|
||||||
|
|
|
@ -4069,6 +4069,8 @@ void BfCompiler::ProcessAutocompleteTempType()
|
||||||
elemType = BfSourceElementType_Interface;
|
elemType = BfSourceElementType_Interface;
|
||||||
else if (checkTempType->mTypeCode == BfTypeCode_Object)
|
else if (checkTempType->mTypeCode == BfTypeCode_Object)
|
||||||
elemType = BfSourceElementType_RefType;
|
elemType = BfSourceElementType_RefType;
|
||||||
|
else if (checkTempType->mTypeCode == BfTypeCode_Struct)
|
||||||
|
elemType = BfSourceElementType_Struct;
|
||||||
mResolvePassData->mSourceClassifier->SetElementType(checkTempType->mTypeDeclaration->mNameNode, elemType);
|
mResolvePassData->mSourceClassifier->SetElementType(checkTempType->mTypeDeclaration->mNameNode, elemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8492,7 +8492,7 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto identifier = BfNodeDynCastExact<BfIdentifierNode>(targetSrc))
|
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)
|
if (mModule->mCompiler->mResolvePassData != NULL)
|
||||||
mModule->mCompiler->mResolvePassData->HandleTypeReference(targetSrc, resolvedTypeInstance->mTypeDef);
|
mModule->mCompiler->mResolvePassData->HandleTypeReference(targetSrc, resolvedTypeInstance->mTypeDef);
|
||||||
|
|
||||||
|
|
|
@ -4772,6 +4772,8 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
elemType = BfSourceElementType_Interface;
|
elemType = BfSourceElementType_Interface;
|
||||||
else if (typeInstance->IsObject())
|
else if (typeInstance->IsObject())
|
||||||
elemType = BfSourceElementType_RefType;
|
elemType = BfSourceElementType_RefType;
|
||||||
|
else if (typeInstance->IsStruct() || (typeInstance->IsTypedPrimitive() && !typeInstance->IsEnum()))
|
||||||
|
elemType = BfSourceElementType_Struct;
|
||||||
mCompiler->mResolvePassData->mSourceClassifier->SetElementType(typeDeclaration->mNameNode, elemType);
|
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))
|
while (auto qualifiedTypeRef = BfNodeDynCast<BfQualifiedTypeReference>(checkTypeRef))
|
||||||
{
|
{
|
||||||
if ((mCompiler->mResolvePassData->mSourceClassifier != NULL) && (checkTypeRef == headTypeRef) && (resolvedTypeRef->IsObjectOrInterface()))
|
if ((mCompiler->mResolvePassData->mSourceClassifier != NULL) && (checkTypeRef == headTypeRef) && (elemType != BfSourceElementType_Type))
|
||||||
mCompiler->mResolvePassData->mSourceClassifier->SetElementType(qualifiedTypeRef->mRight, resolvedTypeRef->IsInterface() ? BfSourceElementType_Interface : BfSourceElementType_RefType);
|
mCompiler->mResolvePassData->mSourceClassifier->SetElementType(qualifiedTypeRef->mRight, elemType);
|
||||||
|
|
||||||
StringView leftString = qualifiedTypeRef->mLeft->ToStringView();
|
StringView leftString = qualifiedTypeRef->mLeft->ToStringView();
|
||||||
BfSizedAtomComposite leftComposite;
|
BfSizedAtomComposite leftComposite;
|
||||||
|
@ -8107,16 +8134,16 @@ BfType* BfModule::ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTy
|
||||||
auto checkNameNode = namedTypeRef->mNameNode;
|
auto checkNameNode = namedTypeRef->mNameNode;
|
||||||
bool setType = false;
|
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))
|
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
|
else
|
||||||
{
|
{
|
||||||
setType = true;
|
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();
|
auto typeRefSource = identifierNode->GetSourceData();
|
||||||
if ((mCompiler->mResolvePassData != NULL) && (mCompiler->mResolvePassData->mSourceClassifier != NULL) && (typeRefSource != NULL) && (typeRefSource == mCompiler->mResolvePassData->mParser->mSourceData))
|
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())
|
if (genericParamResult->IsConstExprValue())
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,6 +55,8 @@ void BfSourceClassifier::SetElementType(BfAstNode * node, BfTypeCode typeCode)
|
||||||
elemType = BfSourceElementType_Interface;
|
elemType = BfSourceElementType_Interface;
|
||||||
else if (typeCode == BfTypeCode_Object)
|
else if (typeCode == BfTypeCode_Object)
|
||||||
elemType = BfSourceElementType_RefType;
|
elemType = BfSourceElementType_RefType;
|
||||||
|
else if (typeCode == BfTypeCode_Struct)
|
||||||
|
elemType = BfSourceElementType_Struct;
|
||||||
SetElementType(node, elemType);
|
SetElementType(node, elemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,7 +560,7 @@ void BfSourceClassifier::Visit(BfMethodDeclaration* methodDeclaration)
|
||||||
for (auto& genericParam : methodDeclaration->mGenericParams->mGenericParams)
|
for (auto& genericParam : methodDeclaration->mGenericParams->mGenericParams)
|
||||||
{
|
{
|
||||||
BfIdentifierNode* typeRef = genericParam;
|
BfIdentifierNode* typeRef = genericParam;
|
||||||
SetElementType(typeRef, BfSourceElementType_Type);
|
SetElementType(typeRef, BfSourceElementType_GenericParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,7 +572,7 @@ void BfSourceClassifier::Visit(BfMethodDeclaration* methodDeclaration)
|
||||||
{
|
{
|
||||||
BfTypeReference* typeRef = genericConstraint->mTypeRef;
|
BfTypeReference* typeRef = genericConstraint->mTypeRef;
|
||||||
if (typeRef != NULL)
|
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)
|
for (auto& genericParam : typeDeclaration->mGenericParams->mGenericParams)
|
||||||
{
|
{
|
||||||
BfIdentifierNode* typeRef = genericParam;
|
BfIdentifierNode* typeRef = genericParam;
|
||||||
SetElementType(typeRef, BfSourceElementType_Type);
|
SetElementType(typeRef, BfSourceElementType_GenericParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,7 +656,7 @@ void BfSourceClassifier::Handle(BfTypeDeclaration* typeDeclaration)
|
||||||
|
|
||||||
BfTypeReference* typeRef = genericConstraint->mTypeRef;
|
BfTypeReference* typeRef = genericConstraint->mTypeRef;
|
||||||
if (typeRef != NULL)
|
if (typeRef != NULL)
|
||||||
SetElementType(typeRef, BfSourceElementType_Type);
|
SetElementType(typeRef, BfSourceElementType_GenericParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,9 @@ enum BfSourceElementType
|
||||||
BfSourceElementType_Comment,
|
BfSourceElementType_Comment,
|
||||||
BfSourceElementType_Method,
|
BfSourceElementType_Method,
|
||||||
BfSourceElementType_Type,
|
BfSourceElementType_Type,
|
||||||
|
BfSourceElementType_PrimitiveType,
|
||||||
|
BfSourceElementType_Struct,
|
||||||
|
BfSourceElementType_GenericParam,
|
||||||
BfSourceElementType_RefType,
|
BfSourceElementType_RefType,
|
||||||
BfSourceElementType_Interface,
|
BfSourceElementType_Interface,
|
||||||
BfSourceElementType_Namespace
|
BfSourceElementType_Namespace
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue