本文整理汇总了C++中TokenIdxSet::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ TokenIdxSet::insert方法的具体用法?C++ TokenIdxSet::insert怎么用?C++ TokenIdxSet::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TokenIdxSet
的用法示例。
在下文中一共展示了TokenIdxSet::insert方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindTokensInFile
size_t ParserBase::FindTokensInFile(const wxString& filename, TokenIdxSet& result, short int kindMask)
{
result.clear();
size_t tokens_found = 0;
TRACE(_T("Parser::FindTokensInFile() : Searching for file '%s' in tokens tree..."), filename.wx_str());
CC_LOCKER_TRACK_TT_MTX_LOCK(s_TokenTreeMutex)
TokenIdxSet tmpresult;
if ( m_TokenTree->FindTokensInFile(filename, tmpresult, kindMask) )
{
for (TokenIdxSet::const_iterator it = tmpresult.begin(); it != tmpresult.end(); ++it)
{
const Token* token = m_TokenTree->at(*it);
if (token)
result.insert(*it);
}
tokens_found = result.size();
}
CC_LOCKER_TRACK_TT_MTX_UNLOCK(s_TokenTreeMutex)
return tokens_found;
}
示例2: 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);
}
}
}
示例3: FindMatches
size_t TokensTree::FindMatches(const cc_string& s,TokenIdxSet& result,bool caseSensitive,bool is_prefix, int kindMask)
{
set<size_t> lists;
result.clear();
int numitems = m_Tree.FindMatches(s,lists,caseSensitive,is_prefix);
if(!numitems)
return 0;
// now the lists contains indexes to all the matching keywords
TokenIdxSet* curset;
set<size_t>::iterator it;
TokenIdxSet::iterator it2;
// first loop will find all the keywords
for(it = lists.begin(); it != lists.end(); it++)
{
curset = &(m_Tree.GetItemAtPos(*it));
// second loop will get all the items maped by the same keyword,
// for example, we have ClassA::foo, ClassB::foo ...
for(it2 = curset->begin();it2 != curset->end(); it2++)
{
if (kindMask == 0xffff || (at(*it)->m_TokenKind & kindMask))
result.insert(*it2);
}
}
return result.size();
}
示例4: FindMatches
size_t TokenTree::FindMatches(const wxString& query, TokenIdxSet& result, bool caseSensitive, bool is_prefix, TokenKind kindMask)
{
result.clear();
std::set<size_t> lists;
int numitems = m_Tree.FindMatches(query, lists, caseSensitive, is_prefix);
if (!numitems)
return 0;
// now the lists contains indexes to all the matching keywords
// first loop will find all the keywords
for (std::set<size_t>::const_iterator it = lists.begin(); it != lists.end(); ++it)
{
const TokenIdxSet* curset = &(m_Tree.GetItemAtPos(*it));
// second loop will get all the items mapped by the same keyword,
// for example, we have ClassA::foo, ClassB::foo ...
if (curset)
{
for (TokenIdxSet::const_iterator it2 = curset->begin(); it2 != curset->end(); ++it2)
{
const Token* token = at(*it2);
if ( token
&& ( (kindMask == tkUndefined)
|| (token->m_TokenKind & kindMask) ) )
result.insert(*it2);
}
}
}
return result.size();
}
示例5: OnFindClick
void CCDebugInfo::OnFindClick(wxCommandEvent& /*event*/)
{
TokensTree* tokens = m_Parser->GetTokensTree();
wxString search = txtFilter->GetValue();
m_Token = 0;
// first determine if the user entered an ID or a search mask
long unsigned id;
if (search.ToULong(&id, 10))
{
// easy; ID
m_Token = tokens->at(id);
}
else
{
// find all matching tokens
TokenIdxSet result;
for (size_t i = 0; i < tokens->size(); ++i)
{
Token* token = tokens->at(i);
if (token && token->m_Name.Matches(search))
result.insert(i);
}
// a single result?
if (result.size() == 1)
{
m_Token = tokens->at(*(result.begin()));
}
else
{
// fill a list and ask the user which token to display
wxArrayString arr;
wxArrayInt intarr;
for (TokenIdxSet::iterator it = result.begin(); it != result.end(); ++it)
{
Token* token = tokens->at(*it);
arr.Add(token->DisplayName());
intarr.Add(*it);
}
int sel = wxGetSingleChoiceIndex(_("Please make a selection:"), _("Multiple matches"), arr, this);
if (sel == -1)
return;
m_Token = tokens->at(intarr[sel]);
}
}
DisplayTokenInfo();
}
示例6: FindMatches
size_t TokensTree::FindMatches(const wxString& s,TokenIdxSet& result,bool caseSensitive,bool is_prefix, int kindMask)
{
set<size_t> lists;
result.clear();
int numitems = m_Tree.FindMatches(s,lists,caseSensitive,is_prefix);
if(!numitems)
return 0;
TokenIdxSet* curset;
set<size_t>::iterator it;
TokenIdxSet::iterator it2;
for(it = lists.begin(); it != lists.end(); it++)
{
curset = &(m_Tree.GetItemAtPos(*it));
for(it2 = curset->begin();it2 != curset->end(); it2++)
{
if (kindMask == 0xffff || (at(*it)->m_TokenKind & kindMask))
result.insert(*it2);
}
}
return result.size();
}
示例7: FindTokensInFile
size_t ParserBase::FindTokensInFile(const wxString& fileName, TokenIdxSet& result, short int kindMask)
{
result.clear();
wxString file = UnixFilename(fileName);
TRACE(_T("Parser::FindTokensInFile() : Searching for file '%s' in tokens tree..."), file.wx_str());
TRACK_THREAD_LOCKER(s_TokensTreeCritical);
wxCriticalSectionLocker locker(s_TokensTreeCritical);
THREAD_LOCKER_SUCCESS(s_TokensTreeCritical);
TokenIdxSet tmpresult;
if ( !m_TokensTree->FindTokensInFile(file, tmpresult, kindMask) )
return 0;
for (TokenIdxSet::iterator it = tmpresult.begin(); it != tmpresult.end(); ++it)
{
Token* token = m_TokensTree->at(*it);
if (token)
result.insert(*it);
}
return result.size();
}
示例8: FindTokensInFile
size_t TokenTree::FindTokensInFile(const wxString& filename, TokenIdxSet& result, short int kindMask)
{
result.clear();
// get file idx
wxString f(filename); while (f.Replace(_T("\\"),_T("/"))) { ; }
if ( !m_FilenameMap.HasItem(f) )
{
// CCLogger::Get()->DebugLog(F(_T("TokenTree::FindTokensInFile() : File '%s' not found in file names map."), f.wx_str()));
TRACE(_T("TokenTree::FindTokensInFile() : File '%s' not found in file names map."), f.wx_str());
return 0;
}
int idx = m_FilenameMap.GetItemNo(f);
// now get the tokens set matching this file idx
TokenFileMap::iterator itf = m_FileMap.find(idx);
if (itf == m_FileMap.end())
{
// CCLogger::Get()->DebugLog(F(_T("TokenTree::FindTokensInFile() : No tokens found for file '%s' (index %d)."), f.wx_str(), idx));
TRACE(_T("TokenTree::FindTokensInFile() : No tokens found for file '%s' (index %d)."), f.wx_str(), idx);
return 0;
}
// loop all results and add to final result set after filtering on token kind
TokenIdxSet& tokens = itf->second;
for (TokenIdxSet::const_iterator it = tokens.begin(); it != tokens.end(); ++it)
{
const Token* token = at(*it);
if (token && (kindMask & token->m_TokenKind))
result.insert(*it);
}
// CCLogger::Get()->DebugLog(F(_T("TokenTree::FindTokensInFile() : Found %lu results for file '%s'."), static_cast<unsigned long>(result.size()), f.wx_str()));
TRACE(_T("TokenTree::FindTokensInFile() : Found %lu results for file '%s'."), static_cast<unsigned long>(result.size()), f.wx_str());
return result.size();
}
示例9: FindTokensInFile
size_t TokensTree::FindTokensInFile(const cc_string& file, TokenIdxSet& result, short int kindMask)
{
result.clear();
// get file idx
if (!m_FilenamesMap.HasItem(file))
return 0;
int idx = m_FilenamesMap.GetItemIdx(file);
// now get the tokens set matching this file idx
TokenFilesMap::iterator itf = m_FilesMap.find(idx);
if (itf == m_FilesMap.end())
return 0;
TokenIdxSet& tokens = itf->second;
// loop all results and add to final result set after filtering on token kind
for (TokenIdxSet::iterator it = tokens.begin(); it != tokens.end(); ++it)
{
Token* token = at(*it);
if (kindMask & token->m_TokenKind)
result.insert(*it);
}
return result.size();
}
示例10: ParseAndCodeCompletion
//.........这里部分代码省略.........
match_doc = str.Mid(pos + 4);
str = str.Mid(0, pos);
}
// find the second "//", the string after the second double slash are the
// the result should be listed
pos = str.Find(_T("//"));
if (pos != wxNOT_FOUND)
{
expression = str.Mid(0, pos);
match = str.Mid(pos + 2);// the remaining string
}
else
{
expression = str;
if (!match_doc.IsEmpty())
match = _T("* @doxygen");
}
expression.Trim(true).Trim(false);
match.Trim(true).Trim(false);
match_doc.Trim(true).Trim(false);
wxArrayString suggestList;
// the match can have many items, like: AAA,BBBB
wxStringTokenizer tkz(match, wxT(","));
while ( tkz.HasMoreTokens() )
{
wxString token = tkz.GetNextToken().Trim(true).Trim(false);
suggestList.Add(token);
}
TokenIdxSet searchScope;
searchScope.insert(-1);
TokenIdxSet result;
TestExpression(expression,searchScope,result);
// loop the suggestList to see it is in the result Tokens
for (size_t i=0; i<suggestList.GetCount(); i++)
{
wxString element = suggestList[i];
bool pass = false; // pass the test?
for (TokenIdxSet::const_iterator it = result.begin();
it != result.end();
++it)
{
const Token* token = m_Parser.GetTokenTree()->at(*it);
if (!token || token->m_Name.IsEmpty())
continue;
if (element.IsSameAs(token->m_Name) || element[0] == '*')
{
// no doxygen documents, only matches the suggestion list
if (match_doc.IsEmpty())
{
message = wxString::Format(_T("+ PASS: %s %s"), expression.wx_str(), element.wx_str());
testResult << message << wxT("\n");
wxLogMessage(message);
pass = true;
++passCount;
}
else
{
// check whether doxygen documents are matched
if (token->m_Doc.Contains(match_doc)
|| (match_doc[0] == '*' && match_doc.Len() == 1 && !token->m_Doc.IsEmpty())
示例11: Start
//.........这里部分代码省略.........
m_LogCount = 0;
m_LogCtrl->Clear();
CCTest::Get()->Clear(); // initial clearance
// make sure not to over-write an existing file (in case content had changed)
wxString tf(wxFileName::CreateTempFileName(wxT("cc")));
// make the parser recognise it as header file:
wxFileName fn(tf); fn.SetExt(wxT("h")); wxRemoveFile(tf); // no longer needed
if (m_Control->SaveFile(fn.GetFullPath()))
CCTestAppGlobal::s_fileQueue.Add(fn.GetFullPath());
else
AppendToLog(_T("Unable to parse buffer (could not convert to file)."));
AppendToLog(_T("--------------M-a-i-n--L-o-g--------------\r\n\r\n"));
// parse file from the queue one-by-one
while (!CCTestAppGlobal::s_fileQueue.IsEmpty())
{
wxString file = CCTestAppGlobal::s_fileQueue.Item(0);
CCTestAppGlobal::s_fileQueue.Remove(file);
if (file.IsEmpty()) continue;
AppendToLog(_T("-----------I-n-t-e-r-i-m--L-o-g-----------"));
m_CurrentFile = file;
m_ProgDlg->Update(-1, m_CurrentFile);
m_StatuBar->SetStatusText(m_CurrentFile);
// This is the core parse stage for files
CCTest::Get()->Start(m_CurrentFile);
CCTestAppGlobal::s_filesParsed.Add(m_CurrentFile); // done
}
// don't forget to remove the temporary file (w/ ".h" extension)
wxRemoveFile(fn.GetFullPath());
m_ProgDlg->Update(-1, wxT("Creating tree log..."));
AppendToLog(_T("--------------T-r-e-e--L-o-g--------------\r\n"));
CCTest::Get()->PrintTree();
m_ProgDlg->Update(-1, wxT("Creating list log..."));
AppendToLog(_T("--------------L-i-s-t--L-o-g--------------\r\n"));
CCTest::Get()->PrintList();
if (m_DoTreeCtrl->IsChecked())
{
m_ProgDlg->Update(-1, wxT("Serializing tree..."));
Freeze();
m_TreeCtrl->SetValue( CCTest::Get()->SerializeTree() );
Thaw();
}
// Here we are going to test the expression solving algorithm
NativeParserTest nativeParserTest;
wxString exp = _T("obj.m_Member1");
TokenIdxSet searchScope;
searchScope.insert(-1);
TokenIdxSet result;
TokenTree *tree = CCTest::Get()->GetTokenTree();
nativeParserTest.TestExpression(exp,
tree,
searchScope,
result );
wxLogMessage(_T("Result have %lu matches"), static_cast<unsigned long>(result.size()));
for (TokenIdxSet::iterator it=result.begin(); it!=result.end(); ++it)
{
Token* token = tree->at(*it);
if (token)
{
wxString log;
log << token->GetTokenKindString() << _T(" ")
<< token->DisplayName() << _T("\t[")
<< token->m_Line << _T(",")
<< token->m_ImplLine << _T("]");
CCLogger::Get()->Log(log);
}
}
if (m_ProgDlg) { delete m_ProgDlg; m_ProgDlg = 0; }
if ( !IsShown() ) Show();
TokenTree* tt = CCTest::Get()->GetTokenTree();
if (tt)
{
AppendToLog((wxString::Format(_("The parser contains %lu tokens, found in %lu files."),
static_cast<unsigned long>(tt->size()), static_cast<unsigned long>(tt->m_FileMap.size()))));
}
}