本文整理汇总了C++中TokenIdxSet::find方法的典型用法代码示例。如果您正苦于以下问题:C++ TokenIdxSet::find方法的具体用法?C++ TokenIdxSet::find怎么用?C++ TokenIdxSet::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TokenIdxSet
的用法示例。
在下文中一共展示了TokenIdxSet::find方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RecalcFullInheritance
// caches the inheritance info for each token (recursive function)
void TokensTree::RecalcFullInheritance(int parentIdx, TokenIdxSet& result)
{
// no parent token? no ancestors...
if (parentIdx == -1)
return;
// no parent token? no ancestors...
Token* ancestor = at(parentIdx);
if (!ancestor)
return;
// only classes take part in inheritance
if (!(ancestor->m_TokenKind & (tkClass | tkTypedef)))
return;
TRACE(cc_text("RecalcFullInheritance() : Anc: '%s'"), ancestor->m_Name.wx_str());
// for all its ancestors
for (TokenIdxSet::iterator it = ancestor->m_Ancestors.begin(); it != ancestor->m_Ancestors.end(); it++)
{
if (*it != -1 && // not global scope
*it != parentIdx && // not the same token (avoid infinite loop)
result.find(*it) == result.end()) // not already in the set (avoid infinite loop)
{
// add it to the set
result.insert(*it);
// and recurse for its ancestors
RecalcFullInheritance(*it, result);
}
}
}
示例2: VerifyResult
size_t CodeRefactoring::VerifyResult(const TokenIdxSet& targetResult, const wxString& targetText,
bool isLocalVariable)
{
EditorManager* edMan = Manager::Get()->GetEditorManager();
cbEditor* editor = edMan->GetBuiltinActiveEditor();
if (!editor)
return 0;
const Token* parentOfLocalVariable = nullptr;
if (isLocalVariable)
{
TokenTree* tree = m_NativeParser.GetParser().GetTokenTree();
CC_LOCKER_TRACK_TT_MTX_LOCK(s_TokenTreeMutex)
const Token* token = tree->at(*targetResult.begin());
parentOfLocalVariable = tree->at(token->m_ParentIndex);
CC_LOCKER_TRACK_TT_MTX_UNLOCK(s_TokenTreeMutex)
}
// now that list is filled, we'll search
cbStyledTextCtrl* control = new cbStyledTextCtrl(editor->GetParent(), wxID_ANY, wxDefaultPosition,
wxSize(0, 0));
control->Show(false);
// styled the text to support control->GetStyleAt()
cbEditor::ApplyStyles(control);
EditorColourSet edColSet;
size_t totalCount = 0;
for (SearchDataMap::const_iterator it = m_SearchDataMap.begin(); it != m_SearchDataMap.end(); ++it)
totalCount += it->second.size();
// let's create a progress dialog because it might take some time depending on the files count
wxProgressDialog* progress = new wxProgressDialog(_("Code Refactoring"),
_("Please wait while verifying result..."),
totalCount,
Manager::Get()->GetAppWindow(),
wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_CAN_ABORT);
PlaceWindow(progress);
size_t task = totalCount;
TokenIdxSet result;
bool userBreak = false;
for (SearchDataMap::iterator it = m_SearchDataMap.begin(); it != m_SearchDataMap.end();)
{
// check if the file is already opened in built-in editor and do search in it
cbEditor* ed = edMan->IsBuiltinOpen(it->first);
if (ed)
control->SetText(ed->GetControl()->GetText());
else // else load the file in the control
{
EncodingDetector detector(it->first);
if (!detector.IsOK())
{
task -= it->second.size();
m_SearchDataMap.erase(it++);
continue; // failed
}
control->SetText(detector.GetWxStr());
}
// apply the corlor setting
edColSet.Apply(editor->GetLanguage(), control);
ccSearchData searchData = { control, it->first };
for (SearchDataList::iterator itList = it->second.begin(); itList != it->second.end();)
{
// update the progress bar
if (!progress->Update(totalCount - (--task)))
{
userBreak = true;
break; // user pressed "Cancel"
}
// skip string or comment
const int style = control->GetStyleAt(itList->pos);
if (control->IsString(style) || control->IsComment(style))
{
it->second.erase(itList++);
continue;
}
// do cc search
const int endOfWord = itList->pos + targetText.Len();
control->GotoPos(endOfWord);
m_NativeParser.MarkItemsByAI(&searchData, result, true, false, true, endOfWord);
if (result.empty())
{
it->second.erase(itList++);
continue;
}
// verify result
TokenIdxSet::const_iterator findIter = targetResult.begin();
for (; findIter != targetResult.end(); ++findIter)
{
if (result.find(*findIter) != result.end())
break;
//.........这里部分代码省略.........