52
52
DEBUG_MESSAGE( wxString::Format(wxT("ParseThread::ProcessIncludes -> received 'TestDestroy()'") ) );\
57
57
const wxEventType wxEVT_PARSE_THREAD_UPDATED_FILE_SYMBOLS = XRCID("parse_thread_updated_symbols");
58
58
const wxEventType wxEVT_PARSE_THREAD_MESSAGE = XRCID("parse_thread_update_status_bar");
59
59
const wxEventType wxEVT_PARSE_THREAD_SCAN_INCLUDES_DONE = XRCID("parse_thread_scan_includes_done");
60
60
const wxEventType wxEVT_PARSE_THREAD_CLEAR_TAGS_CACHE = XRCID("parse_thread_clear_tags_cache");
61
const wxEventType wxEVT_PARSE_THREAD_RETAGGING_PROGRESS = XRCID("parse_thread_clear_retagging_progress");
62
const wxEventType wxEVT_PARSE_THREAD_RETAGGING_COMPLETED = XRCID("parse_thread_clear_retagging_compelted");
63
64
ParseThread::ParseThread()
170
174
// Remove from this list all files which starts with one of the crawler search paths
171
175
wxArrayString searchPaths, excludePaths, filteredFileList;
172
176
GetSearchPaths( searchPaths, excludePaths );
174
178
DEBUG_MESSAGE( wxString::Format(wxT("Initial workspace files count is %d"), req->_workspaceFiles.size()) ) ;
176
180
for(size_t i=0; i<req->_workspaceFiles.size(); i++) {
177
181
wxString name(req->_workspaceFiles.at(i).c_str(), wxConvUTF8);
178
182
wxFileName fn(name);
179
183
fn.MakeAbsolute();
181
bool isFromSearchPath(false);
182
for(size_t j=0; j<searchPaths.GetCount(); j++) {
183
wxFileName p ( searchPaths.Item(j) + wxFileName::GetPathSeparator());
184
//DEBUG_MESSAGE( wxString::Format(wxT("Comparing %s vs %s"), fn.GetFullPath().c_str(), p.GetPath().c_str()));
185
if( fn.GetFullPath().StartsWith(p.GetPath()) ) {
186
//DEBUG_MESSAGE(wxT("Match was found for file, this file will NOT be parsed!"));
187
isFromSearchPath = true;
192
// this file is not part of the search paths
193
if( !isFromSearchPath ) {
194
filteredFileList.Add( fn.GetFullPath() );
184
filteredFileList.Add( fn.GetFullPath() );
198
187
DEBUG_MESSAGE( wxString::Format(wxT("ParseThread::ProcessIncludes -> Workspace files %d"), filteredFileList.GetCount()) );
337
326
// If there is no event handler set to handle this comaprison
338
327
// results, then nothing more to be done
339
328
if (m_notifiedWindow ) {
341
330
bool sendClearCacheEvent(false);
342
331
std::vector<std::pair<wxString, TagEntry> > realModifiedItems;
344
333
sendClearCacheEvent = (!deletedItems.empty() || !realModifiedItems.empty() || !newItems.empty());
346
335
// send "end" event
347
336
wxCommandEvent e(wxEVT_PARSE_THREAD_UPDATED_FILE_SYMBOLS);
348
337
wxPostEvent(m_notifiedWindow, e);
355
344
SendEvent(wxEVT_COMMAND_SYMBOL_TREE_ADD_ITEM, req->getFile(), goodNewItems);
357
346
if ( !modifiedItems.empty() ) {
359
348
for (size_t i=0; i<modifiedItems.size(); i++) {
360
349
std::pair<wxString, TagEntry> p = modifiedItems.at(i);
361
350
if (!p.second.GetDifferOnByLineNumber()) {
366
355
SendEvent(wxEVT_COMMAND_SYMBOL_TREE_UPDATE_ITEM, req->getFile(), realModifiedItems);
370
359
if(sendClearCacheEvent) {
371
360
wxCommandEvent clearCacheEvent(wxEVT_PARSE_THREAD_CLEAR_TAGS_CACHE);
372
361
wxPostEvent(m_notifiedWindow, clearCacheEvent);
383
372
if ( !this->IsCrawlerEnabled() ) {
389
378
wxCriticalSectionLocker locker( TagsManagerST::Get()->m_crawlerLocker );
391
380
wxArrayString includePaths, excludePaths;
392
381
GetSearchPaths( includePaths, excludePaths );
406
395
// Before using the 'crawlerScan' we lock it, since it is not mt-safe
407
396
crawlerScan( cfile.data() );
411
400
std::set<std::string> fileSet = fcFileOpener::Instance()->GetResults();
412
401
std::set<std::string>::iterator iter = fileSet.begin();
413
402
for (; iter != fileSet.end(); iter++ ) {
452
void ParseThread::ProcessParseAndStore(ParseRequest* req)
454
wxString dbfile = req->getDbfile();
456
// convert the file to tags
457
double maxVal = (double)req->_workspaceFiles.size();
458
if ( maxVal == 0.0 ) {
462
// we report every 10%
463
double reportingPoint = maxVal / 100.0;
464
reportingPoint = ceil( reportingPoint );
465
if(reportingPoint == 0.0) {
466
reportingPoint = 1.0;
470
m_pDb = new TagsStorageSQLite();
472
m_pDb->OpenDatabase( dbfile );
474
// We commit every 10 files
477
int lastPercentageReported(0);
479
for (size_t i=0; i<maxVal; i++) {
481
// give a shutdown request a chance
482
if( TestDestroy() ) {
483
// Do an ordered shutdown:
484
// rollback any transaction
485
// and close the database
492
wxFileName curFile(wxString(req->_workspaceFiles.at(i).c_str(), wxConvUTF8));
494
// Send notification to the main window with our progress report
495
precent = (int)((i / maxVal) * 100);
497
if( lastPercentageReported != precent) {
498
lastPercentageReported = precent;
499
wxCommandEvent retaggingProgressEvent(wxEVT_PARSE_THREAD_RETAGGING_PROGRESS);
500
retaggingProgressEvent.SetInt( (int)precent );
501
m_notifiedWindow->AddPendingEvent(retaggingProgressEvent);
504
TagTreePtr tree = TagsManagerST::Get()->ParseSourceFile(curFile);
505
m_pDb->Store(tree, wxFileName(), false);
506
if(m_pDb->InsertFileEntry(curFile.GetFullPath(), (int)time(NULL)) == TagExist) {
507
m_pDb->UpdateFileEntry(curFile.GetFullPath(), (int)time(NULL));
511
// Commit what we got so far
513
// Start a new transaction
521
/// Send notification to the main window with our progress report
522
if(m_notifiedWindow) {
524
wxCommandEvent retaggingCompletedEvent(wxEVT_PARSE_THREAD_RETAGGING_COMPLETED);
525
std::vector<std::string> *arrFiles = new std::vector<std::string>;
526
*arrFiles = req->_workspaceFiles;
527
retaggingCompletedEvent.SetClientData( arrFiles );
529
m_notifiedWindow->AddPendingEvent(retaggingCompletedEvent);
532
// Close the database
463
537
//--------------------------------------------------------------------------------------
464
538
// Parse Request Class
465
539
//--------------------------------------------------------------------------------------