本文整理汇总了C++中Token::GetTokenKindString方法的典型用法代码示例。如果您正苦于以下问题:C++ Token::GetTokenKindString方法的具体用法?C++ Token::GetTokenKindString怎么用?C++ Token::GetTokenKindString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Token
的用法示例。
在下文中一共展示了Token::GetTokenKindString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintList
void NativeParserTest::PrintList()
{
const TokenList* tokens = m_Parser.GetTokenTree()->GetTokens();
for (TokenList::const_iterator it=tokens->begin(); it!=tokens->end(); ++it)
{
Token* token = (*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);
}
}
}
示例2: 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()))));
}
}
示例3: OnSave
void CCDebugInfo::OnSave(wxCommandEvent& /*event*/)
{
TokensTree* tokens = m_Parser->GetTokensTree();
wxArrayString saveWhat;
saveWhat.Add(_("Dump the tokens tree"));
saveWhat.Add(_("Dump the file list"));
saveWhat.Add(_("Dump the list of include directories"));
saveWhat.Add(_("Dump the token list of files"));
int sel = wxGetSingleChoiceIndex(_("What do you want to save?"),
_("CC Debug Info"), saveWhat, this);
switch (sel)
{
case -1:
// cancelled
return;
case 0:
{
wxString tt;
{ // life time of wxWindowDisabler/wxBusyInfo
wxWindowDisabler disableAll;
wxBusyInfo running(_("Obtaining tokens tree... please wait (this may take several seconds)..."),
Manager::Get()->GetAppWindow());
tt = tokens->m_Tree.dump();
}
SaveCCDebugInfo(_("Save tokens tree"), tt);
}
break;
case 1:
{
wxString files;
for (size_t i = 0; i < tokens->m_FilenamesMap.size(); ++i)
{
wxString file = tokens->m_FilenamesMap.GetString(i);
if (!file.IsEmpty())
files += file + _T("\r\n");
}
SaveCCDebugInfo(_("Save file list"), files);
}
break;
case 2:
{
wxString dirs;
const wxArrayString& dirsArray = m_Parser->GetIncludeDirs();
for (size_t i = 0; i < dirsArray.GetCount(); ++i)
{
const wxString& dir = dirsArray[i];
if (!dir.IsEmpty())
dirs += dir + _T("\r\n");
}
SaveCCDebugInfo(_("Save list of include directories"), dirs);
}
break;
case 3:
{
wxString fileTokens;
{
wxWindowDisabler disableAll;
wxBusyInfo running(_("Obtaining tokens tree... please wait (this may take several seconds)..."),
Manager::Get()->GetAppWindow());
for (size_t i = 0; i < tokens->m_FilenamesMap.size(); ++i)
{
const wxString file = tokens->m_FilenamesMap.GetString(i);
if (!file.IsEmpty())
{
fileTokens += file + _T("\r\n");
TokenIdxSet result;
tokens->FindTokensInFile(file, result, tkUndefined);
for (TokenIdxSet::iterator it = result.begin(); it != result.end(); ++it)
{
Token* token = tokens->at(*it);
fileTokens << token->GetTokenKindString() << _T(" ");
if (token->m_TokenKind == tkFunction)
fileTokens << token->m_Name << token->GetFormattedArgs() << _T("\t");
else
fileTokens << token->DisplayName() << _T("\t");
fileTokens << _T("[") << token->m_Line << _T(",") << token->m_ImplLine << _T("]");
fileTokens << _T("\r\n");
}
}
fileTokens += _T("\r\n");
}
}
SaveCCDebugInfo(_("Save token list of files"), fileTokens);
}
break;
default:
cbMessageBox(_("Invalid selection."), _("CC Debug Info"));
}
}