Code::Blocks  SVN r11506
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
TokenTree Class Reference

a container class to hold all the Tokens getting from parsing stage More...

#include <tokentree.h>

Collaboration diagram for TokenTree:

Public Member Functions

 TokenTree ()
 
virtual ~TokenTree ()
 
void clear ()
 
Tokenoperator[] (int idx)
 
Tokenat (int idx)
 
const Tokenat (int idx) const
 
size_t size ()
 total size of std::vector<Token*> More...
 
size_t realsize ()
 some position of the std::vector<Token*> are not used, so the real size maybe a bit smaller than the total size More...
 
bool empty ()
 check to see whether the TokenTree is empty More...
 
int insert (Token *newToken)
 add a new Token instance to the TokenTree More...
 
int insert (int loc, Token *newToken)
 add a new Token instance to the TokenTree More...
 
int erase (int loc)
 remove the Token specified by the index More...
 
void erase (Token *oldToken)
 remove the Token from the TokenTree More...
 
void Clear ()
 
void RecalcFreeList ()
 collect the unused slots in the std::vector<Token*> More...
 
void RenameToken (Token *token, const wxString &newName)
 only the token's name need to be changed, thus update the index map of the TokenTree More...
 
void RecalcInheritanceChain (Token *token)
 convert the Token's ancestor string to it's IDs this contains recursive calls, for example in such code More...
 
int TokenExists (const wxString &name, int parent, short int kindMask)
 query tokens by names More...
 
int TokenExists (const wxString &name, const wxString &baseArgs, int parent, TokenKind kind)
 query tokens by names More...
 
int TokenExists (const wxString &name, const TokenIdxSet &parents, short int kindMask)
 query tokens by names More...
 
int TokenExists (const wxString &name, const wxString &baseArgs, const TokenIdxSet &parents, TokenKind kind)
 query tokens by names More...
 
size_t FindMatches (const wxString &query, TokenIdxSet &result, bool caseSensitive, bool is_prefix, TokenKind kindMask=tkUndefined)
 find a collection of matched tokens More...
 
size_t FindTokensInFile (const wxString &filename, TokenIdxSet &result, short int kindMask)
 find tokens belong to a specified file More...
 
void RemoveFile (const wxString &filename)
 remove tokens belong to the file More...
 
void RemoveFile (int fileIndex)
 remove tokens belong to the file More...
 
const TokenListGetTokens () const
 Protected access to internal lists / maps. More...
 
const TokenIdxSetGetGlobalNameSpaces () const
 all kinds of tokens under global name spaces More...
 
const TokenFileMapGetFilesMap () const
 
const TokenIdxSetGetTokensBelongToFile (size_t fileIdx) const
 
const TokenFileSetGetFilesToBeReparsed () const
 
size_t GetFileMapSize () const
 
void InsertTokenBelongToFile (size_t fileIdx, int tokenIdx)
 
void EraseFileMapInFileMap (size_t fileIdx)
 
size_t GetFileStatusCountForIndex (size_t fileIdx) const
 
void EraseFileStatusByIndex (size_t fileIdx)
 
void EraseFilesToBeReparsedByIndex (size_t fileIdx)
 
size_t InsertFileOrGetIndex (const wxString &filename)
 put the filename in the m_FilenameMap, and return the file index, if this file is already in the m_FilenameMap, it just return the file index. More...
 
size_t GetFileMatches (const wxString &filename, std::set< size_t > &result, bool caseSensitive, bool is_prefix)
 
size_t GetFileIndex (const wxString &filename)
 
const wxString GetFilename (size_t fileIdx) const
 
size_t ReserveFileForParsing (const wxString &filename, bool preliminary=false)
 mark a file to be parsed. More...
 
void FlagFileForReparsing (const wxString &filename)
 mark the file as "need to be reparsed" status, usually happens that this file is saved(updated) so a reparse need to be done. More...
 
void FlagFileAsParsed (const wxString &filename)
 mark the file status as fpsDone, since parsing this file is done More...
 
bool IsFileParsed (const wxString &filename)
 is the file name is in the tokentree, and it's status is either assigned or beingparsed or done also, should make sure that this file is not marked as "need to be reparsed". More...
 
void MarkFileTokensAsLocal (const wxString &filename, bool local=true, void *userData=0)
 mark the tokens so that they are associated with a C::B project More...
 
void MarkFileTokensAsLocal (size_t fileIdx, bool local=true, void *userData=0)
 mark the tokens so that they are associated with a C::B project More...
 
void AppendDocumentation (int tokenIdx, unsigned int fileIdx, const wxString &doc)
 associate a document string with the token More...
 
wxString GetDocumentation (int tokenIdx)
 get the document string associated with the token More...
 

Public Attributes

size_t m_TokenTicketCount
 

Protected Member Functions

TokenGetTokenAt (int idx)
 
Token const * GetTokenAt (int idx) const
 
int AddToken (Token *newToken, int forceidx=-1)
 
void RemoveToken (int idx)
 
void RemoveToken (Token *oldToken)
 
int AddTokenToList (Token *newToken, int forceidx=-1)
 add the Token pointer to the vector<Token*>, mostly the default value forceidx = -1 is used which add a new slot in the vector or reused an empty slot. More...
 
void RemoveTokenFromList (int idx)
 Remove the Token specified by the idx in the vector<Token*>, note the Token instance is destroyed, and the slot becomes empty. More...
 
void RecalcFullInheritance (int parentIdx, TokenIdxSet &result)
 
bool CheckChildRemove (const Token *token, int fileIdx)
 Check all the children belong this token should be removed. More...
 

Protected Attributes

TokenSearchTree m_Tree
 This is a string->TokenIndexSet map. More...
 
TokenList m_Tokens
 Contains the pointers to all the Token instances, it is just a std::vector<Token*>, the suggest way to access a Token instance is by first get its index in the m_Tokens, then get its address by m_Tokens[index], the reason we have such indirect access is that there are many Tokens which can reference each other, it is much safe using index instead of raw pointers. More...
 
TokenIdxList m_FreeTokens
 List of all the deleted (and available) tokens. More...
 
TokenIdxSet m_TopNameSpaces
 namespace tokens belongs to the global namespace More...
 
TokenIdxSet m_GlobalNameSpaces
 any tokens belong to the global namespace More...
 
TokenFilenameMap m_FilenameMap
 Map: file names -> file indices. More...
 
TokenFileMap m_FileMap
 Map: file indices -> sets of TokenIndexes. More...
 
TokenFileStatusMap m_FileStatusMap
 Map: file indices -> status. More...
 
TokenFileSet m_FilesToBeReparsed
 Set: file indices. More...
 

Friends

class CCDebugInfo
 
class CCTest
 
class CCTestFrame
 
class NativeParserTest
 

Detailed Description

a container class to hold all the Tokens getting from parsing stage

To query a Token, a unique index is needed, the index is actually position in the std::vector<Token*> (namely TokenList).

Definition at line 37 of file tokentree.h.

Constructor & Destructor Documentation

◆ TokenTree()

TokenTree::TokenTree ( )

◆ ~TokenTree()

TokenTree::~TokenTree ( )
virtual

Definition at line 69 of file tokentree.cpp.

References clear().

Member Function Documentation

◆ AddToken()

int TokenTree::AddToken ( Token newToken,
int  forceidx = -1 
)
protected

◆ AddTokenToList()

int TokenTree::AddTokenToList ( Token newToken,
int  forceidx = -1 
)
protected

add the Token pointer to the vector<Token*>, mostly the default value forceidx = -1 is used which add a new slot in the vector or reused an empty slot.

if forceidx >= 0, this means we need to replace the value in the specified slot index, the later case only happens we are re-construct the Tokentree from the cache. always return the used slot index in the vector.

Definition at line 485 of file tokentree.cpp.

References Token::m_AncestorsString, Token::m_Args, Token::m_BaseArgs, Token::m_BaseType, m_FreeTokens, Token::m_FullType, Token::m_Index, Token::m_Name, Token::m_TemplateArgument, m_Tokens, Token::m_TokenTree, and wxString::Shrink().

Referenced by AddToken().

◆ AppendDocumentation()

void TokenTree::AppendDocumentation ( int  tokenIdx,
unsigned int  fileIdx,
const wxString doc 
)

associate a document string with the token

Parameters
tokenIdxtoken index
fileIdxthe file index where the doc locates
docdocument string

Definition at line 936 of file tokentree.cpp.

References GetTokenAt(), Token::m_Doc, Token::m_FileIdx, Token::m_ImplDoc, Token::m_ImplFileIdx, and wxString::Shrink().

Referenced by EraseFilesToBeReparsedByIndex(), Tokenizer::SetLastTokenIdx(), and Tokenizer::SkipComment().

◆ at() [1/2]

Token* TokenTree::at ( int  idx)
inline

Definition at line 51 of file tokentree.h.

References GetTokenAt().

Referenced by ClassBrowserBuilderThread::AddAncestorsOf(), ClassBrowserBuilderThread::AddChildrenOf(), NativeParserBase::AddChildrenOfEnum(), NativeParserBase::AddChildrenOfUnnamed(), NativeParserBase::AddConstructors(), ClassBrowserBuilderThread::AddDescendantsOf(), Tokenizer::AddMacroDefinition(), ClassBrowserBuilderThread::AddNodes(), NativeParserBase::AddTemplateAlias(), ParserThread::CalcEnumExpression(), CheckChildRemove(), Tokenizer::CheckMacroUsageAndReplace(), NativeParserBase::CleanupSearchScope(), NativeParserBase::CollectSearchScopes(), NativeParserBase::ComputeCallTip(), ClassBrowserBuilderThread::CreateSpecialFolders(), NativeParserBase::DependsOnAllocator(), CCDebugInfo::DisplayTokenInfo(), ParserThread::DoAddToken(), CodeCompletion::DoAllMethodsImpl(), CodeCompletion::DoCodeComplete(), InsertClassMethodDlgHelper::DoFillMethodsFor(), CCDebugInfo::FillAncestors(), CCDebugInfo::FillChildren(), InsertClassMethodDlg::FillClasses(), CCDebugInfo::FillDescendants(), NativeParserBase::FindAIMatches(), NativeParserBase::FindCurrentFunctionScope(), NativeParser::FindCurrentFunctionStart(), FindMatches(), FindTokensInFile(), ParserBase::FindTokensInFile(), DocumentationHelper::GenerateHTML(), NativeParserBase::GenerateResultSet(), Token::GetNamespace(), CodeCompletion::GetTokenAt(), NativeParserBase::GetTokenFromCurrentLine(), Token::InheritsFrom(), ClassBrowserBuilderThread::Init(), NativeParserBase::IsAllocator(), NativeParserBase::IsChildOfUnnamedOrEnum(), DocumentationHelper::OnDocumentationLink(), CCDebugInfo::OnFindClick(), CodeCompletion::OnGotoDeclaration(), CodeCompletion::OnGotoFunction(), CCDebugInfo::OnSave(), ClassBrowser::OnSearch(), CodeRefactoring::Parse(), NativeParser::ParseBufferForUsingNamespace(), NativeParser::ParseFunctionArguments(), NativeParser::ParseLocalBlock(), NativeParserBase::PrettyPrintToken(), RecalcFullInheritance(), RecalcInheritanceChain(), RemoveFile(), ClassBrowserBuilderThread::RemoveInvalidNodes(), NativeParserBase::RemoveLastFunctionChildren(), NativeParserBase::ResolveExpression(), NativeParserBase::ResolveOperator(), ParserThread::ResolveTemplateMap(), ClassBrowserBuilderThread::TokenContainsChildrenOfKind(), ParserThread::TokenExists(), ClassBrowserBuilderThread::TokenMatchesFilter(), CodeCompletion::UpdateEditorSyntax(), and CodeRefactoring::VerifyResult().

◆ at() [2/2]

const Token* TokenTree::at ( int  idx) const
inline

Definition at line 52 of file tokentree.h.

References GetTokenAt(), realsize(), and size().

◆ CheckChildRemove()

bool TokenTree::CheckChildRemove ( const Token token,
int  fileIdx 
)
protected

Check all the children belong this token should be removed.

Parameters
tokenthe checked token pointer
fileIdxfile index the token belongs to
Returns
if true, we can safely remove the token

Definition at line 609 of file tokentree.cpp.

References at(), Token::m_Children, Token::m_FileIdx, Token::m_ImplFileIdx, and m_Tokens.

Referenced by RemoveFile().

◆ clear()

void TokenTree::clear ( )

◆ Clear()

void TokenTree::Clear ( )
inline

◆ empty()

bool TokenTree::empty ( )
inline

check to see whether the TokenTree is empty

Definition at line 63 of file tokentree.h.

References erase(), insert(), and size().

Referenced by NativeParserBase::AddTemplateAlias(), CodeCompletion::OnGotoFunction(), and NativeParserBase::ResolveOperator().

◆ erase() [1/2]

int TokenTree::erase ( int  loc)

remove the Token specified by the index

Definition at line 127 of file tokentree.cpp.

References m_Tokens, and RemoveToken().

Referenced by Token::DeleteAllChildren(), empty(), and Tokenizer::HandleUndefs().

◆ erase() [2/2]

void TokenTree::erase ( Token oldToken)

remove the Token from the TokenTree

Parameters
oldTokenthe token need to be removed, if success, the pointer is invalid after the function call

Definition at line 136 of file tokentree.cpp.

References RemoveToken().

◆ EraseFileMapInFileMap()

void TokenTree::EraseFileMapInFileMap ( size_t  fileIdx)
inline

Definition at line 217 of file tokentree.h.

References m_FileMap.

Referenced by Parser::RemoveFile().

◆ EraseFileStatusByIndex()

void TokenTree::EraseFileStatusByIndex ( size_t  fileIdx)
inline

Definition at line 227 of file tokentree.h.

References m_FileStatusMap.

Referenced by Parser::RemoveFile().

◆ EraseFilesToBeReparsedByIndex()

void TokenTree::EraseFilesToBeReparsedByIndex ( size_t  fileIdx)
inline

◆ FindMatches()

size_t TokenTree::FindMatches ( const wxString query,
TokenIdxSet result,
bool  caseSensitive,
bool  is_prefix,
TokenKind  kindMask = tkUndefined 
)

find a collection of matched tokens

Parameters
querysearch name
resultthe return collection token index
caseSensitivetrue if we need the case sensitive search for the query name
is_prefixtrue if the query is only a prefix of any matched token
kindMasktoken kind match mask
Returns
the number of matched tokens

Definition at line 266 of file tokentree.cpp.

References at(), BasicSearchTree::FindMatches(), SearchTree< T >::GetItemAtPos(), Token::m_TokenKind, m_Tree, and tkUndefined.

Referenced by Clear(), NativeParserBase::ComputeCallTip(), NativeParserBase::GenerateResultSet(), DocumentationHelper::OnDocumentationLink(), ClassBrowser::OnSearch(), RecalcInheritanceChain(), and ParserThread::ResolveTemplateMap().

◆ FindTokensInFile()

size_t TokenTree::FindTokensInFile ( const wxString filename,
TokenIdxSet result,
short int  kindMask 
)

find tokens belong to a specified file

Parameters
filenamesearch key
resultreturned tokens
kindMasktoken filter mask
Returns
the number of matched tokens

Definition at line 298 of file tokentree.cpp.

References _T, at(), BasicSearchTree::GetItemNo(), BasicSearchTree::HasItem(), m_FileMap, m_FilenameMap, Token::m_TokenKind, wxString::Replace(), TRACE, and wxString::wx_str().

Referenced by Clear(), ParserBase::FindTokensInFile(), and CCDebugInfo::OnSave().

◆ FlagFileAsParsed()

void TokenTree::FlagFileAsParsed ( const wxString filename)

mark the file status as fpsDone, since parsing this file is done

Definition at line 931 of file tokentree.cpp.

References fpsDone, InsertFileOrGetIndex(), and m_FileStatusMap.

Referenced by EraseFilesToBeReparsedByIndex(), and ParserThread::Parse().

◆ FlagFileForReparsing()

void TokenTree::FlagFileForReparsing ( const wxString filename)

mark the file as "need to be reparsed" status, usually happens that this file is saved(updated) so a reparse need to be done.

Definition at line 926 of file tokentree.cpp.

References InsertFileOrGetIndex(), and m_FilesToBeReparsed.

Referenced by EraseFilesToBeReparsedByIndex(), and Parser::Reparse().

◆ GetDocumentation()

wxString TokenTree::GetDocumentation ( int  tokenIdx)

get the document string associated with the token

Parameters
tokenIdxtoken index
Returns
wxString the document

Definition at line 960 of file tokentree.cpp.

References GetTokenAt(), Token::m_Doc, Token::m_ImplDoc, and wxEmptyString.

Referenced by EraseFilesToBeReparsedByIndex(), and DocumentationHelper::GenerateHTML().

◆ GetFileIndex()

size_t TokenTree::GetFileIndex ( const wxString filename)

◆ GetFileMapSize()

size_t TokenTree::GetFileMapSize ( ) const
inline

Definition at line 207 of file tokentree.h.

References m_FileMap.

Referenced by Parser::OnAllThreadsDone().

◆ GetFileMatches()

size_t TokenTree::GetFileMatches ( const wxString filename,
std::set< size_t > &  result,
bool  caseSensitive,
bool  is_prefix 
)

◆ GetFilename()

const wxString TokenTree::GetFilename ( size_t  fileIdx) const

◆ GetFilesMap()

const TokenFileMap* TokenTree::GetFilesMap ( ) const
inline

Definition at line 191 of file tokentree.h.

References m_FileMap.

◆ GetFileStatusCountForIndex()

size_t TokenTree::GetFileStatusCountForIndex ( size_t  fileIdx) const
inline

Definition at line 222 of file tokentree.h.

References m_FileStatusMap.

Referenced by Parser::RemoveFile().

◆ GetFilesToBeReparsed()

const TokenFileSet* TokenTree::GetFilesToBeReparsed ( ) const
inline

Definition at line 202 of file tokentree.h.

References m_FilesToBeReparsed.

Referenced by Parser::ReparseModifiedFiles().

◆ GetGlobalNameSpaces()

const TokenIdxSet* TokenTree::GetGlobalNameSpaces ( ) const
inline

all kinds of tokens under global name spaces

Definition at line 186 of file tokentree.h.

References m_GlobalNameSpaces.

Referenced by ClassBrowserBuilderThread::AddChildrenOf(), and ClassBrowserBuilderThread::CreateSpecialFolders().

◆ GetTokenAt() [1/2]

Token * TokenTree::GetTokenAt ( int  idx)
protected

Definition at line 819 of file tokentree.cpp.

References m_Tokens.

Referenced by AppendDocumentation(), at(), GetDocumentation(), and operator[]().

◆ GetTokenAt() [2/2]

const Token * TokenTree::GetTokenAt ( int  idx) const
protected

Definition at line 827 of file tokentree.cpp.

References m_Tokens.

◆ GetTokens()

const TokenList* TokenTree::GetTokens ( ) const
inline

Protected access to internal lists / maps.

Definition at line 180 of file tokentree.h.

References m_Tokens.

Referenced by NativeParserBase::GenerateResultSet().

◆ GetTokensBelongToFile()

const TokenIdxSet* TokenTree::GetTokensBelongToFile ( size_t  fileIdx) const
inline

Definition at line 196 of file tokentree.h.

References m_FileMap.

Referenced by CodeCompletion::DoAllMethodsImpl(), and ClassBrowserBuilderThread::Init().

◆ insert() [1/2]

int TokenTree::insert ( Token newToken)

add a new Token instance to the TokenTree

Parameters
newTokenthe pointer to a Token instance
Returns
the index of the Token in the TokenTree

Definition at line 111 of file tokentree.cpp.

References AddToken().

Referenced by Tokenizer::AddMacroDefinition(), ParserThread::DoAddToken(), empty(), and ParserThread::FindTokenFromQueue().

◆ insert() [2/2]

int TokenTree::insert ( int  loc,
Token newToken 
)

add a new Token instance to the TokenTree

Parameters
loc-1 means we add a new slot to the Token list (vector), otherwise, the new added Token will replace the old one in that location(index).

Definition at line 119 of file tokentree.cpp.

References AddToken().

◆ InsertFileOrGetIndex()

size_t TokenTree::InsertFileOrGetIndex ( const wxString filename)

put the filename in the m_FilenameMap, and return the file index, if this file is already in the m_FilenameMap, it just return the file index.

Definition at line 835 of file tokentree.cpp.

References _T, BasicSearchTree::insert(), m_FilenameMap, and wxString::Replace().

Referenced by EraseFilesToBeReparsedByIndex(), FlagFileAsParsed(), FlagFileForReparsing(), NativeParserBase::GetTokenFromCurrentLine(), ParserThread::InitTokenizer(), IsFileParsed(), MarkFileTokensAsLocal(), RemoveFile(), Parser::RemoveFile(), and ReserveFileForParsing().

◆ InsertTokenBelongToFile()

void TokenTree::InsertTokenBelongToFile ( size_t  fileIdx,
int  tokenIdx 
)
inline

Definition at line 212 of file tokentree.h.

References m_FileMap.

Referenced by ParserThread::DoAddToken().

◆ IsFileParsed()

bool TokenTree::IsFileParsed ( const wxString filename)

is the file name is in the tokentree, and it's status is either assigned or beingparsed or done also, should make sure that this file is not marked as "need to be reparsed".

Definition at line 863 of file tokentree.cpp.

References fpsNotParsed, InsertFileOrGetIndex(), m_FileMap, m_FileStatusMap, and m_FilesToBeReparsed.

Referenced by EraseFilesToBeReparsedByIndex(), ParserThread::HandleIncludes(), Parser::IsFileParsed(), and Parser::Parse().

◆ MarkFileTokensAsLocal() [1/2]

void TokenTree::MarkFileTokensAsLocal ( const wxString filename,
bool  local = true,
void *  userData = 0 
)

mark the tokens so that they are associated with a C::B project

Parameters
filenamespecify the tokens which belong to the file
localtrue if the tokens belong to project files
userDataa pointer to the c::b project

Definition at line 874 of file tokentree.cpp.

References InsertFileOrGetIndex().

Referenced by EraseFilesToBeReparsedByIndex(), and MarkFileAsLocalThreadedTask::Execute().

◆ MarkFileTokensAsLocal() [2/2]

void TokenTree::MarkFileTokensAsLocal ( size_t  fileIdx,
bool  local = true,
void *  userData = 0 
)

mark the tokens so that they are associated with a C::B project

Parameters
fileIdxspecify the tokens which belong to the file
localtrue if the tokens belong to project files
userDataa pointer to the c::b project

Definition at line 879 of file tokentree.cpp.

References m_FileMap, Token::m_IsLocal, m_Tokens, and Token::m_UserData.

◆ operator[]()

Token* TokenTree::operator[] ( int  idx)
inline

Definition at line 50 of file tokentree.h.

References GetTokenAt().

◆ realsize()

size_t TokenTree::realsize ( )

some position of the std::vector<Token*> are not used, so the real size maybe a bit smaller than the total size

Definition at line 103 of file tokentree.cpp.

References m_FreeTokens, and m_Tokens.

Referenced by at(), and Parser::OnAllThreadsDone().

◆ RecalcFreeList()

void TokenTree::RecalcFreeList ( )

collect the unused slots in the std::vector<Token*>

Definition at line 633 of file tokentree.cpp.

References m_FreeTokens, and m_Tokens.

Referenced by Clear().

◆ RecalcFullInheritance()

void TokenTree::RecalcFullInheritance ( int  parentIdx,
TokenIdxSet result 
)
protected

◆ RecalcInheritanceChain()

void TokenTree::RecalcInheritanceChain ( Token token)

◆ RemoveFile() [1/2]

void TokenTree::RemoveFile ( const wxString filename)

remove tokens belong to the file

Definition at line 549 of file tokentree.cpp.

References InsertFileOrGetIndex().

Referenced by Clear(), Parser::RemoveFile(), Parser::ReparseModifiedFiles(), and ReserveFileForParsing().

◆ RemoveFile() [2/2]

void TokenTree::RemoveFile ( int  fileIndex)

◆ RemoveToken() [1/2]

void TokenTree::RemoveToken ( int  idx)
protected

Definition at line 396 of file tokentree.cpp.

References m_Tokens.

Referenced by erase(), RemoveFile(), and RemoveToken().

◆ RemoveToken() [2/2]

void TokenTree::RemoveToken ( Token oldToken)
protected

◆ RemoveTokenFromList()

void TokenTree::RemoveTokenFromList ( int  idx)
protected

Remove the Token specified by the idx in the vector<Token*>, note the Token instance is destroyed, and the slot becomes empty.

The empty slot was recored and will be re-used later.

Definition at line 536 of file tokentree.cpp.

References m_FreeTokens, and m_Tokens.

Referenced by RemoveToken().

◆ RenameToken()

void TokenTree::RenameToken ( Token token,
const wxString newName 
)

only the token's name need to be changed, thus update the index map of the TokenTree

Definition at line 338 of file tokentree.cpp.

References SearchTree< T >::AddItem(), SearchTree< T >::GetItemAtPos(), BasicSearchTree::GetItemNo(), Token::m_Index, Token::m_Name, and m_Tree.

Referenced by Clear(), and ParserThread::RefineAnonymousTypeToken().

◆ ReserveFileForParsing()

size_t TokenTree::ReserveFileForParsing ( const wxString filename,
bool  preliminary = false 
)

mark a file to be parsed.

Or, assigned, return non-zero if success.

Parameters
filenamethe file need to be parsed
preliminaryif true, this means we will put the file status as assigned (not parse it soon, just assigned a Parserthread task, and the actually parsing will be done later; if false, then set the file status to being parsed, so parsing must be happened immediately after this function call.

Definition at line 896 of file tokentree.cpp.

References fpsAssigned, fpsBeingParsed, fpsDone, fpsNotParsed, InsertFileOrGetIndex(), m_FileStatusMap, m_FilesToBeReparsed, and RemoveFile().

Referenced by EraseFilesToBeReparsedByIndex(), ParserThread::Parse(), Parser::Parse(), and ParserBase::Reparse().

◆ size()

size_t TokenTree::size ( )

◆ TokenExists() [1/4]

int TokenTree::TokenExists ( const wxString name,
int  parent,
short int  kindMask 
)

query tokens by names

Parameters
namethe search key, token's name
parentsearch only the tokens under the token specified by parent
kindMasktoken kind mask
Returns
int the first matched token index will be returned, return -1 if no matched token is found.

Definition at line 141 of file tokentree.cpp.

References SearchTree< T >::GetItemAtPos(), BasicSearchTree::GetItemNo(), Token::m_ParentIndex, Token::m_TokenKind, m_Tokens, and m_Tree.

Referenced by Tokenizer::AddMacroDefinition(), ParserThread::CalcEnumExpression(), Tokenizer::CheckMacroUsageAndReplace(), Clear(), NativeParserBase::ComputeCallTip(), Tokenizer::HandleUndefs(), Tokenizer::IsMacroDefined(), CodeCompletion::OnGotoDeclaration(), NativeParser::ParseBufferForUsingNamespace(), NativeParserBase::PrettyPrintToken(), RecalcInheritanceChain(), and ParserThread::TokenExists().

◆ TokenExists() [2/4]

int TokenTree::TokenExists ( const wxString name,
const wxString baseArgs,
int  parent,
TokenKind  kind 
)

query tokens by names

Parameters
namethe search key, token's name
baseArgsspecify the function parameter
parentsearch only the tokens under the token specified by parent
kindMasktoken kind mask
Returns
int the first matched token index will be returned, return -1 if no matched token is found.

Definition at line 167 of file tokentree.cpp.

References SearchTree< T >::GetItemAtPos(), BasicSearchTree::GetItemNo(), Token::m_BaseArgs, Token::m_ParentIndex, Token::m_TokenKind, m_Tokens, m_Tree, and tkAnyContainer.

◆ TokenExists() [3/4]

int TokenTree::TokenExists ( const wxString name,
const TokenIdxSet parents,
short int  kindMask 
)

query tokens by names

Parameters
namethe search key, token's name
parentssearch only the tokens under the token specified by parent collection tokens
kindMasktoken kind mask
Returns
int the first matched token index will be returned, return -1 if no matched token is found.

Definition at line 198 of file tokentree.cpp.

References SearchTree< T >::GetItemAtPos(), BasicSearchTree::GetItemNo(), Token::m_ParentIndex, Token::m_TokenKind, m_Tokens, and m_Tree.

◆ TokenExists() [4/4]

int TokenTree::TokenExists ( const wxString name,
const wxString baseArgs,
const TokenIdxSet parents,
TokenKind  kind 
)

query tokens by names

Parameters
namethe search key, token's name
baseArgsspecify the function parameter
parentssearch only the tokens under the token specified by parent collection tokens
kindMasktoken kind mask
Returns
int the first matched token index will be returned, return -1 if no matched token is found.

Definition at line 230 of file tokentree.cpp.

References SearchTree< T >::GetItemAtPos(), BasicSearchTree::GetItemNo(), Token::m_BaseArgs, Token::m_ParentIndex, Token::m_TokenKind, m_Tokens, m_Tree, and tkAnyContainer.

Friends And Related Function Documentation

◆ CCDebugInfo

friend class CCDebugInfo
friend

Definition at line 39 of file tokentree.h.

◆ CCTest

friend class CCTest
friend

Definition at line 40 of file tokentree.h.

◆ CCTestFrame

friend class CCTestFrame
friend

Definition at line 41 of file tokentree.h.

◆ NativeParserTest

friend class NativeParserTest
friend

Definition at line 42 of file tokentree.h.

Member Data Documentation

◆ m_FileMap

TokenFileMap TokenTree::m_FileMap
protected

◆ m_FilenameMap

TokenFilenameMap TokenTree::m_FilenameMap
protected

◆ m_FileStatusMap

TokenFileStatusMap TokenTree::m_FileStatusMap
protected

◆ m_FilesToBeReparsed

TokenFileSet TokenTree::m_FilesToBeReparsed
protected

◆ m_FreeTokens

TokenIdxList TokenTree::m_FreeTokens
protected

List of all the deleted (and available) tokens.

When more and more Tokens were allocated, their address was recorded in the m_Tokens, m_Tokens grows larger, but if we delete some Tokens, the will have some empty slots in the std::vector<Token*>, we need to reuse those slots, here m_FreeTokens is to hold those empty slots for reuse, so we don't waste empty slots in the m_Tokens

Definition at line 360 of file tokentree.h.

Referenced by AddTokenToList(), clear(), realsize(), RecalcFreeList(), RemoveTokenFromList(), and TokenTree().

◆ m_GlobalNameSpaces

TokenIdxSet TokenTree::m_GlobalNameSpaces
protected

any tokens belong to the global namespace

Definition at line 366 of file tokentree.h.

Referenced by AddToken(), clear(), GetGlobalNameSpaces(), RemoveToken(), and TokenTree().

◆ m_Tokens

TokenList TokenTree::m_Tokens
protected

Contains the pointers to all the Token instances, it is just a std::vector<Token*>, the suggest way to access a Token instance is by first get its index in the m_Tokens, then get its address by m_Tokens[index], the reason we have such indirect access is that there are many Tokens which can reference each other, it is much safe using index instead of raw pointers.

Definition at line 353 of file tokentree.h.

Referenced by AddTokenToList(), CheckChildRemove(), clear(), erase(), GetTokenAt(), GetTokens(), MarkFileTokensAsLocal(), realsize(), RecalcFreeList(), RemoveFile(), RemoveToken(), RemoveTokenFromList(), size(), TokenExists(), and TokenTree().

◆ m_TokenTicketCount

size_t TokenTree::m_TokenTicketCount

◆ m_TopNameSpaces

TokenIdxSet TokenTree::m_TopNameSpaces
protected

namespace tokens belongs to the global namespace

Definition at line 363 of file tokentree.h.

Referenced by AddToken(), clear(), RemoveToken(), and TokenTree().

◆ m_Tree

TokenSearchTree TokenTree::m_Tree
protected

This is a string->TokenIndexSet map.

E.g. we have a class Token named "AAA", also, we can have a function Token named "AAA", they are different Tokens, but they share the same name. So we may have an tree point "AAA" -> <30, 40> map in the TokenSearchTree. Note here 30 and 40 are the indexes (slots) in the m_Tokens vector, which holds the Tokens pointers. In-fact, "AAA" -> <30, 40> is not mapped directly, it has a indirect map like "AAA" -> 16 -> <30, 40>, the middle number 16 here is the tree point item index in the BasicSearchTree, as we have a std::vector< TokenIndexSet > in the SearchTree, the 16 is the index to fetch the value <30,40> in the vector

Definition at line 345 of file tokentree.h.

Referenced by AddToken(), clear(), FindMatches(), CCDebugInfo::OnSave(), RemoveToken(), RenameToken(), TokenExists(), and TokenTree().


The documentation for this class was generated from the following files: