void PHPCodeCompletion::DoShowCompletionBox(const PHPEntityBase::List_t& entries, PHPExpression::Ptr_t expr) { wxCodeCompletionBoxEntry::Vec_t ccEntries; TagEntryPtrVector_t tags; wxStringSet_t uniqueEntries; // search for the old item PHPEntityBase::List_t::const_iterator iter = entries.begin(); for(; iter != entries.end(); ++iter) { PHPEntityBase::Ptr_t entry = *iter; if(uniqueEntries.count(entry->GetFullName()) == 0) { uniqueEntries.insert(entry->GetFullName()); } else { // don't add duplicate entries continue; } PHPEntityBase::Ptr_t ns = expr->GetSourceFile()->Namespace(); // the namespace at the source file TagEntryPtr t = DoPHPEntityToTagEntry(entry); tags.push_back(t); } std::sort(tags.begin(), tags.end(), _SAscendingSort()); for(size_t i = 0; i < tags.size(); ++i) { wxCodeCompletionBoxEntry::Ptr_t ccEntry = wxCodeCompletionBox::TagToEntry(tags.at(i)); ccEntry->SetComment(tags.at(i)->GetComment()); ccEntries.push_back(ccEntry); } wxCodeCompletionBoxManager::Get().ShowCompletionBox( m_manager->GetActiveEditor()->GetCtrl(), ccEntries, wxCodeCompletionBox::kRefreshOnKeyType, wxNOT_FOUND); }
AddFunctionsImpDlg::AddFunctionsImpDlg(wxWindow* parent, const TagEntryPtrVector_t &tags, const wxString &targetFile) : AddFunctionsImplBaseDlg(parent) { unsigned int colCount = m_dataviewModel->GetColCount(); m_dataviewModel = new MyAddFunctionsModel(); m_dataviewModel->SetColCount( colCount ); m_dataview->AssociateModel( m_dataviewModel.get() ); m_tags.insert(m_tags.end(), tags.begin(), tags.end()); for(size_t i=0; i<m_tags.size(); ++i) { wxVector<wxVariant> cols; cols.push_back(true); cols.push_back( m_tags.at(i)->GetDisplayName() ); // keep the implementation as the client data wxString body; TagEntryPtr tag = m_tags.at(i); tag->SetSignature( TagsManagerST::Get()->NormalizeFunctionSig( tag->GetSignature(), Normalize_Func_Name ) ); body << TagsManagerST::Get()->FormatFunction(tag, FunctionFormat_Impl); body << wxT("\n"); m_dataviewModel->AppendItem( wxDataViewItem(0), cols, new wxStringClientData(body) ); } m_filePicker->SetPath( targetFile ); WindowAttrManager::Load(this, "AddFunctionsImpDlg", NULL); }
void svSymbolTree::BuildTree(const wxFileName& fn) { TagEntryPtrVector_t newTags; ITagsStoragePtr db = TagsManagerST::Get()->GetDatabase(); if(!db) { return; } db->SelectTagsByFile(fn.GetFullPath(), newTags); if(TagsManagerST::Get()->AreTheSame(newTags, m_currentTags)) return; std::sort( newTags.begin(), newTags.end(), [&](TagEntryPtr t1, TagEntryPtr t2) { return t1->GetLine() > t2->GetLine(); }); wxWindowUpdateLocker locker(this); SymbolTree::BuildTree(fn, &newTags); // Request from the parsing thread list of include files ++m_uid; ParseRequest* req = new ParseRequest(this); req->setFile(fn.GetFullPath()); req->setType(ParseRequest::PR_PARSE_INCLUDE_STATEMENTS); req->_uid = m_uid; // Identifies this request ParseThreadST::Get()->Add(req); wxTreeItemId root = GetRootItem(); if(root.IsOk() && ItemHasChildren(root)) { wxTreeItemIdValue cookie; wxTreeItemId child = GetFirstChild(root, cookie); while(child.IsOk()) { Expand(child); child = GetNextChild(root, cookie); } } }
void SymbolTree::BuildTree(const wxFileName &fileName, TagEntryPtrVector_t* tags /*NULL*/) { TagEntryPtrVector_t newTags; if ( !tags ) { // Get the current database ITagsStoragePtr db = TagsManagerST::Get()->GetDatabase(); if ( ! db ) { Clear(); return; } // Load the new tags from the database db->SelectTagsByFile(fileName.GetFullPath(), newTags); // Compare the new tags with the old ones if ( TagsManagerST::Get()->AreTheSame(newTags, m_currentTags) ) return; m_currentTags.clear(); m_currentTags.insert(m_currentTags.end(), newTags.begin(), newTags.end()); } else { m_currentTags.clear(); m_currentTags.insert(m_currentTags.end(), tags->begin(), tags->end()); } wxWindowUpdateLocker locker(this); Clear(); m_fileName = fileName; // Convert them into tree m_tree = TagsManagerST::Get()->Load(m_fileName, &m_currentTags); if ( !m_tree ) { return; } // Add invisible root node wxTreeItemId root; root = AddRoot(fileName.GetFullName(), 15, 15); TreeWalker<wxString, TagEntry> walker(m_tree->GetRoot()); // add three items here: // the globals node, the mcros and the prototype node m_globalsNode = AppendItem(root, wxT("Global Functions and Variables"), 2, 2, new MyTreeItemData(wxT("Global Functions and Variables"), wxEmptyString)); m_prototypesNode = AppendItem(root, wxT("Functions Prototypes"), 2, 2, new MyTreeItemData(wxT("Functions Prototypes"), wxEmptyString)); m_macrosNode = AppendItem(root, wxT("Macros"), 2, 2, new MyTreeItemData(wxT("Macros"), wxEmptyString)); // Iterate over the tree and add items m_sortItems.clear(); Freeze(); for (; !walker.End(); walker++) { // Add the item to the tree TagNode* node = walker.GetNode(); // Skip root node if (node->IsRoot()) continue; // Add the node AddItem(node); } SortTree(m_sortItems); if ( ItemHasChildren(m_globalsNode) == false ) { Delete(m_globalsNode); } if ( ItemHasChildren(m_prototypesNode) == false ) { Delete(m_prototypesNode); } if ( ItemHasChildren(m_macrosNode) == false ) { Delete(m_macrosNode); } Thaw(); //select the root node by default if (!(GetWindowStyleFlag() & wxTR_HIDE_ROOT)) { //root is visible, select it SelectItem(GetRootItem()); } }