2019-08-23 11:56:54 -07:00
|
|
|
#include "BfSourceClassifier.h"
|
|
|
|
#include "BfParser.h"
|
2021-02-25 10:14:22 -08:00
|
|
|
#include "BeefySysLib/util/BeefPerf.h"
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
USING_NS_BF;
|
|
|
|
|
|
|
|
BfSourceClassifier::BfSourceClassifier(BfParser* bfParser, CharData* charData)
|
|
|
|
{
|
|
|
|
mParser = bfParser;
|
|
|
|
mCharData = charData;
|
2022-07-26 13:27:03 -04:00
|
|
|
mSkipMethodInternals = false;
|
2019-08-23 11:56:54 -07:00
|
|
|
mSkipTypeDeclarations = false;
|
|
|
|
mSkipAttributes = false;
|
|
|
|
mIsSideChannel = false;
|
|
|
|
mPreserveFlags = false;
|
|
|
|
mClassifierPassId = 0;
|
|
|
|
mEnabled = true;
|
|
|
|
mPrevNode = NULL;
|
|
|
|
mCurMember = NULL;
|
2022-05-27 11:28:53 -07:00
|
|
|
mCurLocalMethodDeclaration = NULL;
|
2025-01-04 10:57:37 -08:00
|
|
|
mSkipAnonymousTypes = false;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::ModifyFlags(BfAstNode* node, uint8 andFlags, uint8 orFlags)
|
|
|
|
{
|
|
|
|
if (node != NULL)
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
ModifyFlags(node->GetSrcStart(), node->GetSrcEnd(), andFlags, orFlags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::ModifyFlags(int startPos, int endPos, uint8 andFlags, uint8 orFlags)
|
|
|
|
{
|
|
|
|
if (!mEnabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
endPos = std::min(endPos, mParser->mOrigSrcLength);
|
|
|
|
for (int i = startPos; i < endPos; i++)
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
|
|
|
mCharData[i].mDisplayPassId = mClassifierPassId;
|
2019-08-23 11:56:54 -07:00
|
|
|
mCharData[i].mDisplayFlags = (mCharData[i].mDisplayFlags & andFlags) | orFlags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::SetElementType(BfAstNode* node, BfSourceElementType elementType)
|
|
|
|
{
|
|
|
|
if (node != NULL)
|
|
|
|
{
|
|
|
|
SetElementType(node->GetSrcStart(), node->GetSrcEnd(), elementType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-31 14:16:22 -07:00
|
|
|
void BfSourceClassifier::SetElementType(BfAstNode * node, BfTypeCode typeCode)
|
|
|
|
{
|
|
|
|
BfSourceElementType elemType = BfSourceElementType_Type;
|
|
|
|
if (typeCode == BfTypeCode_Interface)
|
|
|
|
elemType = BfSourceElementType_Interface;
|
|
|
|
else if (typeCode == BfTypeCode_Object)
|
|
|
|
elemType = BfSourceElementType_RefType;
|
2021-03-22 11:44:13 +01:00
|
|
|
else if (typeCode == BfTypeCode_Struct)
|
|
|
|
elemType = BfSourceElementType_Struct;
|
2020-08-31 14:16:22 -07:00
|
|
|
SetElementType(node, elemType);
|
|
|
|
}
|
|
|
|
|
2020-08-13 06:28:31 -07:00
|
|
|
void BfSourceClassifier::SetHighestElementType(int startPos, int endPos, BfSourceElementType elementType)
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
if (!mEnabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
endPos = BF_MIN(endPos, mParser->mOrigSrcLength);
|
|
|
|
for (int i = startPos; i < endPos; i++)
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2020-08-13 06:28:31 -07:00
|
|
|
auto& charData = mCharData[i];
|
|
|
|
charData.mDisplayPassId = mClassifierPassId;
|
|
|
|
charData.mDisplayTypeId = BF_MAX(charData.mDisplayTypeId, (uint8)elementType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::SetHighestElementType(BfAstNode* node, BfSourceElementType elementType)
|
|
|
|
{
|
|
|
|
if (node != NULL)
|
|
|
|
{
|
|
|
|
SetHighestElementType(node->GetSrcStart(), node->GetSrcEnd(), elementType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::SetElementType(int startPos, int endPos, BfSourceElementType elementType)
|
|
|
|
{
|
|
|
|
if (!mEnabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
endPos = BF_MIN(endPos, mParser->mOrigSrcLength);
|
|
|
|
for (int i = startPos; i < endPos; i++)
|
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
mCharData[i].mDisplayPassId = mClassifierPassId;
|
2020-08-13 06:28:31 -07:00
|
|
|
mCharData[i].mDisplayTypeId = (uint8)elementType;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::VisitMembers(BfBlock* node)
|
|
|
|
{
|
|
|
|
mPrevNode = NULL;
|
|
|
|
for (auto& childNodeRef : *node)
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
BfAstNode* child = childNodeRef;
|
|
|
|
child->Accept(this);
|
2022-07-26 13:27:03 -04:00
|
|
|
mPrevNode = child;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BfSourceClassifier::IsInterestedInMember(BfAstNode* node, bool forceSkip)
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
if ((mSkipMethodInternals || forceSkip) && (mParser->mCursorIdx != -1) &&
|
|
|
|
(!node->Contains(mParser->mCursorIdx, 1, 0)))
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::HandleLeafNode(BfAstNode* node)
|
|
|
|
{
|
|
|
|
if (!mEnabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int nodeStart = node->GetSrcStart();
|
2022-07-26 13:27:03 -04:00
|
|
|
int srcStart = nodeStart;
|
2019-08-23 11:56:54 -07:00
|
|
|
int triviaStart = node->GetTriviaStart();
|
|
|
|
if (triviaStart != -1)
|
|
|
|
{
|
|
|
|
srcStart = triviaStart;
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
if ((mIsSideChannel) && (mPrevNode != NULL))
|
|
|
|
srcStart = std::max(mPrevNode->GetSrcEnd(), srcStart);
|
|
|
|
}
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
if (nodeStart != srcStart)
|
|
|
|
SetElementType(srcStart, nodeStart, BfSourceElementType_Normal);
|
|
|
|
//SetElementType(srcStart, node->GetSrcEnd(), BfSourceElementType_Normal);
|
|
|
|
if (!mPreserveFlags)
|
|
|
|
ModifyFlags(srcStart, node->GetSrcEnd(), ~BfSourceElementFlag_CompilerFlags_Mask, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfAstNode* node)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfErrorNode* errorNode)
|
|
|
|
{
|
|
|
|
//Visit(errorNode->ToBase());
|
|
|
|
VisitChildNoRef(errorNode->mRefNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfFieldDeclaration* fieldDecl)
|
|
|
|
{
|
|
|
|
if (!IsInterestedInMember(fieldDecl))
|
|
|
|
return;
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
BfElementVisitor::Visit(fieldDecl);
|
|
|
|
|
|
|
|
VisitChild(fieldDecl->mConstSpecifier);
|
|
|
|
VisitChild(fieldDecl->mReadOnlySpecifier);
|
|
|
|
VisitChild(fieldDecl->mTypeRef);
|
|
|
|
VisitChild(fieldDecl->mNameNode);
|
2024-12-02 07:39:17 -05:00
|
|
|
SetElementType(fieldDecl->mNameNode, BfSourceElementType_Member);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfFieldDtorDeclaration* fieldDtorDecl)
|
|
|
|
{
|
|
|
|
Visit(fieldDtorDecl->ToBase());
|
|
|
|
|
|
|
|
BfElementVisitor::Visit(fieldDtorDecl);
|
|
|
|
|
|
|
|
if (fieldDtorDecl->mTildeToken != NULL)
|
|
|
|
SetElementType(fieldDtorDecl->mTildeToken, BfSourceElementType_Method);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfPreprocesorIgnoredSectionNode* preprocesorIgnoredSection)
|
|
|
|
{
|
|
|
|
HandleLeafNode(preprocesorIgnoredSection);
|
|
|
|
|
|
|
|
Visit(preprocesorIgnoredSection->ToBase());
|
|
|
|
|
|
|
|
SetElementType(preprocesorIgnoredSection, BfSourceElementType_Comment);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfPreprocessorNode* preprocessorNode)
|
|
|
|
{
|
|
|
|
HandleLeafNode(preprocessorNode);
|
|
|
|
|
|
|
|
if (!mPreserveFlags)
|
|
|
|
ModifyFlags(preprocessorNode, ~BfSourceElementFlag_CompilerFlags_Mask, 0);
|
|
|
|
SetElementType(preprocessorNode, BfSourceElementType_Normal);
|
2022-07-26 13:27:03 -04:00
|
|
|
|
|
|
|
Visit(preprocessorNode->ToBase());
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfCommentNode* commentNode)
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
HandleLeafNode(commentNode);
|
|
|
|
|
|
|
|
Visit(commentNode->ToBase());
|
|
|
|
|
|
|
|
SetElementType(commentNode, BfSourceElementType_Comment);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfAttributeDirective* attributeDirective)
|
|
|
|
{
|
|
|
|
if (mSkipAttributes)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Skip?
|
|
|
|
{
|
|
|
|
if (auto typeDeclaration = BfNodeDynCast<BfTypeDeclaration>(mCurMember))
|
|
|
|
{
|
|
|
|
if (typeDeclaration->mAttributes == attributeDirective)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-27 11:28:53 -07:00
|
|
|
if (mCurLocalMethodDeclaration == NULL)
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
2022-05-27 11:28:53 -07:00
|
|
|
if (auto methodDecl = BfNodeDynCast<BfMethodDeclaration>(mCurMember))
|
|
|
|
{
|
|
|
|
if (methodDecl->mAttributes == attributeDirective)
|
|
|
|
return;
|
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (auto propDecl = BfNodeDynCast<BfPropertyDeclaration>(mCurMember))
|
|
|
|
{
|
|
|
|
if (propDecl->mAttributes == attributeDirective)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (auto methodDeclaration : propDecl->mMethods)
|
|
|
|
{
|
|
|
|
if (methodDeclaration->mAttributes == attributeDirective)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-26 13:27:03 -04:00
|
|
|
BfElementVisitor::Visit(attributeDirective);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
VisitChild(attributeDirective->mAttrCloseToken);
|
|
|
|
|
|
|
|
VisitChild(attributeDirective->mAttrOpenToken); // Either [ or ,
|
|
|
|
VisitChild(attributeDirective->mAttrCloseToken);
|
|
|
|
|
|
|
|
if (attributeDirective->mAttributeTargetSpecifier != NULL)
|
|
|
|
{
|
2019-11-26 13:11:17 -08:00
|
|
|
if (auto attributeTargetSpecifier = BfNodeDynCast<BfAttributeTargetSpecifier>(attributeDirective->mAttributeTargetSpecifier))
|
|
|
|
{
|
|
|
|
VisitChild(attributeTargetSpecifier->mTargetToken);
|
|
|
|
VisitChild(attributeTargetSpecifier->mColonToken);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
VisitChild(attributeDirective->mAttributeTargetSpecifier);
|
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
VisitChild(attributeDirective->mAttributeTypeRef);
|
|
|
|
VisitChild(attributeDirective->mCtorOpenParen);
|
|
|
|
VisitChild(attributeDirective->mCtorCloseParen);
|
|
|
|
for (auto& arg : attributeDirective->mArguments)
|
|
|
|
VisitChild(arg);
|
|
|
|
for (auto& comma : attributeDirective->mCommas)
|
2022-07-26 13:27:03 -04:00
|
|
|
VisitChild(comma);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
VisitChild(attributeDirective->mNextAttribute);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfIdentifierNode* identifier)
|
|
|
|
{
|
|
|
|
HandleLeafNode(identifier);
|
|
|
|
|
|
|
|
Visit(identifier->ToBase());
|
|
|
|
|
2020-02-21 09:26:02 -08:00
|
|
|
if ((identifier->Equals("this")) || (identifier->Equals("base")))
|
|
|
|
SetElementType(identifier, BfSourceElementType_Keyword);
|
|
|
|
else
|
|
|
|
SetElementType(identifier, BfSourceElementType_Identifier);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfQualifiedNameNode* qualifiedName)
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
Visit((BfAstNode*)qualifiedName);
|
2025-05-18 12:13:15 +02:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
VisitChild(qualifiedName->mLeft);
|
2025-05-18 12:13:15 +02:00
|
|
|
if (qualifiedName->IsGlobalLookup())
|
|
|
|
SetElementType(qualifiedName->mLeft, BfSourceElementType_Namespace);
|
2019-08-23 11:56:54 -07:00
|
|
|
VisitChild(qualifiedName->mDot);
|
|
|
|
VisitChild(qualifiedName->mRight);
|
2024-12-02 07:39:17 -05:00
|
|
|
if (BfNodeIsExact<BfIdentifierNode>(qualifiedName->mRight))
|
|
|
|
SetElementType(qualifiedName->mRight, BfSourceElementType_Member);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfThisExpression* thisExpr)
|
|
|
|
{
|
|
|
|
HandleLeafNode(thisExpr);
|
|
|
|
Visit((BfAstNode*)thisExpr);
|
2019-12-13 14:22:23 -08:00
|
|
|
SetElementType(thisExpr, BfSourceElementType_Keyword);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfBaseExpression* baseExpr)
|
|
|
|
{
|
|
|
|
HandleLeafNode(baseExpr);
|
|
|
|
Visit((BfAstNode*)baseExpr);
|
2019-12-13 14:22:23 -08:00
|
|
|
SetElementType(baseExpr, BfSourceElementType_Keyword);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfMemberReferenceExpression* memberRefExpr)
|
|
|
|
{
|
|
|
|
Visit((BfAstNode*)memberRefExpr);
|
|
|
|
VisitChild(memberRefExpr->mTarget);
|
|
|
|
VisitChild(memberRefExpr->mDotToken);
|
2024-12-04 08:42:31 -05:00
|
|
|
VisitChild(memberRefExpr->mMemberName);
|
2024-12-02 07:39:17 -05:00
|
|
|
SetElementType(memberRefExpr->mMemberName, BfSourceElementType_Member);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfNamedTypeReference* typeRef)
|
|
|
|
{
|
|
|
|
HandleLeafNode(typeRef);
|
|
|
|
|
|
|
|
Visit(typeRef->ToBase());
|
|
|
|
|
|
|
|
//auto identifier = typeRef->mNameNode;
|
|
|
|
if (typeRef != NULL)
|
|
|
|
{
|
|
|
|
BfIdentifierNode* checkName = typeRef->mNameNode;
|
|
|
|
while (auto qualifiedNameNode = BfNodeDynCast<BfQualifiedNameNode>(checkName))
|
|
|
|
{
|
2020-08-13 06:28:31 -07:00
|
|
|
SetElementType(qualifiedNameNode->mRight, BfSourceElementType_Type);
|
2019-08-23 11:56:54 -07:00
|
|
|
checkName = qualifiedNameNode->mLeft;
|
|
|
|
}
|
|
|
|
if (checkName != NULL)
|
2020-08-13 06:28:31 -07:00
|
|
|
SetElementType(checkName, BfSourceElementType_Type);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-08 09:16:27 -05:00
|
|
|
void BfSourceClassifier::Visit(BfTagTypeRef* typeRef)
|
|
|
|
{
|
|
|
|
Visit((BfAstNode*)typeRef);
|
|
|
|
|
|
|
|
VisitChild(typeRef->mTagNode);
|
|
|
|
SetElementType(typeRef->mTagNode, BfSourceElementType_Keyword);
|
|
|
|
|
|
|
|
VisitChild(typeRef->mNameNode);
|
|
|
|
SetElementType(typeRef->mNameNode, BfSourceElementType_Type);
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
void BfSourceClassifier::Visit(BfQualifiedTypeReference* qualifiedType)
|
|
|
|
{
|
|
|
|
Visit((BfAstNode*)qualifiedType);
|
|
|
|
|
|
|
|
VisitChild(qualifiedType->mLeft);
|
2025-05-18 12:13:15 +02:00
|
|
|
if (qualifiedType->IsGlobalLookup())
|
|
|
|
SetElementType(qualifiedType->mLeft, BfSourceElementType_Namespace);
|
2019-08-23 11:56:54 -07:00
|
|
|
VisitChild(qualifiedType->mDot);
|
|
|
|
VisitChild(qualifiedType->mRight);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfRefTypeRef* typeRef)
|
|
|
|
{
|
|
|
|
Visit((BfAstNode*)typeRef);
|
|
|
|
|
|
|
|
VisitChild(typeRef->mRefToken);
|
2020-08-13 06:28:31 -07:00
|
|
|
SetElementType(typeRef->mRefToken, BfSourceElementType_Type);
|
2019-08-23 11:56:54 -07:00
|
|
|
VisitChild(typeRef->mElementType);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfArrayTypeRef* arrayType)
|
|
|
|
{
|
|
|
|
Visit((BfAstNode*)arrayType);
|
|
|
|
|
|
|
|
VisitChild(arrayType->mElementType);
|
|
|
|
VisitChild(arrayType->mOpenBracket);
|
|
|
|
for (auto& param : arrayType->mParams)
|
|
|
|
VisitChild(param);
|
|
|
|
VisitChild(arrayType->mCloseBracket);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfPointerTypeRef* pointerType)
|
|
|
|
{
|
|
|
|
Visit((BfAstNode*)pointerType);
|
|
|
|
|
|
|
|
VisitChild(pointerType->mElementType);
|
|
|
|
VisitChild(pointerType->mStarNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfGenericInstanceTypeRef* genericInstTypeRef)
|
|
|
|
{
|
|
|
|
BfElementVisitor::Visit(genericInstTypeRef);
|
|
|
|
|
|
|
|
VisitChild(genericInstTypeRef->mElementType);
|
|
|
|
VisitChild(genericInstTypeRef->mOpenChevron);
|
|
|
|
for (int i = 0; i < (int) genericInstTypeRef->mGenericArguments.size(); i++)
|
|
|
|
{
|
|
|
|
if (genericInstTypeRef->mCommas.mVals != NULL)
|
|
|
|
{
|
|
|
|
if ((i > 0) && (i - 1 < (int)genericInstTypeRef->mCommas.size()))
|
|
|
|
VisitChild(genericInstTypeRef->mCommas[i - 1]);
|
|
|
|
}
|
|
|
|
VisitChild(genericInstTypeRef->mGenericArguments[i]);
|
|
|
|
}
|
|
|
|
VisitChild(genericInstTypeRef->mCloseChevron);
|
|
|
|
}
|
|
|
|
|
2024-12-02 07:39:17 -05:00
|
|
|
void BfSourceClassifier::Visit(BfVariableDeclaration* varDecl)
|
|
|
|
{
|
|
|
|
BfElementVisitor::Visit(varDecl);
|
|
|
|
|
|
|
|
if (!varDecl->IsA<BfParameterDeclaration>())
|
|
|
|
SetElementType(varDecl->mNameNode, BfSourceElementType_Local);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfLambdaBindExpression* lambdaBindExpr)
|
|
|
|
{
|
|
|
|
BfElementVisitor::Visit(lambdaBindExpr);
|
|
|
|
|
|
|
|
for (auto param : lambdaBindExpr->mParams)
|
|
|
|
{
|
|
|
|
SetElementType(param, BfSourceElementType_Parameter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
void BfSourceClassifier::Visit(BfLocalMethodDeclaration* methodDecl)
|
|
|
|
{
|
|
|
|
if (IsInterestedInMember(methodDecl, true))
|
2022-05-27 11:28:53 -07:00
|
|
|
{
|
|
|
|
SetAndRestoreValue<BfLocalMethodDeclaration*> prevLocalMethodDecl(mCurLocalMethodDeclaration, methodDecl);
|
2019-08-23 11:56:54 -07:00
|
|
|
BfElementVisitor::Visit(methodDecl);
|
2022-05-27 11:28:53 -07:00
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfLiteralExpression* literalExpr)
|
|
|
|
{
|
|
|
|
HandleLeafNode(literalExpr);
|
|
|
|
|
|
|
|
Visit(literalExpr->ToBase());
|
|
|
|
|
|
|
|
SetElementType(literalExpr, BfSourceElementType_Literal);
|
|
|
|
}
|
|
|
|
|
2020-11-11 05:46:52 -08:00
|
|
|
void BfSourceClassifier::Visit(BfStringInterpolationExpression* stringInterpolationExpression)
|
|
|
|
{
|
|
|
|
HandleLeafNode(stringInterpolationExpression);
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2020-11-11 05:46:52 -08:00
|
|
|
Visit(stringInterpolationExpression->ToBase());
|
|
|
|
SetElementType(stringInterpolationExpression, BfSourceElementType_Literal);
|
|
|
|
|
2022-07-26 13:27:03 -04:00
|
|
|
VisitChild(stringInterpolationExpression->mAllocNode);
|
2020-11-11 05:46:52 -08:00
|
|
|
for (auto& expr : stringInterpolationExpression->mExpressions)
|
|
|
|
{
|
2022-02-12 09:42:42 -05:00
|
|
|
SetElementType(expr, BfSourceElementType_Normal);
|
2020-11-11 05:46:52 -08:00
|
|
|
VisitChild(expr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
void BfSourceClassifier::Visit(BfTokenNode* tokenNode)
|
|
|
|
{
|
|
|
|
HandleLeafNode(tokenNode);
|
|
|
|
|
|
|
|
Visit(tokenNode->ToBase());
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
if (BfTokenIsKeyword(tokenNode->GetToken()))
|
|
|
|
SetElementType(tokenNode, BfSourceElementType_Keyword);
|
|
|
|
else
|
|
|
|
SetElementType(tokenNode, BfSourceElementType_Normal);
|
|
|
|
}
|
|
|
|
|
2025-02-22 09:56:39 -08:00
|
|
|
void BfSourceClassifier::Visit(BfCaseExpression* caseExpr)
|
|
|
|
{
|
|
|
|
BfElementVisitor::Visit(caseExpr);
|
|
|
|
SetElementType(caseExpr->mNotToken, BfSourceElementType_Keyword);
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
void BfSourceClassifier::Visit(BfInvocationExpression* invocationExpr)
|
|
|
|
{
|
2021-02-25 10:14:22 -08:00
|
|
|
//BfElementVisitor::Visit(invocationExpr);
|
|
|
|
Visit(invocationExpr->ToBase());
|
|
|
|
|
|
|
|
//BP_ZONE("BfSourceClassifier BfInvocationExpression");
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
BfAstNode* target = invocationExpr->mTarget;
|
|
|
|
if (target == NULL)
|
|
|
|
return;
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2021-02-25 10:14:22 -08:00
|
|
|
VisitChild(invocationExpr->mOpenParen);
|
|
|
|
VisitChild(invocationExpr->mCloseParen);
|
|
|
|
VisitChild(invocationExpr->mGenericArgs);
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
if (auto scopedTarget = BfNodeDynCast<BfScopedInvocationTarget>(target))
|
|
|
|
{
|
2021-02-25 10:14:22 -08:00
|
|
|
VisitChild(target);
|
2019-08-23 11:56:54 -07:00
|
|
|
target = scopedTarget->mTarget;
|
|
|
|
VisitChild(scopedTarget->mScopeName);
|
|
|
|
}
|
|
|
|
|
|
|
|
BfAstNode* identifier = NULL;
|
|
|
|
if (auto qualifiedName = BfNodeDynCast<BfQualifiedNameNode>(target))
|
|
|
|
{
|
|
|
|
VisitChild(qualifiedName->mLeft);
|
2025-05-18 12:13:15 +02:00
|
|
|
if (qualifiedName->IsGlobalLookup())
|
|
|
|
SetElementType(qualifiedName->mLeft, BfSourceElementType_Namespace);
|
2019-08-23 11:56:54 -07:00
|
|
|
VisitChild(qualifiedName->mDot);
|
2021-02-25 10:14:22 -08:00
|
|
|
VisitChild(qualifiedName->mRight);
|
2022-07-26 13:27:03 -04:00
|
|
|
identifier = qualifiedName->mRight;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
2019-10-14 14:08:29 -07:00
|
|
|
else if ((identifier = BfNodeDynCast<BfIdentifierNode>(target)))
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
2021-02-25 10:14:22 -08:00
|
|
|
VisitChild(target);
|
2019-08-23 11:56:54 -07:00
|
|
|
// Leave as BfAttributedIdentifierNode if that's the case
|
2022-07-26 13:27:03 -04:00
|
|
|
identifier = target;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
else if (auto qualifiedName = BfNodeDynCast<BfQualifiedNameNode>(target))
|
|
|
|
{
|
|
|
|
VisitChild(qualifiedName->mLeft);
|
|
|
|
VisitChild(qualifiedName->mDot);
|
2021-02-25 10:14:22 -08:00
|
|
|
VisitChild(qualifiedName->mRight);
|
2022-07-26 13:27:03 -04:00
|
|
|
identifier = qualifiedName->mRight;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
else if (auto memberRefExpr = BfNodeDynCast<BfMemberReferenceExpression>(target))
|
|
|
|
{
|
|
|
|
VisitChild(memberRefExpr->mTarget);
|
|
|
|
VisitChild(memberRefExpr->mDotToken);
|
2021-02-25 10:14:22 -08:00
|
|
|
VisitChild(memberRefExpr->mMemberName);
|
2022-07-26 13:27:03 -04:00
|
|
|
identifier = memberRefExpr->mMemberName;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
2021-02-25 10:14:22 -08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
VisitChild(target);
|
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
if (identifier != NULL)
|
|
|
|
{
|
|
|
|
if (auto attrIdentifier = BfNodeDynCast<BfAttributedIdentifierNode>(identifier))
|
|
|
|
{
|
|
|
|
VisitChild(attrIdentifier->mAttributes);
|
2022-07-26 13:27:03 -04:00
|
|
|
identifier = attrIdentifier->mIdentifier;
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
if (identifier != NULL)
|
|
|
|
SetElementType(identifier, BfSourceElementType_Method);
|
|
|
|
}
|
2021-02-25 10:14:22 -08:00
|
|
|
|
|
|
|
for (auto& val : invocationExpr->mArguments)
|
|
|
|
VisitChild(val);
|
|
|
|
for (auto& val : invocationExpr->mCommas)
|
|
|
|
VisitChild(val);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfIndexerExpression* indexerExpr)
|
|
|
|
{
|
2021-02-25 10:14:22 -08:00
|
|
|
//BfElementVisitor::Visit(indexerExpr);
|
|
|
|
Visit(indexerExpr->ToBase());
|
2019-08-23 11:56:54 -07:00
|
|
|
|
|
|
|
VisitChild(indexerExpr->mTarget);
|
|
|
|
VisitChild(indexerExpr->mOpenBracket);
|
2021-02-25 10:14:22 -08:00
|
|
|
|
|
|
|
for (auto& val : indexerExpr->mArguments)
|
|
|
|
VisitChild(val);
|
|
|
|
for (auto& val : indexerExpr->mCommas)
|
|
|
|
VisitChild(val);
|
2019-08-23 11:56:54 -07:00
|
|
|
VisitChild(indexerExpr->mCloseBracket);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfConstructorDeclaration* ctorDeclaration)
|
|
|
|
{
|
|
|
|
if (!IsInterestedInMember(ctorDeclaration))
|
|
|
|
return;
|
|
|
|
|
|
|
|
BfElementVisitor::Visit(ctorDeclaration);
|
|
|
|
VisitChild(ctorDeclaration->mThisToken);
|
|
|
|
|
|
|
|
auto identifier = ctorDeclaration->mThisToken;
|
|
|
|
if (identifier == NULL)
|
|
|
|
return;
|
|
|
|
SetElementType(identifier, BfSourceElementType_Method);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfDestructorDeclaration* dtorDeclaration)
|
|
|
|
{
|
|
|
|
BfElementVisitor::Visit(dtorDeclaration);
|
|
|
|
|
|
|
|
VisitChild(dtorDeclaration->mTildeToken);
|
|
|
|
VisitChild(dtorDeclaration->mThisToken);
|
|
|
|
|
|
|
|
auto identifier = dtorDeclaration->mThisToken;
|
|
|
|
if (identifier == NULL)
|
|
|
|
return;
|
|
|
|
SetElementType(identifier, BfSourceElementType_Method);
|
|
|
|
|
|
|
|
identifier = dtorDeclaration->mTildeToken;
|
|
|
|
if (identifier == NULL)
|
|
|
|
return;
|
|
|
|
SetElementType(identifier, BfSourceElementType_Method);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfMethodDeclaration* methodDeclaration)
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
if (!IsInterestedInMember(methodDeclaration))
|
|
|
|
return;
|
|
|
|
|
2021-02-25 10:14:22 -08:00
|
|
|
//BP_ZONE("BfSourceClassifier BfMethodDeclaration");
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
SetAndRestoreValue<BfAstNode*> prevMember(mCurMember, methodDeclaration);
|
|
|
|
|
2022-07-26 13:27:03 -04:00
|
|
|
BfElementVisitor::Visit(methodDeclaration);
|
|
|
|
|
2019-11-17 09:28:39 -08:00
|
|
|
SetElementType(methodDeclaration->mNameNode, BfSourceElementType_Method);
|
2019-08-23 11:56:54 -07:00
|
|
|
|
2024-12-02 07:39:17 -05:00
|
|
|
for (auto paramDecl : methodDeclaration->mParams)
|
|
|
|
{
|
|
|
|
if (paramDecl != NULL)
|
|
|
|
SetElementType(paramDecl->mNameNode, BfSourceElementType_Parameter);
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
if (methodDeclaration->mGenericParams != NULL)
|
|
|
|
{
|
|
|
|
for (auto& genericParam : methodDeclaration->mGenericParams->mGenericParams)
|
|
|
|
{
|
|
|
|
BfIdentifierNode* typeRef = genericParam;
|
2021-03-22 11:44:13 +01:00
|
|
|
SetElementType(typeRef, BfSourceElementType_GenericParam);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (methodDeclaration->mGenericConstraintsDeclaration != NULL)
|
|
|
|
{
|
2019-11-17 09:28:39 -08:00
|
|
|
for (auto constraintNode : methodDeclaration->mGenericConstraintsDeclaration->mGenericConstraints)
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
2019-11-17 09:28:39 -08:00
|
|
|
if (auto genericConstraint = BfNodeDynCast<BfGenericConstraint>(constraintNode))
|
|
|
|
{
|
|
|
|
BfTypeReference* typeRef = genericConstraint->mTypeRef;
|
|
|
|
if (typeRef != NULL)
|
2021-11-23 09:12:10 -08:00
|
|
|
{
|
|
|
|
if (auto namedTypeRef = BfNodeDynCast<BfNamedTypeReference>(typeRef))
|
2022-07-26 13:27:03 -04:00
|
|
|
SetElementType(typeRef, BfSourceElementType_GenericParam);
|
2021-11-23 09:12:10 -08:00
|
|
|
else
|
|
|
|
VisitChild(typeRef);
|
|
|
|
}
|
2019-11-17 09:28:39 -08:00
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfPropertyMethodDeclaration* propertyMethodDeclaration)
|
|
|
|
{
|
|
|
|
if ((propertyMethodDeclaration->mBody != NULL) && (!IsInterestedInMember(propertyMethodDeclaration->mBody)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
BfElementVisitor::Visit(propertyMethodDeclaration);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfPropertyDeclaration* propertyDeclaration)
|
|
|
|
{
|
|
|
|
SetAndRestoreValue<BfAstNode*> prevMember(mCurMember, propertyDeclaration);
|
|
|
|
|
|
|
|
BfElementVisitor::Visit(propertyDeclaration);
|
|
|
|
|
2024-12-02 07:39:17 -05:00
|
|
|
SetElementType(propertyDeclaration->mNameNode, BfSourceElementType_Member);
|
|
|
|
|
2020-09-01 15:57:08 -07:00
|
|
|
if (auto expr = BfNodeDynCast<BfPropertyBodyExpression>(propertyDeclaration->mDefinitionBlock))
|
|
|
|
return;
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
for (auto methodDeclaration : propertyDeclaration->mMethods)
|
|
|
|
{
|
|
|
|
if ((methodDeclaration != NULL) && (methodDeclaration->mNameNode != NULL))
|
|
|
|
SetElementType(methodDeclaration->mNameNode, BfSourceElementType_Method);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfTypeDeclaration* typeDeclaration)
|
|
|
|
{
|
2025-01-04 10:57:37 -08:00
|
|
|
if ((mSkipAnonymousTypes) && (typeDeclaration->IsAnonymous()))
|
|
|
|
return;
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
if (typeDeclaration->mIgnoreDeclaration)
|
|
|
|
return;
|
|
|
|
|
|
|
|
SetAndRestoreValue<BfAstNode*> prevMember(mCurMember, typeDeclaration);
|
|
|
|
|
2025-01-02 11:42:33 -08:00
|
|
|
if ((mSkipTypeDeclarations) && (!typeDeclaration->IsAnonymous()))
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
|
|
|
if (auto defineBlock = BfNodeDynCast<BfBlock>(typeDeclaration->mDefineNode))
|
|
|
|
{
|
|
|
|
// Clear out any potential "fail after" errors on the closing brace-
|
|
|
|
// Can happen when we don't close out a namespace, for example
|
|
|
|
if (defineBlock->mCloseBrace != NULL)
|
|
|
|
VisitChild(defineBlock->mCloseBrace);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Handle(typeDeclaration);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Handle(BfTypeDeclaration* typeDeclaration)
|
|
|
|
{
|
|
|
|
if (mParser->mCursorIdx != -1)
|
|
|
|
{
|
|
|
|
// This is to fix a case where we are typing out a type name, so an "actualTypeDef" will not be found during autocomplete
|
|
|
|
// and therefore we will not process the attributes. Removing this will cause classify flashing while typing
|
|
|
|
SetAndRestoreValue<bool> prevSkipAttributes(mSkipAttributes, true);
|
|
|
|
BfElementVisitor::Visit(typeDeclaration);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
BfElementVisitor::Visit(typeDeclaration);
|
|
|
|
|
|
|
|
llvm::SmallVector<BfTypeReference*, 2> mBaseClasses;
|
|
|
|
llvm::SmallVector<BfAstNode*, 2> mBaseClassCommas;
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
if (typeDeclaration->mGenericParams != NULL)
|
|
|
|
{
|
|
|
|
for (auto& genericParam : typeDeclaration->mGenericParams->mGenericParams)
|
|
|
|
{
|
|
|
|
BfIdentifierNode* typeRef = genericParam;
|
2021-03-22 11:44:13 +01:00
|
|
|
SetElementType(typeRef, BfSourceElementType_GenericParam);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeDeclaration->mGenericConstraintsDeclaration != NULL)
|
|
|
|
{
|
2019-11-17 09:28:39 -08:00
|
|
|
for (auto constraintNode : typeDeclaration->mGenericConstraintsDeclaration->mGenericConstraints)
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
2019-11-17 09:28:39 -08:00
|
|
|
auto genericConstraint = BfNodeDynCast<BfGenericConstraint>(constraintNode);
|
|
|
|
|
|
|
|
BfTypeReference* typeRef = genericConstraint->mTypeRef;
|
2019-08-23 11:56:54 -07:00
|
|
|
if (typeRef != NULL)
|
2022-02-06 08:21:53 -05:00
|
|
|
{
|
|
|
|
if (auto namedTypeRef = BfNodeDynCast<BfNamedTypeReference>(typeRef))
|
|
|
|
SetElementType(namedTypeRef, BfSourceElementType_GenericParam);
|
|
|
|
}
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto typeRef = typeDeclaration->mNameNode;
|
|
|
|
if (typeRef != NULL)
|
2020-08-13 06:28:31 -07:00
|
|
|
SetElementType(typeRef, BfSourceElementType_Type);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::MarkSkipped(int startPos, int endPos)
|
|
|
|
{
|
|
|
|
for (int i = startPos; i < endPos; i++)
|
|
|
|
{
|
|
|
|
mCharData[i].mDisplayPassId = BfSourceDisplayId_SkipResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::MarkSkipped(BfAstNode* node)
|
|
|
|
{
|
|
|
|
MarkSkipped(node->GetSrcStart(), node->GetSrcEnd());
|
|
|
|
}
|
|
|
|
|
2022-07-02 10:32:19 -07:00
|
|
|
void BfSourceClassifier::DeferNodes(BfBlock* block)
|
|
|
|
{
|
|
|
|
for (auto child : *block)
|
|
|
|
mDeferredNodes.Add(child);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::FlushDeferredNodes()
|
|
|
|
{
|
|
|
|
for (auto node : mDeferredNodes)
|
|
|
|
VisitChild(node);
|
|
|
|
mDeferredNodes.Clear();
|
|
|
|
}
|
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
void BfSourceClassifier::Visit(BfTypeAliasDeclaration* typeDeclaration)
|
|
|
|
{
|
|
|
|
if (typeDeclaration->mIgnoreDeclaration)
|
|
|
|
return;
|
|
|
|
|
2022-07-26 13:27:03 -04:00
|
|
|
BfElementVisitor::Visit(typeDeclaration);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfUsingDirective* usingDirective)
|
|
|
|
{
|
|
|
|
BfElementVisitor::Visit(usingDirective);
|
|
|
|
|
|
|
|
auto checkIdentifier = usingDirective->mNamespace;
|
|
|
|
if (checkIdentifier != NULL)
|
|
|
|
{
|
|
|
|
while (auto qualifiedNameNode = BfNodeDynCast<BfQualifiedNameNode>(checkIdentifier))
|
|
|
|
{
|
|
|
|
SetElementType(qualifiedNameNode->mRight, BfSourceElementType_Namespace);
|
|
|
|
checkIdentifier = qualifiedNameNode->mLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (checkIdentifier != NULL)
|
|
|
|
SetElementType(checkIdentifier, BfSourceElementType_Namespace);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-14 11:33:41 -07:00
|
|
|
void BfSourceClassifier::Visit(BfUsingModDirective* usingDirective)
|
2019-08-23 11:56:54 -07:00
|
|
|
{
|
2022-07-26 13:27:03 -04:00
|
|
|
BfElementVisitor::Visit(usingDirective);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfNamespaceDeclaration* namespaceDeclaration)
|
|
|
|
{
|
|
|
|
BfElementVisitor::Visit(namespaceDeclaration);
|
|
|
|
|
|
|
|
auto checkIdentifier = namespaceDeclaration->mNameNode;
|
|
|
|
if (checkIdentifier != NULL)
|
|
|
|
{
|
|
|
|
while (auto qualifiedNameNode = BfNodeDynCast<BfQualifiedNameNode>(checkIdentifier))
|
|
|
|
{
|
|
|
|
SetElementType(qualifiedNameNode->mRight, BfSourceElementType_Namespace);
|
|
|
|
checkIdentifier = qualifiedNameNode->mLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (checkIdentifier != NULL)
|
|
|
|
SetElementType(checkIdentifier, BfSourceElementType_Namespace);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BfSourceClassifier::WantsSkipParentMethod(BfAstNode* node)
|
|
|
|
{
|
|
|
|
if (!mSkipMethodInternals)
|
|
|
|
return false;
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
#ifdef BF_AST_HAS_PARENT_MEMBER
|
|
|
|
if (node->mParent->IsA<BfMethodDeclaration>())
|
|
|
|
{
|
|
|
|
BF_ASSERT(node->mParent == mCurMember);
|
|
|
|
}
|
|
|
|
if (auto propDecl = BfNodeDynCast<BfPropertyDeclaration>(node->mParent))
|
|
|
|
{
|
|
|
|
BF_ASSERT(node->mParent == mCurMember);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (auto methodDecl = BfNodeDynCast<BfMethodDeclaration>(mCurMember))
|
|
|
|
{
|
|
|
|
if (methodDecl->mBody == node)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (auto propDecl = BfNodeDynCast<BfPropertyDeclaration>(mCurMember))
|
|
|
|
{
|
|
|
|
for (auto methodDeclaration : propDecl->mMethods)
|
|
|
|
{
|
|
|
|
if (node == methodDeclaration->mBody)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfGenericConstraintsDeclaration* genericConstraints)
|
|
|
|
{
|
|
|
|
/*if (WantsSkipParentMethod(genericConstraints))
|
|
|
|
return;*/
|
|
|
|
BfElementVisitor::Visit(genericConstraints);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfBlock* block)
|
2022-07-26 13:27:03 -04:00
|
|
|
{
|
2019-08-23 11:56:54 -07:00
|
|
|
if (WantsSkipParentMethod(block))
|
|
|
|
return;
|
|
|
|
if (block->mOpenBrace != NULL)
|
|
|
|
Visit(block->mOpenBrace);
|
|
|
|
if (block->mCloseBrace != NULL)
|
|
|
|
Visit(block->mCloseBrace);
|
|
|
|
VisitMembers(block);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfRootNode* rootNode)
|
|
|
|
{
|
|
|
|
// Clear off the flags at the end
|
|
|
|
ModifyFlags(mParser->mRootNode->GetSrcEnd(), mParser->mOrigSrcLength, 0, 0);
|
|
|
|
|
2022-07-26 13:27:03 -04:00
|
|
|
VisitMembers(rootNode);
|
2019-08-23 11:56:54 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfInlineAsmStatement* asmStmt)
|
|
|
|
{
|
|
|
|
if (asmStmt->mOpenBrace != NULL)
|
|
|
|
Visit(asmStmt->mOpenBrace);
|
|
|
|
if (asmStmt->mCloseBrace != NULL)
|
|
|
|
Visit(asmStmt->mCloseBrace);
|
2022-07-26 13:27:03 -04:00
|
|
|
|
2019-08-23 11:56:54 -07:00
|
|
|
//VisitMembers(asmStmt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BfSourceClassifier::Visit(BfInlineAsmInstruction* asmInst)
|
|
|
|
{
|
|
|
|
//VisitMembers(asmInst);
|
|
|
|
}
|