Code::Blocks
SVN r11506
|
Parser class holds all the tokens of a C::B project. More...
#include <parser.h>
Public Member Functions | |
Parser (wxEvtHandler *parent, cbProject *project) | |
constructor More... | |
virtual | ~Parser () |
destructor More... | |
virtual void | AddBatchParse (const StringList &filenames) |
Add files to batch parse mode, internally. More... | |
virtual void | AddParse (const wxString &filename) |
Add one file to Batch mode Parsing, this is the bridge between the main thread and the thread pool, after this function call, the file(Parserthread) will be run from the thread pool. More... | |
virtual void | AddPredefinedMacros (const wxString &defs) |
set the predefined macro definition string was collected from the GCC command line, this function adds the string to an internal m_PredefinedMacros, and switch the ParserState More... | |
virtual void | ClearPredefinedMacros () |
clears the list of predefined macros after it has been parsed More... | |
virtual const wxString | GetPredefinedMacros () const |
return the predefined macro definition string that has been collected More... | |
virtual bool | UpdateParsingProject (cbProject *project) |
set the associated C::B project pointer. More... | |
virtual bool | ParseBuffer (const wxString &buffer, bool isLocal, bool bufferSkipBlocks=false, bool isTemp=false, const wxString &filename=wxEmptyString, int parentIdx=-1, int initLine=0) |
Must add a locker before call all named ParseBufferXXX functions, ParseBuffer function will directly run the parsing in the same thread as the caller. More... | |
virtual bool | ParseBufferForFunctions (const wxString &buffer) |
parser the current editor control, this function is used to list all the functions in the current code editor More... | |
virtual bool | ParseBufferForNamespaces (const wxString &buffer, NameSpaceVec &result) |
parse the buffer for collecting exposed namespace scopes More... | |
virtual bool | ParseBufferForUsingNamespace (const wxString &buffer, wxArrayString &result, bool bufferSkipBlocks=true) |
parse the buffer for collecting using namespace directive More... | |
virtual bool | Reparse (const wxString &filename, bool isLocal=true) |
mark this file to be re-parsed in the TokenTree, tick the reparse timer, note it looks like the isLocal parameter is not used in Parser::Reparse function. More... | |
virtual bool | AddFile (const wxString &filename, cbProject *project, bool isLocal=true) |
this usually happens when user adds some files to an existing project, it just use AddParse() function internally to add the file. More... | |
virtual bool | RemoveFile (const wxString &filename) |
this usually happens when the user removes a file from the existing project, it will remove all the tokens belong to the file. More... | |
virtual bool | IsFileParsed (const wxString &filename) |
check to see a file is parsed already, it first check the TokenTree to see whether it has the specified file, but if a file is already queued (put in m_BatchParseFiles), we regard it as already parsed. More... | |
virtual bool | Done () |
check to see whether Parser is in Idle mode, there is no work need to be done in the Parser More... | |
virtual wxString | NotDoneReason () |
if the Parser is not in Idle mode, show which need to be done More... | |
Public Member Functions inherited from ParserBase | |
ParserBase () | |
virtual | ~ParserBase () |
virtual void | AddBatchParse (cb_unused const StringList &filenames) |
virtual void | AddParse (cb_unused const wxString &filename) |
virtual void | AddPredefinedMacros (cb_unused const wxString &defs) |
virtual bool | UpdateParsingProject (cb_unused cbProject *project) |
virtual bool | ParseBufferForFunctions (cb_unused const wxString &buffer) |
virtual bool | ParseBufferForNamespaces (cb_unused const wxString &buffer, cb_unused NameSpaceVec &result) |
virtual bool | ParseBufferForUsingNamespace (cb_unused const wxString &buffer, cb_unused wxArrayString &result, cb_unused bool bufferSkipBlocks=true) |
virtual bool | Reparse (cb_unused const wxString &filename, cb_unused bool isLocal=true) |
virtual bool | AddFile (cb_unused const wxString &filename, cb_unused cbProject *project, cb_unused bool isLocal=true) |
virtual bool | RemoveFile (cb_unused const wxString &filename) |
virtual bool | IsFileParsed (cb_unused const wxString &filename) |
virtual TokenTree * | GetTokenTree () const |
TokenTree * | GetTempTokenTree () |
void | AddIncludeDir (const wxString &dir) |
add a directory to the Parser's include path database More... | |
const wxArrayString & | GetIncludeDirs () const |
wxString | GetFullFileName (const wxString &src, const wxString &tgt, bool isGlobal) |
wxArrayString | FindFileInIncludeDirs (const wxString &file, bool firstonly=false) |
it mimics what a compiler does to find an include header files, if the firstonly option is true, it will return the first found header file, otherwise, the complete database of the Parser's include paths will be searched. More... | |
virtual ParserOptions & | Options () |
virtual BrowserOptions & | ClassBrowserOptions () |
size_t | FindTokensInFile (const wxString &filename, TokenIdxSet &result, short int kindMask) |
Protected Member Functions | |
void | StartStopWatch () |
void | EndStopWatch () |
unsigned int | GetMaxThreads () const |
Node: Currently, the max. More... | |
void | SetMaxThreads (unsigned int max) |
Not used, because the ThreadPool only support running ONE ParserThread concurrently. More... | |
bool | Parse (const wxString &filename, bool isLocal=true, bool locked=false) |
parse the file, either immediately or delayed. More... | |
void | ReparseModifiedFiles () |
delete those files from the TokenTree, and add them again through AddParse() function More... | |
void | TerminateAllThreads () |
cancel all the tasks in the thread pool m_Pool More... | |
void | OnAllThreadsDone (CodeBlocksEvent &event) |
When a ThreadPool batch parse stage is done, it will issue a cbEVT_THREADTASK_ALLDONE message. More... | |
void | OnReparseTimer (wxTimerEvent &event) |
some files in the Tokentree is marked as need to be reparsed, this can be done by a call of Reparse() before. More... | |
void | OnBatchTimer (wxTimerEvent &event) |
A timer is used to optimized the event handling for parsing, e.g. More... | |
void | ProcessParserEvent (ParserCommon::ParserState state, int id, const wxString &info=wxEmptyString) |
The parser will let its parent (NativeParser) to handle the event, as the CodeCompletion instance was set as the next handler of the NativeParser. More... | |
virtual void | ReadOptions () |
read Parser options from configure file More... | |
virtual void | WriteOptions () |
write Parse options to configure file More... | |
Protected Attributes | |
bool | m_UsingCache |
used to detect changes between in-memory data and cache, true if loaded from cache More... | |
cbThreadPool | m_Pool |
Thread Pool, executing all the ParserThread, used in batch parse mode. More... | |
bool | m_IsParsing |
true, if the parser is still busy with parsing, false if the parsing stage has finished this value is set in parserthreadedtask after putting all the batchFiles to pool(task) it was reset after the last stage (mark tokens as local) More... | |
bool | m_NeedsReparse |
Indicates some files in the current project need to be re-parsed, this is commonly caused that the "real-time parsing option" is enabled, and user is editing source file. More... | |
bool | m_IsFirstBatch |
batch Parse mode flag. More... | |
Protected Attributes inherited from ParserBase | |
TokenTree * | m_TokenTree |
each Parser class contains a TokenTree object which used to record tokens per project this tree will be created in the constructor and destroyed in destructor. More... | |
TokenTree * | m_TempTokenTree |
a temp Token tree hold some temporary tokens, e.g. More... | |
ParserOptions | m_Options |
options for how the parser try to parse files More... | |
BrowserOptions | m_BrowserOptions |
options for how the symbol browser was shown More... | |
Private Types | |
typedef std::list< cbThreadedTask * > | TasksQueue |
A list to contain pointers to internal running threads. More... | |
Private Member Functions | |
virtual bool | ParseFile (const wxString &filename, bool isGlobal, bool locked=false) |
the only usage of this function is in the Parserthread class, when handling include directives the parserthread use some call like m_Parent->ParseFile() to call this function, but this function just call Parser::Parse() function, which either run the syntax analysis immediately or create a parsing task in the Pool. More... | |
void | ConnectEvents () |
connect event handlers of the timers and thread pool More... | |
void | DisconnectEvents () |
connect event handlers of the timers and thread pool More... | |
void | AddParserThread (cbThreadedTask *task) |
Remember a newly created internal running threads. More... | |
void | RemoveParserThread (cbThreadedTask *task) |
Remove a completed internal running threads. More... | |
void | AbortParserThreads () |
Tell internal running threads to abort further processing. More... | |
Private Attributes | |
wxEvtHandler * | m_Parent |
when initialized, this variable will be an instance of a NativeParser More... | |
cbProject * | m_Project |
referring to the C::B cbp project currently parsing in one parser per workspace mode More... | |
wxTimer | m_ReparseTimer |
a file is need to be reparsed, maybe another file will to be reparsed very soon, so use a timer to collect all the files need to be reparsed. More... | |
wxTimer | m_BatchTimer |
a timer to delay the operation of batch parsing, see OnBatchTimer() member function as a reference More... | |
wxStopWatch | m_StopWatch |
a stop watch to measure parsing time More... | |
bool | m_StopWatchRunning |
long | m_LastStopWatchTime |
bool | m_IgnoreThreadEvents |
Parser::OnAllThreadsDone will be called when m_Pool finished its job, but when we run a batch parsing, we may receive several such event from the m_Pool, because 1, when ParserThreadedTask finished 2, when batchFiles get finished 3, mark C::B project files's token as local. More... | |
StringList | m_BatchParseFiles |
All other batch parse files, like the normal headers/sources. More... | |
wxString | m_PredefinedMacros |
Pre-defined macros, its a buffer queried from the compiler command line. More... | |
wxString | m_LastPredefinedMacros |
bool | m_IsBatchParseDone |
used to measure batch parse time More... | |
ParserCommon::ParserState | m_ParserState |
indicated the current state the parser More... | |
bool | m_NeedMarkFileAsLocal |
if true, all the files of the current project will be labeled as "local" More... | |
TasksQueue | m_tasksQueue |
Friends | |
class | ParserThreadedTask |
Parser class holds all the tokens of a C::B project.
Parser class contains the TokenTree which is a trie structure to record the token information. For details about trie, see http://en.wikipedia.org/wiki/Trie The parser class manages Parser threaded Tasks in a ThreadPool. A ParserThread object is associated with a single source file. Batch parse mode means we have a lot of files to be parsed, so a lot of ParserThreads were generated and added to the ThreadPool, and finally, the ParserThread was executed by ThreadPool.
|
private |
Parser::Parser | ( | wxEvtHandler * | parent, |
cbProject * | project | ||
) |
constructor
parent | which is actually a NativeParser object |
project | the C::B project associated with the current Parser |
Definition at line 98 of file parser.cpp.
References ConnectEvents(), and ReadOptions().
|
virtual |
destructor
Definition at line 119 of file parser.cpp.
References CC_LOCKER_TRACK_P_MTX_LOCK, CC_LOCKER_TRACK_P_MTX_UNLOCK, DisconnectEvents(), ParserCommon::s_CurrentParser, ParserCommon::s_ParserMutex, and TerminateAllThreads().
|
private |
Tell internal running threads to abort further processing.
Definition at line 945 of file parser.cpp.
References m_tasksQueue.
Referenced by TerminateAllThreads().
|
virtual |
Add files to batch parse mode, internally.
The files will be parsed sequentially.
filenames | input files name array |
Definition at line 227 of file parser.cpp.
References _T, CC_LOCKER_TRACK_P_MTX_LOCK, CC_LOCKER_TRACK_P_MTX_UNLOCK, wxTimer::IsRunning(), m_BatchParseFiles, m_BatchTimer, m_IsParsing, m_ParserState, ParserCommon::PARSER_BATCHPARSE_TIMER_DELAY, ParserCommon::ptCreateParser, ParserCommon::ptUndefined, ParserCommon::s_ParserMutex, wxTimer::Start(), wxTimer::Stop(), TRACE, and wxTIMER_ONE_SHOT.
|
virtual |
this usually happens when user adds some files to an existing project, it just use AddParse() function internally to add the file.
and switch the ParserState to ParserCommon::ptAddFileToParser.
Definition at line 494 of file parser.cpp.
References AddParse(), IsFileParsed(), m_NeedMarkFileAsLocal, m_ParserState, m_Project, ParserCommon::ptAddFileToParser, and ParserCommon::ptUndefined.
|
virtual |
Add one file to Batch mode Parsing, this is the bridge between the main thread and the thread pool, after this function call, the file(Parserthread) will be run from the thread pool.
filenames | input file name |
Definition at line 253 of file parser.cpp.
References _T, CC_LOCKER_TRACK_P_MTX_LOCK, CC_LOCKER_TRACK_P_MTX_UNLOCK, wxTimer::IsRunning(), m_BatchParseFiles, m_BatchTimer, m_IsParsing, ParserCommon::PARSER_BATCHPARSE_TIMER_DELAY, ParserCommon::s_ParserMutex, wxTimer::Start(), wxTimer::Stop(), TRACE, and wxTIMER_ONE_SHOT.
Referenced by AddFile(), and ReparseModifiedFiles().
|
private |
Remember a newly created internal running threads.
Definition at line 933 of file parser.cpp.
References m_tasksQueue.
Referenced by Parse().
|
virtual |
set the predefined macro definition string was collected from the GCC command line, this function adds the string to an internal m_PredefinedMacros, and switch the ParserState
Definition at line 184 of file parser.cpp.
References _T, CC_LOCKER_TRACK_P_MTX_LOCK, CC_LOCKER_TRACK_P_MTX_UNLOCK, wxTimer::IsRunning(), m_BatchTimer, m_IsParsing, m_ParserState, m_PredefinedMacros, ParserCommon::PARSER_BATCHPARSE_TIMER_DELAY, ParserCommon::ptCreateParser, ParserCommon::ptUndefined, ParserCommon::s_ParserMutex, wxTimer::Start(), wxTimer::Stop(), TRACE, and wxTIMER_ONE_SHOT.
|
virtual |
clears the list of predefined macros after it has been parsed
Definition at line 211 of file parser.cpp.
References CC_LOCKER_TRACK_P_MTX_LOCK, CC_LOCKER_TRACK_P_MTX_UNLOCK, wxString::Clear(), m_LastPredefinedMacros, m_PredefinedMacros, and ParserCommon::s_ParserMutex.
Referenced by ParserThreadedTask::Execute().
|
private |
connect event handlers of the timers and thread pool
Definition at line 135 of file parser.cpp.
References cbEVT_THREADTASK_ALLDONE, wxTimer::GetId(), cbThreadPool::GetId(), m_BatchTimer, m_Pool, m_ReparseTimer, OnAllThreadsDone(), OnBatchTimer(), OnReparseTimer(), and wxEVT_TIMER.
Referenced by Parser().
|
private |
connect event handlers of the timers and thread pool
Definition at line 143 of file parser.cpp.
References cbEVT_THREADTASK_ALLDONE, wxTimer::GetId(), cbThreadPool::GetId(), m_BatchTimer, m_Pool, m_ReparseTimer, OnAllThreadsDone(), OnBatchTimer(), OnReparseTimer(), and wxEVT_TIMER.
Referenced by ~Parser().
|
virtual |
check to see whether Parser is in Idle mode, there is no work need to be done in the Parser
Reimplemented from ParserBase.
Definition at line 151 of file parser.cpp.
References CC_LOCKER_TRACK_P_MTX_LOCK, CC_LOCKER_TRACK_P_MTX_UNLOCK, cbThreadPool::Done(), wxString::IsEmpty(), m_BatchParseFiles, m_NeedMarkFileAsLocal, m_Pool, m_PredefinedMacros, and ParserCommon::s_ParserMutex.
Referenced by Reparse(), ReparseModifiedFiles(), and UpdateParsingProject().
|
protected |
Definition at line 684 of file parser.cpp.
References m_IsBatchParseDone, m_LastStopWatchTime, m_StopWatch, m_StopWatchRunning, wxStopWatch::Pause(), and wxStopWatch::Time().
Referenced by OnAllThreadsDone().
|
inlineprotected |
Node: Currently, the max.
concurrent ParserThread number should be ONE, CC does not support multiply threads parsing.
|
virtual |
return the predefined macro definition string that has been collected
Reimplemented from ParserBase.
Definition at line 221 of file parser.cpp.
References _T, CCLogger::DebugLog(), CCLogger::Get(), and m_LastPredefinedMacros.
|
virtual |
check to see a file is parsed already, it first check the TokenTree to see whether it has the specified file, but if a file is already queued (put in m_BatchParseFiles), we regard it as already parsed.
Definition at line 821 of file parser.cpp.
References CC_LOCKER_TRACK_P_MTX_LOCK, CC_LOCKER_TRACK_P_MTX_UNLOCK, CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, TokenTree::IsFileParsed(), m_BatchParseFiles, ParserBase::m_TokenTree, ParserCommon::s_ParserMutex, and s_TokenTreeMutex.
Referenced by AddFile().
|
virtual |
if the Parser is not in Idle mode, show which need to be done
Reimplemented from ParserBase.
Definition at line 165 of file parser.cpp.
References _T, CC_LOCKER_TRACK_P_MTX_LOCK, CC_LOCKER_TRACK_P_MTX_UNLOCK, cbThreadPool::Done(), wxString::IsEmpty(), m_BatchParseFiles, m_NeedMarkFileAsLocal, m_Pool, m_PredefinedMacros, and ParserCommon::s_ParserMutex.
Referenced by Reparse(), ReparseModifiedFiles(), and UpdateParsingProject().
|
protected |
When a ThreadPool batch parse stage is done, it will issue a cbEVT_THREADTASK_ALLDONE message.
In some situations this event will be triggered, such as:
Definition at line 572 of file parser.cpp.
References _T, cbThreadPool::AddTask(), cbThrow, CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, CCLogger::DebugLog(), EndStopWatch(), CCLogger::Get(), TokenTree::GetFileMapSize(), cbThreadPool::GetId(), CompileTargetBase::GetTitle(), ParserCommon::idParserEnd, Manager::IsAppShuttingDown(), wxString::IsEmpty(), m_BatchParseFiles, m_BatchTimer, m_IgnoreThreadEvents, m_IsBatchParseDone, m_IsParsing, m_LastStopWatchTime, m_NeedMarkFileAsLocal, m_NeedsReparse, m_ParserState, m_Pool, m_PredefinedMacros, m_Project, ParserBase::m_TokenTree, ParserCommon::PARSER_BATCHPARSE_TIMER_RUN_IMMEDIATELY, wxString::Printf(), ProcessParserEvent(), ParserCommon::ptAddFileToParser, ParserCommon::ptCreateParser, ParserCommon::ptUndefined, TokenTree::realsize(), ParserCommon::s_CurrentParser, s_TokenTreeMutex, wxTimer::Start(), TRACE, wxString::wx_str(), and wxTIMER_ONE_SHOT.
Referenced by ConnectEvents(), and DisconnectEvents().
|
protected |
A timer is used to optimized the event handling for parsing, e.g.
several files/projects were added to the project, so we don't start the real parsing stage until the last file/project was added,
Definition at line 703 of file parser.cpp.
References _T, cbThreadPool::AddTask(), CC_LOCKER_TRACK_P_MTX_LOCK, CC_LOCKER_TRACK_P_MTX_UNLOCK, ParserCommon::idParserStart, Manager::IsAppShuttingDown(), wxString::IsEmpty(), m_BatchParseFiles, m_BatchTimer, m_ParserState, m_Pool, m_PredefinedMacros, m_StopWatch, ParserCommon::PARSER_BATCHPARSE_TIMER_DELAY_LONG, ParserThreadedTask, ProcessParserEvent(), ParserCommon::ptUndefined, ParserCommon::s_CurrentParser, ParserCommon::s_ParserMutex, wxTimer::Start(), wxStopWatch::Start(), StartStopWatch(), TRACE, and wxTIMER_ONE_SHOT.
Referenced by ConnectEvents(), and DisconnectEvents().
|
protected |
some files in the Tokentree is marked as need to be reparsed, this can be done by a call of Reparse() before.
So, in this timer event handler, we need to remove all the tokens of files in the Tree, and then re-parse them again. This is done by AddParse() again. the Parser status now switch to ParserCommon::ptReparseFile.
Definition at line 697 of file parser.cpp.
References ReparseModifiedFiles().
Referenced by ConnectEvents(), and DisconnectEvents().
|
protected |
parse the file, either immediately or delayed.
isLocal | true if the file belong to a C::B project |
locked | give the status of the Tokentree, false means the tree is not locked |
Definition at line 273 of file parser.cpp.
References _T, AddParserThread(), cbThreadPool::AddTask(), ParserThreadOptions::bufferSkipBlocks, ParserThreadOptions::bufferSkipOuterBlocks, CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, ParserThreadOptions::followGlobalIncludes, ParserOptions::followGlobalIncludes, ParserThreadOptions::followLocalIncludes, ParserOptions::followLocalIncludes, Manager::Get(), Manager::GetFileManager(), TokenTree::IsFileParsed(), FileManager::Load(), ParserThreadOptions::loader, m_NeedsReparse, ParserBase::m_Options, m_Pool, ParserBase::m_TokenTree, ParserThread::Parse(), ParserThreadOptions::parseComplexMacros, ParserOptions::parseComplexMacros, ParserBase::ParserThread, ParserThreadOptions::platformCheck, ParserOptions::platformCheck, RemoveParserThread(), TokenTree::ReserveFileForParsing(), s_TokenTreeMutex, ParserOptions::storeDocumentation, ParserThreadOptions::storeDocumentation, TRACE, ParserThreadOptions::useBuffer, ParserThreadOptions::wantPreprocessor, ParserOptions::wantPreprocessor, wxString::wx_str(), and wxMilliSleep().
Referenced by ParserThreadedTask::Execute(), and ParseFile().
|
virtual |
Must add a locker before call all named ParseBufferXXX functions, ParseBuffer function will directly run the parsing in the same thread as the caller.
So, take care if the time is limited. this function usually used to parse the function body to fetch the local variable information.
Reimplemented from ParserBase.
Definition at line 364 of file parser.cpp.
References ParserThreadOptions::bufferSkipBlocks, CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, ParserThreadOptions::fileOfBuffer, ParserThreadOptions::followGlobalIncludes, ParserThreadOptions::followLocalIncludes, ParserThreadOptions::handleFunctions, ParserThreadOptions::initLineOfBuffer, ParserThreadOptions::isTemp, ParserBase::m_Options, ParserBase::m_TokenTree, ParserThreadOptions::parentIdxOfBuffer, ParserThread::Parse(), ParserThreadOptions::parseComplexMacros, ParserOptions::parseComplexMacros, ParserThreadOptions::platformCheck, s_TokenTreeMutex, ParserOptions::storeDocumentation, ParserThreadOptions::storeDocumentation, ParserThreadOptions::useBuffer, ParserThreadOptions::wantPreprocessor, and ParserOptions::wantPreprocessor.
Referenced by ParserThreadedTask::Execute().
|
virtual |
parser the current editor control, this function is used to list all the functions in the current code editor
Definition at line 398 of file parser.cpp.
References ParserThreadOptions::bufferSkipBlocks, CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, ParserThreadOptions::followGlobalIncludes, ParserThreadOptions::followLocalIncludes, ParserThreadOptions::handleFunctions, ParserBase::m_Options, ParserBase::m_TempTokenTree, ParserThread::Parse(), ParserThreadOptions::parseComplexMacros, ParserOptions::parseComplexMacros, ParserThreadOptions::platformCheck, ParserOptions::platformCheck, s_TokenTreeMutex, ParserOptions::storeDocumentation, ParserThreadOptions::storeDocumentation, ParserThreadOptions::useBuffer, ParserThreadOptions::wantPreprocessor, and ParserOptions::wantPreprocessor.
|
virtual |
parse the buffer for collecting exposed namespace scopes
Definition at line 426 of file parser.cpp.
References CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, ParserThreadOptions::followGlobalIncludes, ParserThreadOptions::followLocalIncludes, ParserBase::m_Options, ParserBase::m_TempTokenTree, ParserThread::ParseBufferForNamespaces(), ParserThreadOptions::parseComplexMacros, ParserThreadOptions::platformCheck, s_TokenTreeMutex, ParserOptions::storeDocumentation, ParserThreadOptions::storeDocumentation, ParserThreadOptions::useBuffer, ParserThreadOptions::wantPreprocessor, ParserOptions::wantPreprocessor, and wxEmptyString.
|
virtual |
parse the buffer for collecting using namespace directive
Definition at line 451 of file parser.cpp.
References ParserThreadOptions::bufferSkipBlocks, CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, ParserThreadOptions::followGlobalIncludes, ParserThreadOptions::followLocalIncludes, ParserBase::m_Options, ParserBase::m_TempTokenTree, ParserThread::ParseBufferForUsingNamespace(), ParserThreadOptions::parseComplexMacros, ParserThreadOptions::platformCheck, s_TokenTreeMutex, ParserOptions::storeDocumentation, ParserThreadOptions::storeDocumentation, ParserThreadOptions::useBuffer, ParserThreadOptions::wantPreprocessor, ParserOptions::wantPreprocessor, and wxEmptyString.
|
privatevirtual |
the only usage of this function is in the Parserthread class, when handling include directives the parserthread use some call like m_Parent->ParseFile() to call this function, but this function just call Parser::Parse() function, which either run the syntax analysis immediately or create a parsing task in the Pool.
filename | the file we want to parse |
isGlobal | true if the file is not belong to a C::B project |
locked | true if the TokenTree is locked. when initially parse a translation unit file the locked should be set as false, but if you want to recursive parse to an include file the locked value should be set as true. |
Reimplemented from ParserBase.
Definition at line 660 of file parser.cpp.
References ParserOptions::followGlobalIncludes, ParserOptions::followLocalIncludes, wxString::IsEmpty(), ParserBase::m_Options, and Parse().
|
protected |
The parser will let its parent (NativeParser) to handle the event, as the CodeCompletion instance was set as the next handler of the NativeParser.
Those events can finally go to the CodeCompletion's event handler.
state | the state of the Parser, it could be any kind of enum ParserState |
id | either idParserStart or idParserEnd |
info | the log message |
Definition at line 845 of file parser.cpp.
References m_Parent, and m_Project.
Referenced by OnAllThreadsDone(), and OnBatchTimer().
|
protectedvirtual |
read Parser options from configure file
Reimplemented from ParserBase.
Definition at line 855 of file parser.cpp.
References _T, bdfFile, bstKind, ParserOptions::caseSensitive, BrowserOptions::displayFilter, BrowserOptions::expandNS, ParserCommon::FileType(), ParserOptions::followGlobalIncludes, ParserOptions::followLocalIncludes, Manager::Get(), Manager::GetConfigManager(), ParserBase::m_BrowserOptions, ParserBase::m_Options, ParserOptions::parseComplexMacros, ParserOptions::platformCheck, ConfigManager::ReadBool(), ConfigManager::ReadInt(), BrowserOptions::showInheritance, BrowserOptions::sortType, ParserOptions::storeDocumentation, BrowserOptions::treeMembers, ParserOptions::useSmartSense, ParserOptions::wantPreprocessor, ParserOptions::whileTyping, ConfigManager::Write(), and wxEmptyString.
Referenced by Parser().
|
virtual |
this usually happens when the user removes a file from the existing project, it will remove all the tokens belong to the file.
Definition at line 477 of file parser.cpp.
References CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, TokenTree::EraseFileMapInFileMap(), TokenTree::EraseFileStatusByIndex(), TokenTree::EraseFilesToBeReparsedByIndex(), TokenTree::GetFileStatusCountForIndex(), TokenTree::InsertFileOrGetIndex(), ParserBase::m_TokenTree, TokenTree::RemoveFile(), and s_TokenTreeMutex.
|
private |
Remove a completed internal running threads.
Definition at line 939 of file parser.cpp.
References m_tasksQueue.
Referenced by Parse().
|
virtual |
mark this file to be re-parsed in the TokenTree, tick the reparse timer, note it looks like the isLocal parameter is not used in Parser::Reparse function.
A better function name could be: MarkFileNeedToBeReParsed()
Definition at line 515 of file parser.cpp.
References _T, CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, CCLogger::DebugLog(), Done(), TokenTree::FlagFileForReparsing(), CCLogger::Get(), wxTimer::IsRunning(), m_NeedsReparse, m_ReparseTimer, ParserBase::m_TokenTree, NotDoneReason(), ParserCommon::PARSER_REPARSE_TIMER_DELAY, s_TokenTreeMutex, wxTimer::Start(), wxTimer::Stop(), TRACE, and wxTIMER_ONE_SHOT.
|
protected |
delete those files from the TokenTree, and add them again through AddParse() function
Definition at line 757 of file parser.cpp.
References _T, AddParse(), CC_LOCKER_TRACK_TT_MTX_LOCK, CC_LOCKER_TRACK_TT_MTX_UNLOCK, CCLogger::DebugLog(), Done(), FileTypeOf(), ftSource, ftTemplateSource, CCLogger::Get(), TokenTree::GetFilename(), TokenTree::GetFilesToBeReparsed(), m_NeedsReparse, m_ParserState, m_ReparseTimer, ParserBase::m_TokenTree, NotDoneReason(), ParserCommon::PARSER_REPARSE_TIMER_DELAY, ParserCommon::ptReparseFile, ParserCommon::ptUndefined, TokenTree::RemoveFile(), s_TokenTreeMutex, wxTimer::Start(), TRACE, and wxTIMER_ONE_SHOT.
Referenced by OnReparseTimer().
|
inlineprotected |
Not used, because the ThreadPool only support running ONE ParserThread concurrently.
Definition at line 217 of file parser.h.
References wxEmptyString.
|
protected |
Definition at line 675 of file parser.cpp.
References m_StopWatch, m_StopWatchRunning, and wxStopWatch::Start().
Referenced by OnBatchTimer().
|
protected |
cancel all the tasks in the thread pool m_Pool
Definition at line 541 of file parser.cpp.
References cbThreadPool::AbortAllTasks(), AbortParserThreads(), cbThreadPool::Done(), m_Pool, and wxMilliSleep().
Referenced by ~Parser().
|
virtual |
set the associated C::B project pointer.
(only used by one parser for whole workspace)
Definition at line 553 of file parser.cpp.
References _T, CCLogger::DebugLog(), Done(), CCLogger::Get(), m_Project, and NotDoneReason().
|
protectedvirtual |
write Parse options to configure file
Reimplemented from ParserBase.
Definition at line 905 of file parser.cpp.
References _T, BrowserOptions::displayFilter, BrowserOptions::expandNS, ParserOptions::followGlobalIncludes, ParserOptions::followLocalIncludes, Manager::Get(), Manager::GetConfigManager(), ParserBase::m_BrowserOptions, ParserBase::m_Options, ParserOptions::parseComplexMacros, ParserOptions::platformCheck, BrowserOptions::showInheritance, BrowserOptions::sortType, BrowserOptions::treeMembers, ParserOptions::useSmartSense, ParserOptions::wantPreprocessor, ParserOptions::whileTyping, and ConfigManager::Write().
|
friend |
Definition at line 119 of file parser.h.
Referenced by OnBatchTimer().
|
private |
All other batch parse files, like the normal headers/sources.
Definition at line 344 of file parser.h.
Referenced by AddBatchParse(), AddParse(), Done(), ParserThreadedTask::Execute(), IsFileParsed(), NotDoneReason(), OnAllThreadsDone(), and OnBatchTimer().
|
private |
a timer to delay the operation of batch parsing, see OnBatchTimer() member function as a reference
Definition at line 328 of file parser.h.
Referenced by AddBatchParse(), AddParse(), AddPredefinedMacros(), ConnectEvents(), DisconnectEvents(), OnAllThreadsDone(), and OnBatchTimer().
|
private |
Parser::OnAllThreadsDone will be called when m_Pool finished its job, but when we run a batch parsing, we may receive several such event from the m_Pool, because 1, when ParserThreadedTask finished 2, when batchFiles get finished 3, mark C::B project files's token as local.
Definition at line 341 of file parser.h.
Referenced by ParserThreadedTask::Execute(), and OnAllThreadsDone().
|
private |
used to measure batch parse time
Definition at line 351 of file parser.h.
Referenced by EndStopWatch(), and OnAllThreadsDone().
|
protected |
batch Parse mode flag.
It was set after consuming m_PredefinedMacros, it was reset after the final stage (mark token as local).
Definition at line 315 of file parser.h.
Referenced by ParserThreadedTask::Execute().
|
protected |
true, if the parser is still busy with parsing, false if the parsing stage has finished this value is set in parserthreadedtask after putting all the batchFiles to pool(task) it was reset after the last stage (mark tokens as local)
Definition at line 304 of file parser.h.
Referenced by AddBatchParse(), AddParse(), AddPredefinedMacros(), ParserThreadedTask::Execute(), and OnAllThreadsDone().
|
private |
Definition at line 348 of file parser.h.
Referenced by ClearPredefinedMacros(), and GetPredefinedMacros().
|
private |
Definition at line 333 of file parser.h.
Referenced by EndStopWatch(), and OnAllThreadsDone().
|
private |
if true, all the files of the current project will be labeled as "local"
Definition at line 357 of file parser.h.
Referenced by AddFile(), Done(), NotDoneReason(), and OnAllThreadsDone().
|
protected |
Indicates some files in the current project need to be re-parsed, this is commonly caused that the "real-time parsing option" is enabled, and user is editing source file.
Definition at line 310 of file parser.h.
Referenced by OnAllThreadsDone(), Parse(), Reparse(), and ReparseModifiedFiles().
|
private |
when initialized, this variable will be an instance of a NativeParser
Definition at line 285 of file parser.h.
Referenced by ProcessParserEvent().
|
private |
indicated the current state the parser
Definition at line 354 of file parser.h.
Referenced by AddBatchParse(), AddFile(), AddPredefinedMacros(), OnAllThreadsDone(), OnBatchTimer(), and ReparseModifiedFiles().
|
protected |
Thread Pool, executing all the ParserThread, used in batch parse mode.
The thread pool can add/remove/execute the ParserThread tasks, it will also notify the Parser that all the thread are done.
Definition at line 298 of file parser.h.
Referenced by ConnectEvents(), DisconnectEvents(), Done(), NotDoneReason(), OnAllThreadsDone(), OnBatchTimer(), Parse(), and TerminateAllThreads().
|
private |
Pre-defined macros, its a buffer queried from the compiler command line.
Definition at line 347 of file parser.h.
Referenced by AddPredefinedMacros(), ClearPredefinedMacros(), Done(), ParserThreadedTask::Execute(), NotDoneReason(), OnAllThreadsDone(), and OnBatchTimer().
|
private |
referring to the C::B cbp project currently parsing in one parser per workspace mode
Definition at line 288 of file parser.h.
Referenced by AddFile(), OnAllThreadsDone(), ProcessParserEvent(), and UpdateParsingProject().
|
private |
a file is need to be reparsed, maybe another file will to be reparsed very soon, so use a timer to collect all the files need to be reparsed.
This avoid starting running the thread pool to quickly
Definition at line 323 of file parser.h.
Referenced by ConnectEvents(), DisconnectEvents(), Reparse(), and ReparseModifiedFiles().
|
private |
a stop watch to measure parsing time
Definition at line 331 of file parser.h.
Referenced by EndStopWatch(), OnBatchTimer(), and StartStopWatch().
|
private |
Definition at line 332 of file parser.h.
Referenced by EndStopWatch(), and StartStopWatch().
|
private |
Definition at line 361 of file parser.h.
Referenced by AbortParserThreads(), AddParserThread(), and RemoveParserThread().
|
protected |