18 #define CC_TOKENTREE_DEBUG_OUTPUT 0 20 #if defined(CC_GLOBAL_DEBUG_OUTPUT) 21 #if CC_GLOBAL_DEBUG_OUTPUT == 1 22 #undef CC_TOKENTREE_DEBUG_OUTPUT 23 #define CC_TOKENTREE_DEBUG_OUTPUT 1 24 #elif CC_GLOBAL_DEBUG_OUTPUT == 2 25 #undef CC_TOKENTREE_DEBUG_OUTPUT 26 #define CC_TOKENTREE_DEBUG_OUTPUT 2 30 #if CC_TOKENTREE_DEBUG_OUTPUT == 1 31 #define TRACE(format, args...) \ 32 CCLogger::Get()->DebugLog(F(format, ##args)) 33 #define TRACE2(format, args...) 34 #elif CC_TOKENTREE_DEBUG_OUTPUT == 2 35 #define TRACE(format, args...) \ 38 if (g_EnableDebugTrace) \ 39 CCLogger::Get()->DebugLog(F(format, ##args)); \ 42 #define TRACE2(format, args...) \ 43 CCLogger::Get()->DebugLog(F(format, ##args)) 45 #define TRACE(format, args...) 46 #define TRACE2(format, args...) 52 m_TokenTicketCount(255)
148 for (TokenIdxSet::const_iterator it = curList.begin(); it != curList.end(); ++it)
151 if (result < 0 || (
size_t)result >=
m_Tokens.size())
173 TokenIdxSet::const_iterator it;
175 for (it = curList.begin(); it != curList.end(); ++it)
178 if (result < 0 || (
size_t)result >=
m_Tokens.size())
204 TokenIdxSet::const_iterator it;
206 for (it = curList.begin(); it != curList.end(); ++it)
209 if (result < 0 || (
size_t)result >=
m_Tokens.size())
218 for ( TokenIdxSet::const_iterator pIt = parents.begin();
219 pIt != parents.end(); ++pIt )
236 TokenIdxSet::const_iterator it;
238 for (it = curList.begin(); it != curList.end(); ++it)
241 if (result < 0 || (
size_t)result >=
m_Tokens.size())
254 for ( TokenIdxSet::const_iterator pIt = parents.begin();
255 pIt != parents.end(); ++pIt )
271 std::set<size_t> lists;
278 for (std::set<size_t>::const_iterator it = lists.begin(); it != lists.end(); ++it)
285 for (TokenIdxSet::const_iterator it2 = curset->begin(); it2 != curset->end(); ++it2)
295 return result.size();
310 TRACE(
_T(
"TokenTree::FindTokensInFile() : File '%s' not found in file names map."), f.
wx_str());
317 TokenFileMap::iterator itf =
m_FileMap.find(idx);
320 TRACE(
_T(
"TokenTree::FindTokensInFile() : No tokens found for file '%s' (index %d)."), f.
wx_str(), idx);
326 for (TokenIdxSet::const_iterator it = tokens.begin(); it != tokens.end(); ++it)
333 TRACE(
_T(
"TokenTree::FindTokensInFile() : Found %lu results for file '%s'."),
334 static_cast<unsigned long>(result.size()), f.
wx_str());
335 return result.size();
361 curList.insert(token->
m_Index);
378 curList.insert(newItem);
398 if (idx<0 || (
size_t)idx >=
m_Tokens.size())
415 Token* parentToken = 0;
424 TokenIdxSet::const_iterator it;
429 for (it = nodes.begin();it!=nodes.end(); ++it)
431 int ancestoridx = *it;
432 if (ancestoridx < 0 || (
size_t)ancestoridx >=
m_Tokens.size())
444 for (it = nodes.begin();it!=nodes.end(); ++it)
452 for (it = nodes.begin();it!=nodes.end(); ++it)
456 CCLogger::Get()->
DebugLog(
_T(
"Break out the loop to remove descendants, to avoid a crash. We can not be our own descendant!"));
498 if ((
size_t)forceidx >=
m_Tokens.size())
500 int max = 250*((forceidx + 250) / 250);
538 if (idx < 0 || (
size_t)idx >=
m_Tokens.size())
556 if (fileIdx <= 0)
return;
559 for (TokenIdxSet::const_iterator it = the_list.begin(); it != the_list.end();)
562 if (idx < 0 || (
size_t)idx >
m_Tokens.size())
564 the_list.erase(it++);
571 the_list.erase(it++);
579 bool match1 = the_token->
m_FileIdx == 0 ||
static_cast<int>(the_token->
m_FileIdx) == fileIdx;
582 if (match1 && match2 && match3)
585 the_list.erase(it++);
612 TokenIdxSet::const_iterator it;
613 for (it = nodes.begin(); it != nodes.end(); ++it)
616 if (idx < 0 || (
size_t)idx >
m_Tokens.size())
619 const Token* the_token =
at(idx);
623 bool match1 = the_token->
m_FileIdx == 0 ||
static_cast<int>(the_token->
m_FileIdx) == fileIdx;
625 if (match1 && match2)
636 for (
int i =
m_Tokens.size() - 1; i >= 0; --i)
658 TRACE(
_T(
"RecalcInheritanceChain() : Removing ancestor string from %s"), token->
m_Name.
wx_str());
667 TRACE(
_T(
"RecalcInheritanceChain() : Ancestor %s"), ancestor.
wx_str());
672 Token* ancestorToken = 0;
681 ancestorToken =
at(ancestorIdx);
687 && ancestorToken != token
698 TRACE(
_T(
"RecalcInheritanceChain() : ! '%s' (unresolved)"), ancestor.
wx_str());
706 for (TokenIdxSet::const_iterator it = result.begin(); it != result.end(); ++it)
708 Token* ancestorToken =
at(*it);
711 && (ancestorToken != token)
723 #if defined(CC_TOKEN_DEBUG_OUTPUT) 724 #if CC_TOKEN_DEBUG_OUTPUT 726 TRACE(
_T(
"RecalcInheritanceChain() : ! '%s' (unresolved)"), ancestor.
wx_str());
735 #if defined(CC_TOKEN_DEBUG_OUTPUT) 736 #if CC_TOKEN_DEBUG_OUTPUT 738 TRACE(
_T(
"RecalcInheritanceChain() : First iteration took : %ld ms"), sw.
Time());
749 for (TokenIdxSet::const_iterator it = result.begin(); it != result.end(); ++it)
759 #if defined(CC_TOKEN_DEBUG_OUTPUT) 760 #if CC_TOKEN_DEBUG_OUTPUT 767 const Token* anc_token =
at(*it);
771 TRACE(
_T(
"RecalcInheritanceChain() : + NULL?!"));
777 #if defined(CC_TOKEN_DEBUG_OUTPUT) 778 #if CC_TOKEN_DEBUG_OUTPUT 779 TRACE(
_T(
"RecalcInheritanceChain() : Second iteration took : %ld ms"), sw.
Time());
783 TRACE(
_T(
"RecalcInheritanceChain() : Full inheritance calculated."));
794 const Token* ancestor =
at(parentIdx);
805 for (TokenIdxSet::const_iterator it = ancestor->
m_Ancestors.begin(); it != ancestor->
m_Ancestors.end(); ++it)
809 result.find(*it) == result.end())
821 if (idx < 0 || (
size_t)idx >=
m_Tokens.size())
829 if (idx < 0 || (
size_t)idx >=
m_Tokens.size())
844 bool caseSensitive,
bool is_prefix)
885 for (TokenIdxSet::const_iterator it = tokens.begin(); it != tokens.end(); ++it)
int TokenExists(const wxString &name, int parent, short int kindMask)
query tokens by names
int m_ParentIndex
Parent Token index.
TokenSearchTree m_Tree
This is a string->TokenIndexSet map.
void RenameToken(Token *token, const wxString &newName)
only the token's name need to be changed, thus update the index map of the TokenTree ...
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_Fi...
virtual void clear()
Gets the number of items stored.
wxString m_BaseType
this is what the parser believes is the actual return value: e.g.
size_t GetItemNo(const wxString &s)
Gets the array position defined by s.
wxString m_Name
Token's name, it can be searched in the TokenTree.
unsigned int m_ImplLine
function implementation line index
T & GetItemAtPos(size_t i)
Gets the item found at position i, the i is the item index.
typedef, note typedefs are stored as classes inheriting from the typedef'd type, this takes advantage...
int erase(int loc)
remove the Token specified by the index
container like tokens, those tokens can have children tokens
const wxString GetFilename(size_t fileIdx) const
wxString m_BaseArgs
stripped arguments e.g.
void FlagFileAsParsed(const wxString &filename)
mark the file status as fpsDone, since parsing this file is done
virtual void clear()
Gets the number of items stored.
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.
TokenIdxSet m_Children
if it is a class kind token, then it contains all the member tokens
void * m_UserData
custom user-data (the classbrowser expects it to be a pointer to a cbProject), this field is used whe...
TokenFileMap m_FileMap
Map: file indices -> sets of TokenIndexes.
TokenIdxSet m_Ancestors
all the ancestors in the inheritance hierarchy
size_t realsize()
some position of the std::vector<Token*> are not used, so the real size maybe a bit smaller than the ...
TokenFileStatusMap m_FileStatusMap
Map: file indices -> status.
unsigned int m_Line
Line index where the token was met, which is 1 based.
size_t size()
total size of std::vector<Token*>
int m_Index
current Token index in the tree, it is index of the std::vector<Token*>, so use the index...
size_t FindMatches(const wxString &s, std::set< size_t > &result, bool caseSensitive, bool is_prefix)
Finds items that match a given string.
void AppendDocumentation(int tokenIdx, unsigned int fileIdx, const wxString &doc)
associate a document string with the token
void RecalcFreeList()
collect the unused slots in the std::vector<Token*>
void DebugLog(const wxString &msg)
size_t AddItem(const wxString &s, T item, bool replaceexisting=false)
Adds an item to position defined by s and return the item number.
void RecalcInheritanceChain(Token *token)
convert the Token's ancestor string to it's IDs this contains recursive calls, for example in such co...
void RecalcFullInheritance(int parentIdx, TokenIdxSet &result)
unsigned int m_FileIdx
File index in TokenTree.
wxString m_Doc
doxygen style comments
bool CheckChildRemove(const Token *token, int fileIdx)
Check all the children belong this token should be removed.
void RemoveFile(const wxString &filename)
remove tokens belong to the file
a symbol found in the parsed files, it can be many kinds, such as a variable, a class and so on...
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...
std::set< int, std::less< int > > TokenIdxSet
size_t GetFileIndex(const wxString &filename)
size_t Replace(const wxString &strOld, const wxString &strNew, bool replaceAll=true)
#define TRACE(format, args...)
size_t FindTokensInFile(const wxString &filename, TokenIdxSet &result, short int kindMask)
find tokens belong to a specified file
const wxStringCharType * wx_str() const
void MarkFileTokensAsLocal(const wxString &filename, bool local=true, void *userData=0)
mark the tokens so that they are associated with a C::B project
wxString m_Args
If it is a function Token, then this value is function arguments, e.g.
unsigned int m_ImplFileIdx
function implementation file index
wxString m_TemplateArgument
template argument list, comma separated list string
bool HasMoreTokens() const
TokenIdxSet m_Descendants
all the descendants in the inheritance hierarchy
TokenTree * m_TokenTree
a pointer to TokenTree
size_t GetFileMatches(const wxString &filename, std::set< size_t > &result, bool caseSensitive, bool is_prefix)
void Start(long milliseconds=0)
wxString GetDocumentation(int tokenIdx)
get the document string associated with the token
TokenKind m_TokenKind
See TokenKind class.
Token * GetTokenAt(int idx)
size_t insert(const wxString &s)
Clear items and tree.
TokenIdxSet m_GlobalNameSpaces
any tokens belong to the global namespace
size_t FindMatches(const wxString &query, TokenIdxSet &result, bool caseSensitive, bool is_prefix, TokenKind kindMask=tkUndefined)
find a collection of matched tokens
void RemoveToken(int idx)
int Find(wxUniChar ch, bool fromEnd=false) const
void RemoveTokenFromList(int idx)
Remove the Token specified by the idx in the vector<Token*>, note the Token instance is destroyed...
TokenIdxSet m_TopNameSpaces
namespace tokens belongs to the global namespace
TokenFileSet m_FilesToBeReparsed
Set: file indices.
TokenFilenameMap m_FilenameMap
Map: file names -> file indices.
size_t ReserveFileForParsing(const wxString &filename, bool preliminary=false)
mark a file to be parsed.
wxString m_ImplDoc
doxygen style comments in the Impl file
int insert(Token *newToken)
add a new Token instance to the TokenTree
const wxString GetString(size_t n) const
Gets the key string for item n.
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...
wxString m_FullType
this is the full return value (if any): e.g.
void FlagFileForReparsing(const wxString &filename)
mark the file as "need to be reparsed" status, usually happens that this file is saved(updated) so a ...
bool m_IsLocal
if true, means the token belong to a C::B project, it exists in the project's source/header files...
TokenIdxList m_FreeTokens
List of all the deleted (and available) tokens.
TokenIdxSet m_DirectAncestors
the nearest ancestors
int AddToken(Token *newToken, int forceidx=-1)
bool HasItem(const wxString &s)
Tells if there is an item for string s.