本文整理汇总了C++中Token::GetSelf方法的典型用法代码示例。如果您正苦于以下问题:C++ Token::GetSelf方法的具体用法?C++ Token::GetSelf怎么用?C++ Token::GetSelf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token::GetSelf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RecalcData
void TokensTree::RecalcData()
{
TRACE(cc_text("RecalcData() : Calculating full inheritance tree."));
// first loop to convert ancestors string to token indices for each token
for (size_t i = 0; i < size(); ++i)
{
Token* token = at(i);
if (!token)
continue;
if (!(token->m_TokenKind & (tkClass | tkTypedef | tkEnum)))
continue;
if (token->m_AncestorsString.empty())
continue;
// only local symbols might change inheritance
// if (!token->m_IsLocal)
// continue;
token->m_DirectAncestors.clear();
token->m_Ancestors.clear();
TRACE(cc_text("RecalcData() : Token %s, Ancestors %s"),
token->m_Name.wx_str(),
token->m_AncestorsString.wx_str());
StringTokenizer tkz(token->m_AncestorsString, cc_text(","));
while (tkz.HasMoreTokens())
{
cc_string ancestor = tkz.GetNextToken();
if (ancestor.empty() || ancestor == token->m_Name)
continue;
TRACE(cc_text("RecalcData() : Ancestor %s"), ancestor.wx_str());
// ancestors might contain namespaces, e.g. NS::Ancestor
if (ancestor.find(cc_text("::")) != cc_string::npos)
{
Token* ancestorToken = 0;
StringTokenizer anctkz(ancestor, cc_text("::"));
while (anctkz.HasMoreTokens())
{
cc_string ns = anctkz.GetNextToken();
if (!ns.empty())
{
int ancestorIdx = TokenExists(ns, ancestorToken ? ancestorToken->GetSelf() : -1, tkNamespace | tkClass | tkTypedef);
ancestorToken = at(ancestorIdx);
// ancestorToken = token->HasChildToken(ns, tkNamespace | tkClass);
if (!ancestorToken) // unresolved
break;
}
}
if (ancestorToken && ancestorToken != token && ancestorToken->m_TokenKind == tkClass)// && !ancestorToken->m_IsTypedef)
{
TRACE(cc_text("RecalcData() : Resolved to %s"), ancestorToken->m_Name.wx_str());
token->m_Ancestors.insert(ancestorToken->GetSelf());
ancestorToken->m_Descendants.insert(i);
TRACE(cc_text("RecalcData() : + '%s'"), ancestorToken->m_Name.wx_str());
}
else
TRACE(cc_text("RecalcData() : ! '%s' (unresolved)"), ancestor.wx_str());
}
else // no namespaces in ancestor
{
// accept multiple matches for inheritance
TokenIdxSet result;
FindMatches(ancestor, result, true, false);
for (TokenIdxSet::iterator it = result.begin(); it != result.end(); it++)
{
Token* ancestorToken = at(*it);
// only classes take part in inheritance
if ( ancestorToken
&& (ancestorToken != token)
&& ( (ancestorToken->m_TokenKind == tkClass)
|| (ancestorToken->m_TokenKind == tkEnum)
|| (ancestorToken->m_TokenKind == tkTypedef) ) ) // && !ancestorToken->m_IsTypedef)
{
token->m_Ancestors.insert(*it);
ancestorToken->m_Descendants.insert(i);
TRACE(cc_text("RecalcData() : + '%s'"), ancestorToken->m_Name.wx_str());
}
}
#if TOKEN_DEBUG_OUTPUT
if (result.empty())
TRACE(_T("RecalcData() : ! '%s' (unresolved)"), ancestor.wx_str());
#endif
}
}
token->m_DirectAncestors = token->m_Ancestors;
if (!token->m_IsLocal) // global symbols are linked once
{
TRACE(cc_text("RecalcData() : Removing ancestor string from %s"), token->m_Name.wx_str(), token->m_Name.wx_str());
token->m_AncestorsString.clear();
}
}
// second loop to calculate full inheritance for each token
for (size_t i = 0; i < size(); ++i)
//.........这里部分代码省略.........
示例2: RecalcData
void TokensTree::RecalcData()
{
// Manager::Get()->GetMessageManager()->DebugLog(_T("Calculating full inheritance tree"));
// first loop to convert ancestors string to token indices for each token
for (size_t i = 0; i < size(); ++i)
{
Token* token = at(i);
if (!token)
continue;
if (!(token->m_TokenKind & (tkClass | tkTypedef | tkEnum)))
continue;
if (token->m_AncestorsString.IsEmpty())
continue;
// only local symbols might change inheritance
// if (!token->m_IsLocal)
// continue;
token->m_DirectAncestors.clear();
token->m_Ancestors.clear();
// Manager::Get()->GetMessageManager()->DebugLog(_T(" : '%s'"), token->m_Name.c_str());
//Manager::Get()->GetMessageManager()->DebugLog("Token %s, Ancestors %s", token->m_Name.c_str(), token->m_AncestorsString.c_str());
wxStringTokenizer tkz(token->m_AncestorsString, _T(","));
while (tkz.HasMoreTokens())
{
wxString ancestor = tkz.GetNextToken();
if (ancestor.IsEmpty() || ancestor == token->m_Name)
continue;
// Manager::Get()->GetMessageManager()->DebugLog(_T("Ancestor %s"), ancestor.c_str());
// ancestors might contain namespaces, e.g. NS::Ancestor
if (ancestor.Find(_T("::")) != wxNOT_FOUND)
{
Token* ancestorToken = 0;
wxStringTokenizer anctkz(ancestor, _T("::"));
while (anctkz.HasMoreTokens())
{
wxString ns = anctkz.GetNextToken();
if (!ns.IsEmpty())
{
int ancestorIdx = TokenExists(ns, ancestorToken ? ancestorToken->GetSelf() : -1, tkNamespace | tkClass | tkTypedef);
ancestorToken = at(ancestorIdx);
// ancestorToken = token->HasChildToken(ns, tkNamespace | tkClass);
if (!ancestorToken) // unresolved
break;
}
}
if (ancestorToken && ancestorToken != token && ancestorToken->m_TokenKind == tkClass)// && !ancestorToken->m_IsTypedef)
{
// Manager::Get()->GetMessageManager()->DebugLog(_T("Resolved to %s"), ancestorToken->m_Name.c_str());
token->m_Ancestors.insert(ancestorToken->GetSelf());
ancestorToken->m_Descendants.insert(i);
// Manager::Get()->GetMessageManager()->DebugLog(_T(" + '%s'"), ancestorToken->m_Name.c_str());
}
// else
// Manager::Get()->GetMessageManager()->DebugLog(_T(" ! '%s' (unresolved)"), ancestor.c_str());
}
else // no namespaces in ancestor
{
// accept multiple matches for inheritance
TokenIdxSet result;
FindMatches(ancestor, result, true, false);
for (TokenIdxSet::iterator it = result.begin(); it != result.end(); it++)
{
Token* ancestorToken = at(*it);
// only classes take part in inheritance
if (ancestorToken && ancestorToken != token && (ancestorToken->m_TokenKind == tkClass || ancestorToken->m_TokenKind == tkEnum))// && !ancestorToken->m_IsTypedef)
{
token->m_Ancestors.insert(*it);
ancestorToken->m_Descendants.insert(i);
// Manager::Get()->GetMessageManager()->DebugLog(_T(" + '%s'"), ancestorToken->m_Name.c_str());
}
}
// if (result.empty())
// Manager::Get()->GetMessageManager()->DebugLog(_T(" ! '%s' (unresolved)"), ancestor.c_str());
}
}
token->m_DirectAncestors = token->m_Ancestors;
if (!token->m_IsLocal) // global symbols are linked once
{
//Manager::Get()->GetMessageManager()->DebugLog("Removing ancestor string from %s", token->m_Name.c_str(), token->m_Name.c_str());
token->m_AncestorsString.Clear();
}
}
// second loop to calculate full inheritance for each token
for (size_t i = 0; i < size(); ++i)
{
Token* token = at(i);
if (!token)
continue;
if (!(token->m_TokenKind & (tkClass | tkTypedef | tkEnum)))
continue;
// recalc
TokenIdxSet result;
//.........这里部分代码省略.........