void TagsOptionsDlg::Parse() { // Prepate list of files to work on wxArrayString files = wxStringTokenize(m_textCtrlFilesList->GetValue(), wxT(" \t"), wxTOKEN_STRTOK); wxArrayString searchPaths = GetCTagsSearchPaths(); wxArrayString fullpathsArr; for(size_t i = 0; i < files.size(); i++) { wxString file = files[i].Trim().Trim(false); if(file.IsEmpty()) continue; for(size_t xx = 0; xx < searchPaths.size(); xx++) { wxString fullpath; fullpath << searchPaths.Item(xx) << wxFileName::GetPathSeparator() << file; wxFileName fn(fullpath); if(fn.FileExists()) { fullpathsArr.Add(fn.GetFullPath()); break; } } } // Clear the PreProcessor table PPTable::Instance()->Clear(); for(size_t i = 0; i < fullpathsArr.size(); i++) PPScan(fullpathsArr.Item(i), true); // Open an editor and print out the results IEditor* editor = PluginManager::Get()->NewEditor(); if(editor) { editor->AppendText(PPTable::Instance()->Export()); CopyData(); EndModal(wxID_OK); } }
void ParseThread::ProcessSimple(ParseRequest* req) { wxString dbfile = req->getDbfile(); wxString file = req->getFile(); // Skip binary file if(TagsManagerST::Get()->IsBinaryFile(file)) { DEBUG_MESSAGE( wxString::Format(wxT("Skipping binary file %s"), file.c_str()) ); return; } // convert the file to tags TagsManager *tagmgr = TagsManagerST::Get(); ITagsStoragePtr db(new TagsStorageSQLite()); db->OpenDatabase( dbfile ); //convert the file content into tags wxString tags; wxString file_name(req->getFile()); tagmgr->SourceToTags(file_name, tags); int count; DoStoreTags(tags, file_name, count, db); db->Begin(); /////////////////////////////////////////// // update the file retag timestamp /////////////////////////////////////////// db->InsertFileEntry(file, (int)time(NULL)); //////////////////////////////////////////////// // Parse and store the macros found in this file //////////////////////////////////////////////// PPTable::Instance()->Clear(); PPScan( file, true ); db->StoreMacros( PPTable::Instance()->GetTable() ); PPTable::Instance()->Clear(); db->Commit(); // Parse the saved file to get a list of files to include ParseIncludeFiles(req, file, db ); // If there is no event handler set to handle this comaprison // results, then nothing more to be done if (req->_evtHandler ) { wxCommandEvent clearCacheEvent(wxEVT_PARSE_THREAD_CLEAR_TAGS_CACHE); req->_evtHandler->AddPendingEvent(clearCacheEvent); wxCommandEvent retaggingCompletedEvent(wxEVT_PARSE_THREAD_RETAGGING_COMPLETED); retaggingCompletedEvent.SetClientData( NULL ); req->_evtHandler->AddPendingEvent(retaggingCompletedEvent); } }
void ParseThread::ProcessParseAndStore(ParseRequest* req) { wxString dbfile = req->getDbfile(); // convert the file to tags double maxVal = (double)req->_workspaceFiles.size(); if ( maxVal == 0.0 ) { return; } // we report every 10% double reportingPoint = maxVal / 100.0; reportingPoint = ceil( reportingPoint ); if(reportingPoint == 0.0) { reportingPoint = 1.0; } ITagsStoragePtr db(new TagsStorageSQLite()); db->OpenDatabase( dbfile ); // We commit every 10 files db->Begin(); int precent (0); int lastPercentageReported(0); PPTable::Instance()->Clear(); for (size_t i=0; i<maxVal; i++) { // give a shutdown request a chance if( TestDestroy() ) { // Do an ordered shutdown: // rollback any transaction // and close the database db->Rollback(); return; } wxFileName curFile(wxString(req->_workspaceFiles.at(i).c_str(), wxConvUTF8)); // Skip binary files if(TagsManagerST::Get()->IsBinaryFile(curFile.GetFullPath())) { DEBUG_MESSAGE( wxString::Format(wxT("Skipping binary file %s"), curFile.GetFullPath().c_str()) ); continue; } // Send notification to the main window with our progress report precent = (int)((i / maxVal) * 100); if( req->_evtHandler && lastPercentageReported != precent) { lastPercentageReported = precent; wxCommandEvent retaggingProgressEvent(wxEVT_PARSE_THREAD_RETAGGING_PROGRESS); retaggingProgressEvent.SetInt( (int)precent ); req->_evtHandler->AddPendingEvent(retaggingProgressEvent); } else if(lastPercentageReported != precent) { wxPrintf(wxT("parsing: %%%d completed\n"), precent); } TagTreePtr tree = TagsManagerST::Get()->ParseSourceFile(curFile); PPScan( curFile.GetFullPath(), false ); db->Store(tree, wxFileName(), false); if(db->InsertFileEntry(curFile.GetFullPath(), (int)time(NULL)) == TagExist) { db->UpdateFileEntry(curFile.GetFullPath(), (int)time(NULL)); } if ( i % 50 == 0 ) { // Commit what we got so far db->Commit(); // Start a new transaction db->Begin(); } } // Process the macros PPTable::Instance()->Squeeze(); const std::map<wxString, PPToken>& table = PPTable::Instance()->GetTable(); // Store the macros db->StoreMacros( table ); // Commit whats left db->Commit(); // Clear the results PPTable::Instance()->Clear(); /// Send notification to the main window with our progress report if( req->_evtHandler ) { wxCommandEvent retaggingCompletedEvent(wxEVT_PARSE_THREAD_RETAGGING_COMPLETED); std::vector<std::string> *arrFiles = new std::vector<std::string>; *arrFiles = req->_workspaceFiles; retaggingCompletedEvent.SetClientData( arrFiles ); req->_evtHandler->AddPendingEvent(retaggingCompletedEvent); } }